Skip to content

Commit 6a88601

Browse files
authored
Allow SAM types to contain match alias refinements (#20092)
Fixes #20080
2 parents 3bf44f1 + 369ac1c commit 6a88601

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

compiler/src/dotty/tools/dotc/core/Types.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5892,7 +5892,7 @@ object Types extends TypeUtils {
58925892

58935893
/** Copy type aliases refinements to `toTp` from `fromTp` */
58945894
def withRefinements(toType: Type, fromTp: Type): Type = fromTp.dealias match
5895-
case RefinedType(fromParent, name, info: TypeAlias) if tp0.member(name).exists =>
5895+
case RefinedType(fromParent, name, info: AliasingBounds) if tp0.member(name).exists =>
58965896
val parent1 = withRefinements(toType, fromParent)
58975897
RefinedType(toType, name, info)
58985898
case _ => toType

tests/pos/i20080.scala

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
2+
trait Zippable[-A, -B]:
3+
type Out
4+
def zip(left: A, right: B): Out
5+
6+
object Zippable extends ZippableLowPrio:
7+
given append[A <: Tuple, B]: (Zippable[A, B] { type Out = Tuple.Append[A, B] }) =
8+
(left, right) => left :* right
9+
10+
trait ZippableLowPrio:
11+
given pair[A, B]: (Zippable[A, B] { type Out = (A, B) }) =
12+
(left, right) => (left, right)
13+
14+
15+
object Minimization:
16+
17+
trait Fun1:
18+
type Out
19+
def apply(x: Any): Out
20+
21+
type M[X] = X match
22+
case String => X
23+
24+
def test[A] =
25+
26+
val _: Fun1 { type Out = M[A] } = new Fun1:
27+
type Out = M[A]
28+
def apply(x: Any): Out = ???
29+
30+
val _: Fun1 { type Out = M[A] } = x => ???
31+
32+
val _: Fun1 { type Out = A match {case String => A} } = x => ???

0 commit comments

Comments
 (0)