File tree Expand file tree Collapse file tree 2 files changed +11
-3
lines changed
compiler/src/dotty/tools/dotc/typer Expand file tree Collapse file tree 2 files changed +11
-3
lines changed Original file line number Diff line number Diff line change @@ -1210,9 +1210,13 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
1210
1210
tpd.cpy.UnApply (body1)(fn, Nil ,
1211
1211
typed(untpd.Bind (tree.name, untpd.TypedSplice (arg)).withPos(tree.pos), arg.tpe) :: Nil )
1212
1212
case _ =>
1213
- val sym = newPatternBoundSym(tree.name, body1.tpe, tree.pos)
1214
- if (ctx.mode.is(Mode .InPatternAlternative )) ctx.error(" Illegal variable in pattern alternative" , tree.pos)
1215
- assignType(cpy.Bind (tree)(tree.name, body1), sym)
1213
+ if (tree.name == nme.WILDCARD ) body1
1214
+ else {
1215
+ val sym = newPatternBoundSym(tree.name, body1.tpe, tree.pos)
1216
+ if (ctx.mode.is(Mode .InPatternAlternative ))
1217
+ ctx.error(i " Illegal variable ${sym.name} in pattern alternative " , tree.pos)
1218
+ assignType(cpy.Bind (tree)(tree.name, body1), sym)
1219
+ }
1216
1220
}
1217
1221
}
1218
1222
Original file line number Diff line number Diff line change @@ -10,8 +10,12 @@ object Main {
10
10
11
11
// #1612
12
12
object Test {
13
+ case class A ()
13
14
def g (p: (Int ,Int )) = p match {
14
15
case (10 ,n) | (n,10 ) => println(n) // error // error (Illegal variable in pattern alternative)
15
16
case _ => println(" nope" )
16
17
}
18
+ def test (x : Any ) = x match {
19
+ case _ : String | _ @ A () => 1
20
+ }
17
21
}
You can’t perform that action at this time.
0 commit comments