Skip to content

Commit

Permalink
Revert unnecessary changes
Browse files Browse the repository at this point in the history
  • Loading branch information
noti0na1 committed Apr 1, 2024
1 parent bd9f4d0 commit 362beb5
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 19 deletions.
23 changes: 9 additions & 14 deletions compiler/src/dotty/tools/dotc/core/TypeComparer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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:
//
Expand All @@ -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.
Expand Down
4 changes: 0 additions & 4 deletions compiler/src/dotty/tools/dotc/core/Types.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/typer/Applications.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 362beb5

Please sign in to comment.