Skip to content

Commit 36146eb

Browse files
committed
Stabilise SIP-47
1 parent aad6f7d commit 36146eb

31 files changed

+38
-71
lines changed

compiler/src/dotty/tools/dotc/config/Feature.scala

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,8 @@ object Feature:
121121

122122
def namedTypeArgsEnabled(using Context) = enabled(namedTypeArguments)
123123

124-
def clauseInterleavingEnabled(using Context) = enabled(clauseInterleaving)
124+
def clauseInterleavingEnabled(using Context) =
125+
sourceVersion.isAtLeast(`3.6`) || enabled(clauseInterleaving)
125126

126127
def genericNumberLiteralsEnabled(using Context) = enabled(genericNumberLiterals)
127128

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

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3836,9 +3836,6 @@ object Parsers {
38363836

38373837
/** DefDef ::= DefSig [‘:’ Type] [‘=’ Expr]
38383838
* | this TypelessClauses [DefImplicitClause] `=' ConstrExpr
3839-
* DefSig ::= id [DefTypeParamClause] DefTermParamClauses
3840-
*
3841-
* if clauseInterleaving is enabled:
38423839
* DefSig ::= id [DefParamClauses] [DefImplicitClause]
38433840
*/
38443841
def defDefOrDcl(start: Offset, mods: Modifiers, numLeadParams: Int = 0): DefDef = atSpan(start, nameStart) {
@@ -3878,13 +3875,11 @@ object Parsers {
38783875
val ident = termIdent()
38793876
var name = ident.name.asTermName
38803877
val paramss =
3881-
if in.featureEnabled(Feature.clauseInterleaving) then
3882-
// If you are making interleaving stable manually, please refer to the PR introducing it instead, section "How to make non-experimental"
3878+
if Feature.clauseInterleavingEnabled(using in.languageImportContext) then
38833879
typeOrTermParamClauses(ParamOwner.Def, numLeadParams)
38843880
else
38853881
val tparams = typeParamClauseOpt(ParamOwner.Def)
38863882
val vparamss = termParamClauses(ParamOwner.Def, numLeadParams)
3887-
38883883
joinParams(tparams, vparamss)
38893884

38903885
var tpt = fromWithinReturnType { typedOpt() }

docs/_docs/reference/experimental/generalized-method-syntax.md renamed to docs/_docs/reference/other-new-features/generalized-method-syntax.md

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,9 @@
11
---
22
layout: doc-page
33
title: "Generalized Method Syntax"
4-
nightlyOf: https://docs.scala-lang.org/scala3/reference/experimental/generalized-method-syntax.html
4+
nightlyOf: https://docs.scala-lang.org/scala3/reference/other-new-features/generalized-method-syntax.html
55
---
66

7-
This feature is not yet part of the Scala 3 language definition. It can be made available by a language import:
8-
9-
```scala
10-
import scala.language.experimental.clauseInterleaving
11-
```
12-
137
The inclusion of using clauses is not the only way in which methods have been updated, type parameter clauses are now allowed in any number and at any position.
148

159
## Syntax Changes
@@ -51,7 +45,7 @@ trait DB {
5145
}
5246
```
5347

54-
Note that simply replacing `V` by `k.Value` would not be equivalent. For example, if `k.Value` is `Some[Int]`, only the above allows:
48+
Note that simply replacing `V` by `k.Value` would not be equivalent. For example, if `k.Value` is `Some[Int]`, only the above allows:
5549
`getOrElse(k)[Option[Int]](None)`, which returns a `Number`.
5650

5751
## Details

library/src/scala/runtime/stdLibPatches/language.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ object language:
6767
* @see [[https://github.com/scala/improvement-proposals/blob/main/content/clause-interleaving.md]]
6868
*/
6969
@compileTimeOnly("`clauseInterleaving` can only be used at compile time in import statements")
70+
@deprecated("`clauseInterleaving` is now standard, no language import is needed", since = "3.6")
7071
object clauseInterleaving
7172

7273
/** Experimental support for pure function type syntax

presentation-compiler/test/dotty/tools/pc/tests/signaturehelp/SignatureHelpInterleavingSuite.scala

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@ import java.nio.file.Path
88

99
class SignatureHelpInterleavingSuite extends BaseSignatureHelpSuite:
1010

11-
override protected def scalacOptions(classpath: Seq[Path]): Seq[String] =
12-
List("-language:experimental.clauseInterleaving")
13-
1411
@Test def `proper-position-1` =
1512
check(
1613
"""

scaladoc-testcases/src/tests/extensionParams.scala

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,6 @@ extension (using Unit)(a: Int)
6161
def f14(): Any
6262
= ???
6363

64-
import scala.language.experimental.clauseInterleaving
65-
6664
extension (using String)(using Int)(a: Animal)(using Unit)(using Number)
6765
def f16(b: Any)[T](c: T): T
6866
= ???

scaladoc-testcases/src/tests/methodsAndConstructors.scala

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
package tests.methodsAndConstructors
22

3-
import scala.language.experimental.clauseInterleaving
4-
53
class A
64
class B extends A
75
class C

tests/neg/interleaving-ab.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
1-
import scala.language.experimental.clauseInterleaving
21

32
object Ab:
43
given String = ""
54
given Double = 0
65

76
def illegal[A][B](x: A)(using B): B = summon[B] // error: Type parameter lists must be separated by a term or using parameter list
8-
7+
98
def ab[A](x: A)[B](using B): B = summon[B]
109
def test =
1110
ab[Int](0: Int) // error

tests/neg/interleaving-params.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import scala.language.experimental.clauseInterleaving
21

32
class Params{
43
def bar[T](x: T)[T]: String = ??? // error

tests/neg/interleaving-signatureCollision.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import scala.language.experimental.clauseInterleaving
21

32
object signatureCollision:
43
def f[T](x: T)[U](y: U) = (x,y)

0 commit comments

Comments
 (0)