File tree 4 files changed +13
-7
lines changed
compiler/src/dotty/tools/dotc/typer
4 files changed +13
-7
lines changed Original file line number Diff line number Diff line change @@ -77,11 +77,17 @@ object RefChecks {
77
77
78
78
/** Check that a stable identifier pattern is indeed stable (SLS 8.1.5)
79
79
*/
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
+ }
85
91
}
86
92
87
93
/** 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
2453
2453
*/
2454
2454
protected def checkEqualityEvidence (tree : tpd.Tree , pt : Type )(implicit ctx : Context ) : Unit = {
2455
2455
tree match {
2456
- case _ : RefTree | _ : Literal | _ : Apply
2456
+ case _ : RefTree | _ : Literal
2457
2457
if ! isVarPattern(tree) &&
2458
2458
! (tree.tpe <:< pt) (ctx.addMode(Mode .GADTflexible )) =>
2459
2459
val cmp =
Original file line number Diff line number Diff line change @@ -13,7 +13,6 @@ object Test {
13
13
x match { case Y => () } // error
14
14
x match { case { Y .toInt } => () } // error
15
15
x match { case { Y }.toInt => () } // error
16
- x match { case Y .toString => () } // error
17
16
x match { case { Y }.toString => () } // error
18
17
x match { case { Y .toString } => () } // error
19
18
}
Original file line number Diff line number Diff line change @@ -10,6 +10,7 @@ object Test {
10
10
11
11
x match { case Y1 => () } // error
12
12
x match { case Y2 .toInt => () } // error
13
+ x match { case Y1 .toString => () } // error
13
14
14
15
x match { case Z1 .v => () } // error
15
16
x match { case Z2 .v => () } // ok
You can’t perform that action at this time.
0 commit comments