@@ -2016,6 +2016,11 @@ class Namer { typer: Typer =>
2016
2016
paramFn : Type => Type ,
2017
2017
fallbackProto : Type
2018
2018
)(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 )
2019
2024
2020
2025
/** A type for this definition that might be inherited from elsewhere:
2021
2026
* If this is a setter parameter, the corresponding getter type.
@@ -2053,15 +2058,12 @@ class Namer { typer: Typer =>
2053
2058
2054
2059
val iDenot = cls.info.nonPrivateDecl(sym.name).matchingDenotation(site, schema, sym.targetName)
2055
2060
val iSym = iDenot.symbol
2061
+ if iSym.is(Tracked ) then isTracked = true
2056
2062
val iRawInfo = iDenot.info
2057
2063
val iResType = instantiatedResType(iRawInfo, paramss).asSeenFrom(site, cls)
2058
- if iSym.is(Tracked ) && ! mdef.rhs.isEmpty then
2059
- // When inherting a tracked member, we infer a precise type from the rhs
2060
- tp & typedAheadExpr(mdef.rhs, iResType).tpe
2061
- else
2062
- if (iResType.exists)
2063
- typr.println(i " using inherited type for ${mdef.name}; raw: $iRawInfo, inherited: $iResType" )
2064
- tp & iResType
2064
+ if (iResType.exists)
2065
+ typr.println(i " using inherited type for ${mdef.name}; raw: $iRawInfo, inherited: $iResType" )
2066
+ tp & iResType
2065
2067
}
2066
2068
end inherited
2067
2069
@@ -2146,6 +2148,7 @@ class Namer { typer: Typer =>
2146
2148
if defaultTp.exists then TypeOps .SimplifyKeepUnchecked () else null )
2147
2149
match
2148
2150
case ctp : ConstantType if sym.isInlineVal => ctp
2151
+ case tp if isTracked => tp
2149
2152
case tp => TypeComparer .widenInferred(tp, pt, Widen .Unions )
2150
2153
2151
2154
// Replace aliases to Unit by Unit itself. If we leave the alias in
@@ -2156,7 +2159,7 @@ class Namer { typer: Typer =>
2156
2159
def lhsType = fullyDefinedType(cookedRhsType, " right-hand side" , mdef.srcPos)
2157
2160
// if (sym.name.toString == "y") println(i"rhs = $rhsType, cooked = $cookedRhsType")
2158
2161
if (inherited.exists)
2159
- if sym.isInlineVal then lhsType else inherited
2162
+ if sym.isInlineVal || isTracked then lhsType else inherited
2160
2163
else {
2161
2164
if (sym.is(Implicit ))
2162
2165
mdef match {
0 commit comments