diff --git a/compiler/src/dotty/tools/dotc/parsing/Parsers.scala b/compiler/src/dotty/tools/dotc/parsing/Parsers.scala index fbb4e1319948..50380e5b14d3 100644 --- a/compiler/src/dotty/tools/dotc/parsing/Parsers.scala +++ b/compiler/src/dotty/tools/dotc/parsing/Parsers.scala @@ -4012,7 +4012,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() diff --git a/tests/neg/i19402.scala b/tests/neg/i19402.scala new file mode 100644 index 000000000000..dd5a4903027c --- /dev/null +++ b/tests/neg/i19402.scala @@ -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 + \ No newline at end of file