Skip to content

Commit 3ab1fa8

Browse files
committed
Find & fix a LB/contra case
1 parent d0f9f5f commit 3ab1fa8

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

compiler/src/dotty/tools/dotc/core/TypeComparer.scala

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3136,6 +3136,14 @@ class TrackingTypeComparer(initctx: Context) extends TypeComparer(initctx) {
31363136

31373137
def instantiateParams(insts: Array[Type]) = new ApproximatingTypeMap {
31383138
variance = 0
3139+
3140+
override def range(lo: Type, hi: Type): Type =
3141+
if variance == 0 && (lo eq hi) then
3142+
// override the default `lo eq hi` test, which removes the Range
3143+
// which leads to a Reduced result, instead of NoInstance
3144+
Range(lower(lo), upper(hi))
3145+
else super.range(lo, hi)
3146+
31393147
def apply(t: Type) = t match {
31403148
case t @ TypeParamRef(b, n) if b `eq` caseLambda => insts(n)
31413149
case t: LazyRef => apply(t.ref)

tests/pos/i15926.contra.scala

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
trait Show[-A >: Nothing]
2+
3+
type MT1[I <: Show[Nothing], N] = I match
4+
case Show[a] => N match
5+
case Int => a
6+
7+
val a = summon[MT1[Show[String], Int] =:= String]

0 commit comments

Comments
 (0)