Skip to content

Commit 1b42175

Browse files
committed
Avoid comparing RefinementClassSymbols with isSubClass in RefChecks
RefinementClassSymbols are created ad hoc for types in asSeenFrom, two symbols with the same parents don't compare `isSubClass`.
1 parent bea510c commit 1b42175

File tree

2 files changed

+18
-3
lines changed

2 files changed

+18
-3
lines changed

src/compiler/scala/tools/nsc/typechecker/RefChecks.scala

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,11 +97,17 @@ abstract class RefChecks extends Transform {
9797
private val checkedCombinations = mutable.Map[List[Symbol], (Symbol, Type)]()
9898
private def notYetCheckedOrAdd(rt: RefinedType, currentBase: Symbol) = {
9999
val seen = checkedCombinations.get(rt.parents.map(_.typeSymbol)).exists {
100-
case (prevBase, prevTp) => currentBase.isSubClass(prevBase) && rt =:= prevTp.asSeenFrom(currentBase.thisType, prevBase)
100+
case (prevBase, prevTp) =>
101+
val isSub = (currentBase, prevBase) match {
102+
case (cRef: RefinementClassSymbol, pRef: RefinementClassSymbol) =>
103+
cRef.info.parents.map(_.typeSymbol) == pRef.info.parents.map(_.typeSymbol)
104+
case _ =>
105+
currentBase.isSubClass(prevBase)
106+
}
107+
val sameTp = rt =:= prevTp.asSeenFrom(currentBase.thisType, prevBase)
108+
isSub && sameTp
101109
}
102-
103110
if (!seen) checkedCombinations.addOne((rt.parents.map(_.typeSymbol), (currentBase, rt)))
104-
105111
!seen
106112
}
107113

test/files/pos/t13013.scala

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
object Node {
2+
trait Root { self: Node =>
3+
val root = this
4+
}
5+
}
6+
trait Node {
7+
def root: Node
8+
}
9+
final class RootNode extends Node with Node.Root

0 commit comments

Comments
 (0)