Skip to content

Commit

Permalink
Fix #19402: improved parsing of given paramiters with absence of usin…
Browse files Browse the repository at this point in the history
…g keyword

[Cherry-picked 300f2cc]
  • Loading branch information
OlgaMazhara-TomTom authored and WojciechMazur committed Jul 2, 2024
1 parent 9ce109d commit 977dc5d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/parsing/Parsers.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3958,7 +3958,7 @@ object Parsers {
val tparams = typeParamClauseOpt(ParamOwner.Given)
newLineOpt()
val vparamss =
if in.token == LPAREN && in.lookahead.isIdent(nme.using)
if in.token == LPAREN && (in.lookahead.isIdent(nme.using) || name != EmptyTermName)
then termParamClauses(ParamOwner.Given)
else Nil
newLinesOpt()
Expand Down
11 changes: 11 additions & 0 deletions tests/neg/i19402.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
object Test:

class Bar(foo: Foo)

class Foo

given (Foo) = ???
given (using a: Int): Int = ???
given [T](using a: T): T = ???
given bar(foo: Foo): Bar = Bar(foo) // error: using is expected

0 comments on commit 977dc5d

Please sign in to comment.