From 61c30f8d949a43ad0580ef421c4fe94acc3c340e Mon Sep 17 00:00:00 2001 From: Dmitry Petrashko Date: Mon, 13 Jul 2015 17:39:46 +0200 Subject: [PATCH 1/5] Relax Ycheck for labels after LabelDefs LabelDefs reorders labels. As a result of reordering label-def defined inside other label-def could be lifted outside. LabelDefs doesn't update owner chains to represent this. Making treeChecker aware of this. --- src/dotty/tools/dotc/core/Phases.scala | 6 +++++- src/dotty/tools/dotc/transform/TreeChecker.scala | 3 ++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/src/dotty/tools/dotc/core/Phases.scala b/src/dotty/tools/dotc/core/Phases.scala index b086308a2c86..42b03484e670 100644 --- a/src/dotty/tools/dotc/core/Phases.scala +++ b/src/dotty/tools/dotc/core/Phases.scala @@ -3,7 +3,7 @@ package core import Periods._ import Contexts._ -import dotty.tools.backend.jvm.GenBCode +import dotty.tools.backend.jvm.{LabelDefs, GenBCode} import util.DotClass import DenotTransformers._ import Denotations._ @@ -296,6 +296,8 @@ object Phases { private var myFlatClasses = false private var myRefChecked = false private var mySymbolicRefs = false + private var myLabelsReordered = false + /** The sequence position of this phase in the given context where 0 * is reserved for NoPhase and the first real phase is at position 1. @@ -311,6 +313,7 @@ object Phases { final def flatClasses = myFlatClasses // Phase is after flatten final def refChecked = myRefChecked // Phase is after RefChecks final def symbolicRefs = mySymbolicRefs // Phase is after ResolveSuper, newly generated TermRefs should be symbolic + final def labelsReordered = myLabelsReordered // Phase is after LabelDefs, labels are flattened and owner chains don't mirror this protected[Phases] def init(base: ContextBase, start: Int, end:Int): Unit = { if (start >= FirstPhaseId) @@ -321,6 +324,7 @@ object Phases { myFlatClasses = prev.getClass == classOf[Flatten] || prev.flatClasses myRefChecked = prev.getClass == classOf[RefChecks] || prev.refChecked mySymbolicRefs = prev.getClass == classOf[ResolveSuper] || prev.symbolicRefs + myLabelsReordered = prev.getClass == classOf[LabelDefs] || prev.labelsReordered } protected[Phases] def init(base: ContextBase, id: Int): Unit = init(base, id, id) diff --git a/src/dotty/tools/dotc/transform/TreeChecker.scala b/src/dotty/tools/dotc/transform/TreeChecker.scala index 0e69b9d1fd93..b76f04b58891 100644 --- a/src/dotty/tools/dotc/transform/TreeChecker.scala +++ b/src/dotty/tools/dotc/transform/TreeChecker.scala @@ -242,7 +242,8 @@ class TreeChecker extends Phase with SymTransformer { private def checkOwner(tree: untpd.Tree)(implicit ctx: Context): Unit = { def ownerMatches(symOwner: Symbol, ctxOwner: Symbol): Boolean = symOwner == ctxOwner || - ctxOwner.isWeakOwner && ownerMatches(symOwner, ctxOwner.owner) + ctxOwner.isWeakOwner && ownerMatches(symOwner, ctxOwner.owner) || + ctx.phase.labelsReordered && symOwner.isWeakOwner && ownerMatches(symOwner.owner, ctxOwner) assert(ownerMatches(tree.symbol.owner, ctx.owner), i"bad owner; ${tree.symbol} has owner ${tree.symbol.owner}, expected was ${ctx.owner}\n" + i"owner chain = ${tree.symbol.ownersIterator.toList}%, %, ctxOwners = ${ctx.outersIterator.map(_.owner).toList}%, %") From 6369d6f39dd411e940264cde7ad7cc82d0292793 Mon Sep 17 00:00:00 2001 From: Dmitry Petrashko Date: Mon, 13 Jul 2015 17:42:23 +0200 Subject: [PATCH 2/5] Enable Ycheck after labelDef. Fixes #701 --- test/dotc/tests.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/dotc/tests.scala b/test/dotc/tests.scala index 2baeeb49e4a6..7aa43c13e9a9 100644 --- a/test/dotc/tests.scala +++ b/test/dotc/tests.scala @@ -20,7 +20,7 @@ class tests extends CompilerTest { implicit val defaultOptions = noCheckOptions ++ List( "-Yno-deep-subtypes", "-Yno-double-bindings", - "-Ycheck:tailrec,resolveSuper,mixin,restoreScopes", + "-Ycheck:tailrec,resolveSuper,mixin,restoreScopes,labelDef", "-d", defaultOutputDir ) val testPickling = List("-Xprint-types", "-Ytest-pickler", "-Ystop-after:pickler") From fa3265e37a1e480861cc09102ec0dc94dd4a7557 Mon Sep 17 00:00:00 2001 From: Dmitry Petrashko Date: Mon, 20 Jul 2015 16:09:04 +0200 Subject: [PATCH 3/5] Remove .travis.yml We no longer use Travis, and testing infrastructure is not guaranteed to work there. --- .travis.yml | 15 --------------- 1 file changed, 15 deletions(-) delete mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index c8061b4f8168..000000000000 --- a/.travis.yml +++ /dev/null @@ -1,15 +0,0 @@ -language: scala -script: - - sbt -Ddotty.travis.build=yes update compile test scalastyle -jdk: - - oraclejdk8 -notifications: - email: - - dotty-reports@googlegroups.com -branches: - only: - - master -before_install: - - cd .. - - git clone https://github.com/scala/scala.git - - cd dotty From 8d266198c5ef3fd82511a6c6882d94bf5d7e50e4 Mon Sep 17 00:00:00 2001 From: Dmitry Petrashko Date: Mon, 20 Jul 2015 16:10:35 +0200 Subject: [PATCH 4/5] Enable -Ycheck:all in Jenkins. Done by setting an environment variable and checking it in runtime. This enables Ycheck:all for all kinds of tests, including partest. --- project/Build.scala | 10 +++++----- scripts/common | 2 +- test/dotc/tests.scala | 11 ++++++++--- 3 files changed, 14 insertions(+), 9 deletions(-) diff --git a/project/Build.scala b/project/Build.scala index 473ef2443f06..9c80fdc11c2b 100644 --- a/project/Build.scala +++ b/project/Build.scala @@ -8,7 +8,7 @@ object DottyBuild extends Build { val travisMemLimit = List("-Xmx1g", "-Xss2m") - val TRAVIS_BUILD = "dotty.travis.build" + val JENKINS_BUILD = "dotty.jenkins.build" val agentOptions = List( // "-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5005" @@ -104,8 +104,8 @@ object DottyBuild extends Build { // System.err.println("BOOTPATH: " + fullpath) val travis_build = // propagate if this is a travis build - if (sys.props.isDefinedAt(TRAVIS_BUILD)) - List(s"-D$TRAVIS_BUILD=${sys.props(TRAVIS_BUILD)}") ::: travisMemLimit + if (sys.props.isDefinedAt(JENKINS_BUILD)) + List(s"-D$JENKINS_BUILD=${sys.props(JENKINS_BUILD)}") ::: travisMemLimit else List() @@ -156,8 +156,8 @@ object DottyBuild extends Build { // System.err.println("BOOTPATH: " + fullpath) val travis_build = // propagate if this is a travis build - if (sys.props.isDefinedAt(TRAVIS_BUILD)) - List(s"-D$TRAVIS_BUILD=${sys.props(TRAVIS_BUILD)}") + if (sys.props.isDefinedAt(JENKINS_BUILD)) + List(s"-D$JENKINS_BUILD=${sys.props(JENKINS_BUILD)}") else List() val res = agentOptions ::: travis_build ::: fullpath diff --git a/scripts/common b/scripts/common index 4924538f08b0..a51a60a01498 100755 --- a/scripts/common +++ b/scripts/common @@ -14,4 +14,4 @@ update() { export LC_ALL=en_US.UTF-8 -sbtArgs="-Ddotty.travis.build=yes -Dfile.encoding=UTF-8 -ivy $baseDir/ivy2 -Dsbt.global.base=$HOME/.sbt/0.13 -sbt-dir $HOME/.sbt/0.13" +sbtArgs="-Ddotty.jenkins.build=yes -Dfile.encoding=UTF-8 -ivy $baseDir/ivy2 -Dsbt.global.base=$HOME/.sbt/0.13 -sbt-dir $HOME/.sbt/0.13" diff --git a/test/dotc/tests.scala b/test/dotc/tests.scala index 7aa43c13e9a9..6fefbf6645fa 100644 --- a/test/dotc/tests.scala +++ b/test/dotc/tests.scala @@ -8,6 +8,8 @@ import org.junit.experimental.categories._ class tests extends CompilerTest { + def isRunByJenkins: Boolean = sys.props.isDefinedAt("dotty.jenkins.build") + val noCheckOptions = List( // "-verbose", // "-Ylog:frontend", @@ -20,9 +22,12 @@ class tests extends CompilerTest { implicit val defaultOptions = noCheckOptions ++ List( "-Yno-deep-subtypes", "-Yno-double-bindings", - "-Ycheck:tailrec,resolveSuper,mixin,restoreScopes,labelDef", - "-d", defaultOutputDir - ) + "-d", defaultOutputDir) ++ { + if (isRunByJenkins) List("-Ycheck:all") + else List("-Ycheck:tailrec,resolveSuper,mixin,restoreScopes,labelDef") + } + + val testPickling = List("-Xprint-types", "-Ytest-pickler", "-Ystop-after:pickler") val twice = List("#runs", "2") From 7eef035ea617be1f38c9d901b6c08ee8982fb73e Mon Sep 17 00:00:00 2001 From: Dmitry Petrashko Date: Mon, 20 Jul 2015 16:11:49 +0200 Subject: [PATCH 5/5] Disable Ycheck:all until #725 is fixed. --- test/dotc/tests.scala | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/dotc/tests.scala b/test/dotc/tests.scala index 6fefbf6645fa..9c8257493123 100644 --- a/test/dotc/tests.scala +++ b/test/dotc/tests.scala @@ -23,7 +23,7 @@ class tests extends CompilerTest { implicit val defaultOptions = noCheckOptions ++ List( "-Yno-deep-subtypes", "-Yno-double-bindings", "-d", defaultOutputDir) ++ { - if (isRunByJenkins) List("-Ycheck:all") + if (isRunByJenkins) List("-Ycheck:-Ycheck:tailrec,resolveSuper,mixin,restoreScopes,labelDef") // should be Ycheck:all, but #725 else List("-Ycheck:tailrec,resolveSuper,mixin,restoreScopes,labelDef") }