Skip to content

Fix #1401: Make sure all references are forwarded #1407

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 3 commits into from
Jul 22, 2016

Conversation

odersky
Copy link
Contributor

@odersky odersky commented Jul 21, 2016

I minimized the problem to i1401.scala. If we swap Buffer and BufferLike, the test already succeeds without this PR. The difference between the two orders is that we are lacking some parameter forwarders in the error scenario. This PR fixes that.

@odersky
Copy link
Contributor Author

odersky commented Jul 21, 2016

Review by @liufengyun ?

@liufengyun
Copy link
Contributor

Well done @odersky 👍 I don't feel confident for the type system internals, but I'll try to understand the fix. Maybe @smarter can help review as well?

odersky added 2 commits July 21, 2016 17:42
- increase page width
- print scopes more legibly under -verbose
Faced with recursive dependencies through self types, we might have
to apply `normalizeToClassRefs` to a class P with a parent that is not
yet initialized (witnessed by P's parents being Nil). In that case
we should still execute forwardRefs on P, but we have to
wait in a suspension until P is initialized.

This avoids the problem raised in scala#1401. I am still not quite sure
why forwardRefs is needed, but it seems that asSeenFrom alone is not
enough to track the dependencies in this case.
@odersky
Copy link
Contributor Author

odersky commented Jul 21, 2016

Rebased to master

@odersky odersky added area:reporting Error reporting including formatting, implicit suggestions, etc Needs review and removed In progress area:reporting Error reporting including formatting, implicit suggestions, etc labels Jul 21, 2016
@@ -106,7 +106,7 @@ object Scala2Unpickler {
// `denot.sourceModule.exists` provision i859.scala crashes in the backend.
denot.owner.thisType select denot.sourceModule
else selfInfo
denot.info = ClassInfo(denot.owner.thisType, denot.classSymbol, Nil, decls, ost) // first rough info to avoid CyclicReferences
denot.info = new TempClassInfo(denot.owner.thisType, denot.classSymbol, decls, ost) // first rough info to avoid CyclicReferences
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's not clear to me where the suspensions of this TempClassInfo is executed. For the TempClassInfo in Namer, there's an explicit call tempClassInfo.suspensions.foreach(_()).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch (they were never executed). I added a commit that fixes that. I could not come up with a test case specifically for classfile reading, but it seems obvious that the treatment
should be the same as in Namer.

Make treatment in Scala2Unpickler and Namer the same and factor
out common functionality.
@liufengyun
Copy link
Contributor

LGTM

@liufengyun liufengyun merged commit 11f06fe into scala:master Jul 22, 2016
@liufengyun
Copy link
Contributor

Thanks @odersky for fixing this tricky bug.

@allanrenucci allanrenucci deleted the fix-#1401 branch December 14, 2017 16:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants