Skip to content

Commit

Permalink
Fix #19402: emit proper error in absence of using in given definitions (
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolasstucki authored Feb 20, 2024
2 parents ab44759 + 300f2cc commit a6df9ca
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 @@ -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()
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 a6df9ca

Please sign in to comment.