Skip to content

Commit c9a4196

Browse files
authored
Merge pull request #9093 from dotty-staging/fix-#9091
Fix #9091: Drop deprecated extension method syntax
2 parents 53f95d1 + ffe859e commit c9a4196

File tree

9 files changed

+13
-17
lines changed

9 files changed

+13
-17
lines changed

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

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3320,11 +3320,7 @@ object Parsers {
33203320
mods1 = mods1.withAddedAnnotation(infixAnnot)
33213321
val tparams =
33223322
if in.token == LBRACKET then
3323-
if mods1.is(Extension) then
3324-
if leadingTparams.isEmpty then
3325-
deprecationWarning("type parameters in extension methods should be written after `def`")
3326-
else
3327-
syntaxError("no type parameters allowed here")
3323+
if mods1.is(Extension) then syntaxError("no type parameters allowed here")
33283324
typeParamClause(ParamOwner.Def)
33293325
else leadingTparams
33303326
val vparamss = paramClauses() match

tests/init/crash/i5606.scala

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

3-
def (f: A => B) `$`[A, B](a: A): B = f(a)
3+
def [A, B](f: A => B) `$` (a: A): B = f(a)
44

55
assert((((a: Int) => a.toString()) `$` 10) == "10")
66

tests/neg/i6662.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
opaque type Opt[A >: Null] = A
22

3-
inline def (x: Opt[A]) nonEmpty[A >: Null]: Boolean = x.get != null // error: Implementation restriction
4-
inline def (x: Opt[A]) isEmpty[A >: Null]: Boolean = x.get == null // error: Implementation restriction
5-
inline def (x: Opt[A]) isDefined[A >: Null]: Boolean = x.nonEmpty // error: Implementation restriction
6-
inline def (x: Opt[A]) get[A >: Null]: A = Opt.unOpt(x) // error: Implementation restriction
3+
inline def [A >: Null](x: Opt[A]) nonEmpty: Boolean = x.get != null // error: Implementation restriction
4+
inline def [A >: Null](x: Opt[A]) isEmpty: Boolean = x.get == null // error: Implementation restriction
5+
inline def [A >: Null](x: Opt[A]) isDefined: Boolean = x.nonEmpty // error: Implementation restriction
6+
inline def [A >: Null](x: Opt[A]) get: A = Opt.unOpt(x) // error: Implementation restriction
77

88
object Opt
99
{

tests/neg/i6762b.scala

Lines changed: 1 addition & 1 deletion
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](using Liftable): Expr[T] = ???
12+
def [T](x: T).toExpr(using Liftable): Expr[T] = ???
1313
}

tests/neg/i6779.scala

Lines changed: 1 addition & 1 deletion
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](using Stuff): F[T] = ???
6+
def [T](x: T).f(using Stuff): F[T] = ???
77

88

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

tests/neg/i7438.scala

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

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

tests/pos/i6565.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@ class Err
33
type Lifted[A] = Err | A
44

55
def point[O](o: O): Lifted[O] = o
6-
def (o: Lifted[O]) map [O, U] (f: O => U): Lifted[U] = ???
7-
def (o: Lifted[O]) flatMap [O, U] (f: O => Lifted[U]): Lifted[U] = ???
6+
def [O, U](o: Lifted[O]).map(f: O => U): Lifted[U] = ???
7+
def [O, U](o: Lifted[O]).flatMap(f: O => Lifted[U]): Lifted[U] = ???
88

99
val error: Err = Err()
1010

tests/run-macros/i6772/Macro_1.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ object Macros {
77
def mImpl()(using QuoteContext): Expr[Any] =
88
List(Expr(1), Expr(2), Expr(3)).toExprOfList
99

10-
def (list: List[Expr[T]]).toExprOfList[T](using Type[T], QuoteContext): Expr[List[T]] = '{
10+
def [T](list: List[Expr[T]]).toExprOfList(using Type[T], QuoteContext): Expr[List[T]] = '{
1111
val buff = List.newBuilder[T]
1212
${ Expr.block(list.map(v => '{ buff += $v }), '{ buff.result() }) }
1313
}

tests/run-macros/reflect-sourceCode/Macro_1.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import scala.quoted._
22

33
object api {
4-
inline def (x: => T) reflect[T] : String =
4+
inline def [T](x: => T).reflect: String =
55
${ reflImpl('x) }
66

77
private def reflImpl[T](x: Expr[T])(implicit qctx: QuoteContext): Expr[String] = {

0 commit comments

Comments
 (0)