Skip to content

Commit f49e653

Browse files
committed
isAsSpecific: restrict usage of fullyDefinedType
We only need to fully define the bounds of the PolyType parameters, not the whole PolyType.
1 parent eb2fdf2 commit f49e653

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

compiler/src/dotty/tools/dotc/typer/Applications.scala

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1094,14 +1094,16 @@ trait Applications extends Compatibility { self: Typer with Dynamic =>
10941094
{
10951095
implicit val ctx = nestedCtx
10961096

1097-
// Fully define the type so that the types of the tparams created
1098-
// below never contain TypeRefs whose underling types contain
1099-
// uninstantiated TypeVars, this could lead to cycles in `isSubType`
1100-
// as a TypeVar might get constrained by a TypeRef it's part of.
1101-
val tp1a = fullyDefinedType(tp1, "alternative", alt1.symbol.pos).asInstanceOf[PolyType]
1102-
1103-
val tparams = ctx.newTypeParams(alt1.symbol, tp1.paramNames, EmptyFlags, tp1a.instantiateBounds)
1104-
isAsSpecific(alt1, tp1a.instantiate(tparams.map(_.typeRef)), alt2, tp2)
1097+
// Fully define the PolyType parameters so that the infos of the
1098+
// tparams created below never contain TypeRefs whose underling types
1099+
// contain uninstantiated TypeVars, this could lead to cycles in
1100+
// `isSubType` as a TypeVar might get constrained by a TypeRef it's
1101+
// part of.
1102+
val tp1Params = tp1.newLikeThis(tp1.paramNames, tp1.paramInfos, defn.AnyType)
1103+
fullyDefinedType(tp1Params, "type parameters of alternative", alt1.symbol.pos)
1104+
1105+
val tparams = ctx.newTypeParams(alt1.symbol, tp1.paramNames, EmptyFlags, tp1.instantiateBounds)
1106+
isAsSpecific(alt1, tp1.instantiate(tparams.map(_.typeRef)), alt2, tp2)
11051107
}
11061108
case _ => // (3)
11071109
tp2 match {

0 commit comments

Comments
 (0)