Skip to content

Commit 601a286

Browse files
authored
Merge pull request #1724 from dotty-staging/fix-i1648
Fix #1648: don't define companion object for java.lang.Object
2 parents dd0db48 + 9f8c81c commit 601a286

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -194,6 +194,13 @@ class Definitions {
194194
val cls = ctx.requiredClass("java.lang.Object")
195195
assert(!cls.isCompleted, "race for completing java.lang.Object")
196196
cls.info = ClassInfo(cls.owner.thisType, cls, AnyClass.typeRef :: Nil, newScope)
197+
198+
// The companion object doesn't really exist, `NoType` is the general
199+
// technique to do that. Here we need to set it before completing
200+
// attempt to load Object's classfile, which causes issue #1648.
201+
val companion = JavaLangPackageVal.info.decl(nme.Object).symbol
202+
companion.info = NoType // to indicate that it does not really exist
203+
197204
completeClass(cls)
198205
}
199206
def ObjectType = ObjectClass.typeRef

tests/neg/i1648.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
class Foo { Object[A] } // error // error

0 commit comments

Comments
 (0)