-
Notifications
You must be signed in to change notification settings - Fork 1.1k
forbid default values for extension parameters #12460
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
note that default arguments are still acceptable in locally {
extension (x: String)(using s: String = "default value")
def f1: String = x.reverse
"my string".f1
} |
|
Discussing this with @mbovel, we believe we should put these checks in Refchecks |
You can find our work over there: I left some |
Fixes #12460 I shied away from making it an error, as that is a language change that violates the rule that extension methods are ordinary methods. There are other restrictions, but an extension always allows explicit invocation `m()(x)` that could leverage a default. The caret is wrong on the second test case (~todo~). Edit: span of default getter was union of first parameter and the param RHS, so that the synthetic position of the getter symbol was a point at the first parameter. Now the getter tree gets the span of the RHS. (That span is non-synthetic, but the definition is still synthetic. The name pos of a synthetic is the point.)
Compiler version
Minimized code
Currently this compiles fine:
Expectation
Seems that there are no use cases for it and only misleads
Probably a compiler error should be shown here.
The text was updated successfully, but these errors were encountered: