Skip to content

Commit 9c4af0f

Browse files
committed
Revert "Disallow direct unqualified mentions of extension methods."
Partial revert of the tests that had to be changed to satisfy the restriction which is now dropped again.
1 parent 697b099 commit 9c4af0f

File tree

5 files changed

+13
-16
lines changed

5 files changed

+13
-16
lines changed

tests/pos/i7401.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@ object Test {
77
x.foo(4)
88
x.foo
99
Test.foo(x)(4)
10-
this.foo(x)
10+
foo(x)
1111
}

tests/pos/reference/extension-methods.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,6 @@ object ExtMethods:
118118
if exponent == 0 then 1 else x * (x ** (exponent - 1))
119119

120120
import DoubleOps.{**}
121-
assert(2.0 ** 3 == DoubleOps.**(2.0)(3))
121+
assert(2.0 ** 3 == **(2.0)(3))
122122

123123
end ExtMethods

tests/run-macros/i6201/macro_1.scala

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,13 @@
11
import scala.quoted._
22

3-
object M:
3+
extension (inline x: String) inline def strip: String =
4+
${ stripImpl('x) }
45

5-
extension (inline x: String) inline def strip: String =
6-
${ stripImpl('x) }
6+
def stripImpl(x: Expr[String])(using qctx: QuoteContext) : Expr[String] =
7+
Expr(x.unliftOrError.stripMargin)
78

8-
def stripImpl(x: Expr[String])(using qctx: QuoteContext) : Expr[String] =
9-
Expr(x.unliftOrError.stripMargin)
9+
inline def isHello(inline x: String): Boolean =
10+
${ isHelloImpl('x) }
1011

11-
inline def isHello(inline x: String): Boolean =
12-
${ isHelloImpl('x) }
13-
14-
def isHelloImpl(x: Expr[String])(using qctx: QuoteContext) : Expr[Boolean] =
15-
if (x.unliftOrError == "hello") Expr(true) else Expr(false)
12+
def isHelloImpl(x: Expr[String])(using qctx: QuoteContext) : Expr[Boolean] =
13+
if (x.unliftOrError == "hello") Expr(true) else Expr(false)

tests/run-macros/i6201/test_2.scala

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
object Test {
2-
import M._
32
def main(args: Array[String]): Unit = {
4-
assert(isHello(M.strip("hello")))
5-
assert(!isHello(M.strip("bonjour")))
3+
assert(isHello(strip("hello")))
4+
assert(!isHello(strip("bonjour")))
65
}
76
}

tests/run/extension-methods.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ object Test extends App {
22

33
extension (x: Int) def em: Boolean = x > 0
44

5-
assert(1.em == this.em(1))
5+
assert(1.em == em(1))
66

77
case class Circle(x: Double, y: Double, radius: Double)
88

0 commit comments

Comments
 (0)