Skip to content

Commit 0f7f890

Browse files
committed
Add and Fix tests
1 parent 3a6f874 commit 0f7f890

23 files changed

+273
-45
lines changed

scaladoc-testcases/src/tests/extensionParams.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,4 +56,3 @@ extension (using String)(using Unit)(a: Animal)(using Int)(using Number)
5656
= ???
5757
def f14[D](b: D)[T](c: T): T
5858
= ???
59-

scaladoc-testcases/src/tests/methodsAndConstructors.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,4 +62,3 @@ class Methods:
6262

6363
def clauseInterleaving[T](x: T)[U](y: U)(using (T, U)): (T, U)
6464
= ???
65-

tests/neg/extension-methods.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@ object Test {
1515
def f2[T]: T = ??? // error: T is already defined as type T
1616
def f3(xs: List[T]) = ??? // error: xs is already defined as value xs
1717
}
18-
}
18+
}

tests/neg/interleaving-ab.scala

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
object Ab:
2-
given String = ""
3-
given Double = 0
2+
given String = ""
3+
given Double = 0
44

5-
def illegal[A][B](x: A)(using B): B = summon[B] // error: Type parameter lists must be separated by a term or using parameter list
6-
7-
def ab[A](x: A)[B](using B): B = summon[B]
8-
def test =
9-
ab[Int](0: Int) // error
5+
def illegal[A][B](x: A)(using B): B = summon[B] // error: Type parameter lists must be separated by a term or using parameter list
6+
7+
def ab[A](x: A)[B](using B): B = summon[B]
8+
def test =
9+
ab[Int](0: Int) // error

tests/neg/interleaving-nameCollision.scala

Lines changed: 0 additions & 3 deletions
This file was deleted.

tests/neg/interleaving-params.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ class Params{
44
def bbb[T <: U](x: U)[U]: U = ??? // error // error
55
def f0[T](implicit x: T)[U](y: U) = (x,y) // error
66
def f1[T](implicit x: T)[U] = (x,y) // error
7-
}
7+
}
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
object signatureCollision:
2+
def f[T](x: T)[U](y: U) = (x,y)
3+
def f[T](x: T, y: T) = (x,y) // error
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
-- [E057] Type Mismatch Error: tests/neg/interleaving-typeApply.scala:10:11 --------------------------------------------
2+
10 | f3[String]() // error
3+
| ^
4+
| Type argument String does not conform to upper bound Int
5+
|
6+
| longer explanation available when compiling with `-explain`
7+
-- [E057] Type Mismatch Error: tests/neg/interleaving-typeApply.scala:11:16 --------------------------------------------
8+
11 | f5[Int][Unit] // error
9+
| ^
10+
| Type argument Unit does not conform to upper bound String
11+
|
12+
| longer explanation available when compiling with `-explain`
13+
-- [E057] Type Mismatch Error: tests/neg/interleaving-typeApply.scala:12:19 --------------------------------------------
14+
12 | f5[String][Unit] // error // error
15+
| ^
16+
| Type argument Unit does not conform to upper bound String
17+
|
18+
| longer explanation available when compiling with `-explain`
19+
-- [E057] Type Mismatch Error: tests/neg/interleaving-typeApply.scala:12:11 --------------------------------------------
20+
12 | f5[String][Unit] // error // error
21+
| ^
22+
| Type argument String does not conform to upper bound Int
23+
|
24+
| longer explanation available when compiling with `-explain`
25+
-- [E057] Type Mismatch Error: tests/neg/interleaving-typeApply.scala:13:11 --------------------------------------------
26+
13 | f7[String]()[Unit] // error
27+
| ^
28+
| Type argument String does not conform to upper bound Int
29+
|
30+
| longer explanation available when compiling with `-explain`

tests/neg/interleaving-typeApply.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ object typeApply:
99
f5[Int][Unit] // error
1010
f5[String][Unit] // error // error
1111
f7[String]()[Unit] // error
12-
}
12+
}
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
object unmatched:
22
def f1[T (x: T)] = ??? // error
3-
def f2(x: Any[)T] = ??? // error // error
3+
def f2(x: Any[)T] = ??? // error // error

