-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Crash when refining a private type member #19929
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
Comments
Fixes scala#19929 Two main changes: - In TypeErasure, throw a TypeError instead of a FatalError if a supertype of an applied type does not exist. That way, we get a proper error with a position. - Move some catch-and-rethrow logic from ReTyper to TreeChecker. ReTyper alreayd had special exceptions that disabled the logic for all uses of ReTyper except TreeChecker. Unfortunately the ReTyper override also disabled the special TypeError handling in Typer.
The fixing commit has been merged since. I think it was on another PR. |
Fixes scala#19929 Two main changes: - In TypeErasure, throw a TypeError instead of a FatalError if a supertype of an applied type does not exist. That way, we get a proper error with a position. - Move some catch-and-rethrow logic from ReTyper to TreeChecker. ReTyper alreayd had special exceptions that disabled the logic for all uses of ReTyper except TreeChecker. Unfortunately the ReTyper override also disabled the special TypeError handling in Typer.
The test case no longer crashes and does not give an error either. I expected it to mean we are refining the trait A with an unrelated public type member M, which would be ok, even if non-obvious. But that does not seem to be the case: type Aux[m] = A {type M = m}
type Leak[a] = a match
case Aux[m] => m
trait A:
private type M
def m: Leak[this.type]
def foo(a: A{type M = Int}): Int = a.m compiles. But should it ? I expected something like a non-private method refers to a private type in its signature error, or |
Yes, that would be consistent with how a public def in a subclass can have the same name as a private def, otherwise adding a private definition could break backward compatibility. |
So it should not compile right ? |
Right |
Fixes #19929 Two main changes: - In TypeErasure, throw a TypeError instead of a FatalError if a supertype of an applied type does not exist. That way, we get a proper error with a position. - Move some catch-and-rethrow logic from ReTyper to TreeChecker. ReTyper already had special exceptions that disabled the logic for all uses of ReTyper except TreeChecker. Unfortunately the ReTyper override also disabled the special TypeError handling in Typer. The root cause of #19929 got fixed by another PR, but I think it's still good to do the hardening of this commit.
Fixes #19929 Two main changes: - In TypeErasure, throw a TypeError instead of a FatalError if a supertype of an applied type does not exist. That way, we get a proper error with a position. - Move some catch-and-rethrow logic from ReTyper to TreeChecker. ReTyper alreayd had special exceptions that disabled the logic for all uses of ReTyper except TreeChecker. Unfortunately the ReTyper override also disabled the special TypeError handling in Typer. [Cherry-picked 822e792]
Compiler version
3.4.2-RC1
Minimized code
Note that replacing
???
with0
gives an error instead.Output (click arrow to expand)
The text was updated successfully, but these errors were encountered: