Skip to content

Commit 979fa47

Browse files
committed
More assertions in TreeChecker.
Flushed out a caching bug in Scopes.
1 parent 3fea947 commit 979fa47

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -278,6 +278,7 @@ object Scopes {
278278
if (e.sym == prev) e.sym = replacement
279279
e = lookupNextEntry(e)
280280
}
281+
elemsCache = null
281282
}
282283

283284
/** Lookup a symbol entry matching given name.

src/dotty/tools/dotc/transform/TreeChecker.scala

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,15 +101,17 @@ class TreeChecker {
101101
def ownerMatches(symOwner: Symbol, ctxOwner: Symbol): Boolean =
102102
symOwner == ctxOwner ||
103103
ctxOwner.isWeakOwner && ownerMatches(symOwner, ctxOwner.owner)
104-
if(!ownerMatches(tree.symbol.owner, ctx.owner)) {
105-
assert(ownerMatches(tree.symbol.owner, ctx.owner),
106-
i"bad owner; ${tree.symbol} has owner ${tree.symbol.owner}, expected was ${ctx.owner}\n" +
107-
i"owner chain = ${tree.symbol.ownersIterator.toList}%, %, ctxOwners = ${ctx.outersIterator.map(_.owner).toList}%, %")
108-
}
104+
assert(ownerMatches(tree.symbol.owner, ctx.owner),
105+
i"bad owner; ${tree.symbol} has owner ${tree.symbol.owner}, expected was ${ctx.owner}\n" +
106+
i"owner chain = ${tree.symbol.ownersIterator.toList}%, %, ctxOwners = ${ctx.outersIterator.map(_.owner).toList}%, %")
109107
}
110108

111109
override def typedClassDef(cdef: untpd.TypeDef, cls: ClassSymbol)(implicit ctx: Context) = {
112110
val TypeDef(_, _, impl @ Template(constr, _, _, _)) = cdef
111+
assert(cdef.symbol == cls)
112+
assert(impl.symbol.owner == cls)
113+
assert(constr.symbol.owner == cls)
114+
assert(cls.primaryConstructor == constr.symbol, i"mismatch, primary constructor ${cls.primaryConstructor}, in tree = ${constr.symbol}")
113115
checkOwner(impl)
114116
checkOwner(impl.constr)
115117
super.typedClassDef(cdef, cls)

0 commit comments

Comments
 (0)