tests/neg/namedTypeParams.check

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
-- [E040] Syntax Error: tests/neg/namedTypeParams.scala:2:8 ------------------------------------------------------------
2+
2 |class D[type T] // error: identifier expected, but `type` found
3+
| ^^^^
4+
| an identifier expected, but 'type' found
5+
|
6+
| longer explanation available when compiling with `-explain`
7+
-- [E040] Syntax Error: tests/neg/namedTypeParams.scala:11:13 ----------------------------------------------------------
8+
11 | val x: C[T = Int] = // error: ']' expected, but `=` found // error
9+
| ^
10+
| ']' expected, but '=' found
11+
-- [E040] Syntax Error: tests/neg/namedTypeParams.scala:12:12 ----------------------------------------------------------
12+
12 | new C[T = Int] // error: ']' expected, but `=` found // error
13+
| ^
14+
| ']' expected, but '=' found
15+
-- [E040] Syntax Error: tests/neg/namedTypeParams.scala:14:22 ----------------------------------------------------------
16+
14 | class E extends C[T = Int] // error: ']' expected, but `=` found // error
17+
| ^
18+
| ']' expected, but '=' found
19+
-- [E040] Syntax Error: tests/neg/namedTypeParams.scala:15:22 ----------------------------------------------------------
20+
15 | class F extends C[T = Int]() // error: ']' expected, but `=` found // error
21+
| ^
22+
| ']' expected, but '=' found
23+
-- [E040] Syntax Error: tests/neg/namedTypeParams.scala:19:19 ----------------------------------------------------------
24+
19 | f[X = Int, String](1, "") // error // error
25+
| ^
26+
| '=' expected, but ']' found
27+
-- Error: tests/neg/namedTypeParams.scala:6:8 --------------------------------------------------------------------------
28+
6 | f[X = Int, Y = Int](1, 2) // error: experimental // error: experimental
29+
| ^^^
30+
| Named type arguments are experimental,
31+
| they must be enabled with a `experimental.namedTypeArguments` language import or setting
32+
-- Error: tests/neg/namedTypeParams.scala:6:17 -------------------------------------------------------------------------
33+
6 | f[X = Int, Y = Int](1, 2) // error: experimental // error: experimental
34+
| ^^^
35+
| Named type arguments are experimental,
36+
| they must be enabled with a `experimental.namedTypeArguments` language import or setting
37+
-- [E006] Not Found Error: tests/neg/namedTypeParams.scala:11:11 -------------------------------------------------------
38+
11 | val x: C[T = Int] = // error: ']' expected, but `=` found // error
39+
| ^
40+
| Not found: type T
41+
|
42+
| longer explanation available when compiling with `-explain`
43+
-- [E006] Not Found Error: tests/neg/namedTypeParams.scala:12:10 -------------------------------------------------------
44+
12 | new C[T = Int] // error: ']' expected, but `=` found // error
45+
| ^
46+
| Not found: type T
47+
|
48+
| longer explanation available when compiling with `-explain`
49+
-- [E006] Not Found Error: tests/neg/namedTypeParams.scala:14:20 -------------------------------------------------------
50+
14 | class E extends C[T = Int] // error: ']' expected, but `=` found // error
51+
| ^
52+
| Not found: type T
53+
|
54+
| longer explanation available when compiling with `-explain`
55+
-- [E006] Not Found Error: tests/neg/namedTypeParams.scala:15:20 -------------------------------------------------------
56+
15 | class F extends C[T = Int]() // error: ']' expected, but `=` found // error
57+
| ^
58+
| Not found: type T
59+
|
60+
| longer explanation available when compiling with `-explain`
61+
-- [E102] Syntax Error: tests/neg/namedTypeParams.scala:19:18 ----------------------------------------------------------
62+
19 | f[X = Int, String](1, "") // error // error
63+
| ^
64+
| Type parameter String is undefined. Expected one of X, Y.
65+
-- Error: tests/neg/namedTypeParams.scala:20:12 ------------------------------------------------------------------------
66+
20 | f[X = Int][X = Int][Y = String](1, "") // error: illegal repeated type application
67+
| ^^^^^^^^^^^^^^^^^^^
68+
| illegal repeated type application
69+
| You might have meant something like:
70+
| Test.f[X = Int, X = Int]
71+
-- Error: tests/neg/namedTypeParams.scala:22:12 ------------------------------------------------------------------------
72+
22 | f[X = Int][Y = String](1, "") // error: illegal repeated type application
73+
| ^^^^^^^^^^^^^^^^^^^^^^
74+
| illegal repeated type application
75+
| You might have meant something like:
76+
| Test.f[X = Int, Y = String]
77+
-- Error: tests/neg/namedTypeParams.scala:23:12 ------------------------------------------------------------------------
78+
23 | f[X = Int][String](1, "") // error: illegal repeated type application
79+
| ^^^^^^^^^^^^^^^^^^
80+
| illegal repeated type application
81+
| You might have meant something like:
82+
| Test.f[X = Int, String]
83+
-- Error: tests/neg/namedTypeParams.scala:25:15 ------------------------------------------------------------------------
84+
25 | f[Y = String][X = Int](1, "") // error: illegal repeated type application
85+
| ^^^^^^^^^^^^^^^^^^^^^^
86+
| illegal repeated type application
87+
| You might have meant something like:
88+
| Test.f[Y = String, X = Int]
89+
-- Error: tests/neg/namedTypeParams.scala:26:15 ------------------------------------------------------------------------
90+
26 | f[Y = String][Int](1, "") // error: illegal repeated type application
91+
| ^^^^^^^^^^^^^^^^^^
92+
| illegal repeated type application
93+
| You might have meant something like:
94+
| Test.f[Y = String, Int]
95+
-- [E102] Syntax Error: tests/neg/namedTypeParams.scala:33:9 -----------------------------------------------------------
96+
33 | f2[Y = String][X = Int](1, "") // error: Y is undefined
97+
| ^^^^^^
98+
| Type parameter Y is undefined. Expected one of X.
99+
-- [E102] Syntax Error: tests/neg/namedTypeParams.scala:34:9 -----------------------------------------------------------
100+
34 | f2[Y = String](1, "") // error: Y is undefined
101+
| ^^^^^^
102+
| Type parameter Y is undefined. Expected one of X.

