Skip to content

Commit 3a44cf8

Browse files
committed
Update most tests to new syntax
I left some tests to use the old syntax, just so that we have early warnings for possible regressions. But most tests are now using the new syntax, so that we best reassurance that corner cases work.
1 parent 0c721dc commit 3a44cf8

File tree

239 files changed

+1135
-468
lines changed

Some content is hidden

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

239 files changed

+1135
-468
lines changed

docs/_docs/reference/contextual/sip-64.md

+684
Large diffs are not rendered by default.

tests/init/crash/i6914.scala

+3-5
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]): ToExpr[T] with {}
8+
given toExprFun: [T] => Liftable[T] => ToExpr[T]()
99

1010
given Liftable[Int] = ???
1111
given Liftable[String] = ???
@@ -16,14 +16,12 @@ object test1 {
1616
def a: Expr[String] = "abc"
1717
}
1818

19-
object test2 {
19+
object test2:
2020

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

2524
given Liftable[Int] = ???
2625
given Liftable[String] = ???
2726

2827
def a: Expr[String] = "abc"
29-
}

tests/init/crash/i7821.scala

+2-4
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,17 @@ object XObject {
33

44
def anX: X = 5
55

6-
given ops: Object with {
6+
given ops: Object:
77
extension (x: X) def + (y: X): X = x + y
8-
}
98
}
109

1110
object MyXObject {
1211
opaque type MyX = XObject.X
1312

1413
def anX: MyX = XObject.anX
1514

16-
given ops: Object with {
15+
given ops: Object:
1716
extension (x: MyX) def + (y: MyX): MyX = x + y // error: warring: Infinite recursive call
18-
}
1917
}
2018

