Skip to content

Commit 3dc60ee

Browse files
committed
Revert "Separate features related to tracked into a separate sub-feature"
This reverts commit 1e2c226.
1 parent ddfb4fd commit 3dc60ee

File tree

13 files changed

+19
-29
lines changed

13 files changed

+19
-29
lines changed

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

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ object Feature:
3636
val into = experimental("into")
3737
val namedTuples = experimental("namedTuples")
3838
val modularity = experimental("modularity")
39-
val tracked = experimental("tracked")
4039
val betterMatchTypeExtractors = experimental("betterMatchTypeExtractors")
4140
val quotedPatternsWithPolymorphicFunctions = experimental("quotedPatternsWithPolymorphicFunctions")
4241
val betterFors = experimental("betterFors")
@@ -69,7 +68,6 @@ object Feature:
6968
(into, "Allow into modifier on parameter types"),
7069
(namedTuples, "Allow named tuples"),
7170
(modularity, "Enable experimental modularity features"),
72-
(tracked, "Enable tracked modifier"),
7371
(betterMatchTypeExtractors, "Enable better match type extractors"),
7472
(betterFors, "Enable improvements in `for` comprehensions")
7573
)
@@ -115,7 +113,7 @@ object Feature:
115113
* feature is defined.
116114
*/
117115
def enabled(feature: TermName)(using Context): Boolean =
118-
enabledBySetting(feature) || enabledByImport(feature)
116+
enabledBySetting(feature) || enabledByImport(feature) || feature == modularity
119117

120118
/** Is auto-tupling enabled? */
121119
def autoTuplingEnabled(using Context): Boolean = !enabled(nme.noAutoTupling)
@@ -131,8 +129,6 @@ object Feature:
131129

132130
def betterForsEnabled(using Context) = enabled(betterFors)
133131

134-
def trackedEnabled(using Context) = enabled(tracked) || enabled(modularity)
135-
136132
def genericNumberLiteralsEnabled(using Context) = enabled(genericNumberLiterals)
137133

138134
def scala2ExperimentalMacroEnabled(using Context) = enabled(scala2macros)

