Skip to content

Commit d57a4a4

Browse files
authored
Merge pull request #14563 from dwijnand/match-types-bounds/i14151-again
2 parents 39b635c + b426699 commit d57a4a4

File tree

4 files changed

+10
-0
lines changed

4 files changed

+10
-0
lines changed

compiler/src/dotty/tools/dotc/typer/Typer.scala

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1713,6 +1713,10 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
17131713
val pat1 = withMode(Mode.Pattern) {
17141714
checkSimpleKinded(typedType(cdef.pat, mapPatternBounds = true))
17151715
}
1716+
if !ctx.isAfterTyper && pt != defn.ImplicitScrutineeTypeRef then
1717+
withMode(Mode.GadtConstraintInference) {
1718+
TypeComparer.constrainPatternType(pat1.tpe, selType)
1719+
}
17161720
val pat2 = indexPattern(cdef).transform(pat1)
17171721
var body1 = typedType(cdef.body, pt)
17181722
if !body1.isType then

tests/pos/i14151.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
class BoundedPair[A, B <: A]:
2+
type Second[A, T <: BoundedPair[A, _ <: A]] <: A = T match { case BoundedPair[A, b] => b }

tests/pos/i14151b.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
class Single[B](val value: B):
2+
type Retrieve[A, T <: Single[_ <: A]] <: A = T match { case Single[b] => b }

tests/pos/i14151c.scala

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
class Single[B](val value: B):
2+
type Retrieve[A] <: A = Single[A] match { case Single[b] => b }

0 commit comments

Comments
 (0)