Skip to content

Commit 347c242

Browse files
Merge pull request #8063 from dotty-staging/fix-#8056
Fix #8056: Handle and/or types in translateParameterized
2 parents 8786d42 + f1a7c76 commit 347c242

File tree

2 files changed

+9
-1
lines changed

2 files changed

+9
-1
lines changed

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

+4-1
Original file line numberDiff line numberDiff line change
@@ -455,7 +455,10 @@ class TypeApplications(val self: Type) extends AnyVal {
455455
self.derivedExprType(tp.translateParameterized(from, to))
456456
case _ =>
457457
if (self.derivesFrom(from)) {
458-
val arg = self.baseType(from).argInfos.head
458+
def elemType(tp: Type): Type = tp match
459+
case tp: AndOrType => tp.derivedAndOrType(elemType(tp.tp1), elemType(tp.tp2))
460+
case _ => tp.baseType(from).argInfos.head
461+
val arg = elemType(self)
459462
val arg1 = if (wildcardArg) TypeBounds.upper(arg) else arg
460463
to.typeRef.appliedTo(arg1)
461464
}

tests/pos/i8056.scala

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
object O{
2+
def m(x: Any*) = ()
3+
def n(l: List[Int] | List[String]): Unit = m(l: _*)
4+
def n2(l: List[Int] & List[String]): Unit = m(l: _*)
5+
}

0 commit comments

Comments
 (0)