2119
object Main extends App {

tests/neg-macros/BigFloat/BigFloat_1.scala

+2-2
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,15 @@ object BigFloat extends App {
3535
def fromDigits(digits: String) = apply(digits)
3636
}
3737

38-
given BigFloatFromDigits with {
38+
given BigFloatFromDigits {
3939
override inline def fromDigits(digits: String) = ${
4040
BigFloatFromDigitsImpl('digits)
4141
}
4242
}
4343

4444
// Should be in StdLib:
4545

46-
given ToExpr[BigInt] with {
46+
given ToExpr[BigInt] {
4747
def apply(x: BigInt)(using Quotes) =
4848
'{BigInt(${Expr(x.toString)})}
4949
}

tests/neg-macros/GenericNumLits/Even_1.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ object Even {
1616
def fromDigits(digits: String) = evenFromDigits(digits)
1717
}
1818

19-
given EvenFromDigits with {
19+
given EvenFromDigits {
2020
override transparent inline def fromDigits(digits: String) = ${
2121
EvenFromDigitsImpl('digits)
2222
}

tests/neg-macros/i11483/Test_2.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ package x
33
import scala.language.implicitConversions
44
import scala.concurrent.Future
55

6-
given FutureAsyncMonad: CpsMonad[Future] with
6+
given FutureAsyncMonad: CpsMonad[Future]:
77
def pure[T](t:T): Future[T] = ???
88
def impure[T](t:Future[T]): T = ???
99
def map[A,B](x:Future[A])(f: A=>B): Future[B] = ???

tests/neg-macros/i17152/DFBits.scala

+2-2
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ trait Baz
1616
trait Width[T]:
1717
type Out <: Int
1818
object Width:
19-
given fromDFBoolOrBit[T <: DFBoolOrBit]: Width[T] with
19+
given fromDFBoolOrBit: [T <: DFBoolOrBit] => Width[T]:
2020
type Out = 1
2121
transparent inline given [T]: Width[T] = ${ getWidthMacro[T] }
2222
def getWidthMacro[T](using Quotes, Type[T]): Expr[Width[T]] =
@@ -38,7 +38,7 @@ private object CompanionsDFBits:
3838
type OutW <: Int
3939
def apply(value: R): DFValOf[DFBits[OutW]]
4040
object Candidate:
41-
given fromDFUInt[W <: Int, R <: DFValOf[DFDecimal]]: Candidate[R] with
41+
given fromDFUInt: [W <: Int, R <: DFValOf[DFDecimal]] => Candidate[R]:
4242
type OutW = W
4343
def apply(value: R): DFValOf[DFBits[W]] =
4444
import DFVal.Ops.bits

tests/neg-macros/i19601/Macro.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ object Macros {
1010
'{ () }
1111

1212
}
13-
given [A](using Type[A]): FromExpr[Assertion[A]] with {
13+
given [A] => Type[A] => FromExpr[Assertion[A]] {
1414
def unapply(assertion: Expr[Assertion[A]])(using Quotes): Option[Assertion[A]] = {
1515
import quotes.reflect.*
1616

tests/neg-macros/i7919.scala

+3-3
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@ import scala.quoted.*
33
object Test {
44
def staged[T](using Quotes) = {
55
import quotes.reflect.*
6-
given typeT: Type[T] with {} // error
6+
given typeT: Type[T] {} // error
77
val tt = TypeRepr.of[T]
88
'{ "in staged" }
99
}
1010

11-
given Expr[Int] with {} // error
11+
given Expr[Int] {} // error
1212
new Expr[Int] // error
1313
class Expr2 extends Expr[Int] // error
1414

15-
given Type[Int] with {} // error
15+
given Type[Int] {} // error
1616
new Type[Int] // error
1717
class Type2 extends Type[Int] // error
1818

tests/neg-with-compiler/GenericNumLits/Even_1.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ object Even {
1616
def fromDigits(digits: String) = evenFromDigits(digits)
1717
}
1818

19-
given EvenFromDigits with {
19+
given EvenFromDigits {
2020
override inline def fromDigits(digits: String) = ${
2121
EvenFromDigitsImpl('digits)
2222
}

tests/neg/17579.check

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,6 @@
2525
|
2626
| longer explanation available when compiling with `-explain`
2727
-- [E147] Syntax Warning: tests/neg/17579.scala:19:6 -------------------------------------------------------------------
28-
19 | final given Object with {} // warning: modifier `final` is redundant for this definition
28+
19 | final given Object() // warning: modifier `final` is redundant for this definition
2929
| ^^^^^
3030
| Modifier final is redundant for this definition

tests/neg/17579.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class C:
1616
{
1717
// No error in this case, because the `given` is translated to a class
1818
// definition, for which `final` is redundant but not illegal.
19-
final given Object with {} // warning: modifier `final` is redundant for this definition
19+
final given Object() // warning: modifier `final` is redundant for this definition
2020
}
2121

2222
{

tests/neg/19414.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ class Printer
99
given Writer[JsValue] = ???
1010
given Writer[JsObject] = ???
1111

12-
given [B: Writer](using printer: Printer = new Printer): BodySerializer[B] = ???
12+
given [B: Writer] => (printer: Printer = new Printer) => BodySerializer[B] = ???
1313

1414
def f: Unit =
1515
summon[BodySerializer[JsObject]] // error: Ambiguous given instances

tests/neg/21538.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
trait Bar[T]
2-
given [T]: Bar[T] with {}
2+
given [T] => Bar[T]()
33
inline def foo[V](inline value: V)(using Bar[value.type]) : Unit = {} // error

tests/neg/abstract-givens.check

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
-- Error: tests/neg/abstract-givens.scala:11:8 -------------------------------------------------------------------------
2-
11 | given s[T](using T): Seq[T] with // error
2+
11 | given s: [T] => T => Seq[T]: // error
33
| ^
44
|instance cannot be created, since def iterator: Iterator[A] in trait IterableOnce in package scala.collection is not defined
55
-- [E164] Declaration Error: tests/neg/abstract-givens.scala:8:8 -------------------------------------------------------

tests/neg/abstract-givens.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ object Test extends T:
88
given y(using Int): String = summon[Int].toString * 22 // error
99
given z[T](using T): Seq[T] = List(summon[T]) // error
1010

11-
given s[T](using T): Seq[T] with // error
11+
given s: [T] => T => Seq[T]: // error
1212
def apply(x: Int) = ???
1313
override def length = ???
1414

tests/neg/eql.scala

+1-1
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]: CanEqual[Lst[T], Lst[U]] = CanEqual.derived
4+
given lstCanEqual: [T, U] => CanEqual[Lst[T], Lst[U]] = CanEqual.derived
55
val Empty: Lst[Nothing] = ???
66
end lst
77

tests/neg/exports.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
type PrinterType
66
def print(bits: BitMap): Unit = ???
77
def status: List[String] = ???
8-
given bitmap: BitMap with {}
8+
given bitmap: BitMap()
99
}
1010

1111
class Scanner {

tests/neg/extmethod-overload.scala

+9-10
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
1-
object Test {
2-
given a: AnyRef with
3-
extension (x: Int) {
1+
object Test:
2+
3+
given a: AnyRef:
4+
extension (x: Int)
45
def |+| (y: Int) = x + y
5-
}
6-
given b: AnyRef with
7-
extension (x: Int) {
6+
7+
given b: AnyRef:
8+
extension (x: Int)
89
def |+| (y: String) = x + y.length
9-
}
10+
1011
assert((1 |+| 2) == 3) // error ambiguous
1112

12-
locally {
13+
locally:
1314
import b.|+|
1415
assert((1 |+| "2") == 2) // OK
15-
}
16-
}

tests/neg/gadt-approximation-interaction.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ object GivenLookup {
2828

2929
class Tag[T]
3030

31-
given ti: Tag[Int] with {}
31+
given ti: Tag[Int]()
3232

3333
def foo[T](t: T, ev: T SUB Int) =
3434
ev match { case SUB.Refl() =>

tests/neg/genericNumbers.scala

+2-4
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,11 @@ object Test extends App {
77

88
case class Even(n: Int)
99

10-
given FromDigits[Even] with {
11-
def fromDigits(digits: String): Even = {
10+
given FromDigits[Even]:
11+
def fromDigits(digits: String): Even =
1212
val intValue = digits.toInt
1313
if (intValue % 2 == 0) Even(intValue)
1414
else throw FromDigits.MalformedNumber()
15-
}
16-
}
1715

1816
val e: Even = 1234 // error
1917

tests/neg/given-loop-prevention.scala

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
class Foo
33

44
object Bar {
5-
given Foo with {}
5+
given Foo()
66
given List[Foo] = List(summon[Foo]) // ok
77
}
88

99
object Baz {
1010
given List[Foo] = List(summon[Foo]) // error
11-
given Foo with {}
11+
given Foo()
1212
}

tests/neg/i10901.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ object BugExp4Point2D {
5353
class C
5454

5555
object Container:
56-
given C with {}
56+
given C()
5757

5858
object Test:
5959
extension (x: String)(using C)

tests/neg/i11985.scala

+1-3
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,8 @@ object Test {
1111
def get(t: TT): C
1212
}
1313

14-
given [T <: Tuple, C, EV <: TupleTypeIndex[T, C]]: TupleExtractor[T, C] with {
14+
given [T <: Tuple, C, EV <: TupleTypeIndex[T, C]] => TupleExtractor[T, C]:
1515
def get(t: T): C = t.toArray.apply(toIntC[TupleTypeIndex[T, C]]).asInstanceOf[C] // error
16-
}
17-
1816

1917
transparent inline def toIntC[N <: Int]: Int =
2018
inline constValue[N] match

tests/neg/i14177a.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ import scala.compiletime.*
22

33
trait C[A]
44

5-
inline given [Tup <: Tuple]: C[Tup] with
5+
inline given [Tup <: Tuple] => C[Tup]:
66
val cs = summonAll[Tuple.Map[Tup, C]] // error: Tuple element types must be known at compile time

tests/neg/i15474b.scala

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

55
object Test1:
6-
given c: Conversion[ String, Int ] with
6+
given c: Conversion[ String, Int ]:
77
def apply(from: String): Int = from.toInt // warn: infinite loop in function body
88
// nopos-error: No warnings can be incurred under -Werror (or -Xfatal-warnings)

tests/neg/i16453.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ def testScala3() = {
1212
given Conversion[Char, String] = ???
1313
given Conversion[Char, Option[Int]] = ???
1414

15-
given foo: Foo with
15+
given foo: Foo:
1616
type T = Int
1717
given bar3: Int = 0
1818
given baz3: Char = 'a'

tests/neg/i19328conversion.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ object i19328conversion:
55

66
type Id[A] = A
77

8-
given wrapId[A]: Conversion[A, Id[A]] with
8+
given wrapId: [A] => Conversion[A, Id[A]]:
99
def apply(x: A): Id[A] = x
1010

1111
def bar(using bool: Boolean): Unit = ()

tests/neg/i5978.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ opaque type Position[Buffer] = Int
55
trait TokenParser[Token, R]
66

77
object TextParser {
8-
given TP: TokenParser[Char, Position[CharSequence]] with {}
8+
given TP: TokenParser[Char, Position[CharSequence]]()
99

1010
given FromCharToken(using T: TokenParser[Char, Position[CharSequence]])
1111
: Conversion[Char, Position[CharSequence]] = ???

tests/neg/i6716.scala

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
class Foo
22

33
object Bar {
4-
given Foo with {}
4+
given Foo()
55
given List[Foo] = List(summon[Foo]) // ok
66
}
77

88
object Baz {
99
@annotation.nowarn
1010
given List[Foo] = List(summon[Foo]) // error
11-
given Foo with {}
11+
given Foo()
1212
}

tests/neg/i7459.scala

+1-1
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ trait Eq[T] {
2222
}
2323

2424
object Eq {
25-
given Eq[Int] with {
25+
given Eq[Int] {
2626
def eqv(x: Int, y: Int) = x == y
2727
}
2828

tests/neg/i8896-a.scala

+1-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ trait Foo[A]
44

55
object Example {
66

7-
given Foo[Int] with {
8-
}
7+
given Foo[Int]()
98

109
def foo0[A: Foo]: A => A = identity
1110
def foo1[A](implicit foo: Foo[A]): A => A = identity

tests/neg/i8896-b.scala

+1-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ trait Foo[A]
44

55
object Example {
66

7-
given Foo[Int] with {
8-
}
7+
given Foo[Int]()
98

109
def foo0[A: Foo]: A => A = identity
1110
def foo1[A](implicit foo: Foo[A]): A => A = identity

tests/neg/i9185.scala

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
trait M[F[_]] { def pure[A](x: A): F[A] }
22
object M {
33
extension [A, F[A]](x: A) def pure(using m: M[F]): F[A] = m.pure(x)
4-
given listMonad: M[List] with { def pure[A](x: A): List[A] = List(x) }
5-
given optionMonad: M[Option] with { def pure[A](x: A): Option[A] = Some(x) }
4+
given listMonad: M[List] { def pure[A](x: A): List[A] = List(x) }
5+
given optionMonad: M[Option] { def pure[A](x: A): Option[A] = Some(x) }
66
val value1: List[String] = "ola".pure
77
val value2 = "ola".pure // error
88
val value3 = M.pure("ola") // error

0 commit comments

Comments
 (0)