Skip to content

Commit a77a4f6

Browse files
committed
Fix RefinementType#member
Type members used to always pick the last refined info for a type name. This is incorrect, as a type might have several refinements for the same type name, which are not necessarily subsumed by the last one. We now only pick the last one if it is an alias type (assuming we check for conflicts elsewhere).
1 parent c4f9683 commit a77a4f6

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/dotty/tools/dotc/core/Types.scala

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -375,9 +375,10 @@ object Types {
375375
def goRefined(tp: RefinedType) = {
376376
val pdenot = go(tp.parent)
377377
val rinfo = tp.refinedInfo.substThis(tp, pre)
378-
if (name.isTypeName) // simplified case that runs more efficiently
379-
pdenot.asSingleDenotation.derivedSingleDenotation(pdenot.symbol, rinfo)
380-
else
378+
if (name.isTypeName) {// simplified case that runs more efficiently
379+
val jointInfo = if (rinfo.isAlias) rinfo else pdenot.info & rinfo
380+
pdenot.asSingleDenotation.derivedSingleDenotation(pdenot.symbol, jointInfo)
381+
} else
381382
pdenot & (new JointRefDenotation(NoSymbol, rinfo, Period.allInRun(ctx.runId)), pre)
382383
}
383384
def goThis(tp: ThisType) = {

0 commit comments

Comments
 (0)