compiler/src/dotty/tools/dotc/core/tasty/TreeUnpickler.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -924,7 +924,7 @@ class TreeUnpickler(reader: TastyReader,
924924
val resType =
925925
if name == nme.CONSTRUCTOR then
926926
effectiveResultType(sym, paramss)
927-
else if sym.isAllOf(Given | Method) && Feature.trackedEnabled then
927+
else if sym.isAllOf(Given | Method) && Feature.enabled(Feature.modularity) then
928928
addParamRefinements(tpt.tpe, paramss)
929929
else
930930
tpt.tpe

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3557,7 +3557,7 @@ object Parsers {
35573557
if isErasedKw then
35583558
mods = addModifier(mods)
35593559
if paramOwner.isClass then
3560-
if isIdent(nme.tracked) && (in.featureEnabled(Feature.tracked) || in.featureEnabled(Feature.modularity)) && !in.lookahead.isColon then
3560+
if isIdent(nme.tracked) && in.featureEnabled(Feature.modularity) && !in.lookahead.isColon then
35613561
mods = addModifier(mods)
35623562
mods = addFlag(modifiers(start = mods), ParamAccessor)
35633563
mods =
@@ -3633,7 +3633,7 @@ object Parsers {
36333633
|| isIdent
36343634
&& (in.name == nme.inline // inline starts a name binding
36353635
|| in.name == nme.tracked // tracked starts a name binding under x.modularity
3636-
&& (in.featureEnabled(Feature.tracked) || in.featureEnabled(Feature.modularity))
3636+
&& in.featureEnabled(Feature.modularity)
36373637
|| in.lookahead.isColon) // a following `:` starts a name binding
36383638
(mods, paramsAreNamed)
36393639
val params =

compiler/src/dotty/tools/dotc/transform/PostTyper.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -378,7 +378,7 @@ class PostTyper extends MacroTransform with InfoTransformer { thisPhase =>
378378
def checkClassType(tpe: Type, stablePrefixReq: Boolean) =
379379
ctx.typer.checkClassType(tpe, tree.srcPos,
380380
traitReq = false, stablePrefixReq = stablePrefixReq,
381-
refinementOK = Feature.trackedEnabled)
381+
refinementOK = Feature.enabled(Feature.modularity))
382382
checkClassType(tree.tpe, true)
383383
if !nu.tpe.isLambdaSub then
384384
// Check the constructor type as well; it could be an illegal singleton type

compiler/src/dotty/tools/dotc/typer/Checking.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ object Checking {
197197
* and that the instance conforms to the self type of the created class.
198198
*/
199199
def checkInstantiable(tp: Type, srcTp: Type, pos: SrcPos)(using Context): Unit =
200-
tp.underlyingClassRef(refinementOK = Feature.trackedEnabled) match
200+
tp.underlyingClassRef(refinementOK = Feature.enabled(modularity)) match
201201
case tref: TypeRef =>
202202
val cls = tref.symbol
203203
if (cls.isOneOf(AbstractOrTrait)) {

compiler/src/dotty/tools/dotc/typer/Namer.scala

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ class Namer { typer: Typer =>
294294

295295
val completer = tree match
296296
case tree: TypeDef => TypeDefCompleter(tree)(cctx)
297-
case tree: ValOrDefDef if Feature.trackedEnabled && isNonInferingTree(tree) =>
297+
case tree: ValOrDefDef if Feature.enabled(Feature.modularity) && isNonInferingTree(tree) =>
298298
NonInferingCompleter(tree)(cctx)
299299
case _ => Completer(tree)(cctx)
300300
val info = adjustIfModule(completer, tree)
@@ -1614,7 +1614,7 @@ class Namer { typer: Typer =>
16141614
if (cls.isRefinementClass) ptype
16151615
else {
16161616
val pt = checkClassType(
1617-
if Feature.trackedEnabled
1617+
if Feature.enabled(modularity)
16181618
then ptype.separateRefinements(cls, parentRefinements)
16191619
else ptype,
16201620
parent.srcPos,
@@ -1790,7 +1790,8 @@ class Namer { typer: Typer =>
17901790
index(constr.leadingTypeParams)
17911791
sym.owner.typeParams.foreach(_.ensureCompleted())
17921792
completeTrailingParamss(constr, sym, indexingCtor = true)
1793-
if Feature.trackedEnabled then
1793+
if Feature.enabled(modularity) then
1794+
// println(i"[indexConstructor] Checking if params of $constr need tracked")
17941795
constr.termParamss.foreach(_.foreach(setTracked))
17951796

17961797
/** The signature of a module valdef.
@@ -1940,7 +1941,7 @@ class Namer { typer: Typer =>
19401941
acc.resetFlag(PrivateLocal)
19411942
acc.setFlag(Tracked)
19421943

1943-
if Feature.trackedEnabled then addTrackedIfNeeded(ddef, sym.maybeOwner)
1944+
if Feature.enabled(modularity) then addTrackedIfNeeded(ddef, sym.maybeOwner)
19441945

19451946
if isConstructor then
19461947
// 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 =>
19491950
if sym.isPrimaryConstructor then checkCaseClassParamDependencies(mt, sym.owner)
19501951
mt
19511952
else
1952-
val paramFn = if Feature.trackedEnabled && sym.isAllOf(Given | Method) then wrapRefinedMethType else wrapMethType
1953+
val paramFn = if Feature.enabled(Feature.modularity) && sym.isAllOf(Given | Method) then wrapRefinedMethType else wrapMethType
19531954
valOrDefDefSig(ddef, sym, paramSymss, paramFn)
19541955
end defDefSig
19551956

compiler/src/dotty/tools/dotc/typer/Typer.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1148,7 +1148,7 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
11481148
if templ1.parents.isEmpty
11491149
&& isFullyDefined(pt, ForceDegree.flipBottom)
11501150
&& isSkolemFree(pt)
1151-
&& isEligible(pt.underlyingClassRef(refinementOK = Feature.trackedEnabled))
1151+
&& isEligible(pt.underlyingClassRef(refinementOK = Feature.enabled(modularity)))
11521152
then
11531153
templ1 = cpy.Template(templ)(parents = untpd.TypeTree(pt) :: Nil)
11541154
for case parent: RefTree <- templ1.parents do
@@ -4719,7 +4719,7 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
47194719
cpy.Ident(qual)(qual.symbol.name.sourceModuleName.toTypeName)
47204720
case _ =>
47214721
errorTree(tree, em"cannot convert from $tree to an instance creation expression")
4722-
val tycon = ctorResultType.underlyingClassRef(refinementOK = Feature.trackedEnabled)
4722+
val tycon = ctorResultType.underlyingClassRef(refinementOK = Feature.enabled(modularity))
47234723
typed(
47244724
untpd.Select(
47254725
untpd.New(untpd.TypedSplice(tpt.withType(tycon))),

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

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -111,13 +111,6 @@ object language:
111111
@compileTimeOnly("`modularity` can only be used at compile time in import statements")
112112
object modularity
113113

114-
/** Experimental support for tracked modifier
115-
*
116-
* `tracked` is a subset of `modularity`
117-
*/
118-
@compileTimeOnly("`tracked` can only be used at compile time in import statements")
119-
object tracked
120-
121114
/** Was needed to add support for relaxed imports of extension methods.
122115
* The language import is no longer needed as this is now a standard feature since SIP was accepted.
123116
* @see [[http://dotty.epfl.ch/docs/reference/contextual/extension-methods]]

tests/pos/infer-tracked-1.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import scala.language.experimental.tracked
1+
import scala.language.experimental.modularity
22
import scala.language.future
33

44
trait Ordering {

tests/pos/infer-tracked-parent-refinements.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import scala.language.experimental.tracked
1+
import scala.language.experimental.modularity
22
import scala.language.future
33

44
trait WithValue { type Value = Int }

tests/pos/infer-tracked-parsercombinators-expanded.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import scala.language.experimental.tracked
1+
import scala.language.experimental.modularity
22
import scala.language.future
33

44
import collection.mutable

tests/pos/infer-tracked-parsercombinators-givens.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import scala.language.experimental.tracked
1+
import scala.language.experimental.modularity
22
import scala.language.future
33
import collection.mutable
44

tests/pos/infer-tracked.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import scala.language.experimental.tracked
1+
import scala.language.experimental.modularity
22
import scala.language.future
33

44
abstract class C:

0 commit comments

Comments
 (0)