diff --git a/compiler/src/dotty/tools/dotc/core/TypeComparer.scala b/compiler/src/dotty/tools/dotc/core/TypeComparer.scala index 1c4991f97bfd..39a8c89af2ea 100644 --- a/compiler/src/dotty/tools/dotc/core/TypeComparer.scala +++ b/compiler/src/dotty/tools/dotc/core/TypeComparer.scala @@ -2564,18 +2564,15 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling case _ => tp - private def andTypeGen(tp1orig: Type, tp2orig: Type, op: (Type, Type) => Type, - original: (Type, Type) => Type = _ & _, isErased: Boolean = ctx.erasedTypes): Type = trace(s"andTypeGen(${tp1orig.show}, ${tp2orig.show})", subtyping, show = true) { - val tp1 = tp1orig.stripFlexible - val tp2 = tp2orig.stripFlexible + private def andTypeGen(tp1: Type, tp2: Type, op: (Type, Type) => Type, + original: (Type, Type) => Type = _ & _, isErased: Boolean = ctx.erasedTypes): Type = trace(s"andTypeGen(${tp1.show}, ${tp2.show})", subtyping, show = true) { val t1 = distributeAnd(tp1, tp2) - val ret = - if t1.exists then t1 - else - val t2 = distributeAnd(tp2, tp1) - if t2.exists then t2 - else if isErased then erasedGlb(tp1, tp2) - else liftIfHK(tp1, tp2, op, original, _ | _) + if (t1.exists) t1 + else { + val t2 = distributeAnd(tp2, tp1) + if (t2.exists) t2 + else if (isErased) erasedGlb(tp1, tp2) + else liftIfHK(tp1, tp2, op, original, _ | _) // The ` | ` on variances is needed since variances are associated with bounds // not lambdas. Example: // @@ -2585,9 +2582,7 @@ class TypeComparer(@constructorOnly initctx: Context) extends ConstraintHandling // // Here, `F` is treated as bivariant in `O`. That is, only bivariant implementation // of `F` are allowed. See neg/hk-variance2s.scala test. - - if tp1orig.isInstanceOf[FlexibleType] && tp2orig.isInstanceOf[FlexibleType] - then FlexibleType(ret) else ret + } } /** Form a normalized conjunction of two types. diff --git a/compiler/src/dotty/tools/dotc/core/Types.scala b/compiler/src/dotty/tools/dotc/core/Types.scala index 0fe42f31a3f3..26885f929e11 100644 --- a/compiler/src/dotty/tools/dotc/core/Types.scala +++ b/compiler/src/dotty/tools/dotc/core/Types.scala @@ -1620,10 +1620,6 @@ object Types extends TypeUtils { /** If this is a repeated type, its element type, otherwise the type itself */ def repeatedToSingle(using Context): Type = this match { case tp @ ExprType(tp1) => tp.derivedExprType(tp1.repeatedToSingle) - case tp: FlexibleType => - // The flexible type is handled here because the varargs from Java can be nullable. - val underlyingSingle = tp.underlying.repeatedToSingle - if underlyingSingle ne tp.underlying then underlyingSingle else tp case _ => if (isRepeatedParam) this.argTypesHi.head else this } diff --git a/compiler/src/dotty/tools/dotc/typer/Applications.scala b/compiler/src/dotty/tools/dotc/typer/Applications.scala index 4fd0e9b90291..82f4c89ae203 100644 --- a/compiler/src/dotty/tools/dotc/typer/Applications.scala +++ b/compiler/src/dotty/tools/dotc/typer/Applications.scala @@ -644,7 +644,7 @@ trait Applications extends Compatibility { missingArg(n) } - if formal.isRepeatedParam then + if (formal.isRepeatedParam) args match { case arg :: Nil if isVarArg(arg) => addTyped(arg)