-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Default given value doesn't work inside given definition #20088
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
Might be related to #19414. If we tweak lookup of implicits with default arguments, maybe that could also fix this issue. |
While the reporting would be improved by the fix of #19414, the core issue is different; it's related to the designing of trait Foo
trait Bar
given wrong(using foo: Foo = new {}): Bar with {}
given good(using foo: Foo): Bar with {} [[syntax trees at end of typer]] // tests/neg/20088.scala
package <empty> {
...
final module class 20088$package() extends Object() {
...
given class wrong(using foo: Foo) extends Object(), Bar { ... }
final lazy module val wrong: wrong = new wrong()
final module class wrong() extends AnyRef() { this: wrong.type => ... }
final given def wrong(using foo: Foo): wrong = new wrong(using foo)()
given class good(using foo: Foo) extends Object(), Bar { ... }
final given def good(using foo: Foo): good = new good(using foo)()
}
} Seems to be the name of the generated companion object for |
Actually, the name clash is not a problem. The issue is that the lookup for default argument fails: the default parameters getters are associated to the constructor, not to the generated implicit wrapper, and are not found. |
Compiler version
3.4.0
Minimized code
Output
Expectation
Minimized code should compile
Alternatively, compiler should prevent (or at least warn) user from giving context parameters default values inside given definition.
The text was updated successfully, but these errors were encountered: