-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Defend against AliasingBounds #23668
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
base: main
Are you sure you want to change the base?
Conversation
|
Ready for review in the sense of open to suggestions. |
|
I appreciate the Odersky PR that says "we need a better solution". This is such a PR, if only it had a PR label. |
| val target = | ||
| val target0 = explicitInfo.firstParamTypes.head // required for extension method, the putative receiver | ||
| target0.dealiasKeepOpaques.typeSymbol.info | ||
| target0.dealiasKeepOpaques.typeSymbol.info match |
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.
This is kind of weird since dealias does skip aliasing bounds. It would be good to get an explanation what exactly goes wrong here. What's the type of target0.dealiasKeepOpaques in the failing test? What is its info? Is there an opaque type involved?
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.
The correct working idiom is
explicitInfo.firstParamTypes.head.typeSymbol.typeRef.dealiasKeepOpaques
but requires reworking https://github.com/scala/scala3/pull/22502/files
or dealias should handle TypeAlias directly.
36dba58 to
8edcb7c
Compare
In refchecks for extension methods, obtain a TypeRef of the receiver parameter type, so that it is correctly dealiased. The prior idiom produced a TypeAlias.
8edcb7c to
b289913
Compare
|
Flaky test in CB probes |
Fixes #23666
Improve use of existing API. The fix is instead of using param's
symbol.info, usesymbol.typeRef.dealiasand follow upper bounds, with a special case in the "subsumes" check for type param; and also a guard to not dealias an opaque type by using its bounds.