Skip to content
Merged
Show file tree
Hide file tree
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
4 changes: 0 additions & 4 deletions compiler/src/dotty/tools/dotc/core/TypeOps.scala
Original file line number Diff line number Diff line change
Expand Up @@ -881,10 +881,6 @@ object TypeOps:
}

def instantiate(): Type = {
// if there's a change in variance in type parameters (between subtype tp1 and supertype tp2)
// then we don't want to maximise the type variables in the wrong direction.
// For instance 15967, A[-Z] and B[Y] extends A[Y], we don't want to maximise Y to Any
maximizeType(protoTp1.baseType(tp2.classSymbol), NoSpan)
maximizeType(protoTp1, NoSpan)
wildApprox(protoTp1)
}
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/typer/Inferencing.scala
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ object Inferencing {
if safeToInstantiate then tvar.instantiate(fromBelow = v == -1)
else {
val bounds = TypeComparer.fullBounds(tvar.origin)
if bounds.hi <:< bounds.lo || bounds.hi.classSymbol.is(Final) then
if (bounds.hi frozen_<:< bounds.lo) || bounds.hi.classSymbol.is(Final) then
tvar.instantiate(fromBelow = false)
else {
// We do not add the created symbols to GADT constraint immediately, since they may have inter-dependencies.
Expand Down
7 changes: 7 additions & 0 deletions tests/pos/i16339.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// scalac: -Werror
sealed trait Get[X, +X2 <: X]
case class Bar[Y, Y2 <: Y](value: Y2) extends Get[Y, Y2]

class Test:
def t1[Z, Z2 <: Z](get: Get[Z, Z2]) = get match
case Bar(_) =>