File tree Expand file tree Collapse file tree 4 files changed +13
-7
lines changed
compiler/src/dotty/tools/dotc/typer Expand file tree Collapse file tree 4 files changed +13
-7
lines changed Original file line number Diff line number Diff line change @@ -77,11 +77,17 @@ object RefChecks {
7777
7878 /** Check that a stable identifier pattern is indeed stable (SLS 8.1.5)
7979 */
80- private def checkStableIdentPattern (tree : Tree )(implicit ctx : Context ) = tree match {
81- case _ : Select | _ : Ident if ! isWildcardArg(tree) =>
82- if (! tree.tpe.isStable)
83- ctx.error(s " stable identifier required, but ${tree.show} found " , tree.pos)
84- case _ =>
80+ private def checkStableIdentPattern (tree : Tree )(implicit ctx : Context ) = {
81+ def error = ctx.error(s " stable identifier required, but ${tree.show} found " , tree.pos)
82+ tree match {
83+ case _ : Ident if ! isWildcardArg(tree) =>
84+ if (! tree.tpe.isStable) error
85+ case _ : Select =>
86+ if (! tree.tpe.isStable) error
87+ case _ : Apply =>
88+ error
89+ case _ =>
90+ }
8591 }
8692
8793 /** The this-type of `cls` which should be used when looking at the types of
Original file line number Diff line number Diff line change @@ -2453,7 +2453,7 @@ class Typer extends Namer
24532453 */
24542454 protected def checkEqualityEvidence (tree : tpd.Tree , pt : Type )(implicit ctx : Context ) : Unit = {
24552455 tree match {
2456- case _ : RefTree | _ : Literal | _ : Apply
2456+ case _ : RefTree | _ : Literal
24572457 if ! isVarPattern(tree) &&
24582458 ! (tree.tpe <:< pt) (ctx.addMode(Mode .GADTflexible )) =>
24592459 val cmp =
Original file line number Diff line number Diff line change @@ -13,7 +13,6 @@ object Test {
1313 x match { case Y => () } // error
1414 x match { case { Y .toInt } => () } // error
1515 x match { case { Y }.toInt => () } // error
16- x match { case Y .toString => () } // error
1716 x match { case { Y }.toString => () } // error
1817 x match { case { Y .toString } => () } // error
1918 }
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ object Test {
1010
1111 x match { case Y1 => () } // error
1212 x match { case Y2 .toInt => () } // error
13+ x match { case Y1 .toString => () } // error
1314
1415 x match { case Z1 .v => () } // error
1516 x match { case Z2 .v => () } // ok
You can’t perform that action at this time.
0 commit comments