Skip to content

Commit cf6fb9e

Browse files
committed
Revert special handling of java.lang.Enum's companion object
Unlike Object, which is the other class we fiddle with, java.lang.Enum really has a companion object. So we should leave it as it is.
1 parent dc9622a commit cf6fb9e

File tree

1 file changed

+9
-12
lines changed

1 file changed

+9
-12
lines changed

compiler/src/dotty/tools/dotc/core/Definitions.scala

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -192,16 +192,6 @@ 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-
205195
lazy val RootClass: ClassSymbol = ctx.newPackageSymbol(
206196
NoSymbol, nme.ROOT, (root, rootcls) => ctx.base.rootLoader(root)).moduleClass.asClass
207197
lazy val RootPackage: TermSymbol = ctx.newSymbol(
@@ -302,7 +292,14 @@ class Definitions {
302292
assert(!cls.isCompleted, "race for completing java.lang.Object")
303293
cls.info = ClassInfo(cls.owner.thisType, cls, AnyClass.typeRef :: Nil, newScope)
304294
cls.setFlag(NoInits)
305-
completeTransformedJavaClass(cls)
295+
296+
// The companion object of a Java class 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(cls.name.toTermName).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+
completeClass(cls)
306303
}
307304
def ObjectType: TypeRef = ObjectClass.typeRef
308305

@@ -632,7 +629,7 @@ class Definitions {
632629
constr.info = newInfo
633630
constr.termRef.recomputeDenot()
634631
cls.setFlag(NoInits)
635-
completeTransformedJavaClass(cls, ensureCtor = false)
632+
cls
636633
}
637634
def JavaEnumType = JavaEnumClass.typeRef
638635

0 commit comments

Comments
 (0)