Skip to content

Commit 6264ff2

Browse files
committed
Convert more tests to postfix as
1 parent 7b57ad6 commit 6264ff2

Some content is hidden

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

43 files changed

+94
-89
lines changed

scala3doc-testcases/src/tests/givenSignatures.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,11 @@ class GivenClass {
2020
if (x < y) -1 else if (x > y) +1 else 0
2121
}
2222

23-
given asd(using int: Int) as B
23+
given (int: Int) => B as asd
2424

25-
given asd2[T] as C[T]
25+
given [T] => C[T] as asd2
2626

27-
given listOrd[T](using ord: Ord[T]) as Ord[List[T]] {
27+
given [T] => (ord: Ord[T]) => Ord[List[T]] as listOrd {
2828

2929
def compare(xs: List[T], ys: List[T]): Int = (xs, ys) match
3030
case (Nil, Nil) => 0

tests/disabled/pos-macros/i7853/JsonEncoder_1.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ object JsonEncoder {
3535
}
3636
}
3737

38-
given listEncoder[T](using encoder: JsonEncoder[T]) as JsonEncoder[List[T]] {
38+
given [T] => (encoder: JsonEncoder[T]) => JsonEncoder[List[T]] as listEncoder {
3939
def encode(list: List[T]) = s"[${ list.map(v => encoder.encode(v)).mkString(", ") }]"
4040
}
4141

tests/disabled/pos/i8311.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ class Foo
88

99
object test:
1010

11-
given box[A](using Show[A]) as Show[Box[A]] = _.toString
11+
given [A] => Show[A] => Show[Box[A]] as box = _.toString
1212
given Show[Foo] as foo = _.toString
1313

1414
def run(s: Box[Box[Foo]]): Unit =

tests/init/crash/i6914.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ object test1 {
55
class ToExpr[T](using Liftable[T]) extends Conversion[T, Expr[T]] {
66
def apply(x: T): Expr[T] = ???
77
}
8-
given toExprFun[T](using Liftable[T]) as ToExpr[T]
8+
given [T] => (Liftable[T]) => ToExpr[T] as toExprFun
99

1010
given Liftable[Int] = ???
1111
given Liftable[String] = ???
@@ -18,7 +18,7 @@ object test1 {
1818

1919
object test2 {
2020

21-
given autoToExpr[T](using Liftable[T]) as Conversion[T, Expr[T]] {
21+
given [T] => (Liftable[T]) => Conversion[T, Expr[T]] as autoToExpr {
2222
def apply(x: T): Expr[T] = ???
2323
}
2424

tests/neg/eql.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
object lst:
22
opaque type Lst[+T] = Any
33
object Lst:
4-
given lstCanEqual[T, U] as CanEqual[Lst[T], Lst[U]] = CanEqual.derived
4+
given [T, U] => CanEqual[Lst[T], Lst[U]] as lstCanEqual = CanEqual.derived
55
val Empty: Lst[Nothing] = ???
66
end lst
77

tests/neg/i5978.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@ trait TokenParser[Token, R]
77
object TextParser {
88
given TokenParser[Char, Position[CharSequence]] as tp {}
99

10-
given FromCharToken(using T: TokenParser[Char, Position[CharSequence]])
11-
as Conversion[Char, Position[CharSequence]] = ???
10+
given (T: TokenParser[Char, Position[CharSequence]])
11+
=> Conversion[Char, Position[CharSequence]]
12+
as FromCharToken = ???
1213
}
1314

1415
object Testcase {

tests/neg/i7248.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
object Test extends App {
2-
given f[H](using h: H) as H = h
2+
given [H] => (h: H) => H as f = h
33
summon[Int] // error
44
}

tests/neg/i7249.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ trait F[H, T]
44

55

66
object Test extends App {
7-
given f[H, T](using h: H, t: T) as F[H, T] = ???
7+
given [H, T] => (h: H, t: T) => F[H, T] as f = ???
88
summon[F[Int, Unit]] // error
99
}

tests/neg/i7294-a.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package foo
22

33
trait Foo { def g(x: Int): Any }
44

5-
inline given f[T <: Foo] as T = ??? match {
5+
inline given [T <: Foo] => T as f = ??? match {
66
case x: T => x.g(10) // error
77
}
88

tests/neg/i7294-b.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package foo
22

33
trait Foo { def g(x: Any): Any }
44

5-
inline given f[T <: Foo] as T = ??? match {
5+
inline given [T <: Foo] => T as f = ??? match {
66
case x: T => x.g(10) // error
77
}
88

tests/neg/i7459.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ object Eq {
4747
}
4848
}
4949

50-
inline given derived[T](using m: Mirror.Of[T]) as Eq[T] = {
50+
inline given [T] => (m: Mirror.Of[T]) => Eq[T] as derived = {
5151
val elemInstances = summonAll[m.MirroredElemTypes]
5252
inline m match {
5353
case s: Mirror.SumOf[T] => eqSum(s, elemInstances)

tests/neg/missing-implicit2.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,12 @@ object test:
66
given Y as y = ???
77
}
88
locally {
9-
given xFromY(using y: Y) as X = ???
9+
given (y: Y) => X as xFromY = ???
1010
f(using xFromY) // error
1111
}
1212
locally {
1313
object instances2 {
14-
given xFromY(using Y) as X = ???
14+
given (Y) => X as xFromY = ???
1515
}
1616
f // error
1717
}

tests/neg/missing-implicit3.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package ord
33
trait Ord[A]
44

55
object Ord {
6-
given ordered[A](using A => java.lang.Comparable[? >: A]) as Ord[A] = ???
6+
given [A] => (A => java.lang.Comparable[? >: A]) => Ord[A] as ordered = ???
77
}
88

99
def sort[A: Ord](as: List[A]): List[A] = ???

tests/neg/multi-param-derives.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ object Test extends App {
66
object Show {
77
given Show[Int] {}
88
given [T] => (st: Show[T]) => Show[Tuple1[T]] {}
9-
given t2[T, U](using st: Show[T], su: Show[U]) as Show[(T, U)] {}
10-
given t3[T, U, V](using st: Show[T], su: Show[U], sv: Show[V]) as Show[(T, U, V)] {}
9+
given [T, U] => (st: Show[T], su: Show[U]) => Show[(T, U)] as t2 {}
10+
given [T, U, V] => (st: Show[T], su: Show[U], sv: Show[V]) => Show[(T, U, V)] as t3 {}
1111

1212
def derived[T](using m: Mirror.Of[T], r: Show[m.MirroredElemTypes]): Show[T] = new Show[T] {}
1313
}

tests/pending/pos/i10161.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ object Incompat3 {
1111
trait Context { type Out }
1212

1313
object Context {
14-
given foo(using ctx: Context) as Option[ctx.Out] = ???
14+
given (ctx: Context) => Option[ctx.Out] as foo = ???
1515

16-
given bar(using ctx: Context) as (Option[ctx.Out], String) = (foo, "foo")
16+
given (ctx: Context) => (Option[ctx.Out], String) as bar = (foo, "foo")
1717
}
1818
}

tests/pos-custom-args/erased/i7868.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ object Coproduct {
1212

1313
object At {
1414

15-
given atHead[Head, Tail] as At[Head +: Tail, Head, 0] {
15+
given [Head, Tail] => At[Head +: Tail, Head, 0] as atHead {
1616
def cast: Head <:< Head +: Tail = summon[Head <:< Head +: Tail]
1717
}
1818

tests/pos-custom-args/erased/i7878.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ object Boom {
22
import scala.compiletime._
33
trait Fail[A <: Int, B <: Int]
44

5-
erased inline given fail[X <: Int, Y <: Int] as Fail[X, Y] = {
5+
erased inline given [X <: Int, Y <: Int] => Fail[X, Y] as fail = {
66
scala.compiletime.summonFrom {
77
case t: Fail[X, y] if constValue[y] < constValue[Y] => ???
88
}

tests/pos/i5915.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ trait RunDSL
22

33
val rdsl = new RunDSL {}
44

5-
given runNNFExpr[B] as RunDSL = rdsl
5+
given [B] => RunDSL as runNNFExpr = rdsl
66

7-
given runNNFImpl[B] as RunDSL {
7+
given [B] => RunDSL as runNNFImpl {
88
//override def runDSL(b: NNF[B]): B = b.terminal
99
}

tests/pos/i5978.scala

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,15 @@ package p1 {
1212
def f
1313
(using TokenParser[Char, Position[CharSequence]]) = ???
1414

15-
given FromCharToken(using T: TokenParser[Char, Position[CharSequence]])
15+
given (T: TokenParser[Char, Position[CharSequence]])
1616

1717
// skipping newlines is OK here
1818

19-
as Conversion[Char, Position[CharSequence]] = ???
19+
=> Conversion[Char, Position[CharSequence]]
20+
21+
// skipping newlines is OK here as well
22+
23+
as FromCharToken = ???
2024
}
2125

2226
object Testcase {
@@ -86,7 +90,7 @@ package p4 {
8690

8791
given TC as a
8892

89-
given b[X[_], Y] as TC
93+
given [X[_], Y] => TC as b
9094

91-
given c(using TC) as TC
95+
given (TC) => TC as c
9296
}

tests/pos/i6914.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ object test1 {
55
class ToExpr[T](using Liftable[T]) extends Conversion[T, Expr[T]] {
66
def apply(x: T): Expr[T] = ???
77
}
8-
given toExpr[T](using Liftable[T]) as ToExpr[T]
8+
given [T] => (Liftable[T]) => ToExpr[T] as toExpr
99

1010
given Liftable[Int] = ???
1111
given Liftable[String] = ???
@@ -18,7 +18,7 @@ object test1 {
1818

1919
object test2 {
2020

21-
given autoToExpr[T](using Liftable[T]) as Conversion[T, Expr[T]] {
21+
given [T] => (Liftable[T]) => Conversion[T, Expr[T]] as autoToExpr {
2222
def apply(x: T): Expr[T] = ???
2323
}
2424

tests/pos/i8198.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ trait Eq[A] {
66

77
case class Id[T](id: T)
88

9-
given idEq[A](using eqA: Eq[A]) as Eq[Id[A]] = new {
9+
given [A] => (eqA: Eq[A]) => Eq[Id[A]] as idEq = new {
1010
extension (i1: Id[A]) def === (i2: Id[A]) = !(i1.id /== i2.id)
1111
}

tests/pos/i8397.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
given foo(using x: Int) as AnyRef:
1+
given (x: Int) => AnyRef as foo:
22
type T = x.type
33

44
// #7859

tests/pos/i8825.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ object Length {
1717
def instance[L <: HList, Out0 <: Nat]: Aux[L, Out0] = new Length[L] { type Out = Out0 }
1818

1919
given Aux[HNil, Zero] as hnilLength = instance
20-
given hconsLength[H, T <: HList] (using length: Length[T]) as Aux[HCons[H, T], Succ[length.Out]] = instance // (*)
21-
//given hconsLength[H, T <: HList, N <: Nat] (using length: Aux[T, N]) as Aux[HCons[H, T], Succ[N]] = instance // (**)
20+
given [H, T <: HList] => (length: Length[T]) => Aux[HCons[H, T], Succ[length.Out]] as hconsLength = instance // (*)
21+
//given [H, T <: HList, N <: Nat] (using length: Aux[T, N]) => Aux[HCons[H, T], Succ[N]] as hconsLength = instance // (**)
2222
}
2323

2424
val test = summon[Length.Aux[HCons[Int, HNil], One]]

tests/pos/inlined-the.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ object Instances {
55
class C {
66
def f() = {
77
locally {
8-
given d[T] as D[T]
8+
given [T] => D[T] as d
99
summon[D[Int]]
1010
implicit val s: 3 = ???
1111
val a: 3 = summon[3]
@@ -14,7 +14,7 @@ object Instances {
1414
}
1515

1616
locally {
17-
given d[T] as D[T]
17+
given [T] => D[T] as d
1818
the2[D[Int]]
1919
implicit val s: 3 = ???
2020
val a: 3 = the2[3]

tests/pos/reference/delegates.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ object Instances extends Common:
3030
extension (x: Int) def compareTo(y: Int) =
3131
if (x < y) -1 else if (x > y) +1 else 0
3232

33-
given listOrd[T](using Ord[T]) as Ord[List[T]]:
33+
given [T] => Ord[T] => Ord[List[T]] as listOrd:
3434
extension (xs: List[T]) def compareTo(ys: List[T]): Int = (xs, ys) match
3535
case (Nil, Nil) => 0
3636
case (Nil, _) => -1
@@ -55,7 +55,7 @@ object Instances extends Common:
5555
def pure[A](x: A): List[A] =
5656
List(x)
5757

58-
given readerMonad[Ctx] as Monad[[X] =>> Ctx => X]:
58+
given [Ctx] => Monad[[X] =>> Ctx => X] as readerMonad:
5959
extension [A, B](r: Ctx => A) def flatMap (f: A => Ctx => B): Ctx => B =
6060
ctx => f(r(ctx))(ctx)
6161
def pure[A](x: A): Ctx => A =
@@ -111,11 +111,11 @@ object Instances extends Common:
111111
println(summon[Context].value)
112112
}
113113
locally {
114-
given d[T] as D[T]
114+
given [T] => D[T] as d
115115
println(summon[D[Int]])
116116
}
117117
locally {
118-
given (using Context) as D[Int]
118+
given Context => D[Int]
119119
println(summon[D[Int]])
120120
}
121121
end C

tests/pos/reference/extension-methods.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ object ExtMethods:
9090
extension [T](xs: Lst[Lst[T]])
9191
def flatten: Lst[T] = xs.foldLeft(Lst())(_ ++ _)
9292

93-
given ord[T: Ord] as Ord[Lst[T]]:
93+
given [T: Ord] => Ord[Lst[T]] as ord:
9494
extension (xs: Lst[T])
9595
def less (ys: Lst[T]): Boolean = ???
9696
end Lst

tests/run-macros/i8007/Macro_3.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ object Eq {
3232
case '[EmptyTuple] => Nil
3333
}
3434

35-
given derived[T: Type](using q: Quotes) as Expr[Eq[T]] = {
35+
given [T: Type] => (q: Quotes) => Expr[Eq[T]] as derived = {
3636
import quotes.reflect._
3737

3838
val ev: Expr[Mirror.Of[T]] = Expr.summon(using Type.of[Mirror.Of[T]]).get

tests/run-macros/i9812b/Macro_1.scala

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,25 +19,25 @@ object SomeEnum:
1919
given Liftable[Foo.type] as liftFoo:
2020
def toExpr(x: Foo.type): Quotes ?=> Expr[Foo.type] = '{Foo}
2121

22-
given liftBar[S <: SomeEnum: Type: Liftable] as Liftable[Bar[S]]:
22+
given [S <: SomeEnum: Type: Liftable] => Liftable[Bar[S]] as liftBar:
2323
def toExpr(x: Bar[S]): Quotes ?=> Expr[Bar[S]] = '{new Bar(${Lift(x.s)})}
2424

2525
sealed abstract class Lst[+T]
2626
final case class CONS[+T](head: T, tail: Lst[T]) extends Lst[T]
2727
case object NIL extends Lst[Nothing]
2828

29-
given intLiftable[T <: Int] as Liftable[T]:
29+
given [T <: Int] => Liftable[T] as intLiftable:
3030
def toExpr(x: T): Quotes ?=> Expr[T] = qctx ?=> {
3131
import quotes.reflect._
3232
Literal(Constant.Int(x)).asExpr.asInstanceOf[Expr[T]]
3333
}
3434

35-
given liftLst[T: Type: Liftable](using ev1: => Liftable[CONS[T]], ev2: => Liftable[NIL.type]) as Liftable[Lst[T]]:
35+
given [T: Type: Liftable] => (ev1: => Liftable[CONS[T]], ev2: => Liftable[NIL.type]) => Liftable[Lst[T]] as liftLst:
3636
def toExpr(xs: Lst[T]): Quotes ?=> Expr[Lst[T]] = xs match
3737
case NIL => ev2.toExpr(NIL)
3838
case cons @ CONS(_, _) => ev1.toExpr(cons)
3939

40-
given liftCONS[T: Type: Liftable](using Liftable[Lst[T]]) as Liftable[CONS[T]]:
40+
given [T: Type: Liftable] => (Liftable[Lst[T]]) => Liftable[CONS[T]] as liftCONS:
4141
def toExpr(x: CONS[T]): Quotes ?=> Expr[CONS[T]] = '{CONS(${Lift(x.head)}, ${Lift(x.tail)})}
4242

4343
given Liftable[NIL.type] as liftNIL:

tests/run/Typeable.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ object Typeable:
3333
case _ => None
3434
def describe = "Int"
3535

36-
given list[T: Typeable] as Typeable[List[T]]:
36+
given [T: Typeable] => Typeable[List[T]] as list:
3737
def cast(x: Any): Option[List[T]] = x match
3838
case x: List[_] if x.forall(Typeable[T].cast(_).isDefined) => Some(x.asInstanceOf[List[T]])
3939
case _ => None

tests/run/cochis-example.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11

22
import Predef.{assert, $conforms => _}
33
trait A {
4-
given id[X] as (X => X) = x => x
4+
given [X] => (X => X) as id = x => x
55
def trans[X](x: X)(using f: X => X) = f(x) // (2)
66
}
77
object Test extends A with App{

tests/run/extmethods2.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
class TC
44

5-
given stringListOps(using TC) as Object {
5+
given TC => Object as stringListOps {
66
type T = List[String]
77
extension (x: T) def foo(y: T) = (x ++ y, summon[TC])
88
extension (x: T) def bar(y: Int) = (x(0)(y), summon[TC])

tests/run/i7788.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ trait Show[-A]:
44
given Show[String] = x => x
55
given Show[Int] = _.toString
66

7-
given showEither[A,B](using sA: Show[A])(using Show[B]) as Show[Either[A,B]] =
7+
given [A,B] => Show[A] => Show[B] => Show[Either[A,B]] as showEither =
88
_.fold(a => s"Left(${summon[Show[A]].show(a)})", b => s"Right(${summon[Show[B]].show(b)})")
99
given [A,B] => (sA: Show[A]) => (sB: Show[B]) => Show[(A,B)] = (a,b) => s"(${sA.show(a)}), ${sB.show(b)})"
1010

0 commit comments

Comments
 (0)