File tree Expand file tree Collapse file tree 2 files changed +11
-0
lines changed
compiler/src/dotty/tools/dotc/typer Expand file tree Collapse file tree 2 files changed +11
-0
lines changed Original file line number Diff line number Diff line change @@ -2805,8 +2805,10 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
28052805 else
28062806 assert(ctx.reporter.errorsReported)
28072807 tree.withType(defn.AnyType )
2808+ val savedGadt = nestedCtx.gadt
28082809 val trees1 = tree.trees.mapconserve(typed(_, pt)(using nestedCtx))
28092810 .mapconserve(ensureValueTypeOrWildcard)
2811+ nestedCtx.gadtState.restore(savedGadt) // Disable GADT reasoning for pattern alternatives
28102812 assignType(cpy.Alternative (tree)(trees1), trees1)
28112813 }
28122814
Original file line number Diff line number Diff line change 1+ enum Expr [+ T ]:
2+ case StringVal (x : String ) extends Expr [String ]
3+ case IntVal (x : Int ) extends Expr [Int ]
4+ case IntValAlt (x : Int ) extends Expr [Int ]
5+ import Expr .*
6+ def eval [T ](e : Expr [T ]): T = e match
7+ case StringVal (_) | IntVal (_) => " 42" // error
8+ def eval1 [T ](e : Expr [T ]): T = e match
9+ case IntValAlt (_) | IntVal (_) => 42 // error // limitation
You can’t perform that action at this time.
0 commit comments