File tree Expand file tree Collapse file tree 3 files changed +24
-6
lines changed
compiler/src/dotty/tools/dotc/parsing Expand file tree Collapse file tree 3 files changed +24
-6
lines changed Original file line number Diff line number Diff line change @@ -3146,14 +3146,15 @@ object Parsers {
31463146 }
31473147 else emptyType
31483148 val rhs =
3149- if ( tpt.isEmpty || in.token == EQUALS )
3149+ if tpt.isEmpty || in.token == EQUALS then
31503150 endMarkerScope(first) {
31513151 accept(EQUALS )
3152- if (in.token == USCORE && ! tpt.isEmpty && mods.is(Mutable ) &&
3153- (lhs.toList forall (_.isInstanceOf [Ident ])))
3154- wildcardIdent()
3155- else
3156- subExpr()
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
31573158 }
31583159 else EmptyTree
31593160 lhs match {
Original file line number Diff line number Diff line change 1+
2+ class Regress {
3+ var v : Int = _
4+ def f = 42
5+ var w : Int = (_) // error: not default value syntax
6+ }
Original file line number Diff line number Diff line change 1+
2+ trait T {
3+ val adder0 : Int => Int = _ + 3 // Works fine
4+ var adder1 : Int => Int = (_ + 3 ) // Works fine
5+ var adder2 : Int => Int = _ + 3 // was: Error
6+ }
7+ class Regress {
8+ var v : Int = _
9+ def f = 42
10+ // var w: Int = (_) //Unbound placeholder parameter; incorrect use of _
11+ }
You can’t perform that action at this time.
0 commit comments