Skip to content

Add regression tests for issues that fixed themselves #12847

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions tests/pos-special/fatal-warnings/i10994.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
def foo = true match
case (b: Boolean): Boolean => ()
26 changes: 26 additions & 0 deletions tests/pos-special/fatal-warnings/i11729.scala
Original file line number Diff line number Diff line change
@@ -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)
9 changes: 9 additions & 0 deletions tests/pos/i10389.scala
Original file line number Diff line number Diff line change
@@ -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
}
}
}
6 changes: 6 additions & 0 deletions tests/pos/i10897.scala
Original file line number Diff line number Diff line change
@@ -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
12 changes: 12 additions & 0 deletions tests/pos/i11163.scala
Original file line number Diff line number Diff line change
@@ -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
()
24 changes: 24 additions & 0 deletions tests/pos/i11556.scala
Original file line number Diff line number Diff line change
@@ -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
17 changes: 17 additions & 0 deletions tests/pos/i12474.scala
Original file line number Diff line number Diff line change
@@ -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)]
9 changes: 9 additions & 0 deletions tests/pos/i9769.scala
Original file line number Diff line number Diff line change
@@ -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)
}

}
7 changes: 7 additions & 0 deletions tests/pos/i9833.scala
Original file line number Diff line number Diff line change
@@ -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
}