Skip to content

Commit dd9831b

Browse files
Add tests for #20071 and #20136
Both observe different behaviours match type reductions depending on whether they are compiled together or separately. They both compile only with separate compilation.
1 parent 1e8a653 commit dd9831b

File tree

6 files changed

+51
-0
lines changed

6 files changed

+51
-0
lines changed
File renamed without changes.

tests/neg/i20071b/A_1.scala

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
2+
trait Scope
3+
object Scope:
4+
given i: Int = ???
5+
6+
type ReferencesScope[S] >: Int <: Int
7+
8+
type ScopeToInt[Why] = Why match
9+
case Scope => Int
10+
11+
def foo[T](using d: ReferencesScope[T]): Any = ???
12+
13+
def bar[T](using d: ScopeToInt[T]): Any = ???

tests/neg/i20071b/B_2.scala

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
2+
def test: Unit =
3+
foo[Scope] // ok
4+
bar[Scope] // error
5+
6+
import Scope.i
7+
bar[Scope] // ok
8+

tests/pos/i20136a.scala

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
2+
trait Expr:
3+
type Value
4+
object Expr:
5+
type Of[V] = Expr { type Value = V }
6+
type ExtractValue[E <: Expr] = E match
7+
case Expr.Of[v] => v
8+
9+
trait TC[E <: Expr]:
10+
type Elem = Expr.ExtractValue[E]
11+
class BIExpr extends Expr:
12+
type Value = BigInt
13+
class Foo extends TC[BIExpr]:
14+
val v: Elem = 0

tests/pos/i20136b/A_1.scala

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package a
2+
3+
trait Expr:
4+
type Value
5+
object Expr:
6+
type Of[V] = Expr { type Value = V }
7+
type ExtractValue[E <: Expr] = E match
8+
case Expr.Of[v] => v

tests/pos/i20136b/B_2.scala

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
package a
2+
3+
trait TC[E <: Expr]:
4+
type Elem = Expr.ExtractValue[E]
5+
class BIExpr extends Expr:
6+
type Value = BigInt
7+
class Foo extends TC[BIExpr]:
8+
val v: Elem = 0

0 commit comments

Comments
 (0)