Ah, it would have to be: 
   val enclosingName = for {
              chars <- enclosingTypeName
              name = new String(chars) if name != "package"
            } yield stripEndingDollar(name)