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
2 changes: 2 additions & 0 deletions compiler/src/dotty/tools/dotc/typer/Typer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -1609,6 +1609,8 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
}

val result = pt match {
case mt: MatchType if isMatchTypeShaped(mt) =>
typedDependentMatchFinish(tree, sel1, selType, tree.cases, mt)
case MatchType.InDisguise(mt) if isMatchTypeShaped(mt) =>
typedDependentMatchFinish(tree, sel1, selType, tree.cases, mt)
case _ =>
Expand Down
22 changes: 22 additions & 0 deletions tests/pos/match-type-inference.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
type IsString[T <: Any] = T match {
case String => true
case _ => false
}

def isString(x: Any): IsString[x.type] = x match
case _: String => true
case _ => false

def isString2(x: Any): x.type match {
case String => true
case _ => false
} = x match
case _: String => true
case _ => false

def isString3[T](x: T): T match {
case String => true
case _ => false
} = x match
case _: String => true
case _ => false