Skip to content

Commit dd530d5

Browse files
committed
Revert "Separate features related to tracked into a separate sub-feature"
This reverts commit 1e2c226.
1 parent 2de8fbf commit dd530d5

14 files changed

+20
-30
lines changed

.github/workflows/ci.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -1125,7 +1125,7 @@ jobs:
11251125
needs: [build-msi-package]
11261126
with:
11271127
# Ensure that version starts with prefix 3.
1128-
# In the future it can be adapted to compare with with git tag or version set in the build.s
1128+
# In the future it can be adapted to compare with with git tag or version set in the build.s
11291129
version: "3."
11301130
java-version: 8
11311131

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

+1-5
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ object Feature:
3535
val captureChecking = experimental("captureChecking")
3636
val into = experimental("into")
3737
val modularity = experimental("modularity")
38-
val tracked = experimental("tracked")
3938
val betterMatchTypeExtractors = experimental("betterMatchTypeExtractors")
4039
val quotedPatternsWithPolymorphicFunctions = experimental("quotedPatternsWithPolymorphicFunctions")
4140
val betterFors = experimental("betterFors")
@@ -67,7 +66,6 @@ object Feature:
6766
(captureChecking, "Enable experimental capture checking"),
6867
(into, "Allow into modifier on parameter types"),
6968
(modularity, "Enable experimental modularity features"),
70-
(tracked, "Enable tracked modifier"),
7169
(betterMatchTypeExtractors, "Enable better match type extractors"),
7270
(betterFors, "Enable improvements in `for` comprehensions")
7371
)
@@ -113,7 +111,7 @@ object Feature:
113111
* feature is defined.
114112
*/
115113
def enabled(feature: TermName)(using Context): Boolean =
116-
enabledBySetting(feature) || enabledByImport(feature)
114+
enabledBySetting(feature) || enabledByImport(feature) || feature == modularity
117115

118116
/** Is auto-tupling enabled? */
119117
def autoTuplingEnabled(using Context): Boolean = !enabled(nme.noAutoTupling)
@@ -129,8 +127,6 @@ object Feature:
129127

130128
def betterForsEnabled(using Context) = enabled(betterFors)
131129

132-
def trackedEnabled(using Context) = enabled(tracked) || enabled(modularity)
133-
134130
def genericNumberLiteralsEnabled(using Context) = enabled(genericNumberLiterals)
135131

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

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

+1-1
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

+2-2
Original file line numberDiff line numberDiff line change
@@ -3525,7 +3525,7 @@ object Parsers {
35253525
if isErasedKw then
35263526
mods = addModifier(mods)
35273527
if paramOwner.isClass then
3528-
if isIdent(nme.tracked) && (in.featureEnabled(Feature.tracked) || in.featureEnabled(Feature.modularity)) && !in.lookahead.isColon then
3528+
if isIdent(nme.tracked) && in.featureEnabled(Feature.modularity) && !in.lookahead.isColon then
35293529
mods = addModifier(mods)
35303530
mods = addFlag(modifiers(start = mods), ParamAccessor)
35313531
mods =
@@ -3601,7 +3601,7 @@ object Parsers {
36013601
|| isIdent
36023602
&& (in.name == nme.inline // inline starts a name binding
36033603
|| in.name == nme.tracked // tracked starts a name binding under x.modularity
3604-
&& (in.featureEnabled(Feature.tracked) || in.featureEnabled(Feature.modularity))
3604+
&& in.featureEnabled(Feature.modularity)
36053605
|| in.lookahead.isColon) // a following `:` starts a name binding
36063606
(mods, paramsAreNamed)
36073607
val params =

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

+1-1
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

+1-1
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

+6-5
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

+2-2
Original file line numberDiff line numberDiff line change
@@ -1145,7 +1145,7 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
11451145
if templ1.parents.isEmpty
11461146
&& isFullyDefined(pt, ForceDegree.flipBottom)
11471147
&& isSkolemFree(pt)
1148-
&& isEligible(pt.underlyingClassRef(refinementOK = Feature.trackedEnabled))
1148+
&& isEligible(pt.underlyingClassRef(refinementOK = Feature.enabled(modularity)))
11491149
then
11501150
templ1 = cpy.Template(templ)(parents = untpd.TypeTree(pt) :: Nil)
11511151
for case parent: RefTree <- templ1.parents do
@@ -4705,7 +4705,7 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
47054705
cpy.Ident(qual)(qual.symbol.name.sourceModuleName.toTypeName)
47064706
case _ =>
47074707
errorTree(tree, em"cannot convert from $tree to an instance creation expression")
4708-
val tycon = ctorResultType.underlyingClassRef(refinementOK = Feature.trackedEnabled)
4708+
val tycon = ctorResultType.underlyingClassRef(refinementOK = Feature.enabled(modularity))
47094709
typed(
47104710
untpd.Select(
47114711
untpd.New(untpd.TypedSplice(tpt.withType(tycon))),

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

-7
Original file line numberDiff line numberDiff line change
@@ -112,13 +112,6 @@ object language:
112112
@compileTimeOnly("`modularity` can only be used at compile time in import statements")
113113
object modularity
114114

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

tests/pos/infer-tracked-1.scala

+1-1
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

+1-1
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

+1-1
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

+1-1
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

+1-1
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)