File tree Expand file tree Collapse file tree 2 files changed +14
-0
lines changed
compiler/src/dotty/tools/dotc/typer Expand file tree Collapse file tree 2 files changed +14
-0
lines changed Original file line number Diff line number Diff line change @@ -1549,7 +1549,13 @@ class Typer extends Namer
15491549
15501550 def typedAlternative (tree : untpd.Alternative , pt : Type )(implicit ctx : Context ): Alternative = {
15511551 val nestedCtx = ctx.addMode(Mode .InPatternAlternative )
1552+ def ensureValueTypeOrWildcard (tree : Tree ) =
1553+ if tree.tpe.isValueTypeOrWildcard then tree
1554+ else
1555+ assert(ctx.reporter.errorsReported)
1556+ tree.withType(defn.AnyType )
15521557 val trees1 = tree.trees.mapconserve(typed(_, pt)(nestedCtx))
1558+ .map(ensureValueTypeOrWildcard)
15531559 assignType(cpy.Alternative (tree)(trees1), trees1)
15541560 }
15551561
Original file line number Diff line number Diff line change 1+ trait Foo [A ]
2+ class A {
3+ def F [x : Foo ]() = ???
4+
5+ Int match {
6+ case Int | F => () // error
7+ }
8+ }
You can’t perform that action at this time.
0 commit comments