Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions compiler/src/dotty/tools/dotc/typer/Applications.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1094,14 +1094,16 @@ trait Applications extends Compatibility { self: Typer with Dynamic =>
{
implicit val ctx = nestedCtx

// Fully define the type so that the types of the tparams created
// below never contain TypeRefs whose underling types contain
// uninstantiated TypeVars, this could lead to cycles in `isSubType`
// as a TypeVar might get constrained by a TypeRef it's part of.
val tp1a = fullyDefinedType(tp1, "alternative", alt1.symbol.pos).asInstanceOf[PolyType]

val tparams = ctx.newTypeParams(alt1.symbol, tp1.paramNames, EmptyFlags, tp1a.instantiateBounds)
isAsSpecific(alt1, tp1a.instantiate(tparams.map(_.typeRef)), alt2, tp2)
// Fully define the PolyType parameters so that the infos of the
// tparams created below never contain TypeRefs whose underling types
// contain uninstantiated TypeVars, this could lead to cycles in
// `isSubType` as a TypeVar might get constrained by a TypeRef it's
// part of.
val tp1Params = tp1.newLikeThis(tp1.paramNames, tp1.paramInfos, defn.AnyType)
fullyDefinedType(tp1Params, "type parameters of alternative", alt1.symbol.pos)

val tparams = ctx.newTypeParams(alt1.symbol, tp1.paramNames, EmptyFlags, tp1.instantiateBounds)
isAsSpecific(alt1, tp1.instantiate(tparams.map(_.typeRef)), alt2, tp2)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have the impression it would be easier to just scan the type parameter bounds whether a fullyDefinedType is needed and, if yes, instantiate the whole type.

}
case _ => // (3)
tp2 match {
Expand Down