@@ -192,6 +192,16 @@ class Definitions {
192192 cls
193193 }
194194
195+ private def completeTransformedJavaClass (cls : ClassSymbol , ensureCtor : Boolean = true ): ClassSymbol = {
196+ // The companion object of a Java class doesn't really exist, `NoType` is the general
197+ // technique to do that. Here we need to set it before completing
198+ // attempt to load Object's classfile, which causes issue #1648.
199+ val companion = JavaLangPackageVal .info.decl(cls.name.toTermName).symbol
200+ companion.moduleClass.info = NoType // to indicate that it does not really exist
201+ companion.info = NoType // to indicate that it does not really exist
202+ completeClass(cls, ensureCtor)
203+ }
204+
195205 lazy val RootClass : ClassSymbol = ctx.newPackageSymbol(
196206 NoSymbol , nme.ROOT , (root, rootcls) => ctx.base.rootLoader(root)).moduleClass.asClass
197207 lazy val RootPackage : TermSymbol = ctx.newSymbol(
@@ -292,15 +302,7 @@ class Definitions {
292302 assert(! cls.isCompleted, " race for completing java.lang.Object" )
293303 cls.info = ClassInfo (cls.owner.thisType, cls, AnyClass .typeRef :: Nil , newScope)
294304 cls.setFlag(NoInits )
295-
296- // The companion object doesn't really exist, `NoType` is the general
297- // technique to do that. Here we need to set it before completing
298- // attempt to load Object's classfile, which causes issue #1648.
299- val companion = JavaLangPackageVal .info.decl(nme.Object ).symbol
300- companion.moduleClass.info = NoType // to indicate that it does not really exist
301- companion.info = NoType // to indicate that it does not really exist
302-
303- completeClass(cls)
305+ completeTransformedJavaClass(cls)
304306 }
305307 def ObjectType : TypeRef = ObjectClass .typeRef
306308
@@ -614,6 +616,26 @@ class Definitions {
614616 JavaSerializableClass .typeRef
615617 else
616618 ctx.requiredClassRef(" scala.Serializable" )
619+
620+ lazy val JavaEnumClass : ClassSymbol = {
621+ val cls = ctx.requiredClass(" java.lang.Enum" )
622+ val constr = cls.primaryConstructor
623+ val newInfo = constr.info match {
624+ case info : PolyType =>
625+ info.resType match {
626+ case meth : MethodType =>
627+ info.derivedLambdaType(
628+ resType = meth.derivedLambdaType(
629+ paramNames = Nil , paramInfos = Nil ))
630+ }
631+ }
632+ constr.info = newInfo
633+ constr.termRef.recomputeDenot()
634+ cls.setFlag(NoInits )
635+ completeTransformedJavaClass(cls, ensureCtor = false )
636+ }
637+ def JavaEnumType = JavaEnumClass .typeRef
638+
617639 def SerializableClass (implicit ctx : Context ): ClassSymbol = SerializableType .symbol.asClass
618640 lazy val StringBuilderType : TypeRef = ctx.requiredClassRef(" scala.collection.mutable.StringBuilder" )
619641 def StringBuilderClass (implicit ctx : Context ): ClassSymbol = StringBuilderType .symbol.asClass
@@ -1438,7 +1460,7 @@ class Definitions {
14381460 ScalaPackageClass .enter(m)
14391461
14401462 // force initialization of every symbol that is synthesized or hijacked by the compiler
1441- val forced = syntheticCoreClasses ++ syntheticCoreMethods ++ ScalaValueClasses ()
1463+ val forced = syntheticCoreClasses ++ syntheticCoreMethods ++ ScalaValueClasses () :+ JavaEnumClass
14421464
14431465 isInitialized = true
14441466 }
0 commit comments