Skip to content

Fix #3559: fix scope for typing this(...) in 2nd constructor #7200

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
Sep 13, 2019

Conversation

liufengyun
Copy link
Contributor

Fix #3559: fix scope for typing this(...) in 2nd constructor

The scope for typing this(...) should include both
constructor params and local defs. The latter are
included to provide more friendly error messages
for references to local definitions.

The scope for typing `this(...)` should include both
constructor params and local defs. The latter are
included to provide more friendly error messages
for references to local definitions.
Copy link
Contributor

@odersky odersky left a comment

Choose a reason for hiding this comment

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

What's important is that a supercall cannot see any members of the enclosing class (defined or inherited). If it could access such members we would get a verify error on the bytecode.

I am not certain whether the change in this PR maintains this restriction. Can we add a neg test that demonstrates that neither defined nor inherited members can be accessed?

@liufengyun
Copy link
Contributor Author

@odersky Just added tests in 4d9c0c5 to show that members are not accessible.

Copy link
Contributor

@odersky odersky left a comment

Choose a reason for hiding this comment

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

With that clarification I am happy.

@liufengyun liufengyun merged commit 1d5e95e into scala:master Sep 13, 2019
@liufengyun liufengyun deleted the fix-3559 branch September 13, 2019 11:41
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.

Dead code in RefCheck for "forward reference in constructor error"
2 participants