-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Fix #2117: bug in typechecking super prefix with invalid enclosing class #2118
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
Conversation
case p :: q :: _ => | ||
errorType("ambiguous parent class qualifier", tree.pos) | ||
qual.tpe match { | ||
case err: ErrorType => untpd.cpy.Super(tree)(qual, mix).withType(err) |
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.
Is this necessary, or can I just do tree.withType(err)
?
In general, when I should I be using the tree copier?
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.
Tree copier provides structural sharing and is used when you think that the tree might stay the same after your changes.
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.
Thanks. In this case, would it be ok/better to do tree.withType(err)
?
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.
What would be a good place to unit tests for this?
Thanks for the contribution!
tests/neg/i2117.scala. Would you also kindly update commit message to "Fix #2117: ..." |
Added the test. PTAL. |
When typechecking class A { C.super.foo() } If C isn't an enclosing class, the compiler was throwing because of an unguarded pattern match. Fix the issue by checking for ErrorType. Tested: Verified that the example above no longer throws. Added a test.
"i" means issue and refers to an issue number on https://github.com/lampepfl/dotty/issues. "t" means ticket and refers to an issue number on scalac bug tracker (because the test was imported from scalac): https://issues.scala-lang.org/secure/Dashboard.jspa |
Friendly ping @DarkDimius @smarter @felixmulder |
@abeln, thank you for pinging. It's good as is. |
When typechecking
class A { C.super.foo() }
If C isn't an enclosing class, the compiler was throwing because of an
unguarded pattern match.
Fix the issue by checking for ErrorType.
Tested:
Verified that the example above no longer throws.