tests/neg/namedTypeParams.scala

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ object Test0:
55
def f[X, Y](x: X, y: Y): Int = ???
66
f[X = Int, Y = Int](1, 2) // error: experimental // error: experimental
77

8-
object Test {
8+
object Test:
99
import language.experimental.namedTypeArguments
1010

1111
val x: C[T = Int] = // error: ']' expected, but `=` found // error
@@ -25,8 +25,9 @@ object Test {
2525
f[Y = String][X = Int](1, "") // error: illegal repeated type application
2626
f[Y = String][Int](1, "") // error: illegal repeated type application
2727

28+
object TestInterleaving:
29+
import language.experimental.namedTypeArguments
2830
def f2[X](using DummyImplicit)[Y](x: X, y: Y): Int = ???
2931

3032
f2[Y = String][X = Int](1, "") // error: Y is undefined
3133
f2[Y = String](1, "") // error: Y is undefined
32-
}

tests/neg/overrides.scala

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,6 @@ class B extends A[Int] {
5353
override def b[T <: Int](x: Int)(y: String) = true // error
5454

5555
override def next(): Int = ??? // error: incompatible type
56-
5756
}
5857

5958
class C extends A[String] {
@@ -115,4 +114,3 @@ class C extends A {
115114
override def m: Int = 42 // error: has incompatible type
116115
}
117116
}
118-

tests/pos/interleaving-ba.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11

2-
32
object BA {
43
given String = ""
54
given Double = 0
@@ -8,4 +7,4 @@ object BA {
87

98
def test = ba(0)[String]
109

11-
}
10+
}
Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,18 @@
11
object chainedParams{
22

3-
trait Chain{
4-
type Tail <: Chain
5-
}
3+
trait Chain{
4+
type Tail <: Chain
5+
}
6+
7+
def f[C1 <: Chain](c1: C1)[C2 <: c1.Tail](c2: C2)[C3 <: c2.Tail](c3: C3): c3.Tail = ???
68

7-
def f[C1 <: Chain](c1: C1)[C2 <: c1.Tail](c2: C2)[C3 <: c2.Tail](c3: C3): c3.Tail = ???
9+
val self = new Chain{ type Tail = this.type }
10+
val res: self.type = f(self)(self)(self)
811

9-
val self = new Chain{ type Tail = this.type }
10-
val res: self.type = f(self)(self)(self)
12+
type C <: Chain
1113

12-
type C <: Chain
13-
14-
val c3 = new Chain{ type Tail = C }
15-
val c2 = new Chain{ type Tail = c3.type }
16-
val c1 = new Chain{ type Tail = c2.type }
17-
val u: C = f(c1)(c2)(c3)
14+
val c3 = new Chain{ type Tail = C }
15+
val c2 = new Chain{ type Tail = c3.type }
16+
val c1 = new Chain{ type Tail = c2.type }
17+
val u: C = f(c1)(c2)(c3)
1818
}

tests/pos/interleaving-functor.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
object functorInterweaving:
1+
object functorInterleaving:
22
//taken from https://dotty.epfl.ch/docs/reference/contextual/type-classes.html
33
//at version 3.1.1-RC1-bin-20210930-01f040b-NIGHTLY
4-
//modified to have type interveawing
4+
//modified to have type interleaving
55
trait Functor[F[_]]:
66
def map[A](x: F[A])[B](f: A => B): F[B]
77

tests/pos/interleaving-nameCollision.scala

Lines changed: 0 additions & 5 deletions
This file was deleted.

tests/pos/interleaving-overload.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,4 +16,4 @@ class A{
1616
f2[Any](1)
1717
f2[Any][Any](1)
1818

19-
}
19+
}

tests/pos/interleaving-params.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@ class Params{
33
def foo[T](x: T)[U >: x.type <: T](using U)[L <: List[U]](l: L): L = ???
44
def aaa(x: U): U = ???
55
def bbb[T <: U](x: U)[U]: U = ???
6-
}
6+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import scala.annotation.targetName
2+
3+
object signatureCollision:
4+
def f[T](x: T)[U](y: U) = (x,y)
5+
@targetName("g") def f[T](x: T, y: T) = (x,y)

tests/pos/interleaving-typeApply.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,4 @@ object typeApply:
1919
f5[Int][String][Unit]
2020
f6[Int]()[Unit]
2121
f7[Int]()[Unit]
22-
}
22+
}

tests/pos/namedTypeParams.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ object Test {
88
f[X = Int](1, "")
99
f[Y = String](1, "")
1010

11-
1211
def f2[X](using DummyImplicit)[Y](x: X, y: Y): Int = ???
1312

1413
f2[X = Int][Y = String](1, "")

0 commit comments

Comments
 (0)