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
object Test:
import C.f
class C:
def m(): Unit = println("m()")
def test: Unit = for { i <- 1 to 2 } do { this.f; println(i); f }
object C:
extension(self: C) { def f: Unit = self.m() }
Output
m()
1
m()
2
Expectation
The second (or any) unqualified call to f should use C.this for self.
m()
1
m()
m()
2
m()
Nevertheless, if the first this.f is replaced with unqualified call to f, the compiler issues a warning:
missing argument list for value of type Test.C => Unit
The text was updated successfully, but these errors were encountered:
There was an old scala 2 ticket for the same intuition for implicits (by paulp).
I agree that it's too bad there is no warning about the mistake. The error in "statement position" is very helpful.
I had to remind myself why -Wnonunit-statement is also unhelpful. (The warning is ignored by IterableOnce et al.) As a mere lint, it could special-case foreach.
Compiler version
3.4.2-RC1
Minimized code
Output
Expectation
The second (or any) unqualified call to
f
should useC.this
forself
.Nevertheless, if the first
this.f
is replaced with unqualified call tof
, the compiler issues a warning:The text was updated successfully, but these errors were encountered: