Skip to content

Commit a116bd0

Browse files
authored
Merge pull request #3276 from dotty-staging/fix-deep-subtypes-2
isAsSpecific: restrict usage of fullyDefinedType
2 parents 3ed8f8e + f49e653 commit a116bd0

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
@@ -1085,14 +1085,16 @@ trait Applications extends Compatibility { self: Typer with Dynamic =>
10851085
{
10861086
implicit val ctx = nestedCtx
10871087

1088-
// Fully define the type so that the types of the tparams created
1089-
// below never contain TypeRefs whose underling types contain
1090-
// uninstantiated TypeVars, this could lead to cycles in `isSubType`
1091-
// as a TypeVar might get constrained by a TypeRef it's part of.
1092-
val tp1a = fullyDefinedType(tp1, "alternative", alt1.symbol.pos).asInstanceOf[PolyType]
1093-
1094-
val tparams = ctx.newTypeParams(alt1.symbol, tp1.paramNames, EmptyFlags, tp1a.instantiateBounds)
1095-
isAsSpecific(alt1, tp1a.instantiate(tparams.map(_.typeRef)), alt2, tp2)
1088+
// Fully define the PolyType parameters so that the infos of the
1089+
// tparams created below never contain TypeRefs whose underling types
1090+
// contain uninstantiated TypeVars, this could lead to cycles in
1091+
// `isSubType` as a TypeVar might get constrained by a TypeRef it's
1092+
// part of.
1093+
val tp1Params = tp1.newLikeThis(tp1.paramNames, tp1.paramInfos, defn.AnyType)
1094+
fullyDefinedType(tp1Params, "type parameters of alternative", alt1.symbol.pos)
1095+
1096+
val tparams = ctx.newTypeParams(alt1.symbol, tp1.paramNames, EmptyFlags, tp1.instantiateBounds)
1097+
isAsSpecific(alt1, tp1.instantiate(tparams.map(_.typeRef)), alt2, tp2)
10961098
}
10971099
case _ => // (3)
10981100
tp2 match {

0 commit comments

Comments
 (0)