File tree Expand file tree Collapse file tree 9 files changed +13
-17
lines changed
compiler/src/dotty/tools/dotc/parsing Expand file tree Collapse file tree 9 files changed +13
-17
lines changed Original file line number Diff line number Diff 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
Original file line number Diff line number Diff line change 11object 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
Original file line number Diff line number Diff line change 11opaque 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
88object Opt
99{
Original file line number Diff line number Diff line change @@ -9,5 +9,5 @@ type Liftable
99given Liftable = ???
1010
1111implicit object ExprOps {
12- def (x : T ).toExpr[ T ] (using Liftable ): Expr [T ] = ???
12+ def [ T ] (x : T ).toExpr(using Liftable ): Expr [T ] = ???
1313}
Original file line number Diff line number Diff line change @@ -3,7 +3,7 @@ type G[T]
33type Stuff
44given Stuff = ???
55
6- def (x : T ).f[ T ] (using Stuff ): F [T ] = ???
6+ def [ T ] (x : T ).f(using Stuff ): F [T ] = ???
77
88
99def g1 [T ](x : T ): F [G [T ]] = x.f(using summon[Stuff ]) // error
Original file line number Diff line number Diff line change 11type 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
44def (d : Double ).func: None .type => Some [Double ] = ???
55
Original file line number Diff line number Diff line change @@ -3,8 +3,8 @@ class Err
33type Lifted [A ] = Err | A
44
55def 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
99val error : Err = Err ()
1010
Original file line number Diff line number Diff 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 }
Original file line number Diff line number Diff line change 11import scala .quoted ._
22
33object 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 ] = {
You can’t perform that action at this time.
0 commit comments