-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Fix errors in the global initialization checker when compiling bootstrapped dotty #23429
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
Fix errors in the global initialization checker when compiling bootstrapped dotty #23429
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
targetType.asInstanceOf[ExprType].resType | ||
else | ||
targetType.asInstanceOf[MethodType].resType | ||
val returnType = targetType.finalResultType |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice simplification 👍
@@ -1326,7 +1318,8 @@ class Objects(using Context @constructorOnly): | |||
report.warning("[Internal error] top-level class should have `Package` as outer, class = " + klass.show + ", outer = " + outer.show + ", " + Trace.show, Trace.position) | |||
(Bottom, Env.NoEnv) | |||
else | |||
val outerCls = klass.owner.enclosingClass.asClass | |||
// enclosingClass is specially handled for java static terms, so use `lexicallyEnclosingClass` here | |||
val outerCls = klass.owner.lexicallyEnclosingClass.asClass |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice catch and comment 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM also except for a comment about why Flags.Param
is an exception.
3c254fd
to
83b6cf2
Compare
83b6cf2
to
ec0d1f9
Compare
@@ -1054,6 +1046,8 @@ class Objects(using Context @constructorOnly): | |||
else if target.equals(defn.Predef_classOf) then | |||
// Predef.classOf is a stub method in tasty and is replaced in backend | |||
UnknownValue | |||
else if target.is(Flags.JavaDefined) then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added the modification here to skip java-defined methods. It is worth noting that java-defined methods has source, but its defTree is incomplete, so we should not evaluate them anyway
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand what way the defTree
is incomplete. The definition of hasSource
is:
def hasSource(using Context): Boolean = !sym.defTree.isEmpty
But anyway, perhaps hasSource
should check for Java-defined and return false for all Java-defined symbols. @liufengyun what do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here's the defTree
of the runtimeVersionMajor
method defined in JDK9Reflectors.java
:
DefDef(runtimeVersionMajor,List(List(ValDef(version,Ident(Object),EmptyTree))),Ident(Integer),Select(Select(Select(Ident(_root_),scala),Predef),???))
The defTree
is not empty, but contains an ???
part.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a good idea to change hasSource
such that it return false for all Java-defined symbols.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a good idea to change
hasSource
such that it return false for all Java-defined symbols.
Done
ec0d1f9
to
13440a7
Compare
With this fix, the global initialization checker can be run when compiling bootstrapped dotty and reported warnings in the dotty source code
[test_scala2_library_tasty]