Skip to content

Commit 1c1ccde

Browse files
committed
Accept as also without preceding name or parameters
This aligns the Parser with the syntax.
1 parent 5627754 commit 1c1ccde

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3495,7 +3495,7 @@ object Parsers {
34953495
then paramClauses(givenOnly = true)
34963496
else Nil
34973497
newLinesOpt()
3498-
if !name.isEmpty || !tparams.isEmpty || !vparamss.isEmpty then
3498+
if isIdent(nme.as) || !name.isEmpty || !tparams.isEmpty || !vparamss.isEmpty then
34993499
accept(nme.as)
35003500
def givenAlias(tpt: Tree) =
35013501
accept(EQUALS)

tests/run/instances-anonymous.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ object Test extends App {
6363
val minimum: T
6464
}
6565

66-
given Ord[Int] {
66+
given as Ord[Int] {
6767
def (x: Int).compareTo(y: Int) =
6868
if (x < y) -1 else if (x > y) +1 else 0
6969
val minimum = Int.MinValue

0 commit comments

Comments
 (0)