Skip to content

Commit 56ac7fd

Browse files
dwijnandWojciechMazur
authored andcommitted
Fix exhaustivity due to separate TypeVar lambdas
[Cherry-picked d5a6d4f]
1 parent 427c444 commit 56ac7fd

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed

compiler/src/dotty/tools/dotc/transform/patmat/Space.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -485,8 +485,8 @@ object SpaceEngine {
485485
erase(parent, inArray, isValue, isTyped)
486486

487487
case tref: TypeRef if tref.symbol.isPatternBound =>
488-
if inArray then tref.underlying
489-
else if isValue then tref.superType
488+
if inArray then erase(tref.underlying, inArray, isValue, isTyped)
489+
else if isValue then erase(tref.superType, inArray, isValue, isTyped)
490490
else WildcardType
491491

492492
case _ => tp
@@ -540,7 +540,7 @@ object SpaceEngine {
540540
val mt: MethodType = unapp.widen match {
541541
case mt: MethodType => mt
542542
case pt: PolyType =>
543-
val tvars = pt.paramInfos.map(newTypeVar(_))
543+
val tvars = constrained(pt, EmptyTree)._2.tpes
544544
val mt = pt.instantiate(tvars).asInstanceOf[MethodType]
545545
scrutineeTp <:< mt.paramInfos(0)
546546
// force type inference to infer a narrower type: could be singleton

tests/pos/i14224.1.scala

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
//> using options -Werror
2+
3+
// Derived from the extensive test in the gist in i14224
4+
// Minimising to the false positive in SealedTrait1.either
5+
6+
sealed trait Foo[A, A1 <: A]
7+
final case class Bar[A, A1 <: A](value: A1) extends Foo[A, A1]
8+
9+
class Main:
10+
def test[A, A1 <: A](foo: Foo[A, A1]): A1 = foo match
11+
case Bar(v) => v

0 commit comments

Comments
 (0)