diff options
author | Martin Odersky <odersky@gmail.com> | 2014-05-01 19:25:29 +0200 |
---|---|---|
committer | Dmitry Petrashko <dmitry.petrashko@gmail.com> | 2014-05-08 21:51:47 +0200 |
commit | 69403ee21743246c3f1d10cfa5f5b0c76d01e0c7 (patch) | |
tree | 9312b99dca04fd32bfd697d605587e4f47dba5aa /src | |
parent | 640feb1fe9de15dbf846c5a1ddc480c44523daa3 (diff) | |
download | dotty-69403ee21743246c3f1d10cfa5f5b0c76d01e0c7.tar.gz dotty-69403ee21743246c3f1d10cfa5f5b0c76d01e0c7.tar.bz2 dotty-69403ee21743246c3f1d10cfa5f5b0c76d01e0c7.zip |
Adding a check that owner chains are correct for -Ycheck
Diffstat (limited to 'src')
-rw-r--r-- | src/dotty/tools/dotc/core/TypeComparer.scala | 1 | ||||
-rw-r--r-- | src/dotty/tools/dotc/transform/TreeChecker.scala | 19 |
2 files changed, 19 insertions, 1 deletions
diff --git a/src/dotty/tools/dotc/core/TypeComparer.scala b/src/dotty/tools/dotc/core/TypeComparer.scala index 2d66e7d2f..6174f0915 100644 --- a/src/dotty/tools/dotc/core/TypeComparer.scala +++ b/src/dotty/tools/dotc/core/TypeComparer.scala @@ -161,7 +161,6 @@ class TypeComparer(initctx: Context) extends DotClass { private def updateConstraint(param: PolyParam, bounds: TypeBounds): Boolean = { val saved = constraint constraint = constraint.updated(param, bounds) - if (propagate(param)) { if (isSatisfiable(param)) return true ctx.log(i"SAT $constraint produced by $param $bounds is not satisfiable") diff --git a/src/dotty/tools/dotc/transform/TreeChecker.scala b/src/dotty/tools/dotc/transform/TreeChecker.scala index f39dd505a..42e4f95ba 100644 --- a/src/dotty/tools/dotc/transform/TreeChecker.scala +++ b/src/dotty/tools/dotc/transform/TreeChecker.scala @@ -8,6 +8,7 @@ import core.SymDenotations._ import core.Contexts._ import core.Symbols._ import core.Types._ +import core.Flags.Method import core.Constants._ import core.StdNames._ import core.Decorators._ @@ -72,6 +73,24 @@ class TreeChecker { assert(tree.isTerm || ctx.phase.prev.id <= ctx.typerPhase.id, tree.show + " at " + ctx.phase) super.typedSelect(tree, pt) } + + /** Check that all defined symbols have legal owners. + * An owner is legal if it is either the same as the context's owner + * or there's an owner chain of valdefs starting at the context's owner and + * reaching up to the symbol's owner. The reason for this relaxed matching + * is that we should be able to pull out an expression as an initializer + * of a helper value without having to do a change owner traversal of the expression. + */ + override def index(trees: List[untpd.Tree])(implicit ctx: Context): Context = { + def ownerMatches(symOwner: Symbol, ctxOwner: Symbol): Boolean = + symOwner == ctxOwner || + ctxOwner.isTerm && !(ctxOwner is Method | Lazy | Mutable) && + ownerMatches(symOwner, ctxOwner.owner) + for (tree <- trees if tree.isDef) + assert(ownerMatches(tree.symbol.owner, ctx.owner), + i"bad owner; $tree has owner ${tree.symbol.owner}, expected was ${ctx.owner}") + super.index(trees) + } } } |