File tree Expand file tree Collapse file tree 3 files changed +40
-2
lines changed
compiler/src/dotty/tools/dotc/typer Expand file tree Collapse file tree 3 files changed +40
-2
lines changed Original file line number Diff line number Diff line change @@ -1478,8 +1478,10 @@ class Typer extends Namer
14781478 case _ =>
14791479 if tree.isInline then checkInInlineContext(" inline match" , tree.srcPos)
14801480 val sel1 = typedExpr(tree.selector)
1481- val selType = fullyDefinedType(sel1.tpe, " pattern selector" , tree.span).widen
1482-
1481+ val rawSelectorTpe = fullyDefinedType(sel1.tpe, " pattern selector" , tree.span)
1482+ val selType = rawSelectorTpe match
1483+ case c : ConstantType if tree.isInline => c
1484+ case otherTpe => otherTpe.widen
14831485 /** Extractor for match types hidden behind an AppliedType/MatchAlias */
14841486 object MatchTypeInDisguise {
14851487 def unapply (tp : AppliedType ): Option [MatchType ] = tp match {
Original file line number Diff line number Diff line change 1+ package repro
2+
3+ import compiletime .{constValue , erasedValue }
4+
5+ sealed trait ValidateExprInt
6+
7+ class And [A <: ValidateExprInt , B <: ValidateExprInt ] extends ValidateExprInt
8+ class GreaterThan [T <: Int ] extends ValidateExprInt
9+
10+ object Repro :
11+ inline def validate [E <: ValidateExprInt ](v : Int ): String =
12+ val failMsg = validateV[E ](v)
13+ if failMsg == " neverPass" then " neverPass"
14+ else " something else"
15+
16+ transparent inline def validateV [E <: ValidateExprInt ](v : Int ): String =
17+ inline erasedValue[E ] match
18+ case _ : GreaterThan [t] =>
19+ " GreaterThan"
20+ case _ : And [a, b] =>
21+ inline validateV[a](v) match
22+ case " " =>
23+ validateV[b](v)
24+ case other =>
25+ other
26+
27+ @ main def test (): Unit =
28+ println(validate[And [GreaterThan [10 ], GreaterThan [12 ]]](5 ))
Original file line number Diff line number Diff line change 1+ transparent inline def f : String =
2+ inline 10 match
3+ case _ =>
4+ inline " foo" match
5+ case x : String => x
6+
7+ def test =
8+ inline val failMsg = f
You can’t perform that action at this time.
0 commit comments