@@ -477,7 +477,7 @@ object Denotations {
477
477
val jointInfo = infoMeet(info1, info2, safeIntersection)
478
478
if jointInfo.exists then
479
479
val sym = if symScore >= 0 then sym1 else sym2
480
- JointRefDenotation (sym, jointInfo, denot1.validFor & denot2.validFor, pre)
480
+ JointRefDenotation (sym, jointInfo, denot1.validFor & denot2.validFor, pre, denot1.isRefinedMethod || denot2.isRefinedMethod )
481
481
else if symScore == 2 then denot1
482
482
else if symScore == - 2 then denot2
483
483
else
@@ -569,7 +569,7 @@ object Denotations {
569
569
570
570
/** A non-overloaded denotation */
571
571
abstract class SingleDenotation (symbol : Symbol , initInfo : Type ) extends Denotation (symbol, initInfo) {
572
- protected def newLikeThis (symbol : Symbol , info : Type , pre : Type ): SingleDenotation
572
+ protected def newLikeThis (symbol : Symbol , info : Type , pre : Type , isRefinedMethod : Boolean ): SingleDenotation
573
573
574
574
final def name (using Context ): Name = symbol.name
575
575
@@ -582,6 +582,9 @@ object Denotations {
582
582
*/
583
583
def prefix : Type = NoPrefix
584
584
585
+ /** True if the info of this denotation comes from a refinement. */
586
+ def isRefinedMethod : Boolean = false
587
+
585
588
/** For SymDenotations, the language-specific signature of the info, depending on
586
589
* where the symbol is defined. For non-SymDenotations, the Scala 3
587
590
* signature.
@@ -615,9 +618,9 @@ object Denotations {
615
618
case _ => Signature .NotAMethod
616
619
}
617
620
618
- def derivedSingleDenotation (symbol : Symbol , info : Type , pre : Type = this .prefix)(using Context ): SingleDenotation =
619
- if ((symbol eq this .symbol) && (info eq this .info) && (pre eq this .prefix)) this
620
- else newLikeThis(symbol, info, pre)
621
+ def derivedSingleDenotation (symbol : Symbol , info : Type , pre : Type = this .prefix, isRefinedMethod : Boolean = this .isRefinedMethod )(using Context ): SingleDenotation =
622
+ if ((symbol eq this .symbol) && (info eq this .info) && (pre eq this .prefix) && (isRefinedMethod == this .isRefinedMethod) ) this
623
+ else newLikeThis(symbol, info, pre, isRefinedMethod )
621
624
622
625
def mapInfo (f : Type => Type )(using Context ): SingleDenotation =
623
626
derivedSingleDenotation(symbol, f(info))
@@ -1107,7 +1110,11 @@ object Denotations {
1107
1110
case sd : SymDenotation => true
1108
1111
case _ => info eq symbol.info
1109
1112
1110
- if ! owner.membersNeedAsSeenFrom(pre) && ((pre ne owner.thisType) || hasOriginalInfo)
1113
+ def ownerIsPrefix = pre match
1114
+ case pre : ThisType => pre.sameThis(owner.thisType)
1115
+ case _ => false
1116
+
1117
+ if ! owner.membersNeedAsSeenFrom(pre) && (! ownerIsPrefix || hasOriginalInfo)
1111
1118
|| symbol.is(NonMember )
1112
1119
then this
1113
1120
else derived(symbol.info)
@@ -1126,26 +1133,30 @@ object Denotations {
1126
1133
prefix : Type ) extends NonSymSingleDenotation (symbol, initInfo, prefix) {
1127
1134
validFor = initValidFor
1128
1135
override def hasUniqueSym : Boolean = true
1129
- protected def newLikeThis (s : Symbol , i : Type , pre : Type ): SingleDenotation =
1130
- new UniqueRefDenotation (s, i, validFor, pre)
1136
+ protected def newLikeThis (s : Symbol , i : Type , pre : Type , isRefinedMethod : Boolean ): SingleDenotation =
1137
+ if isRefinedMethod then
1138
+ new JointRefDenotation (s, i, validFor, pre, isRefinedMethod)
1139
+ else
1140
+ new UniqueRefDenotation (s, i, validFor, pre)
1131
1141
}
1132
1142
1133
1143
class JointRefDenotation (
1134
1144
symbol : Symbol ,
1135
1145
initInfo : Type ,
1136
1146
initValidFor : Period ,
1137
- prefix : Type ) extends NonSymSingleDenotation (symbol, initInfo, prefix) {
1147
+ prefix : Type ,
1148
+ override val isRefinedMethod : Boolean ) extends NonSymSingleDenotation (symbol, initInfo, prefix) {
1138
1149
validFor = initValidFor
1139
1150
override def hasUniqueSym : Boolean = false
1140
- protected def newLikeThis (s : Symbol , i : Type , pre : Type ): SingleDenotation =
1141
- new JointRefDenotation (s, i, validFor, pre)
1151
+ protected def newLikeThis (s : Symbol , i : Type , pre : Type , isRefinedMethod : Boolean ): SingleDenotation =
1152
+ new JointRefDenotation (s, i, validFor, pre, isRefinedMethod )
1142
1153
}
1143
1154
1144
1155
class ErrorDenotation (using Context ) extends NonSymSingleDenotation (NoSymbol , NoType , NoType ) {
1145
1156
override def exists : Boolean = false
1146
1157
override def hasUniqueSym : Boolean = false
1147
1158
validFor = Period .allInRun(ctx.runId)
1148
- protected def newLikeThis (s : Symbol , i : Type , pre : Type ): SingleDenotation =
1159
+ protected def newLikeThis (s : Symbol , i : Type , pre : Type , isRefinedMethod : Boolean ): SingleDenotation =
1149
1160
this
1150
1161
}
1151
1162
0 commit comments