Skip to content

Commit

Permalink
Address some points in code review.
Browse files Browse the repository at this point in the history
  • Loading branch information
odersky committed Oct 4, 2024
1 parent 907d73a commit c76dc80
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion docs/_docs/internals/syntax.md
Original file line number Diff line number Diff line change
Expand Up @@ -486,7 +486,7 @@ GivenConditional ::= DefTypeParamClause
GivenType ::= AnnotType1 {id [nl] AnnotType1}
OldGivenDef ::= [OldGivenSig] (AnnotType [‘=’ Expr] | StructuralInstance) -- syntax up to Scala 3.5, to be deprecated in the future
OldGivenSig ::= [id] [DefTypeParamClause] {UsingParamClause} ‘:’ -- one of `id`, `DefTypeParamClause`, `UsingParamClause` must be present
OldGivenSig ::= [id] [DefTypeParamClause] {UsingParamClause} ‘:’ -- one of `id`, `DefTypeParamClause`, `UsingParamClause` must be present
StructuralInstance ::= ConstrApp {‘with’ ConstrApp} [‘with’ WithTemplateBody]
Extension ::= ‘extension’ [DefTypeParamClause] {UsingParamClause}
Expand Down
9 changes: 6 additions & 3 deletions docs/_docs/reference/contextual/context-bounds.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ The witness context parameter(s) generated from context bounds are added as foll

1. If one of the bounds is referred to by its name in a subsequent parameter clause, the context bounds are mapped to a using clause immediately preceding the first such parameter clause.
2. Otherwise, if the last parameter clause is a using (or implicit) clause, merge all parameters arising from context bounds in front of that clause, creating a single using clause.
3. Otherwise, let the parameters arising from context bounds form a new using clause at the end.
3. Otherwise, the parameters arising from context bounds form a new using clause at the end.

Rules (2) and (3) match Scala 2's rules. Rule (1) is new but since context bounds so far could not be referred to, it does not apply to legacy code. Therefore, binary compatibility with Scala 2 and earlier Scala 3 versions is maintained.

Expand Down Expand Up @@ -151,11 +151,14 @@ val less: Comparer = [X] => (x: X, y: X) => (ord: Ord[X]) ?=>
The expansion of using clauses does look inside alias types. For instance,
here is a variation of the previous example that uses a parameterized type alias:
```scala
type Cmp[X] = (x: X, y: X) => Ord[X] ?=> Boolean
type Cmp[X] = (x: X, y: X) => Boolean
type Comparer2 = [X: Ord] => Cmp[X]
```
The expansion of the right hand side of `Comparer2` expands the `Cmp[X]` alias
and then inserts the context function at the same place as what's done for `Comparer`.
and then inserts the context function at the same place as what's done for `Comparer`:
```scala
[X] => (x: X, y: X) => Ord[X] ?=> Boolean
```

### Context Bounds for Type Members

Expand Down
2 changes: 1 addition & 1 deletion docs/_docs/reference/syntax.md
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ GivenConditional ::= DefTypeParamClause
GivenType ::= AnnotType1 {id [nl] AnnotType1}
OldGivenDef ::= [OldGivenSig] (AnnotType [‘=’ Expr] | StructuralInstance) -- syntax up to Scala 3.5, to be deprecated in the future
OldGivenSig ::= [id] [DefTypeParamClause] {UsingParamClause} ‘:’ -- one of `id`, `DefTypeParamClause`, `UsingParamClause` must be present
OldGivenSig ::= [id] [DefTypeParamClause] {UsingParamClause} ‘:’ -- one of `id`, `DefTypeParamClause`, `UsingParamClause` must be present
StructuralInstance ::= ConstrApp {‘with’ ConstrApp} [‘with’ WithTemplateBody]
Extension ::= ‘extension’ [DefTypeParamClause] {UsingParamClause}
Expand Down

0 comments on commit c76dc80

Please sign in to comment.