@@ -2016,6 +2016,11 @@ class Namer { typer: Typer =>
20162016 paramFn : Type => Type ,
20172017 fallbackProto : Type
20182018 )(using Context ): Type =
2019+ /** Is this member tracked? This is true if it is marked as `tracked` or if
2020+ * it overrides a `tracked` member. To account for the later, `isTracked`
2021+ * is overriden to `true` as a side-effect of computing `inherited`.
2022+ */
2023+ var isTracked : Boolean = sym.is(Tracked )
20192024
20202025 /** A type for this definition that might be inherited from elsewhere:
20212026 * If this is a setter parameter, the corresponding getter type.
@@ -2051,8 +2056,10 @@ class Namer { typer: Typer =>
20512056 if paramss.isEmpty then info.widenExpr
20522057 else NoType
20532058
2054- val iRawInfo =
2055- cls.info.nonPrivateDecl(sym.name).matchingDenotation(site, schema, sym.targetName).info
2059+ val iDenot = cls.info.nonPrivateDecl(sym.name).matchingDenotation(site, schema, sym.targetName)
2060+ val iSym = iDenot.symbol
2061+ if iSym.is(Tracked ) then isTracked = true
2062+ val iRawInfo = iDenot.info
20562063 val iResType = instantiatedResType(iRawInfo, paramss).asSeenFrom(site, cls)
20572064 if (iResType.exists)
20582065 typr.println(i " using inherited type for ${mdef.name}; raw: $iRawInfo, inherited: $iResType" )
@@ -2141,6 +2148,7 @@ class Namer { typer: Typer =>
21412148 if defaultTp.exists then TypeOps .SimplifyKeepUnchecked () else null )
21422149 match
21432150 case ctp : ConstantType if sym.isInlineVal => ctp
2151+ case tp if isTracked => tp
21442152 case tp => TypeComparer .widenInferred(tp, pt, Widen .Unions )
21452153
21462154 // Replace aliases to Unit by Unit itself. If we leave the alias in
@@ -2151,7 +2159,7 @@ class Namer { typer: Typer =>
21512159 def lhsType = fullyDefinedType(cookedRhsType, " right-hand side" , mdef.srcPos)
21522160 // if (sym.name.toString == "y") println(i"rhs = $rhsType, cooked = $cookedRhsType")
21532161 if (inherited.exists)
2154- if sym.isInlineVal then lhsType else inherited
2162+ if sym.isInlineVal || isTracked then lhsType else inherited
21552163 else {
21562164 if (sym.is(Implicit ))
21572165 mdef match {
0 commit comments