Skip to content

Commit 7b0a54b

Browse files
WojciechMazursmarterEugeneFlesselle
authored
Backport "Allow SAM types to contain match alias refinements" to 3.3.4 (#21554)
Backports #20092 to Scala 3.3.4-RC2 LTS on top of #21553. Fixes regression introduced in 3.3.1 No new Open Community Build regressions were detected for this changes --------- Co-authored-by: Guillaume Martres <[email protected]> Co-authored-by: Eugene Flesselle <[email protected]>
1 parent 3d0f02c commit 7b0a54b

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -5577,7 +5577,7 @@ object Types extends TypeUtils {
55775577

55785578
/** Copy type aliases refinements to `toTp` from `fromTp` */
55795579
def withRefinements(toType: Type, fromTp: Type): Type = fromTp.dealias match
5580-
case RefinedType(fromParent, name, info: TypeAlias) if tp0.member(name).exists =>
5580+
case RefinedType(fromParent, name, info: AliasingBounds) if tp0.member(name).exists =>
55815581
val parent1 = withRefinements(toType, fromParent)
55825582
RefinedType(toType, name, info)
55835583
case _ => toType

tests/pos/i20080.scala

+32
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)