From f1a7c76c675938ec590c8149b90ab688a7e4eb90 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Wed, 22 Jan 2020 14:44:41 +0100 Subject: [PATCH] Fix #8056: Handle and/or types in translateParameterized --- compiler/src/dotty/tools/dotc/core/TypeApplications.scala | 5 ++++- tests/pos/i8056.scala | 5 +++++ 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 tests/pos/i8056.scala diff --git a/compiler/src/dotty/tools/dotc/core/TypeApplications.scala b/compiler/src/dotty/tools/dotc/core/TypeApplications.scala index 000125c25d62..ce386e17ec68 100644 --- a/compiler/src/dotty/tools/dotc/core/TypeApplications.scala +++ b/compiler/src/dotty/tools/dotc/core/TypeApplications.scala @@ -455,7 +455,10 @@ class TypeApplications(val self: Type) extends AnyVal { self.derivedExprType(tp.translateParameterized(from, to)) case _ => if (self.derivesFrom(from)) { - val arg = self.baseType(from).argInfos.head + def elemType(tp: Type): Type = tp match + case tp: AndOrType => tp.derivedAndOrType(elemType(tp.tp1), elemType(tp.tp2)) + case _ => tp.baseType(from).argInfos.head + val arg = elemType(self) val arg1 = if (wildcardArg) TypeBounds.upper(arg) else arg to.typeRef.appliedTo(arg1) } diff --git a/tests/pos/i8056.scala b/tests/pos/i8056.scala new file mode 100644 index 000000000000..f105b021c764 --- /dev/null +++ b/tests/pos/i8056.scala @@ -0,0 +1,5 @@ +object O{ + def m(x: Any*) = () + def n(l: List[Int] | List[String]): Unit = m(l: _*) + def n2(l: List[Int] & List[String]): Unit = m(l: _*) +} \ No newline at end of file