diff --git a/tests/pos-special/fatal-warnings/i10994.scala b/tests/pos-special/fatal-warnings/i10994.scala new file mode 100644 index 000000000000..99ae647466b1 --- /dev/null +++ b/tests/pos-special/fatal-warnings/i10994.scala @@ -0,0 +1,2 @@ +def foo = true match + case (b: Boolean): Boolean => () diff --git a/tests/pos-special/fatal-warnings/i11729.scala b/tests/pos-special/fatal-warnings/i11729.scala new file mode 100644 index 000000000000..7ba41d081e3b --- /dev/null +++ b/tests/pos-special/fatal-warnings/i11729.scala @@ -0,0 +1,26 @@ +type Return[X] = X match + case List[t] => List[t] + case Any => List[X] + +object Return: + def apply[A](a:A):Return[A] = a match + case a: List[t] => a + case a: Any => List(a) + +object Test1: + Return(1).map(x => x) + + +type Boxed[X] = X match + case Box[t] => Box[t] + case Any => Box[X] + +def box[X](x: X): Boxed[X] = x match + case b: Box[t] => b + case x: Any => Box(x) + +case class Box[A](a:A): + def map[B](f: A => B): Box[B] = Box(f(a)) + +object Test2: + box(box(1)).map(_ + 1) diff --git a/tests/pos/i10389.scala b/tests/pos/i10389.scala new file mode 100644 index 000000000000..a23f0d269a21 --- /dev/null +++ b/tests/pos/i10389.scala @@ -0,0 +1,9 @@ +import scala.util._ + +object FooBar { + def foo = List("1","two","3").collect{ x => + Try(x.toInt) match { + case Success(int) => int + } + } +} diff --git a/tests/pos/i10897.scala b/tests/pos/i10897.scala new file mode 100644 index 000000000000..da583090992b --- /dev/null +++ b/tests/pos/i10897.scala @@ -0,0 +1,6 @@ +import Tuple.Union + +object Foo + +val x = summon[Union[(Foo.type, 1)] =:= (Foo.type | 1)] // doesn't compile +val y = summon[Union[(Foo.type, 1, String)] =:= (Foo.type | 1 | String)] // compiles diff --git a/tests/pos/i11163.scala b/tests/pos/i11163.scala new file mode 100644 index 000000000000..acf5629d1ae9 --- /dev/null +++ b/tests/pos/i11163.scala @@ -0,0 +1,12 @@ +inline def summonA[T](using x: T): x.type = x +inline def summonB[T](using inline x: T): x.type = x +inline def summonC[T](using inline x: T): T = x + +trait Foo: + def f: Int = 9 + +def test(using Foo) = + summonA[Foo].f + summonB[Foo].f + summonC[Foo].f + () diff --git a/tests/pos/i11556.scala b/tests/pos/i11556.scala new file mode 100644 index 000000000000..881fc6d0fc10 --- /dev/null +++ b/tests/pos/i11556.scala @@ -0,0 +1,24 @@ +type Traverser[-I, +O] = I => LazyList[(O)] +extension[I, O](ta: Traverser[I, O]) + def ~>[P](tb: Traverser[O, P]): Traverser[I, P] = ??? + +class Graph { class Node } + +case class Path[+E](e: E) +type Query[-I, +O] = Traverser[Path[I], Path[O]] + +def nodesQ(using g: Graph): Query[Nothing, g.Node] = ??? +def outsQ(using g: Graph): Query[g.Node, g.Node] = ??? + +object graph extends Graph +import graph._ +given graph.type = graph + +object Issue11556: + val q1: Query[Nothing, Node] = nodesQ ~> outsQ + implicitly[q1.type <:< Query[Nothing, Node]] + + val q2 = nodesQ ~> outsQ + val q3: Query[Nothing, Node] = q2 + implicitly[q2.type <:< Query[Nothing, Node]] +end Issue11556 diff --git a/tests/pos/i12474.scala b/tests/pos/i12474.scala new file mode 100644 index 000000000000..41762fba55c1 --- /dev/null +++ b/tests/pos/i12474.scala @@ -0,0 +1,17 @@ +package bugreport + +import scala.compiletime.erasedValue + +trait Show[A]: + def show(a: A): String + +inline def showTuple[Types]: Show[Types] = + inline erasedValue[Types] match + case _: (head *: tail) => + val instance = + new Show[head *: tail]: + def show(tuple: head *: tail): String = "dummy" + instance.asInstanceOf[Show[Types]] + +@main def run() = + showTuple[(Int, Int)] diff --git a/tests/pos/i9769.scala b/tests/pos/i9769.scala new file mode 100644 index 000000000000..1c57b4bb94d3 --- /dev/null +++ b/tests/pos/i9769.scala @@ -0,0 +1,9 @@ +object Main { + val lifeOfPi = 3.14159 + val fInterpolator = f"The approximate value of pi is $lifeOfPi%4.2f" + + def main(args: Array[String]): Unit = { + println(fInterpolator) + } + +} diff --git a/tests/pos/i9833.scala b/tests/pos/i9833.scala new file mode 100644 index 000000000000..4e5594707831 --- /dev/null +++ b/tests/pos/i9833.scala @@ -0,0 +1,7 @@ +object Main extends App: + enum Extends[A, B]: + case Ev[B, A <: B]() extends (A Extends B) + + def cast(a: A): B = this match { + case Extends.Ev() => a + }