forked from scala/scala3
-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add regression tests for issues that fixed themselves
Fix scala#9769 Fix scala#9833 Fix scala#10389 Fix scala#10897 Fix scala#11163 Fix scala#11556 Fix scala#12474 Fix scala#10994 Fix scala#11729
- Loading branch information
1 parent
a8bbc0e
commit b72de46
Showing
9 changed files
with
112 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
def foo = true match | ||
case (b: Boolean): Boolean => () |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} |