From c76dc8087d34076dcb7b91fa3ba18da07f08d9c6 Mon Sep 17 00:00:00 2001 From: odersky Date: Fri, 4 Oct 2024 19:07:15 +0200 Subject: [PATCH] Address some points in code review. --- docs/_docs/internals/syntax.md | 2 +- docs/_docs/reference/contextual/context-bounds.md | 9 ++++++--- docs/_docs/reference/syntax.md | 2 +- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/docs/_docs/internals/syntax.md b/docs/_docs/internals/syntax.md index 0cde7bc127aa..d0074bb503c2 100644 --- a/docs/_docs/internals/syntax.md +++ b/docs/_docs/internals/syntax.md @@ -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} diff --git a/docs/_docs/reference/contextual/context-bounds.md b/docs/_docs/reference/contextual/context-bounds.md index ef32dc7b08c2..a06cb2d79181 100644 --- a/docs/_docs/reference/contextual/context-bounds.md +++ b/docs/_docs/reference/contextual/context-bounds.md @@ -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. @@ -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 diff --git a/docs/_docs/reference/syntax.md b/docs/_docs/reference/syntax.md index adf25c9342fa..3e71718d0752 100644 --- a/docs/_docs/reference/syntax.md +++ b/docs/_docs/reference/syntax.md @@ -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}