aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDmitry Petrashko <dmitry.petrashko@gmail.com>2014-11-03 14:42:55 +0100
committerDmitry Petrashko <dmitry.petrashko@gmail.com>2014-11-22 20:10:20 +0100
commit35bf9148b6054c3651d597f90b7b721845e8734a (patch)
tree5be9c3ec703baa80411b99103a91c55202960b3f /src
parente935eaa9220eff300ecca891d41c0c421501faf4 (diff)
downloaddotty-35bf9148b6054c3651d597f90b7b721845e8734a.tar.gz
dotty-35bf9148b6054c3651d597f90b7b721845e8734a.tar.bz2
dotty-35bf9148b6054c3651d597f90b7b721845e8734a.zip
Allow checking that trees and their defined symbols have modifiers in sync.
Diffstat (limited to 'src')
-rw-r--r--src/dotty/tools/dotc/config/ScalaSettings.scala1
-rw-r--r--src/dotty/tools/dotc/transform/TreeChecker.scala15
2 files changed, 14 insertions, 2 deletions
diff --git a/src/dotty/tools/dotc/config/ScalaSettings.scala b/src/dotty/tools/dotc/config/ScalaSettings.scala
index abde6cb53..05b936136 100644
--- a/src/dotty/tools/dotc/config/ScalaSettings.scala
+++ b/src/dotty/tools/dotc/config/ScalaSettings.scala
@@ -99,6 +99,7 @@ class ScalaSettings extends Settings.SettingGroup {
val Yhelp = BooleanSetting("-Y", "Print a synopsis of private options.")
val browse = PhasesSetting("-Ybrowse", "Browse the abstract syntax tree after")
val Ycheck = PhasesSetting("-Ycheck", "Check the tree at the end of")
+ val YcheckMods = BooleanSetting("-Ycheck-mods", "Check that symbols and their defining trees have modifiers in sync")
val YcheckTypedTrees = BooleanSetting("-YcheckTypedTrees", "Check all constructured typed trees for type correctness")
val Yshow = PhasesSetting("-Yshow", "(Requires -Xshow-class or -Xshow-object) Show after")
val Xcloselim = BooleanSetting("-Yclosure-elim", "Perform closure elimination.")
diff --git a/src/dotty/tools/dotc/transform/TreeChecker.scala b/src/dotty/tools/dotc/transform/TreeChecker.scala
index baaadb53f..39f4bb067 100644
--- a/src/dotty/tools/dotc/transform/TreeChecker.scala
+++ b/src/dotty/tools/dotc/transform/TreeChecker.scala
@@ -76,12 +76,23 @@ class TreeChecker {
everDefinedSyms.get(sym) match {
case Some(t) =>
if(t ne tree)
- ctx.warning(i"symbol ${tree.symbol} is defined at least twice in different parts of AST")
+ ctx.warning(i"symbol ${sym} is defined at least twice in different parts of AST")
// should become an error
case None =>
everDefinedSyms(sym) = tree
}
- assert(!nowDefinedSyms.contains(tree.symbol), i"doubly defined symbol: ${tree.symbol}in $tree")
+ assert(!nowDefinedSyms.contains(sym), i"doubly defined symbol: ${sym} in $tree")
+
+ if(ctx.settings.YcheckMods.value) {
+ tree match {
+ case t: MemberDef =>
+ if (t.name ne sym.name) ctx.warning(s"symbol ${sym.fullName} name doesn't correspond to AST: ${t}")
+ if (sym.flags != t.mods.flags) ctx.warning(s"symbol ${sym.fullName} flags ${sym.flags} doesn't match AST definition flags ${t.mods.flags}")
+ // todo: compare trees inside annotations
+ case _ =>
+ }
+ }
+
nowDefinedSyms += tree.symbol
//println(i"defined: ${tree.symbol}")
val res = op