-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Fix unreachable warning in deeply nested sealed hierarchy #18706
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
Fix unreachable warning in deeply nested sealed hierarchy #18706
Conversation
Without applying we were constructing the type Jacket#Body, instead of Jacket[?]#Body, which lead down to an incorrect isSubSpace calculation and thus an unreachable warning.
7ccba02
to
9460b7d
Compare
@@ -883,7 +883,7 @@ object TypeOps: | |||
else if symbol.is(Module) then | |||
TermRef(this(tref.prefix), symbol.sourceModule) | |||
else if (prefixTVar != null) | |||
this(tref) | |||
this(tref.applyIfParameterized(tref.typeParams.map(_ => WildcardType))) |
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.
It's not clear why this is correct.
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.
I tried to detail it in the commit message (9460b7d) - given something like:
class Jacket[T]:
sealed trait BodyType
As we map over the type Jacket.this.BodyType
we don't want to take the raw type Jacket
, stripped from its ThisType wrapper, and have it be the prefix of BodyType
, because we would then get Jacket#BodyType
which is ill-formed. Instead we mean to refer to any the BodyType nested class of any Jacket: Jacket[?]#BodyType
.
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 for the explanation. I now see the type will be upper bound for prefixTVar
, so it's harmless.
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.
LGTM
@@ -883,7 +883,7 @@ object TypeOps: | |||
else if symbol.is(Module) then | |||
TermRef(this(tref.prefix), symbol.sourceModule) | |||
else if (prefixTVar != null) | |||
this(tref) | |||
this(tref.applyIfParameterized(tref.typeParams.map(_ => WildcardType))) |
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 for the explanation. I now see the type will be upper bound for prefixTVar
, so it's harmless.
No description provided.