You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
At least:
At the extension method def: Warning: extension method string is shadowed by method string of Foo, as extension methods have lower precedence
The text was updated successfully, but these errors were encountered:
It might be obvious to always warn in the case of public methods.
For the many ways in which an extension method may fail to be invoked, it feels like a lint.
It might also be obvious that
package p:
case class C(i: Int):
private[p] def c = "class"
package q:
import p.C
extension (c: C)
private[q] def c = "ext"
@main def test() = println {
val c = C(42)
c.c
}
The reference doesn't tell us how to call/name "extension invocation syntax" versus "direct invocation syntax".
I wonder if anyone uses extension definition syntax intended just for direction invocation.
extension (phase: Phase)
def enteringPhase[A](body: => A) = ???
def exitingPhase[A](body: => A) = ???
where it's not intended to write TyperPhase.enteringPhase(body) but always enteringPhase(TyperPhase) { body }.
Then the definition syntax is just a convenience to avoid a common first parameter list.
Maybe in that case, it would still be unintended to clash with an existing method on the class.
Compiler version
3.1.3
Minimized code
https://scastie.scala-lang.org/5n1lj6mQR4CLQGRy7pFjZQ
Output
scastie worksheet outputs:
Particularly surprising for string interpolation:
https://scastie.scala-lang.org/s9eUw4j7SrSNZgNrbzgEzg
Expectation
At least:
At the extension method def:
Warning: extension method string is shadowed by method string of Foo, as extension methods have lower precedence
The text was updated successfully, but these errors were encountered: