@@ -192,6 +192,16 @@ class Definitions {
192
192
cls
193
193
}
194
194
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
+
195
205
lazy val RootClass : ClassSymbol = ctx.newPackageSymbol(
196
206
NoSymbol , nme.ROOT , (root, rootcls) => ctx.base.rootLoader(root)).moduleClass.asClass
197
207
lazy val RootPackage : TermSymbol = ctx.newSymbol(
@@ -292,15 +302,7 @@ class Definitions {
292
302
assert(! cls.isCompleted, " race for completing java.lang.Object" )
293
303
cls.info = ClassInfo (cls.owner.thisType, cls, AnyClass .typeRef :: Nil , newScope)
294
304
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)
304
306
}
305
307
def ObjectType : TypeRef = ObjectClass .typeRef
306
308
@@ -614,6 +616,26 @@ class Definitions {
614
616
JavaSerializableClass .typeRef
615
617
else
616
618
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
+
617
639
def SerializableClass (implicit ctx : Context ): ClassSymbol = SerializableType .symbol.asClass
618
640
lazy val StringBuilderType : TypeRef = ctx.requiredClassRef(" scala.collection.mutable.StringBuilder" )
619
641
def StringBuilderClass (implicit ctx : Context ): ClassSymbol = StringBuilderType .symbol.asClass
@@ -1438,7 +1460,7 @@ class Definitions {
1438
1460
ScalaPackageClass .enter(m)
1439
1461
1440
1462
// 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
1442
1464
1443
1465
isInitialized = true
1444
1466
}
0 commit comments