File tree 9 files changed +13
-17
lines changed
compiler/src/dotty/tools/dotc/parsing 9 files changed +13
-17
lines changed Original file line number Diff line number Diff line change @@ -3320,11 +3320,7 @@ object Parsers {
3320
3320
mods1 = mods1.withAddedAnnotation(infixAnnot)
3321
3321
val tparams =
3322
3322
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" )
3328
3324
typeParamClause(ParamOwner .Def )
3329
3325
else leadingTparams
3330
3326
val vparamss = paramClauses() match
Original file line number Diff line number Diff line change 1
1
object Test extends App {
2
2
3
- def (f : A => B ) `$`[ A , B ] (a : A ): B = f(a)
3
+ def [ A , B ] (f : A => B ) `$` (a : A ): B = f(a)
4
4
5
5
assert((((a : Int ) => a.toString()) `$` 10 ) == " 10" )
6
6
Original file line number Diff line number Diff line change 1
1
opaque type Opt [A >: Null ] = A
2
2
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
7
7
8
8
object Opt
9
9
{
Original file line number Diff line number Diff line change @@ -9,5 +9,5 @@ type Liftable
9
9
given Liftable = ???
10
10
11
11
implicit object ExprOps {
12
- def (x : T ).toExpr[ T ] (using Liftable ): Expr [T ] = ???
12
+ def [ T ] (x : T ).toExpr(using Liftable ): Expr [T ] = ???
13
13
}
Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ type G[T]
3
3
type Stuff
4
4
given Stuff = ???
5
5
6
- def (x : T ).f[ T ] (using Stuff ): F [T ] = ???
6
+ def [ T ] (x : T ).f(using Stuff ): F [T ] = ???
7
7
8
8
9
9
def g1 [T ](x : T ): F [G [T ]] = x.f(using summon[Stuff ]) // error
Original file line number Diff line number Diff line change 1
1
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 ] = ???
3
3
4
4
def (d : Double ).func: None .type => Some [Double ] = ???
5
5
Original file line number Diff line number Diff line change @@ -3,8 +3,8 @@ class Err
3
3
type Lifted [A ] = Err | A
4
4
5
5
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 ] = ???
8
8
9
9
val error : Err = Err ()
10
10
Original file line number Diff line number Diff line change @@ -7,7 +7,7 @@ object Macros {
7
7
def mImpl ()(using QuoteContext ): Expr [Any ] =
8
8
List (Expr (1 ), Expr (2 ), Expr (3 )).toExprOfList
9
9
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 ]] = ' {
11
11
val buff = List .newBuilder[T ]
12
12
$ { Expr .block(list.map(v => ' { buff += $v }), ' { buff.result() }) }
13
13
}
Original file line number Diff line number Diff line change 1
1
import scala .quoted ._
2
2
3
3
object api {
4
- inline def (x : => T ) reflect[ T ] : String =
4
+ inline def [ T ] (x : => T ). reflect: String =
5
5
$ { reflImpl(' x ) }
6
6
7
7
private def reflImpl [T ](x : Expr [T ])(implicit qctx : QuoteContext ): Expr [String ] = {
You can’t perform that action at this time.
0 commit comments