File tree Expand file tree Collapse file tree 2 files changed +14
-5
lines changed
compiler/src/dotty/tools/dotc/core Expand file tree Collapse file tree 2 files changed +14
-5
lines changed Original file line number Diff line number Diff line change @@ -475,13 +475,19 @@ class TypeApplications(val self: Type) extends AnyVal {
475475 self.derivedExprType(tp.translateParameterized(from, to))
476476 case _ =>
477477 if (self.derivesFrom(from)) {
478+ // NOTE: we assume the `To` class is covariant s.t.
479+ // `To[T] X To[U] <:< To[T | U]` where X ::= `&` | `|`
478480 def elemType (tp : Type ): Type = tp.widenDealias match
479481 case tp : OrType =>
480482 if tp.tp1.isBottomType then elemType(tp.tp2)
481483 else if tp.tp2.isBottomType then elemType(tp.tp1)
482484 else tp.derivedOrType(elemType(tp.tp1), elemType(tp.tp2))
483- case tp : AndType => tp.derivedAndType(elemType(tp.tp1), elemType(tp.tp2))
484- case _ => tp.baseType(from).argInfos.headOption.getOrElse(defn.NothingType )
485+ case AndType (tp1, tp2) =>
486+ // see #23435 for why this is not `tp.derivedAndType(elemType(tp1), ...)`
487+ OrType (elemType(tp1), elemType(tp2), soft = false )
488+ case _ =>
489+ tp.baseType(from).argInfos.headOption.getOrElse(defn.NothingType )
490+ end elemType
485491 val arg = elemType(self)
486492 val arg1 = if (wildcardArg) TypeBounds .upper(arg) else arg
487493 to.typeRef.appliedTo(arg1)
Original file line number Diff line number Diff line change 1- object O {
1+ object O {
22 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* )
3+
4+ def n2 (l : List [Int ] | List [String ]): Unit = m(l)
5+ def n1 (l : List [Int ] | List [String ]): Unit = m(l* )
6+ def m2 (l : List [Int ] & List [String ]): Unit = m(l)
7+ def m1 (l : List [Int ] & List [String ]): Unit = m(l* )
58}
You can’t perform that action at this time.
0 commit comments