Skip to content

Commit 184f486

Browse files
authored
Merge pull request #7317 from dotty-staging/change-given-eta
Allow normal parameters after given parameters
2 parents 79d2034 + a80e980 commit 184f486

File tree

8 files changed

+64
-337
lines changed

8 files changed

+64
-337
lines changed

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

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2864,7 +2864,7 @@ object Parsers {
28642864
ofCaseClass: Boolean = false,
28652865
ofInstance: Boolean = false): List[List[ValDef]] =
28662866

2867-
def recur(firstClause: Boolean, nparams: Int, contextualOnly: Boolean): List[List[ValDef]] =
2867+
def recur(firstClause: Boolean, nparams: Int): List[List[ValDef]] =
28682868
newLineOptWhenFollowedBy(LPAREN)
28692869
if in.token == LPAREN then
28702870
val paramsStart = in.offset
@@ -2873,23 +2873,14 @@ object Parsers {
28732873
ofClass = ofClass,
28742874
ofCaseClass = ofCaseClass,
28752875
firstClause = firstClause)
2876-
val isGiven = params match
2877-
case param :: _ if param.mods.flags.is(Given) => true
2878-
case _ =>
2879-
if contextualOnly then
2880-
syntaxError(
2881-
if ofInstance then em"parameters of instance definitions must be `given' clauses"
2882-
else em"normal parameters cannot come after `given' clauses",
2883-
paramsStart)
2884-
false
28852876
val lastClause = params.nonEmpty && params.head.mods.flags.is(Implicit)
28862877
params :: (
28872878
if lastClause then Nil
2888-
else recur(firstClause = false, nparams + params.length, isGiven))
2879+
else recur(firstClause = false, nparams + params.length))
28892880
else Nil
28902881
end recur
28912882

2892-
recur(firstClause = true, 0, ofInstance)
2883+
recur(firstClause = true, 0)
28932884
end paramClauses
28942885

28952886
/* -------- DEFS ------------------------------------------- */

docs/docs/reference/contextual-new/given-clauses.md

Lines changed: 0 additions & 116 deletions
This file was deleted.

docs/docs/reference/contextual-new/relationship-implicits.md

Lines changed: 0 additions & 176 deletions
This file was deleted.

docs/docs/reference/contextual/given-clauses.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ maximum(xs)(given descending(given ListOrd(given IntOrd)))
6969
There can be several `given` parameter clauses in a definition and `given` parameter clauses can be freely
7070
mixed with normal ones. Example:
7171
```scala
72-
def f(u: Universe)(given c: u.Context)(given s: ctx.Symbol, k: ctx.Kind) = ...
72+
def f(u: Universe)(given ctx: u.Context)(given s: ctx.Symbol, k: ctx.Kind) = ...
7373
```
7474
Multiple given clauses are matched left-to-right in applications. Example:
7575
```scala

0 commit comments

Comments
 (0)