Skip to content

Commit cc52b7e

Browse files
committed
Handle singlton scrutinees of inline matches
1 parent 4bb42ac commit cc52b7e

File tree

4 files changed

+10
-2
lines changed

4 files changed

+10
-2
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1467,8 +1467,8 @@ class Typer extends Namer
14671467
val sel1 = typedExpr(tree.selector)
14681468
val rawSelectorTpe = fullyDefinedType(sel1.tpe, "pattern selector", tree.span)
14691469
val selType = rawSelectorTpe match
1470-
case c: ConstantType if tree.isInline => c
1471-
case otherTpe => otherTpe.widen
1470+
case tpe: SingletonType if tree.isInline => tpe
1471+
case tpe => tpe.widen
14721472
/** Extractor for match types hidden behind an AppliedType/MatchAlias */
14731473
object MatchTypeInDisguise {
14741474
def unapply(tp: AppliedType): Option[MatchType] = tp match {
File renamed without changes.
File renamed without changes.

tests/pos/i12715c.scala

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
transparent inline def f(x: Any): Any =
2+
inline 10 match
3+
case _ =>
4+
inline x match
5+
case y => y
6+
7+
def test =
8+
def failMsg(x: Int): x.type = f(x)

0 commit comments

Comments
 (0)