Skip to content

Commit 6ad22aa

Browse files
authored
Add tests for clause interleaving to safe initialization test suite. (#16906)
Copies the following tests to the safe initialization test suite to ensure the initialization checker can handle clause interleaving. - tests/pos/interleaving-params.scala - tests/pos/interleaving-overload.scala - tests/neg/interleaving-params.scala
2 parents e422066 + 294fae8 commit 6ad22aa

File tree

3 files changed

+52
-0
lines changed

3 files changed

+52
-0
lines changed
+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import scala.language.experimental.clauseInterleaving
2+
3+
class Params{
4+
def bar[T](x: T)[T]: String = ??? // error
5+
def zoo(x: Int)[T, U](x: U): T = ??? // error
6+
def bbb[T <: U](x: U)[U]: U = ??? // error // error
7+
def f0[T](implicit x: T)[U](y: U) = (x,y) // error
8+
def f1[T](implicit x: T)[U] = (x,y) // error
9+
}
+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import scala.language.experimental.clauseInterleaving
2+
3+
class A{
4+
5+
def f1[T](x: Any)[U] = ???
6+
def f1[T](x: Int)[U] = ???
7+
8+
f1(1)
9+
f1("hello")
10+
f1[Boolean]("a")[Int]
11+
f1[Boolean](1)[Int]
12+
13+
case class B[U](x: Int)
14+
def b[U](x: Int) = B[U](x)
15+
16+
def f2[T]: [U] => Int => B[U] = [U] => (x: Int) => b[U](x)
17+
18+
f2(1)
19+
f2[Any](1)
20+
f2[Any][Any](1)
21+
22+
b[Int](5)
23+
24+
}
+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import scala.collection.mutable.AbstractSet
2+
import scala.collection.mutable.BitSet
3+
import scala.language.experimental.clauseInterleaving
4+
5+
class Params{
6+
type U
7+
def foo[T](x: T)[U >: x.type <: T](using U)[L <: List[U]](l: L): L = ???
8+
def aaa(x: U): U = ???
9+
def bbb[T <: U](x: U)[U]: U = ???
10+
11+
foo[AbstractSet[Int]](BitSet())[AbstractSet[Int]](using BitSet())[List[AbstractSet[Int]]](List[AbstractSet[Int]]())
12+
}
13+
14+
class Param2 extends Params {
15+
type U = AbstractSet[Int]
16+
17+
aaa(BitSet())
18+
bbb[BitSet](BitSet())[AbstractSet[Int]]
19+
}

0 commit comments

Comments
 (0)