Skip to content

Commit

Permalink
Address review comments
Browse files Browse the repository at this point in the history
  • Loading branch information
odersky committed Feb 18, 2025
1 parent 8b00b61 commit a03a2fc
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 12 deletions.
1 change: 0 additions & 1 deletion compiler/src/dotty/tools/dotc/config/Feature.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/config/SourceVersion.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down
14 changes: 7 additions & 7 deletions compiler/src/dotty/tools/dotc/parsing/Parsers.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -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)
}
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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

Expand Down
3 changes: 0 additions & 3 deletions tests/pos/interleavingExperimental.scala

This file was deleted.

0 comments on commit a03a2fc

Please sign in to comment.