Skip to content

Commit a6df9ca

Browse files
Fix #19402: emit proper error in absence of using in given definitions (#19714)
2 parents ab44759 + 300f2cc commit a6df9ca

File tree

2 files changed

+12
-1
lines changed

2 files changed

+12
-1
lines changed

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

+1-1
Original file line numberDiff line numberDiff line change
@@ -4012,7 +4012,7 @@ object Parsers {
40124012
val tparams = typeParamClauseOpt(ParamOwner.Given)
40134013
newLineOpt()
40144014
val vparamss =
4015-
if in.token == LPAREN && in.lookahead.isIdent(nme.using)
4015+
if in.token == LPAREN && (in.lookahead.isIdent(nme.using) || name != EmptyTermName)
40164016
then termParamClauses(ParamOwner.Given)
40174017
else Nil
40184018
newLinesOpt()

tests/neg/i19402.scala

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
object Test:
2+
3+
class Bar(foo: Foo)
4+
5+
class Foo
6+
7+
given (Foo) = ???
8+
given (using a: Int): Int = ???
9+
given [T](using a: T): T = ???
10+
given bar(foo: Foo): Bar = Bar(foo) // error: using is expected
11+

0 commit comments

Comments
 (0)