Extension of Inner Classes #17650
ftucky
started this conversation in
Feature Requests
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Scala Version
3.2.2
Minimized Code
Result
Compilation fails with
value next is not a member of A#X
.Expectation
Would be elegant to let code compile.
For an inner projection
P#T
,(x:P#T).extensionMethod(args)
would desugar into something similar toRationale
In a pattern where the inner class is final but the outer class is open, it is elegant to create extensions which only make sense on the subclasses of the outer class.
So that
bx:B#X
s have afoo
method, whileax:A#X
s do not.Today, a significant boiler plate is necessary:
deflect
method is present in the innerclass, and must be left public.Beta Was this translation helpful? Give feedback.
All reactions