Skip to content

Commit 77ac75c

Browse files
committed
revert the change to typer
1 parent 798b0d3 commit 77ac75c

File tree

4 files changed

+13
-7
lines changed

4 files changed

+13
-7
lines changed

compiler/src/dotty/tools/dotc/typer/RefChecks.scala

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff 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

compiler/src/dotty/tools/dotc/typer/Typer.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff 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 =

tests/neg/i1846.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff 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
}

tests/neg/i3812b.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
 (0)