Skip to content

Commit

Permalink
Find & fix a LB/contra case
Browse files Browse the repository at this point in the history
  • Loading branch information
dwijnand committed Apr 28, 2023
1 parent d0f9f5f commit 3ab1fa8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 0 deletions.
8 changes: 8 additions & 0 deletions compiler/src/dotty/tools/dotc/core/TypeComparer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3136,6 +3136,14 @@ class TrackingTypeComparer(initctx: Context) extends TypeComparer(initctx) {

def instantiateParams(insts: Array[Type]) = new ApproximatingTypeMap {
variance = 0

override def range(lo: Type, hi: Type): Type =
if variance == 0 && (lo eq hi) then
// override the default `lo eq hi` test, which removes the Range
// which leads to a Reduced result, instead of NoInstance
Range(lower(lo), upper(hi))
else super.range(lo, hi)

def apply(t: Type) = t match {
case t @ TypeParamRef(b, n) if b `eq` caseLambda => insts(n)
case t: LazyRef => apply(t.ref)
Expand Down
7 changes: 7 additions & 0 deletions tests/pos/i15926.contra.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
trait Show[-A >: Nothing]

type MT1[I <: Show[Nothing], N] = I match
case Show[a] => N match
case Int => a

val a = summon[MT1[Show[String], Int] =:= String]

0 comments on commit 3ab1fa8

Please sign in to comment.