diff --git a/community-build/community-projects/intent b/community-build/community-projects/intent index 466662fb36ed..c0c4a1939b04 160000 --- a/community-build/community-projects/intent +++ b/community-build/community-projects/intent @@ -1 +1 @@ -Subproject commit 466662fb36ed38d1f045449682bdc109496c6b2d +Subproject commit c0c4a1939b04a6ce4ae5de3aa8949f04674af1f7 diff --git a/compiler/src/dotty/tools/dotc/config/Feature.scala b/compiler/src/dotty/tools/dotc/config/Feature.scala index 8b9a64924ace..5ceca43a212b 100644 --- a/compiler/src/dotty/tools/dotc/config/Feature.scala +++ b/compiler/src/dotty/tools/dotc/config/Feature.scala @@ -28,9 +28,7 @@ object Feature: val dependent = experimental("dependent") val erasedDefinitions = experimental("erasedDefinitions") val symbolLiterals = deprecated("symbolLiterals") - val fewerBraces = experimental("fewerBraces") val saferExceptions = experimental("saferExceptions") - val clauseInterleaving = experimental("clauseInterleaving") val pureFunctions = experimental("pureFunctions") val captureChecking = experimental("captureChecking") val into = experimental("into") @@ -60,9 +58,7 @@ object Feature: (dependent, "Allow dependent method types"), (erasedDefinitions, "Allow erased definitions"), (symbolLiterals, "Allow symbol literals"), - (fewerBraces, "Enable support for using indentation for arguments"), (saferExceptions, "Enable safer exceptions"), - (clauseInterleaving, "Enable clause interleaving"), (pureFunctions, "Enable pure functions for capture checking"), (captureChecking, "Enable experimental capture checking"), (into, "Allow into modifier on parameter types"), @@ -124,9 +120,6 @@ object Feature: def namedTypeArgsEnabled(using Context) = enabled(namedTypeArguments) - def clauseInterleavingEnabled(using Context) = - sourceVersion.isAtLeast(`3.6`) || enabled(clauseInterleaving) - def betterForsEnabled(using Context) = enabled(betterFors) def genericNumberLiteralsEnabled(using Context) = enabled(genericNumberLiterals) @@ -169,9 +162,6 @@ object Feature: def migrateTo3(using Context): Boolean = sourceVersion == `3.0-migration` - def fewerBracesEnabled(using Context) = - sourceVersion.isAtLeast(`3.3`) || enabled(fewerBraces) - /** If current source migrates to `version`, issue given warning message * and return `true`, otherwise return `false`. */ diff --git a/compiler/src/dotty/tools/dotc/config/SourceVersion.scala b/compiler/src/dotty/tools/dotc/config/SourceVersion.scala index 3200f64fa6f9..199350949233 100644 --- a/compiler/src/dotty/tools/dotc/config/SourceVersion.scala +++ b/compiler/src/dotty/tools/dotc/config/SourceVersion.scala @@ -31,6 +31,11 @@ enum SourceVersion: def isAtMost(v: SourceVersion) = stable.ordinal <= v.ordinal + def enablesFewerBraces = isAtLeast(`3.3`) + def enablesClauseInterleaving = isAtLeast(`3.6`) + def enablesNewGivens = 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 ef07d477c303..05d290edf02d 100644 --- a/compiler/src/dotty/tools/dotc/parsing/Parsers.scala +++ b/compiler/src/dotty/tools/dotc/parsing/Parsers.scala @@ -885,7 +885,7 @@ object Parsers { } }) canRewrite &= (in.isAfterLineEnd || statCtdTokens.contains(in.token)) // test (5) - if canRewrite && (!underColonSyntax || Feature.fewerBracesEnabled) then + if canRewrite && (!underColonSyntax || sourceVersion.enablesFewerBraces) then val openingPatchStr = if !colonRequired then "" else if testChar(startOpening - 1, Chars.isOperatorPart(_)) then " :" @@ -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: @@ -1165,7 +1165,7 @@ object Parsers { * body */ def isColonLambda = - Feature.fewerBracesEnabled && in.token == COLONfollow && followingIsLambdaAfterColon() + sourceVersion.enablesFewerBraces && in.token == COLONfollow && followingIsLambdaAfterColon() /** operand { infixop operand | MatchClause } [postfixop], * @@ -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) } @@ -3969,7 +3969,7 @@ object Parsers { val ident = termIdent() var name = ident.name.asTermName val paramss = - if Feature.clauseInterleavingEnabled(using in.languageImportContext) then + if sourceVersion.enablesClauseInterleaving then typeOrTermParamClauses(ParamOwner.Def, numLeadParams) else val tparams = typeParamClauseOpt(ParamOwner.Def) @@ -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/compiler/src/dotty/tools/dotc/parsing/Scanners.scala b/compiler/src/dotty/tools/dotc/parsing/Scanners.scala index e5bba6c3b73b..ed20c189796b 100644 --- a/compiler/src/dotty/tools/dotc/parsing/Scanners.scala +++ b/compiler/src/dotty/tools/dotc/parsing/Scanners.scala @@ -17,7 +17,7 @@ import scala.collection.mutable import scala.collection.immutable.SortedMap import rewrites.Rewrites.patch import config.Feature -import config.Feature.{migrateTo3, fewerBracesEnabled} +import config.Feature.migrateTo3 import config.SourceVersion.{`3.0`, `3.0-migration`} import config.MigrationVersion import reporting.{NoProfile, Profile, Message} @@ -664,7 +664,7 @@ object Scanners { if token == COLONop && inTemplate then report.deprecationWarning(em"`:` after symbolic operator is deprecated; use backticks around operator instead", sourcePos(offset)) true - else token == COLONfollow && (inTemplate || fewerBracesEnabled) + else token == COLONfollow && (inTemplate || sourceVersion.enablesFewerBraces) if enabled then peekAhead() val atEOL = isAfterLineEnd || token == EOF diff --git a/tests/pos/interleavingExperimental.scala b/tests/pos/interleavingExperimental.scala deleted file mode 100644 index 63227ef1ebfe..000000000000 --- a/tests/pos/interleavingExperimental.scala +++ /dev/null @@ -1,5 +0,0 @@ -//> using options --source 3.5 - -import scala.language.experimental.clauseInterleaving - -def ba[A](x: A)[B](using B): B = summon[B] \ No newline at end of file