Skip to content

Fix #1648: don't define companion object for java.lang.Object #1724

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Nov 18, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/dotty/tools/dotc/core/Definitions.scala
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,13 @@ class Definitions {
val cls = ctx.requiredClass("java.lang.Object")
assert(!cls.isCompleted, "race for completing java.lang.Object")
cls.info = ClassInfo(cls.owner.thisType, cls, AnyClass.typeRef :: Nil, newScope)

// The companion object doesn't really exist, `NoType` is the general
// technique to do that. Here we need to set it before completing
// attempt to load Object's classfile, which causes issue #1648.
val companion = JavaLangPackageVal.info.decl(nme.Object).symbol
companion.info = NoType // to indicate that it does not really exist

completeClass(cls)
}
def ObjectType = ObjectClass.typeRef
Expand Down
1 change: 1 addition & 0 deletions tests/neg/i1648.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
class Foo { Object[A] } // error // error