diff --git a/compiler/src/dotty/tools/dotc/config/Feature.scala b/compiler/src/dotty/tools/dotc/config/Feature.scala index 1ff040fda865..ab2597f290da 100644 --- a/compiler/src/dotty/tools/dotc/config/Feature.scala +++ b/compiler/src/dotty/tools/dotc/config/Feature.scala @@ -113,7 +113,7 @@ object Feature: * feature is defined. */ def enabled(feature: TermName)(using Context): Boolean = - enabledBySetting(feature) || enabledByImport(feature) || feature == tracked + enabledBySetting(feature) || enabledByImport(feature) /** Is auto-tupling enabled? */ def autoTuplingEnabled(using Context): Boolean = !enabled(nme.noAutoTupling) diff --git a/compiler/src/dotty/tools/dotc/typer/Namer.scala b/compiler/src/dotty/tools/dotc/typer/Namer.scala index bc34d8175905..ab4d1d2d3847 100644 --- a/compiler/src/dotty/tools/dotc/typer/Namer.scala +++ b/compiler/src/dotty/tools/dotc/typer/Namer.scala @@ -1931,14 +1931,14 @@ class Namer { typer: Typer => def wrapRefinedMethType(restpe: Type): Type = wrapMethType(addParamRefinements(restpe, paramSymss)) - def addTrackedIfNeeded(ddef: DefDef, owningSym: Symbol): Boolean = - var wasSet = false + def addTrackedIfNeeded(ddef: DefDef, owningSym: Symbol): Unit = for params <- ddef.termParamss; param <- params do val psym = symbolOfTree(param) if needsTracked(psym, param, owningSym) then psym.setFlag(Tracked) - wasSet = true - wasSet + for acc <- sym.maybeOwner.infoOrCompleter.decls.lookupAll(psym.name) if acc.is(ParamAccessor) do + acc.resetFlag(PrivateLocal) + acc.setFlag(Tracked) if Feature.trackedEnabled then addTrackedIfNeeded(ddef, sym.maybeOwner) diff --git a/tests/pos/infer-tracked-parsercombinators-givens.scala b/tests/pos/infer-tracked-parsercombinators-givens.scala index 3a66ea717892..f8ed1a768912 100644 --- a/tests/pos/infer-tracked-parsercombinators-givens.scala +++ b/tests/pos/infer-tracked-parsercombinators-givens.scala @@ -26,7 +26,6 @@ given apply: [C, E] => Combinator[Apply[C, E]] { } } -// TODO(kπ) infer tracked correctly here given combine[A, B](using tracked val f: Combinator[A], tracked val s: Combinator[B] { type Context = f.Context } diff --git a/tests/pos/infer-tracked-vector.scala b/tests/pos/infer-tracked-vector.scala deleted file mode 100644 index c952c37bf1e0..000000000000 --- a/tests/pos/infer-tracked-vector.scala +++ /dev/null @@ -1,82 +0,0 @@ -import scala.language.experimental.tracked -import scala.language.future - -object typeparams: - sealed trait Nat - object Z extends Nat - final case class S[N <: Nat]() extends Nat - - type Zero = Z.type - type Succ[N <: Nat] = S[N] - - sealed trait Fin[N <: Nat] - case class FZero[N <: Nat]() extends Fin[Succ[N]] - case class FSucc[N <: Nat](pred: Fin[N]) extends Fin[Succ[N]] - - object Fin: - def zero[N <: Nat]: Fin[Succ[N]] = FZero() - def succ[N <: Nat](i: Fin[N]): Fin[Succ[N]] = FSucc(i) - - sealed trait Vec[A, N <: Nat] - case class VNil[A]() extends Vec[A, Zero] - case class VCons[A, N <: Nat](head: A, tail: Vec[A, N]) extends Vec[A, Succ[N]] - - object Vec: - def empty[A]: Vec[A, Zero] = VNil() - def cons[A, N <: Nat](head: A, tail: Vec[A, N]): Vec[A, Succ[N]] = VCons(head, tail) - - def get[A, N <: Nat](v: Vec[A, N], index: Fin[N]): A = (v, index) match - case (VCons(h, _), FZero()) => h - case (VCons(_, t), FSucc(pred)) => get(t, pred) - - def runVec(): Unit = - val v: Vec[Int, Succ[Succ[Succ[Zero]]]] = Vec.cons(1, Vec.cons(2, Vec.cons(3, Vec.empty))) - - println(s"Element at index 0: ${Vec.get(v, Fin.zero)}") - println(s"Element at index 1: ${Vec.get(v, Fin.succ(Fin.zero))}") - println(s"Element at index 2: ${Vec.get(v, Fin.succ(Fin.succ(Fin.zero)))}") - // println(s"Element at index 2: ${Vec.get(v, Fin.succ(Fin.succ(Fin.succ(Fin.zero))))}") // error - -// TODO(kπ) check if I can get it to work -// object typemembers: -// sealed trait Nat -// object Z extends Nat -// case class S() extends Nat: -// type N <: Nat - -// type Zero = Z.type -// type Succ[N1 <: Nat] = S { type N = N1 } - -// sealed trait Fin: -// type N <: Nat -// case class FZero[N1 <: Nat]() extends Fin: -// type N = Succ[N1] -// case class FSucc(tracked val pred: Fin) extends Fin: -// type N = Succ[pred.N] - -// object Fin: -// def zero[N1 <: Nat]: Fin { type N = Succ[N1] } = FZero[N1]() -// def succ[N1 <: Nat](i: Fin { type N = N1 }): Fin { type N = Succ[N1] } = FSucc(i) - -// sealed trait Vec[A]: -// type N <: Nat -// case class VNil[A]() extends Vec[A]: -// type N = Zero -// case class VCons[A](head: A, tracked val tail: Vec[A]) extends Vec[A]: -// type N = Succ[tail.N] - -// object Vec: -// def empty[A]: Vec[A] = VNil() -// def cons[A](head: A, tail: Vec[A]): Vec[A] = VCons(head, tail) - -// def get[A](v: Vec[A], index: Fin { type N = v.N }): A = (v, index) match -// case (VCons(h, _), FZero()) => h -// case (VCons(_, t), FSucc(pred)) => get(t, pred) - -// // def runVec(): Unit = -// val v: Vec[Int] = Vec.cons(1, Vec.cons(2, Vec.cons(3, Vec.empty))) - -// println(s"Element at index 0: ${Vec.get(v, Fin.zero)}") -// println(s"Element at index 1: ${Vec.get(v, Fin.succ(Fin.zero))}") -// println(s"Element at index 2: ${Vec.get(v, Fin.succ(Fin.succ(Fin.zero)))}") -// // println(s"Element at index 2: ${Vec.get(v, Fin.succ(Fin.succ(Fin.succ(Fin.zero))))}")