Skip to content

Commit d69ae4e

Browse files
WojciechMazursmarterEugeneFlesselle
authored
Backport "Allow SAM types to contain multiple refinements" to 3.3.4 (#21556)
Backports #20172 to Scala 3.3.4-RC2 as the follow-up to #20092 regression fix. --------- Co-authored-by: Guillaume Martres <[email protected]> Co-authored-by: Eugene Flesselle <[email protected]>
1 parent 7b0a54b commit d69ae4e

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -5579,7 +5579,7 @@ object Types extends TypeUtils {
55795579
def withRefinements(toType: Type, fromTp: Type): Type = fromTp.dealias match
55805580
case RefinedType(fromParent, name, info: AliasingBounds) if tp0.member(name).exists =>
55815581
val parent1 = withRefinements(toType, fromParent)
5582-
RefinedType(toType, name, info)
5582+
RefinedType(parent1, name, info)
55835583
case _ => toType
55845584
val tp = withRefinements(tp0, origTp)
55855585

tests/run/i18315.scala

+7
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,16 @@ trait Sam2:
77
type T
88
def apply(x: T): T
99

10+
trait Sam3:
11+
type T
12+
type U
13+
def apply(x: T): U
14+
1015
object Test:
1116
def main(args: Array[String]): Unit =
1217
val s1: Sam1 { type T = String } = x => x.trim
1318
s1.apply("foo")
1419
val s2: Sam2 { type T = Int } = x => x + 1
1520
s2.apply(1)
21+
val s3: Sam3 { type T = Int; type U = String } = x => x.toString
22+
s3.apply(2)

0 commit comments

Comments
 (0)