Skip to content

Commit

Permalink
Revert "Separate features related to tracked into a separate sub-feat…
Browse files Browse the repository at this point in the history
…ure"

This reverts commit 1e2c226.
  • Loading branch information
KacperFKorban committed Nov 1, 2024
1 parent 2de8fbf commit dd530d5
Show file tree
Hide file tree
Showing 14 changed files with 20 additions and 30 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
6 changes: 1 addition & 5 deletions compiler/src/dotty/tools/dotc/config/Feature.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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")
)
Expand Down Expand Up @@ -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)
Expand All @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions compiler/src/dotty/tools/dotc/parsing/Parsers.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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 =
Expand Down Expand Up @@ -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 =
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/transform/PostTyper.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/typer/Checking.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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)) {
Expand Down
11 changes: 6 additions & 5 deletions compiler/src/dotty/tools/dotc/typer/Namer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand All @@ -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

Expand Down
4 changes: 2 additions & 2 deletions compiler/src/dotty/tools/dotc/typer/Typer.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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))),
Expand Down
7 changes: 0 additions & 7 deletions library/src/scala/runtime/stdLibPatches/language.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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]]
Expand Down
2 changes: 1 addition & 1 deletion tests/pos/infer-tracked-1.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import scala.language.experimental.tracked
import scala.language.experimental.modularity
import scala.language.future

trait Ordering {
Expand Down
2 changes: 1 addition & 1 deletion tests/pos/infer-tracked-parent-refinements.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import scala.language.experimental.tracked
import scala.language.experimental.modularity
import scala.language.future

trait WithValue { type Value = Int }
Expand Down
2 changes: 1 addition & 1 deletion tests/pos/infer-tracked-parsercombinators-expanded.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import scala.language.experimental.tracked
import scala.language.experimental.modularity
import scala.language.future

import collection.mutable
Expand Down
2 changes: 1 addition & 1 deletion tests/pos/infer-tracked-parsercombinators-givens.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import scala.language.experimental.tracked
import scala.language.experimental.modularity
import scala.language.future
import collection.mutable

Expand Down
2 changes: 1 addition & 1 deletion tests/pos/infer-tracked.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import scala.language.experimental.tracked
import scala.language.experimental.modularity
import scala.language.future

abstract class C:
Expand Down

0 comments on commit dd530d5

Please sign in to comment.