@@ -182,6 +182,18 @@ object Types {
182
182
loop(this )
183
183
}
184
184
185
+ /** True iff `symd` is a denotation of a class type parameter and the reference
186
+ * `<this> . <symd>` is an actual argument reference, i.e. `this` is different
187
+ * from the ThisType of `symd`'s owner.
188
+ */
189
+ def isArgPrefix (symd : SymDenotation )(implicit ctx : Context ) =
190
+ Config .newScheme && symd.is(ClassTypeParam ) && {
191
+ this match {
192
+ case tp : ThisType => tp.cls ne symd.owner
193
+ case _ => true
194
+ }
195
+ }
196
+
185
197
/** Returns true if the type is a phantom type
186
198
* - true if XYZ extends scala.Phantom and this type is upper bounded XYZ.Any
187
199
* - false otherwise
@@ -1653,6 +1665,8 @@ object Types {
1653
1665
val symd = sym.lastKnownDenotation
1654
1666
if (symd.validFor.runId != ctx.runId && ! ctx.stillValid(symd))
1655
1667
finish(memberDenot(symd.initial.name, allowPrivate = false ))
1668
+ else if (prefix.isArgPrefix(symd))
1669
+ finish(argDenot(sym.asType))
1656
1670
else if (infoDependsOnPrefix(symd, prefix))
1657
1671
finish(memberDenot(symd.initial.name, allowPrivate = symd.is(Private )))
1658
1672
else
@@ -1708,6 +1722,32 @@ object Types {
1708
1722
private def memberDenot (prefix : Type , name : Name , allowPrivate : Boolean )(implicit ctx : Context ): Denotation =
1709
1723
if (allowPrivate) prefix.member(name) else prefix.nonPrivateMember(name)
1710
1724
1725
+ private def argDenot (param : TypeSymbol )(implicit ctx : Context ): Denotation = {
1726
+ val cls = param.owner
1727
+ val args = prefix.baseType(cls).argInfos
1728
+ val typeParams = cls.typeParams
1729
+
1730
+ def concretize (arg : Type , tparam : TypeSymbol ) = arg match {
1731
+ case arg : TypeBounds => TypeRef (prefix, tparam)
1732
+ case arg => arg
1733
+ }
1734
+ val concretized = args.zipWithConserve(typeParams)(concretize)
1735
+
1736
+ def rebase (arg : Type ) = arg.subst(typeParams, concretized)
1737
+
1738
+ val idx = typeParams.indexOf(param)
1739
+ val argInfo = args(idx) match {
1740
+ case arg : TypeBounds =>
1741
+ val v = param.paramVariance
1742
+ val pbounds = param.paramInfo
1743
+ if (v > 0 && pbounds.loBound.dealias.isBottomType) TypeAlias (arg.hiBound & rebase(pbounds.hiBound))
1744
+ else if (v < 0 && pbounds.hiBound.dealias.isTopType) TypeAlias (arg.loBound | rebase(pbounds.loBound))
1745
+ else arg recoverable_& rebase(pbounds)
1746
+ case arg => TypeAlias (arg)
1747
+ }
1748
+ param.derivedSingleDenotation(param, argInfo)
1749
+ }
1750
+
1711
1751
/** Reload denotation by computing the member with the reference's name as seen
1712
1752
* from the reference's prefix.
1713
1753
*/
@@ -1831,7 +1871,9 @@ object Types {
1831
1871
while (tparams.nonEmpty && args.nonEmpty) {
1832
1872
if (tparams.head.eq(tparam))
1833
1873
return args.head match {
1834
- case _ : TypeBounds => TypeArgRef (pre, cls.typeRef, idx)
1874
+ case _ : TypeBounds =>
1875
+ if (Config .newScheme) TypeRef (pre, tparam)
1876
+ else TypeArgRef (pre, cls.typeRef, idx)
1835
1877
case arg => arg
1836
1878
}
1837
1879
tparams = tparams.tail
@@ -1930,7 +1972,7 @@ object Types {
1930
1972
else if (lastDenotation == null ) NamedType (prefix, designator)
1931
1973
else designator match {
1932
1974
case sym : Symbol =>
1933
- if (infoDependsOnPrefix(sym, prefix)) {
1975
+ if (infoDependsOnPrefix(sym, prefix) && ! prefix.isArgPrefix(sym) ) {
1934
1976
val candidate = reload()
1935
1977
val falseOverride = sym.isClass && candidate.symbol.exists && candidate.symbol != symbol
1936
1978
// A false override happens if we rebind an inner class to another type with the same name
@@ -4007,6 +4049,11 @@ object Types {
4007
4049
case TypeBounds (lo, hi) => range(atVariance(- variance)(reapply(lo)), reapply(hi))
4008
4050
case arg => reapply(arg)
4009
4051
}
4052
+ case arg @ TypeRef (pre, _) if pre.isArgPrefix(arg.symbol) =>
4053
+ arg.info match {
4054
+ case TypeBounds (lo, hi) => range(atVariance(- variance)(reapply(lo)), reapply(hi))
4055
+ case arg => reapply(arg)
4056
+ }
4010
4057
case arg => reapply(arg)
4011
4058
}
4012
4059
}
0 commit comments