@@ -751,35 +751,8 @@ object JavaParsers {
751751 makeTemplate(List (), statics, List (), false )).withMods((cdef.mods & Flags .RetainedModuleClassFlags ).toTermFlags)
752752 }
753753
754- def importCompanionObject (cdef : TypeDef ): Tree =
755- Import (
756- Ident (cdef.name.toTermName).withSpan(NoSpan ),
757- ImportSelector (Ident (nme.WILDCARD )) :: Nil )
758-
759- // Importing the companion object members cannot be done uncritically: see
760- // ticket #2377 wherein a class contains two static inner classes, each of which
761- // has a static inner class called "Builder" - this results in an ambiguity error
762- // when each performs the import in the enclosing class's scope.
763- //
764- // To address this I moved the import Companion._ inside the class, as the first
765- // statement. This should work without compromising the enclosing scope, but may (?)
766- // end up suffering from the same issues it does in scala - specifically that this
767- // leaves auxiliary constructors unable to access members of the companion object
768- // as unqualified identifiers.
769- def addCompanionObject (statics : List [Tree ], cdef : TypeDef ): List [Tree ] = {
770- // if there are no statics we can use the original cdef, but we always
771- // create the companion so import A._ is not an error (see ticket #1700)
772- val cdefNew =
773- if (statics.isEmpty) cdef
774- else {
775- val template = cdef.rhs.asInstanceOf [Template ]
776- cpy.TypeDef (cdef)(cdef.name,
777- cpy.Template (template)(body = importCompanionObject(cdef) :: template.body))
778- .withMods(cdef.mods)
779- }
780-
781- List (makeCompanionObject(cdefNew, statics), cdefNew)
782- }
754+ def addCompanionObject (statics : List [Tree ], cdef : TypeDef ): List [Tree ] =
755+ List (makeCompanionObject(cdef, statics), cdef)
783756
784757 def importDecl (): List [Tree ] = {
785758 val start = in.offset
0 commit comments