Skip to content

Commit da29981

Browse files
committed
Fix parsing problem for consecutive anonymous givens
1 parent 76a76ee commit da29981

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2338,7 +2338,8 @@ object Parsers {
23382338
(ofClass || ofInstance) && {
23392339
val lookahead = in.lookaheadScanner // skips newline on startup
23402340
lookahead.nextToken() // skip the `given`
2341-
if (lookahead.token == IDENTIFIER || lookahead.token == BACKQUOTED_IDENT) {
2341+
if (lookahead.token == IDENTIFIER && lookahead.name != nme.as ||
2342+
lookahead.token == BACKQUOTED_IDENT) {
23422343
lookahead.nextToken()
23432344
if (lookahead.token == LBRACKET) {
23442345
lookahead.nextToken()

tests/pos/givens.scala

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
class A
2+
class B
3+
4+
given as A
5+
given as B

0 commit comments

Comments
 (0)