Repository navigation
Fix handling of AppliedType aliases in outerPrefix - #20190
Conversation
Fixes scala#10184 The overlooked case was an AppliedType where we don't dealias correctly (i.e. at phase at most erasure).
|
This also seems to fix the underlying issue with parboiled2, which required a workaround previously. |
There was a problem hiding this comment.
Edited: It's is hard to come up with a simple test case causing the issue with match types, since they get simplified in Typer for now.
trait Color
trait A:
type C
type R = C match
case Color => C
def outer3Local =
object Inner:
case class Rgb() extends Color
val b = new A:
type C = Inner.Rgb
// compiles if definition of R is moved here
new b.R() // Error: b.R is not a class typeThis is not the same problem, but I think once it is fixed we would get the current issue in outerPrefix again.
| case tpe: TypeProxy => | ||
| outerPrefix(tpe.underlying) | ||
| } | ||
| atPhaseNoLater(erasurePhase)(outerPrefix(tpe.superType)) |
There was a problem hiding this comment.
superType will reduce AppliedTypes but not match types, so I think we could still trigger the issue.
|
@EugeneFlesselle ready to merge? |
EugeneFlesselle
left a comment
There was a problem hiding this comment.
The previous example still fails, having reviewed the spec with sjrd, it is clear that it should indeed fail, for the same reasons as in #20259, even though similar cases with match types pass since they go though simplified.
It actually seems that the spec isn't clear about if type Id[X] = X should be accepted either, it addresses more specifically cases such as type A[X] = Array[X]. Either way, there is no simple was of differentiating them, so I think we can merge this.
Fixes #20184
The overlooked case was an AppliedType where we don't dealias correctly (i.e. at phase at most erasure).