Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 8 additions & 2 deletions compiler/src/dotty/tools/dotc/parsing/Parsers.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3412,7 +3412,10 @@ object Parsers {
// begin termParamClause
inParensWithCommas {
if in.token == RPAREN && paramOwner != ParamOwner.ExtensionPrefix && !impliedMods.is(Given)
then Nil
then
if paramOwner.takesOnlyUsingClauses then
syntaxError(em"`using` expected")
Nil
else
val clause =
if paramOwner == ParamOwner.ExtensionPrefix
Expand Down Expand Up @@ -4060,7 +4063,10 @@ object Parsers {
leadParamss += extParams
isUsingClause(extParams)
do ()
leadParamss ++= termParamClauses(ParamOwner.ExtensionFollow, numLeadParams)
// Empty parameter clauses are filtered out. They are already reported as syntax errors and are not
// allowed here.
val extFollowParams = termParamClauses(ParamOwner.ExtensionFollow, numLeadParams).filterNot(_.isEmpty)
leadParamss ++= extFollowParams
if in.isColon then
syntaxError(em"no `:` expected here")
in.nextToken()
Expand Down
3 changes: 3 additions & 0 deletions tests/neg/extensions-can-only-have-using.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
extension(x: Any)() // error
def f = 42
val x = Nil.f