@@ -907,16 +907,6 @@ 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-
920910 /** Invalidate `denot` by overwriting its info with `NoType` if
921911 * `denot` is a compiler generated case class method that clashes
922912 * with a user-defined method in the same scope with a matching type.
@@ -999,7 +989,6 @@ class Namer { typer: Typer =>
999989 addInlineInfo(sym)
1000990 denot.info = typeSig(sym)
1001991 invalidateIfClashingSynthetic(denot)
1002- setAbstractTrackedInfo(sym)
1003992 Checking .checkWellFormed(sym)
1004993 denot.info = avoidPrivateLeaks(sym)
1005994 }
@@ -2062,12 +2051,17 @@ class Namer { typer: Typer =>
20622051 if paramss.isEmpty then info.widenExpr
20632052 else NoType
20642053
2065- val iRawInfo =
2066- cls.info.nonPrivateDecl(sym.name).matchingDenotation(site, schema, sym.targetName).info
2054+ val iDenot = cls.info.nonPrivateDecl(sym.name).matchingDenotation(site, schema, sym.targetName)
2055+ val iSym = iDenot.symbol
2056+ val iRawInfo = iDenot.info
20672057 val iResType = instantiatedResType(iRawInfo, paramss).asSeenFrom(site, cls)
2068- if (iResType.exists)
2069- typr.println(i " using inherited type for ${mdef.name}; raw: $iRawInfo, inherited: $iResType" )
2070- tp & iResType
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
20712065 }
20722066 end inherited
20732067
0 commit comments