-
Notifications
You must be signed in to change notification settings - Fork 1.1k
transparent macro : Unexpected loss of refinement #17398
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
That seems as designed to me, and not related to macros to me. If you manually write such an anonymous class at call site, it will also lose its refinement due to type inference. You would also have to explicitly type is as a refinement to preserve it.
So that is the correct solution (not a workaround). |
refinements of anonymous classes are only inferred if they derive from |
OK, then observations (1) and (2) (where refinement of an anonymous class not deriving from |
What's going on here is a bit subtle:
|
Uh oh!
There was an error while loading. Please reload this page.
Compiler version
3.2.2,
3.3.1-RC1-bin-20230328-5c2efc5-NIGHTLY
Minimized code
Transparent Macro:
Usage:
whiteMacro[Nothing]
Output
Expectation
The returned type is expected to be refined:
Observations:
(1) When the upper bound of
Out
intrait ViewOf[M]
is removed, correct behavior is restored:(2) When the type assigned in the anonymous class does not come from the type match, correct behavior is restored:
(3) When a type ascription is placed on the anonymous class, correct behavior is restored. (thank you, @smarter )
More context
https://stackoverflow.com/questions/74549477/scala3-crafting-types-through-metaprogramming/74575615#74575615
The text was updated successfully, but these errors were encountered: