From a03a2fc5bd894795dcf8c1050f5ded0f59e96cde Mon Sep 17 00:00:00 2001 From: odersky Date: Tue, 18 Feb 2025 16:42:07 +0100 Subject: [PATCH] Address review comments --- compiler/src/dotty/tools/dotc/config/Feature.scala | 1 - .../dotty/tools/dotc/config/SourceVersion.scala | 2 +- .../src/dotty/tools/dotc/parsing/Parsers.scala | 14 +++++++------- tests/pos/interleavingExperimental.scala | 3 --- 4 files changed, 8 insertions(+), 12 deletions(-) delete mode 100644 tests/pos/interleavingExperimental.scala diff --git a/compiler/src/dotty/tools/dotc/config/Feature.scala b/compiler/src/dotty/tools/dotc/config/Feature.scala index 444771366726..5ceca43a212b 100644 --- a/compiler/src/dotty/tools/dotc/config/Feature.scala +++ b/compiler/src/dotty/tools/dotc/config/Feature.scala @@ -29,7 +29,6 @@ object Feature: val erasedDefinitions = experimental("erasedDefinitions") val symbolLiterals = deprecated("symbolLiterals") val saferExceptions = experimental("saferExceptions") - val clauseInterleaving = experimental("clauseInterleaving") val pureFunctions = experimental("pureFunctions") val captureChecking = experimental("captureChecking") val into = experimental("into") diff --git a/compiler/src/dotty/tools/dotc/config/SourceVersion.scala b/compiler/src/dotty/tools/dotc/config/SourceVersion.scala index 84fdeb6bc9f7..199350949233 100644 --- a/compiler/src/dotty/tools/dotc/config/SourceVersion.scala +++ b/compiler/src/dotty/tools/dotc/config/SourceVersion.scala @@ -34,7 +34,7 @@ enum SourceVersion: def enablesFewerBraces = isAtLeast(`3.3`) def enablesClauseInterleaving = isAtLeast(`3.6`) def enablesNewGivens = isAtLeast(`3.6`) - def enablesNamedTuples = isAtLeast(`3.6`) + def enablesNamedTuples = isAtLeast(`3.7`) object SourceVersion extends Property.Key[SourceVersion]: def defaultSourceVersion = `3.7` diff --git a/compiler/src/dotty/tools/dotc/parsing/Parsers.scala b/compiler/src/dotty/tools/dotc/parsing/Parsers.scala index 47bc954db5de..05d290edf02d 100644 --- a/compiler/src/dotty/tools/dotc/parsing/Parsers.scala +++ b/compiler/src/dotty/tools/dotc/parsing/Parsers.scala @@ -1011,7 +1011,7 @@ object Parsers { skipParams() lookahead.isColon && { - !sourceVersion.isAtLeast(`3.6`) + !sourceVersion.enablesNewGivens || { // in the new given syntax, a `:` at EOL after an identifier represents a single identifier given // Example: // given C: @@ -1870,7 +1870,7 @@ object Parsers { infixOps(t, canStartInfixTypeTokens, operand, Location.ElseWhere, ParseKind.Type, isOperator = !followingIsVararg() && !isPureArrow - && !(isIdent(nme.as) && sourceVersion.isAtLeast(`3.6`) && inContextBound) + && !(isIdent(nme.as) && sourceVersion.enablesNewGivens && inContextBound) && nextCanFollowOperator(canStartInfixTypeTokens)) /** RefinedType ::= WithType {[nl] Refinement} [`^` CaptureSet] @@ -2263,7 +2263,7 @@ object Parsers { def contextBound(pname: TypeName): Tree = val t = toplevelTyp(inContextBound = true) val ownName = - if isIdent(nme.as) && sourceVersion.isAtLeast(`3.6`) then + if isIdent(nme.as) && sourceVersion.enablesNewGivens then in.nextToken() ident() else EmptyTermName @@ -2276,7 +2276,7 @@ object Parsers { def contextBounds(pname: TypeName): List[Tree] = if in.isColon then in.nextToken() - if in.token == LBRACE && sourceVersion.isAtLeast(`3.6`) + if in.token == LBRACE && sourceVersion.enablesNewGivens then inBraces(commaSeparated(() => contextBound(pname))) else val bound = contextBound(pname) @@ -3500,7 +3500,7 @@ object Parsers { val hkparams = typeParamClauseOpt(ParamOwner.Hk) val bounds = if paramOwner.acceptsCtxBounds then typeAndCtxBounds(name) - else if sourceVersion.isAtLeast(`3.6`) && paramOwner == ParamOwner.Type then typeAndCtxBounds(name) + else if sourceVersion.enablesNewGivens && paramOwner == ParamOwner.Type then typeAndCtxBounds(name) else typeBounds() TypeDef(name, lambdaAbstract(hkparams, bounds)).withMods(mods) } @@ -4069,7 +4069,7 @@ object Parsers { case SEMI | NEWLINE | NEWLINES | COMMA | RBRACE | OUTDENT | EOF => makeTypeDef(typeAndCtxBounds(tname)) case _ if (staged & StageKind.QuotedPattern) != 0 - || sourceVersion.isAtLeast(`3.6`) && in.isColon => + || sourceVersion.enablesNewGivens && in.isColon => makeTypeDef(typeAndCtxBounds(tname)) case _ => syntaxErrorOrIncomplete(ExpectedTypeBoundOrEquals(in.token)) @@ -4244,7 +4244,7 @@ object Parsers { def givenDef(start: Offset, mods: Modifiers, givenMod: Mod) = atSpan(start, nameStart) { var mods1 = addMod(mods, givenMod) val nameStart = in.offset - var newSyntaxAllowed = sourceVersion.isAtLeast(`3.6`) + var newSyntaxAllowed = sourceVersion.enablesNewGivens val hasEmbeddedColon = !in.isColon && followingIsGivenDefWithColon() val name = if isIdent && hasEmbeddedColon then ident() else EmptyTermName diff --git a/tests/pos/interleavingExperimental.scala b/tests/pos/interleavingExperimental.scala deleted file mode 100644 index a6b60a237dc3..000000000000 --- a/tests/pos/interleavingExperimental.scala +++ /dev/null @@ -1,3 +0,0 @@ -//> using options --source 3.6 - -def ba[A](x: A)[B](using B): B = summon[B] \ No newline at end of file