Skip to content

Commit 644bc4f

Browse files
Backport "Fix #19402: emit proper error in absence of using in given definitions" to LTS (#20929)
Backports #19714 to the LTS branch. PR submitted by the release tooling. [skip ci]
2 parents 017a250 + 977dc5d commit 644bc4f

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
@@ -3958,7 +3958,7 @@ object Parsers {
39583958
val tparams = typeParamClauseOpt(ParamOwner.Given)
39593959
newLineOpt()
39603960
val vparamss =
3961-
if in.token == LPAREN && in.lookahead.isIdent(nme.using)
3961+
if in.token == LPAREN && (in.lookahead.isIdent(nme.using) || name != EmptyTermName)
39623962
then termParamClauses(ParamOwner.Given)
39633963
else Nil
39643964
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)