Skip to content

Commit 215d53f

Browse files
committed
Simplify var x = _
Less fussy, more succinct.
1 parent 1c5364c commit 215d53f

File tree

1 file changed

+6
-11
lines changed

1 file changed

+6
-11
lines changed

compiler/src/dotty/tools/dotc/parsing/Parsers.scala

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3149,17 +3149,12 @@ object Parsers {
31493149
if tpt.isEmpty || in.token == EQUALS then
31503150
endMarkerScope(first) {
31513151
accept(EQUALS)
3152-
val rhs0 = subExpr()
3153-
val defaultOK = !tpt.isEmpty && mods.is(Mutable) && lhs.forall(_.isInstanceOf[Ident])
3154-
def isDefaultSyntax(t: Tree) = t match {
3155-
case Ident(name) => placeholderParams.nonEmpty && name == placeholderParams.head.name
3156-
case _ => false
3157-
}
3158-
if defaultOK && isDefaultSyntax(rhs0) then
3159-
placeholderParams = placeholderParams.tail
3160-
atSpan(rhs0.span) { Ident(nme.WILDCARD) }
3161-
else
3162-
rhs0
3152+
subExpr() match
3153+
case rhs0 @ Ident(name) if placeholderParams.nonEmpty && name == placeholderParams.head.name
3154+
&& !tpt.isEmpty && mods.is(Mutable) && lhs.forall(_.isInstanceOf[Ident]) =>
3155+
placeholderParams = placeholderParams.tail
3156+
atSpan(rhs0.span) { Ident(nme.WILDCARD) }
3157+
case rhs0 => rhs0
31633158
}
31643159
else EmptyTree
31653160
lhs match {

0 commit comments

Comments
 (0)