Skip to content

Commit 28b5725

Browse files
committed
Move setAbstractTrackedInfo to Namer.Completer
1 parent 567b2c1 commit 28b5725

File tree

3 files changed

+25
-13
lines changed

3 files changed

+25
-13
lines changed

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -907,6 +907,16 @@ class Namer { typer: Typer =>
907907
case _ =>
908908
}
909909

910+
private def setAbstractTrackedInfo(sym: Symbol)(using Context): Unit =
911+
if !sym.flags.is(ParamAccessor) && !sym.flags.is(Param) then
912+
if sym.allOverriddenSymbols.exists(_.flags.is(Tracked)) then
913+
sym.setFlag(Tracked)
914+
if sym.flags.is(Tracked) then
915+
original match
916+
case tree: untpd.ValDef if tree.tpt.isEmpty =>
917+
sym.info = typedAheadExpr(tree.rhs).tpe
918+
case _ => ()
919+
910920
/** Invalidate `denot` by overwriting its info with `NoType` if
911921
* `denot` is a compiler generated case class method that clashes
912922
* with a user-defined method in the same scope with a matching type.
@@ -989,6 +999,7 @@ class Namer { typer: Typer =>
989999
addInlineInfo(sym)
9901000
denot.info = typeSig(sym)
9911001
invalidateIfClashingSynthetic(denot)
1002+
setAbstractTrackedInfo(sym)
9921003
Checking.checkWellFormed(sym)
9931004
denot.info = avoidPrivateLeaks(sym)
9941005
}

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

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2834,20 +2834,10 @@ class Typer(@constructorOnly nestingLevel: Int = 0) extends Namer
28342834
case rhs =>
28352835
excludeDeferredGiven(rhs, sym):
28362836
typedExpr(_, tpt1.tpe.widenExpr)
2837-
setAbstractTrackedInfo(sym, rhs1, tpt)
2838-
val tpt2 = if sym.flags.is(Tracked) && tpt.isEmpty && !sym.flags.is(ParamAccessor) && !sym.flags.is(Param) then TypeTree(rhs1.tpe) else tpt1
2839-
val vdef2 = assignType(cpy.ValDef(vdef)(name, tpt2, rhs1), sym)
2840-
postProcessInfo(vdef2, sym)
2841-
vdef2.setDefTree
2837+
val vdef1 = assignType(cpy.ValDef(vdef)(name, tpt1, rhs1), sym)
2838+
postProcessInfo(vdef1, sym)
2839+
vdef1.setDefTree
28422840
}
2843-
2844-
private def setAbstractTrackedInfo(sym: Symbol, rhs: Tree, tpt: untpd.Tree)(using Context): Unit =
2845-
if !sym.flags.is(ParamAccessor) && !sym.flags.is(Param) then
2846-
if sym.allOverriddenSymbols.exists(_.flags.is(Tracked)) then
2847-
sym.setFlag(Tracked)
2848-
if sym.flags.is(Tracked) && tpt.isEmpty then
2849-
sym.info = rhs.tpe
2850-
28512841
private def retractDefDef(sym: Symbol)(using Context): Tree =
28522842
// it's a discarded method (synthetic case class method or synthetic java record constructor or overridden member), drop it
28532843
val canBeInvalidated: Boolean =

tests/pos/abstract-tracked-2.scala

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import scala.language.experimental.modularity
2+
import scala.language.future
3+
4+
abstract class Vec:
5+
tracked val size: Int
6+
7+
@main def main =
8+
val v = new Vec:
9+
val size0: size.type = 10
10+
val size = 10
11+
val size1: size.type = 10

0 commit comments

Comments
 (0)