Skip to content

Commit 682e7b5

Browse files
committed
Syntax Change: Allow '.' in front of extension method
Allow def (c: Circle).circumference: Double alongside def (c: Circle) circumference: Double The syntax with '.' is preferred for normal methods, hose name start with a letter and who are not declared @infix. Right now, this preference is not enforced.
1 parent 58575f9 commit 682e7b5

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

55 files changed

+150
-142
lines changed

compiler/src/dotty/tools/dotc/parsing/Parsers.scala

+6-2
Original file line numberDiff line numberDiff line change
@@ -3105,7 +3105,7 @@ object Parsers {
31053105
* | this ParamClause ParamClauses `=' ConstrExpr
31063106
* DefDcl ::= DefSig `:' Type
31073107
* DefSig ::= id [DefTypeParamClause] DefParamClauses
3108-
* | ExtParamClause [nl] id DefParamClauses
3108+
* | ExtParamClause [nl] [‘.’] id DefParamClauses
31093109
*/
31103110
def defDefOrDcl(start: Offset, mods: Modifiers): Tree = atSpan(start, nameStart) {
31113111
def scala2ProcedureSyntax(resultTypeStr: String) = {
@@ -3134,7 +3134,11 @@ object Parsers {
31343134
makeConstructor(Nil, vparamss, rhs).withMods(mods).setComment(in.getDocComment(start))
31353135
}
31363136
else {
3137-
def extParamss() = try paramClause(0, prefix = true) :: Nil finally newLineOpt()
3137+
def extParamss() =
3138+
try paramClause(0, prefix = true) :: Nil
3139+
finally
3140+
if in.token == DOT then in.nextToken()
3141+
else newLineOpt()
31383142
val (leadingTparams, leadingVparamss, flags) =
31393143
if in.token == LBRACKET then
31403144
(typeParamClause(ParamOwner.Def), extParamss(), Method | Extension)

docs/docs/contributing/debugging.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ But you can also do:
8888
assertPositioned(tree.reporting(s"Tree is: $result"))
8989
```
9090

91-
`def (a: A) reporting(f: given WrappedResult[T] => String, p: Printer = Printers.default): A` is defined on all types. The function `f` can be written without the argument since the argument is `given`. The `result` variable is a part of the `WrapperResult` – a tiny framework powering the `reporting` function. Basically, whenever you are using `reporting` on an object `A`, you can use the `result: A` variable from this function and it will be equal to the object you are calling `reporting` on.
91+
`def (a: A).reporting(f: given WrappedResult[T] => String, p: Printer = Printers.default): A` is defined on all types. The function `f` can be written without the argument since the argument is `given`. The `result` variable is a part of the `WrapperResult` – a tiny framework powering the `reporting` function. Basically, whenever you are using `reporting` on an object `A`, you can use the `result: A` variable from this function and it will be equal to the object you are calling `reporting` on.
9292

9393
## Printing out trees after phases
9494
To print out the trees you are compiling after the FrontEnd (scanner, parser, namer, typer) phases:

docs/docs/internals/syntax.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ ValDcl ::= ids ‘:’ Type
358358
VarDcl ::= ids ‘:’ Type PatDef(_, ids, tpe, EmptyTree)
359359
DefDcl ::= DefSig ‘:’ Type DefDef(_, name, tparams, vparamss, tpe, EmptyTree)
360360
DefSig ::= id [DefTypeParamClause] DefParamClauses
361-
| ExtParamClause [nl] id DefParamClauses
361+
| ExtParamClause [nl] [‘.’] id DefParamClauses
362362
TypeDcl ::= id [TypeParamClause] SubtypeBounds [‘=’ Type] TypeDefTree(_, name, tparams, bound
363363
364364
Def ::= ‘val’ PatDef

docs/docs/reference/contextual/extension-methods.md

+12-8
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Extension methods allow one to add methods to a type after the type is defined.
88
```scala
99
case class Circle(x: Double, y: Double, radius: Double)
1010

11-
def (c: Circle) circumference: Double = c.radius * math.Pi * 2
11+
def (c: Circle).circumference: Double = c.radius * math.Pi * 2
1212
```
1313

1414
Like regular methods, extension methods can be invoked with infix `.`:
@@ -42,7 +42,7 @@ As an example, consider an extension method `longestStrings` on `Seq[String]` de
4242

4343
```scala
4444
trait StringSeqOps {
45-
def (xs: Seq[String]) longestStrings = {
45+
def (xs: Seq[String]).longestStrings = {
4646
val maxLength = xs.map(_.length).max
4747
xs.filter(_.length == maxLength)
4848
}
@@ -80,22 +80,26 @@ So `circle.circumference` translates to `CircleOps.circumference(circle)`, provi
8080

8181
### Operators
8282

83-
The extension method syntax also applies to the definition of operators.
84-
In each case the definition syntax mirrors the way the operator is applied.
83+
The extension method syntax also applies to the definition of operators.
84+
In this case it is allowed and preferable to omit the period between the leading parameter list
85+
and the operator. In each case the definition syntax mirrors the way the operator is applied.
8586
Examples:
8687
```scala
8788
def (x: String) < (y: String) = ...
8889
def (x: Elem) +: (xs: Seq[Elem]) = ...
90+
def (x: Number) min (y: Number) = ...
8991

9092
"ab" < "c"
9193
1 +: List(2, 3)
94+
x min 3
9295
```
93-
The two definitions above translate to
96+
The three definitions above translate to
9497
```scala
9598
def < (x: String)(y: String) = ...
9699
def +: (xs: Seq[Elem])(x: Elem) = ...
100+
def min(x: Number)(y: Number) = ...
97101
```
98-
Note that swap of the two parameters `x` and `xs` when translating
102+
Note the swap of the two parameters `x` and `xs` when translating
99103
the right-binding operator `+:` to an extension method. This is analogous
100104
to the implementation of right binding operators as normal methods.
101105

@@ -144,7 +148,7 @@ If a given extension is anonymous (as in the last clause), its name is synthesiz
144148
The extensions above are equivalent to the following regular given instances where the implemented parent is `AnyRef` and the parameters in the `extension` clause are repeated in each extension method definition:
145149
```scala
146150
given stringOps: AnyRef {
147-
def (xs: Seq[String]) longestStrings: Seq[String] = {
151+
def (xs: Seq[String]).longestStrings: Seq[String] = {
148152
val maxLength = xs.map(_.length).max
149153
xs.filter(_.length == maxLength)
150154
}
@@ -165,7 +169,7 @@ Here are the syntax changes for extension methods and given extensions relative
165169
to the [current syntax](../../internals/syntax.md). `extension` is a soft keyword, recognized only after a `given`. It can be used as an identifier everywhere else.
166170
```
167171
DefSig ::= ...
168-
| ExtParamClause [nl] id DefParamClauses
172+
| ExtParamClause [nl] [‘.’] id DefParamClauses
169173
GivenDef ::= ...
170174
[id ‘:’] ‘extension’ ExtParamClause {GivenParamClause} ExtMethods
171175
ExtParamClause ::= [DefTypeParamClause] ‘(’ DefParam ‘)’

docs/docs/reference/contextual/implicit-function-types.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ object PostConditions {
120120

121121
def result[T](given r: WrappedResult[T]): T = r
122122

123-
def (x: T) ensuring[T](condition: (given WrappedResult[T]) => Boolean): T = {
123+
def (x: T).ensuring[T](condition: (given WrappedResult[T]) => Boolean): T = {
124124
assert(condition(given x))
125125
x
126126
}

docs/docs/reference/contextual/relationship-implicits.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ will map to given clauses instead.
104104

105105
Extension methods have no direct counterpart in Scala 2, but they can be simulated with implicit classes. For instance, the extension method
106106
```scala
107-
def (c: Circle) circumference: Double = c.radius * math.Pi * 2
107+
def (c: Circle).circumference: Double = c.radius * math.Pi * 2
108108
```
109109
could be simulated to some degree by
110110
```scala

docs/docs/reference/contextual/typeclasses.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ with canonical implementations defined by given instances. Here are some example
1111

1212
```scala
1313
trait SemiGroup[T] with
14-
def (x: T) combine (y: T): T
14+
def (x: T).combine(y: T): T
1515

1616
trait Monoid[T] extends SemiGroup[T] with
1717
def unit: T
@@ -20,11 +20,11 @@ object Monoid with
2020
def apply[T](given Monoid[T]) = summon[Monoid[T]]
2121

2222
given Monoid[String] with
23-
def (x: String) combine (y: String): String = x.concat(y)
23+
def (x: String).combine(y: String): String = x.concat(y)
2424
def unit: String = ""
2525

2626
given Monoid[Int] with
27-
def (x: Int) combine (y: Int): Int = x + y
27+
def (x: Int).combine(y: Int): Int = x + y
2828
def unit: Int = 0
2929

3030
def sum[T: Monoid](xs: List[T]): T =

docs/docs/reference/dropped-features/package-objects.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ def b = a._2
2222
case class C()
2323

2424
implicit object Cops {
25-
def (x: C) pair (y: C) = (x, y)
25+
def (x: C).pair(y: C) = (x, y)
2626
}
2727
```
2828
There may be several source files in a package containing such toplevel definitions, and source files can freely mix toplevel value, method, and type definitions with classes and objects.

docs/docs/reference/metaprogramming/macros.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -707,7 +707,7 @@ This might be used to then perform an implicit search as in:
707707

708708

709709
```scala
710-
inline def (sc: StringContext) showMe(args: =>Any*): String = ${ showMeExpr('sc, 'args) }
710+
inline def (sc: StringContext).showMe(args: =>Any*): String = ${ showMeExpr('sc, 'args) }
711711

712712
private def showMeExpr(sc: Expr[StringContext], argsExpr: Expr[Seq[Any]])(given qctx: QuoteContext): Expr[String] = {
713713
argsExpr match {

docs/docs/reference/other-new-features/opaques.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ object Access {
7171

7272
def (x: Permissions) & (y: Permissions): Permissions = x | y
7373
def (x: PermissionChoice) | (y: PermissionChoice): PermissionChoice = x | y
74-
def (x: Permissions) is (y: Permissions) = (x & y) == y
75-
def (x: Permissions) isOneOf (y: PermissionChoice) = (x & y) != 0
74+
def (x: Permissions).is(y: Permissions) = (x & y) == y
75+
def (x: Permissions).isOneOf(y: PermissionChoice) = (x & y) != 0
7676

7777
val NoPermission: Permission = 0
7878
val ReadOnly: Permission = 1

docs/docs/reference/other-new-features/tupled-function.md

+3-3
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ Examples
4343
* @tparam Args the tuple type with the same types as the function arguments of F
4444
* @tparam R the return type of F
4545
*/
46-
def (f: F) tupled[F, Args <: Tuple, R](given tf: TupledFunction[F, Args => R]): Args => R = tf.tupled(f)
46+
def [F, Args <: Tuple, R](f: F).tupled(given tf: TupledFunction[F, Args => R]): Args => R = tf.tupled(f)
4747
```
4848

4949
`TupledFunction` can be used to generalize the `Function.untupled` methods to functions of any arities ([full example](https://github.com/lampepfl/dotty/blob/master/tests/run/tupled-function-untupled.scala))
@@ -58,7 +58,7 @@ def (f: F) tupled[F, Args <: Tuple, R](given tf: TupledFunction[F, Args => R]):
5858
* @tparam Args the tuple type with the same types as the function arguments of F
5959
* @tparam R the return type of F
6060
*/
61-
def (f: Args => R) untupled[F, Args <: Tuple, R](given tf: TupledFunction[F, Args => R]): F = tf.untupled(f)
61+
def [F, Args <: Tuple, R](f: Args => R).untupled(given tf: TupledFunction[F, Args => R]): F = tf.untupled(f)
6262
```
6363

6464
`TupledFunction` can also be used to generalize the [`Tuple1.compose`](https://github.com/lampepfl/dotty/blob/master/tests/run/tupled-function-compose.scala) and [`Tuple1.andThen`](https://github.com/lampepfl/dotty/blob/master/tests/run/tupled-function-andThen.scala) methods to compose functions of larger arities and with functions that return tuples.
@@ -72,7 +72,7 @@ def (f: Args => R) untupled[F, Args <: Tuple, R](given tf: TupledFunction[F, Arg
7272
* @tparam GArgs the tuple type with the same types as the function arguments of G
7373
* @tparam R the return type of F
7474
*/
75-
def (f: F) compose[F, G, FArgs <: Tuple, GArgs <: Tuple, R](g: G)(given tg: TupledFunction[G, GArgs => FArgs], tf: TupledFunction[F, FArgs => R]): GArgs => R = {
75+
def [F, G, FArgs <: Tuple, GArgs <: Tuple, R](f: F).compose(g: G)(given tg: TupledFunction[G, GArgs => FArgs], tf: TupledFunction[F, FArgs => R]): GArgs => R = {
7676
(x: GArgs) => tf.tupled(f)(tg.tupled(g)(x))
7777
}
7878
```

library/src-bootstrapped/scala/IArray.scala

+15-15
Original file line numberDiff line numberDiff line change
@@ -16,27 +16,27 @@ object opaques
1616
* @param n the index of the element to select
1717
* @return the element of the array at the given index
1818
*/
19-
def (arr: IArray[Byte]) apply (n: Int): Byte = arr.asInstanceOf[Array[Byte]].apply(n)
20-
def (arr: IArray[Short]) apply (n: Int): Short = arr.asInstanceOf[Array[Short]].apply(n)
21-
def (arr: IArray[Char]) apply (n: Int): Char = arr.asInstanceOf[Array[Char]].apply(n)
22-
def (arr: IArray[Int]) apply (n: Int): Int = arr.asInstanceOf[Array[Int]].apply(n)
23-
def (arr: IArray[Long]) apply (n: Int): Long = arr.asInstanceOf[Array[Long]].apply(n)
24-
def (arr: IArray[Float]) apply (n: Int): Float = arr.asInstanceOf[Array[Float]].apply(n)
25-
def (arr: IArray[Double]) apply (n: Int): Double = arr.asInstanceOf[Array[Double]].apply(n)
19+
def (arr: IArray[Byte]).apply (n: Int): Byte = arr.asInstanceOf[Array[Byte]].apply(n)
20+
def (arr: IArray[Short]).apply (n: Int): Short = arr.asInstanceOf[Array[Short]].apply(n)
21+
def (arr: IArray[Char]).apply (n: Int): Char = arr.asInstanceOf[Array[Char]].apply(n)
22+
def (arr: IArray[Int]).apply (n: Int): Int = arr.asInstanceOf[Array[Int]].apply(n)
23+
def (arr: IArray[Long]).apply (n: Int): Long = arr.asInstanceOf[Array[Long]].apply(n)
24+
def (arr: IArray[Float]).apply (n: Int): Float = arr.asInstanceOf[Array[Float]].apply(n)
25+
def (arr: IArray[Double]).apply (n: Int): Double = arr.asInstanceOf[Array[Double]].apply(n)
2626
def [T <: Object](arr: IArray[T]) apply (n: Int): T = arr.asInstanceOf[Array[T]].apply(n)
2727
def [T](arr: IArray[T]) apply (n: Int): T = arr.asInstanceOf[Array[T]].apply(n)
2828

2929
/** The number of elements in an immutable array
3030
* @param arr the immutable array
3131
*/
32-
def (arr: IArray[Byte]) length: Int = arr.asInstanceOf[Array[Byte]].length
33-
def (arr: IArray[Short]) length: Int = arr.asInstanceOf[Array[Short]].length
34-
def (arr: IArray[Char]) length: Int = arr.asInstanceOf[Array[Char]].length
35-
def (arr: IArray[Int]) length: Int = arr.asInstanceOf[Array[Int]].length
36-
def (arr: IArray[Long]) length: Int = arr.asInstanceOf[Array[Long]].length
37-
def (arr: IArray[Float]) length: Int = arr.asInstanceOf[Array[Float]].length
38-
def (arr: IArray[Double]) length: Int = arr.asInstanceOf[Array[Double]].length
39-
def (arr: IArray[Object]) length: Int = arr.asInstanceOf[Array[Object]].length
32+
def (arr: IArray[Byte]).length: Int = arr.asInstanceOf[Array[Byte]].length
33+
def (arr: IArray[Short]).length: Int = arr.asInstanceOf[Array[Short]].length
34+
def (arr: IArray[Char]).length: Int = arr.asInstanceOf[Array[Char]].length
35+
def (arr: IArray[Int]).length: Int = arr.asInstanceOf[Array[Int]].length
36+
def (arr: IArray[Long]).length: Int = arr.asInstanceOf[Array[Long]].length
37+
def (arr: IArray[Float]).length: Int = arr.asInstanceOf[Array[Float]].length
38+
def (arr: IArray[Double]).length: Int = arr.asInstanceOf[Array[Double]].length
39+
def (arr: IArray[Object]).length: Int = arr.asInstanceOf[Array[Object]].length
4040
def [T](arr: IArray[T]) length: Int = arr.asInstanceOf[Array[T]].length
4141

4242
/** Returns this array concatenated with the given array. */
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
def (self: T) foo[T] = ??? // error
1+
def (self: T).foo[T] = ??? // error
22
def [T1](self: T1) bar[T2] = ??? // error // error

tests/neg-macros/i6432/Macro_1.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import scala.quoted.autolift.given
44
import scala.quoted.matching._
55

66
object Macro {
7-
inline def (sc: => StringContext) foo (args: String*): Unit = ${ impl('sc) }
7+
inline def (sc: => StringContext).foo(args: String*): Unit = ${ impl('sc) }
88

99
def impl(sc: Expr[StringContext])(given qctx: QuoteContext): Expr[Unit] = {
1010
import qctx.tasty.{_, given}

tests/neg-macros/i6432b/Macro_1.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import scala.quoted.autolift.given
44
import scala.quoted.matching._
55

66
object Macro {
7-
inline def (sc: => StringContext) foo (args: String*): Unit = ${ impl('sc) }
7+
inline def (sc: => StringContext).foo(args: String*): Unit = ${ impl('sc) }
88

99
def impl(sc: Expr[StringContext])(given qctx: QuoteContext): Expr[Unit] = {
1010
import qctx.tasty.{_, given}

tests/neg-macros/reflect-inline/assert_1.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import scala.quoted._
22

33
object api {
4-
inline def (inline x: String) stripMargin2: String =
4+
inline def (inline x: String).stripMargin2: String =
55
${ stripImpl(x) }
66

77
private def stripImpl(x: String)(given qctx: QuoteContext): Expr[String] =

tests/neg-macros/tasty-string-interpolator-position-a/Macro_1.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import scala.language.implicitConversions
33

44
object Macro {
55

6-
implicit inline def (strCtx: => StringContext) f2 (args: =>Any*): String = ${FIntepolator.apply('strCtx, 'args)}
6+
implicit inline def (strCtx: => StringContext).f2(args: =>Any*): String = ${FIntepolator.apply('strCtx, 'args)}
77

88
}
99

tests/neg-macros/tasty-string-interpolator-position-b/Macro_1.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import scala.language.implicitConversions
33

44
object Macro {
55

6-
implicit inline def (strCtx: => StringContext) f3 (args: =>Any*): String = ${FIntepolator.apply('strCtx, 'args)}
6+
implicit inline def (strCtx: => StringContext).f3(args: =>Any*): String = ${FIntepolator.apply('strCtx, 'args)}
77

88
}
99

tests/neg/extension-methods.scala

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
object Test {
22

33
implicit object O {
4-
def (x: String) l1 = x.length
4+
def (x: String).l1 = x.length
55
def l1(x: Int) = x * x
66
def l2(x: String) = x.length
77
}
@@ -11,7 +11,7 @@ object Test {
1111
1.l1 // error
1212

1313
given [T](xs: List[T]) extended with {
14-
def (x: Int) f1: T = ??? // error: No extension method allowed here, since collective parameters are given
14+
def (x: Int).f1: T = ??? // error: No extension method allowed here, since collective parameters are given
1515
def f2[T]: T = ??? // error: T is already defined as type T
1616
def f3(xs: List[T]) = ??? // error: xs is already defined as value xs
1717
}

tests/neg/extmethod-override.scala

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
class A {
22
def f(x: Int)(y: Int): Int = 0
3-
def (x: Int) g (y: Int): Int = 1
3+
def (x: Int).g(y: Int): Int = 1
44
}
55
class B extends A {
6-
override def (x: Int) f (y: Int): Int = 1 // error
6+
override def (x: Int).f(y: Int): Int = 1 // error
77
override def g(x: Int)(y: Int): Int = 0 // error
88
}

tests/neg/i5773.scala

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
trait Semigroup[T] {
2-
def (lhs: T) append (rhs: T): T
3-
def (lhs: Int) appendS (rhs: T): T = ???
2+
def (lhs: T).append(rhs: T): T
3+
def (lhs: Int).appendS(rhs: T): T = ???
44
}
55

66
object Semigroup {
77
implicit object stringAppend extends Semigroup[String] {
8-
override def (lhs: String) append (rhs: String): String = lhs + rhs
8+
override def (lhs: String).append(rhs: String): String = lhs + rhs
99
}
1010

1111
implicit def sumSemigroup[N](implicit N: Numeric[N]): Semigroup[N] = new {
12-
override def (lhs: N) append (rhs: N): N = N.plus(lhs, rhs)
13-
def (lhs: Int) appendS (rhs: N): N = ??? // N.plus(lhs, rhs)
12+
override def (lhs: N).append(rhs: N): N = N.plus(lhs, rhs)
13+
def (lhs: Int).appendS(rhs: N): N = ??? // N.plus(lhs, rhs)
1414
}
1515
}
1616

tests/neg/i6762b.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,5 @@ type Liftable
99
given Liftable = ???
1010

1111
implicit object ExprOps {
12-
def (x: T) toExpr[T](given Liftable): Expr[T] = ???
12+
def (x: T).toExpr[T](given Liftable): Expr[T] = ???
1313
}

tests/neg/i6779.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ type G[T]
33
type Stuff
44
given Stuff = ???
55

6-
def (x: T) f[T](given Stuff): F[T] = ???
6+
def (x: T).f[T](given Stuff): F[T] = ???
77

88

99
def g1[T](x: T): F[G[T]] = x.f(given summon[Stuff]) // error

tests/neg/i7438.scala

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
type Tr[+A]
2-
inline def (tr: Tr[A]) map[A, B](f: A => B): Tr[B] = ???
2+
inline def (tr: Tr[A]).map[A, B](f: A => B): Tr[B] = ???
33

4-
def (d: Double) func: None.type => Some[Double] = ???
4+
def (d: Double).func: None.type => Some[Double] = ???
55

66
def run[A](query: None.type => Some[A]): Some[A] = ???
77

tests/neg/indent.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
object Test {
22

3-
def (x: Int) gt (y: Int) = x > y
3+
def (x: Int).gt (y: Int) = x > y
44
val y3 =
55
if (1) max 10 gt 0 // error: end of statement expected but integer literal found // error // error // error
66
1

tests/neg/opaque-bounds.scala

+2-2
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ object Access {
2121

2222
def (x: Permissions) & (y: Permissions): Permissions = x & y
2323
def (x: PermissionChoice) | (y: PermissionChoice): PermissionChoice = x | y
24-
def (x: Permissions) is (y: Permissions) = (x & y) == y
25-
def (x: Permissions) isOneOf (y: PermissionChoice) = (x & y) != 0
24+
def (x: Permissions).is (y: Permissions) = (x & y) == y
25+
def (x: Permissions).isOneOf (y: PermissionChoice) = (x & y) != 0
2626

2727
val NoPermission: Permission = 0
2828
val ReadOnly: Permission = 1

0 commit comments

Comments
 (0)