diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 94f89ecdad6c..ffa7e515b926 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -1125,7 +1125,7 @@ jobs: needs: [build-msi-package] with: # Ensure that version starts with prefix 3. - # In the future it can be adapted to compare with with git tag or version set in the build.s + # In the future it can be adapted to compare with with git tag or version set in the build.s version: "3." java-version: 8 diff --git a/compiler/src/dotty/tools/dotc/config/Feature.scala b/compiler/src/dotty/tools/dotc/config/Feature.scala index ab2597f290da..c70d4f9e9da6 100644 --- a/compiler/src/dotty/tools/dotc/config/Feature.scala +++ b/compiler/src/dotty/tools/dotc/config/Feature.scala @@ -35,7 +35,6 @@ object Feature: val captureChecking = experimental("captureChecking") val into = experimental("into") val modularity = experimental("modularity") - val tracked = experimental("tracked") val betterMatchTypeExtractors = experimental("betterMatchTypeExtractors") val quotedPatternsWithPolymorphicFunctions = experimental("quotedPatternsWithPolymorphicFunctions") val betterFors = experimental("betterFors") @@ -67,7 +66,6 @@ object Feature: (captureChecking, "Enable experimental capture checking"), (into, "Allow into modifier on parameter types"), (modularity, "Enable experimental modularity features"), - (tracked, "Enable tracked modifier"), (betterMatchTypeExtractors, "Enable better match type extractors"), (betterFors, "Enable improvements in `for` comprehensions") ) @@ -113,7 +111,7 @@ object Feature: * feature is defined. */ def enabled(feature: TermName)(using Context): Boolean = - enabledBySetting(feature) || enabledByImport(feature) + enabledBySetting(feature) || enabledByImport(feature) || feature == modularity /** Is auto-tupling enabled? */ def autoTuplingEnabled(using Context): Boolean = !enabled(nme.noAutoTupling) @@ -129,8 +127,6 @@ object Feature: def betterForsEnabled(using Context) = enabled(betterFors) - def trackedEnabled(using Context) = enabled(tracked) || enabled(modularity) - def genericNumberLiteralsEnabled(using Context) = enabled(genericNumberLiterals) def scala2ExperimentalMacroEnabled(using Context) = enabled(scala2macros) diff --git a/compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala b/compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala index 635919b4e117..e62db9af520a 100644 --- a/compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala +++ b/compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala @@ -924,7 +924,7 @@ class TreeUnpickler(reader: TastyReader, val resType = if name == nme.CONSTRUCTOR then effectiveResultType(sym, paramss) - else if sym.isAllOf(Given | Method) && Feature.trackedEnabled then + else if sym.isAllOf(Given | Method) && Feature.enabled(Feature.modularity) then addParamRefinements(tpt.tpe, paramss) else tpt.tpe diff --git a/compiler/src/dotty/tools/dotc/parsing/Parsers.scala b/compiler/src/dotty/tools/dotc/parsing/Parsers.scala index 466aaa260155..47391a4114cf 100644 --- a/compiler/src/dotty/tools/dotc/parsing/Parsers.scala +++ b/compiler/src/dotty/tools/dotc/parsing/Parsers.scala @@ -3525,7 +3525,7 @@ object Parsers { if isErasedKw then mods = addModifier(mods) if paramOwner.isClass then - if isIdent(nme.tracked) && (in.featureEnabled(Feature.tracked) || in.featureEnabled(Feature.modularity)) && !in.lookahead.isColon then + if isIdent(nme.tracked) && in.featureEnabled(Feature.modularity) && !in.lookahead.isColon then mods = addModifier(mods) mods = addFlag(modifiers(start = mods), ParamAccessor) mods = @@ -3601,7 +3601,7 @@ object Parsers { || isIdent && (in.name == nme.inline // inline starts a name binding || in.name == nme.tracked // tracked starts a name binding under x.modularity - && (in.featureEnabled(Feature.tracked) || in.featureEnabled(Feature.modularity)) + && in.featureEnabled(Feature.modularity) || in.lookahead.isColon) // a following `:` starts a name binding (mods, paramsAreNamed) val params = diff --git a/compiler/src/dotty/tools/dotc/transform/PostTyper.scala b/compiler/src/dotty/tools/dotc/transform/PostTyper.scala index e62ecfadaaaa..0feee53ca50f 100644 --- a/compiler/src/dotty/tools/dotc/transform/PostTyper.scala +++ b/compiler/src/dotty/tools/dotc/transform/PostTyper.scala @@ -378,7 +378,7 @@ class PostTyper extends MacroTransform with InfoTransformer { thisPhase => def checkClassType(tpe: Type, stablePrefixReq: Boolean) = ctx.typer.checkClassType(tpe, tree.srcPos, traitReq = false, stablePrefixReq = stablePrefixReq, - refinementOK = Feature.trackedEnabled) + refinementOK = Feature.enabled(Feature.modularity)) checkClassType(tree.tpe, true) if !nu.tpe.isLambdaSub then // Check the constructor type as well; it could be an illegal singleton type diff --git a/compiler/src/dotty/tools/dotc/typer/Checking.scala b/compiler/src/dotty/tools/dotc/typer/Checking.scala index ae79d621d719..700bd483ff38 100644 --- a/compiler/src/dotty/tools/dotc/typer/Checking.scala +++ b/compiler/src/dotty/tools/dotc/typer/Checking.scala @@ -197,7 +197,7 @@ object Checking { * and that the instance conforms to the self type of the created class. */ def checkInstantiable(tp: Type, srcTp: Type, pos: SrcPos)(using Context): Unit = - tp.underlyingClassRef(refinementOK = Feature.trackedEnabled) match + tp.underlyingClassRef(refinementOK = Feature.enabled(modularity)) match case tref: TypeRef => val cls = tref.symbol if (cls.isOneOf(AbstractOrTrait)) { diff --git a/compiler/src/dotty/tools/dotc/typer/Namer.scala b/compiler/src/dotty/tools/dotc/typer/Namer.scala index ab4d1d2d3847..bb1998be8b59 100644 --- a/compiler/src/dotty/tools/dotc/typer/Namer.scala +++ b/compiler/src/dotty/tools/dotc/typer/Namer.scala @@ -294,7 +294,7 @@ class Namer { typer: Typer => val completer = tree match case tree: TypeDef => TypeDefCompleter(tree)(cctx) - case tree: ValOrDefDef if Feature.trackedEnabled && isNonInferingTree(tree) => + case tree: ValOrDefDef if Feature.enabled(Feature.modularity) && isNonInferingTree(tree) => NonInferingCompleter(tree)(cctx) case _ => Completer(tree)(cctx) val info = adjustIfModule(completer, tree) @@ -1614,7 +1614,7 @@ class Namer { typer: Typer => if (cls.isRefinementClass) ptype else { val pt = checkClassType( - if Feature.trackedEnabled + if Feature.enabled(modularity) then ptype.separateRefinements(cls, parentRefinements) else ptype, parent.srcPos, @@ -1790,7 +1790,8 @@ class Namer { typer: Typer => index(constr.leadingTypeParams) sym.owner.typeParams.foreach(_.ensureCompleted()) completeTrailingParamss(constr, sym, indexingCtor = true) - if Feature.trackedEnabled then + if Feature.enabled(modularity) then + // println(i"[indexConstructor] Checking if params of $constr need tracked") constr.termParamss.foreach(_.foreach(setTracked)) /** The signature of a module valdef. @@ -1940,7 +1941,7 @@ class Namer { typer: Typer => acc.resetFlag(PrivateLocal) acc.setFlag(Tracked) - if Feature.trackedEnabled then addTrackedIfNeeded(ddef, sym.maybeOwner) + if Feature.enabled(modularity) then addTrackedIfNeeded(ddef, sym.maybeOwner) if isConstructor then // set result type tree to unit, but take the current class as result type of the symbol @@ -1949,7 +1950,7 @@ class Namer { typer: Typer => if sym.isPrimaryConstructor then checkCaseClassParamDependencies(mt, sym.owner) mt else - val paramFn = if Feature.trackedEnabled && sym.isAllOf(Given | Method) then wrapRefinedMethType else wrapMethType + val paramFn = if Feature.enabled(Feature.modularity) && sym.isAllOf(Given | Method) then wrapRefinedMethType else wrapMethType valOrDefDefSig(ddef, sym, paramSymss, paramFn) end defDefSig diff --git a/compiler/src/dotty/tools/dotc/typer/Typer.scala b/compiler/src/dotty/tools/dotc/typer/Typer.scala index 3cecc5ff2142..817e7baf1c8c 100644 --- a/compiler/src/dotty/tools/dotc/typer/Typer.scala +++ b/compiler/src/dotty/tools/dotc/typer/Typer.scala @@ -1145,7 +1145,7 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer if templ1.parents.isEmpty && isFullyDefined(pt, ForceDegree.flipBottom) && isSkolemFree(pt) - && isEligible(pt.underlyingClassRef(refinementOK = Feature.trackedEnabled)) + && isEligible(pt.underlyingClassRef(refinementOK = Feature.enabled(modularity))) then templ1 = cpy.Template(templ)(parents = untpd.TypeTree(pt) :: Nil) for case parent: RefTree <- templ1.parents do @@ -4705,7 +4705,7 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer cpy.Ident(qual)(qual.symbol.name.sourceModuleName.toTypeName) case _ => errorTree(tree, em"cannot convert from $tree to an instance creation expression") - val tycon = ctorResultType.underlyingClassRef(refinementOK = Feature.trackedEnabled) + val tycon = ctorResultType.underlyingClassRef(refinementOK = Feature.enabled(modularity)) typed( untpd.Select( untpd.New(untpd.TypedSplice(tpt.withType(tycon))), diff --git a/library/src/scala/runtime/stdLibPatches/language.scala b/library/src/scala/runtime/stdLibPatches/language.scala index 8b696f96feb8..b8d990cf56f5 100644 --- a/library/src/scala/runtime/stdLibPatches/language.scala +++ b/library/src/scala/runtime/stdLibPatches/language.scala @@ -112,13 +112,6 @@ object language: @compileTimeOnly("`modularity` can only be used at compile time in import statements") object modularity - /** Experimental support for tracked modifier - * - * `tracked` is a subset of `modularity` - */ - @compileTimeOnly("`tracked` can only be used at compile time in import statements") - object tracked - /** Was needed to add support for relaxed imports of extension methods. * The language import is no longer needed as this is now a standard feature since SIP was accepted. * @see [[http://dotty.epfl.ch/docs/reference/contextual/extension-methods]] diff --git a/tests/pos/infer-tracked-1.scala b/tests/pos/infer-tracked-1.scala index e75fb88b7521..b4976a963074 100644 --- a/tests/pos/infer-tracked-1.scala +++ b/tests/pos/infer-tracked-1.scala @@ -1,4 +1,4 @@ -import scala.language.experimental.tracked +import scala.language.experimental.modularity import scala.language.future trait Ordering { diff --git a/tests/pos/infer-tracked-parent-refinements.scala b/tests/pos/infer-tracked-parent-refinements.scala index b50c6e88383d..0d71d7cc2897 100644 --- a/tests/pos/infer-tracked-parent-refinements.scala +++ b/tests/pos/infer-tracked-parent-refinements.scala @@ -1,4 +1,4 @@ -import scala.language.experimental.tracked +import scala.language.experimental.modularity import scala.language.future trait WithValue { type Value = Int } diff --git a/tests/pos/infer-tracked-parsercombinators-expanded.scala b/tests/pos/infer-tracked-parsercombinators-expanded.scala index 30828b1341bb..63c6aec9e84a 100644 --- a/tests/pos/infer-tracked-parsercombinators-expanded.scala +++ b/tests/pos/infer-tracked-parsercombinators-expanded.scala @@ -1,4 +1,4 @@ -import scala.language.experimental.tracked +import scala.language.experimental.modularity import scala.language.future import collection.mutable diff --git a/tests/pos/infer-tracked-parsercombinators-givens.scala b/tests/pos/infer-tracked-parsercombinators-givens.scala index f8ed1a768912..c183eb13a9ea 100644 --- a/tests/pos/infer-tracked-parsercombinators-givens.scala +++ b/tests/pos/infer-tracked-parsercombinators-givens.scala @@ -1,4 +1,4 @@ -import scala.language.experimental.tracked +import scala.language.experimental.modularity import scala.language.future import collection.mutable diff --git a/tests/pos/infer-tracked.scala b/tests/pos/infer-tracked.scala index 80626ab74267..496508ffdc6c 100644 --- a/tests/pos/infer-tracked.scala +++ b/tests/pos/infer-tracked.scala @@ -1,4 +1,4 @@ -import scala.language.experimental.tracked +import scala.language.experimental.modularity import scala.language.future abstract class C: