diff --git a/compiler/src/dotty/tools/dotc/core/Symbols.scala b/compiler/src/dotty/tools/dotc/core/Symbols.scala index 2a37714a5de9..b7ea26776bd4 100644 --- a/compiler/src/dotty/tools/dotc/core/Symbols.scala +++ b/compiler/src/dotty/tools/dotc/core/Symbols.scala @@ -638,22 +638,22 @@ object Symbols { * For Tasty trees this means consulting whether the name table defines `id`. * For already loaded trees, we maintain the referenced ids in an attachment. */ - def treeContaining(id: String)(implicit ctx: Context): Tree = denot.infoOrCompleter match { - case _: NoCompleter => - tpd.EmptyTree - case _ => - denot.ensureCompleted() - myTree match { - case fn: TreeProvider => - if (id.isEmpty || fn.mightContain(id)) { - val tree = fn.tree - myTree = tree - tree - } - else tpd.EmptyTree - case tree: Tree @ unchecked => - if (id.isEmpty || mightContain(tree, id)) tree else tpd.EmptyTree - } + def treeContaining(id: String)(implicit ctx: Context): Tree = { + denot.infoOrCompleter match { + case _: NoCompleter => + case _ => denot.ensureCompleted() + } + myTree match { + case fn: TreeProvider => + if (id.isEmpty || fn.mightContain(id)) { + val tree = fn.tree + myTree = tree + tree + } + else tpd.EmptyTree + case tree: Tree @ unchecked => + if (id.isEmpty || mightContain(tree, id)) tree else tpd.EmptyTree + } } def treeOrProvider: TreeOrProvider = myTree diff --git a/project/scripts/cmdTests b/project/scripts/cmdTests index 7c630e4949ee..34785d61fbb4 100755 --- a/project/scripts/cmdTests +++ b/project/scripts/cmdTests @@ -18,46 +18,46 @@ else fi # check that `sbt dotc` compiles and `sbt dotr` runs it -#echo "testing sbt dotc -from-tasty and dotr -classpath" -#mkdir out/scriptedtest1 -#mkdir out/scriptedtest2 -#./project/scripts/sbt ";dotc tests/pos/sbtDotrTest.scala -d out/scriptedtest1/; dotc -from-tasty -classpath out/scriptedtest1/ -d out/scriptedtest2/ dotrtest.Test; dotr -classpath out/scriptedtest2/ dotrtest.Test" > sbtdotr2.out -#cat sbtdotr2.out -#if grep -e "dotr test ok" sbtdotr2.out; then -# echo "output ok" -#else -# echo "failed output check" -# exit -1 -#fi +echo "testing sbt dotc -from-tasty and dotr -classpath" +mkdir out/scriptedtest1 +mkdir out/scriptedtest2 +./project/scripts/sbt ";dotc tests/pos/sbtDotrTest.scala -d out/scriptedtest1/; dotc -from-tasty -classpath out/scriptedtest1/ -d out/scriptedtest2/ dotrtest.Test; dotr -classpath out/scriptedtest2/ dotrtest.Test" > sbtdotr2.out +cat sbtdotr2.out +if grep -e "dotr test ok" sbtdotr2.out; then + echo "output ok" +else + echo "failed output check" + exit -1 +fi # check that `sbt dotc -decompile` runs -#echo "testing sbt dotc -decompile" -#./project/scripts/sbt ";dotc -decompile -color:never -classpath out/scriptedtest1 dotrtest.Test" > sbtdotc3.out -#cat sbtdotc3.out -#if grep -e "def main(args: Array\[String\]): Unit =" sbtdotc3.out; then -# echo "output ok" -#else -# echo "failed output check" -# exit -1 -#fi -#echo "testing sbt dotr with no -classpath" -#./project/scripts/sbt ";dotc tests/pos/sbtDotrTest.scala; dotr dotrtest.Test" > sbtdotr3.out -#cat sbtdotr3.out -#if grep -e "dotr test ok" sbtdotr3.out; then -# echo "output ok" -#else -# exit -1 -#fi +echo "testing sbt dotc -decompile" +./project/scripts/sbt ";dotc -decompile -color:never -classpath out/scriptedtest1 dotrtest.Test" > sbtdotc3.out +cat sbtdotc3.out +if grep -e "def main(args: Array\[String\]): Unit =" sbtdotc3.out; then + echo "output ok" +else + echo "failed output check" + exit -1 +fi +echo "testing sbt dotr with no -classpath" +./project/scripts/sbt ";dotc tests/pos/sbtDotrTest.scala; dotr dotrtest.Test" > sbtdotr3.out +cat sbtdotr3.out +if grep -e "dotr test ok" sbtdotr3.out; then + echo "output ok" +else + exit -1 +fi #echo "testing loading tasty from .tasty file in jar" -#./project/scripts/sbt ";dotc -d out/scriptedtest4.jar -YemitTasty tests/pos/sbtDotrTest.scala; dotc -decompile -classpath out/scriptedtest4.jar -color:never dotrtest.Test" > sbtdot4.out -#cat sbtdot4.out -#if grep -e "def main(args: Array\[String\]): Unit =" sbtdot4.out; then -# echo "output ok" -#else -# echo "failed output check" -# exit -1 -#fi +./project/scripts/sbt ";dotc -d out/scriptedtest4.jar -YemitTasty tests/pos/sbtDotrTest.scala; dotc -decompile -classpath out/scriptedtest4.jar -color:never dotrtest.Test" > sbtdot4.out +cat sbtdot4.out +if grep -e "def main(args: Array\[String\]): Unit =" sbtdot4.out; then + echo "output ok" +else + echo "failed output check" + exit -1 +fi echo "testing scala.quoted.Expr.run from sbt dotr" ./project/scripts/sbt ";dotc -classpath compiler/target/scala-2.12/classes tests/run-with-compiler/quote-run.scala; dotr -with-compiler Test" > sbtdot5.out @@ -83,13 +83,12 @@ mkdir -p out/scriptedtest0 ./bin/dotr -classpath out/scriptedtest0 dotrtest.Test # check that `dotc -from-tasty` compiles and `dotr` runs it -# -#echo "testing ./bin/dotc -from-tasty and dotr -classpath" -#mkdir -p out/scriptedtest1 -#mkdir -p out/scriptedtest2 -#./bin/dotc tests/pos/sbtDotrTest.scala -d out/scriptedtest1/ -#./bin/dotc -from-tasty -classpath out/scriptedtest1/ -d out/scriptedtest2/ dotrtest.Test -#./bin/dotr -classpath out/scriptedtest2/ dotrtest.Test +echo "testing ./bin/dotc -from-tasty and dotr -classpath" +mkdir -p out/scriptedtest1 +mkdir -p out/scriptedtest2 +./bin/dotc tests/pos/sbtDotrTest.scala -d out/scriptedtest1/ +./bin/dotc -from-tasty -classpath out/scriptedtest1/ -d out/scriptedtest2/ dotrtest.Test +./bin/dotr -classpath out/scriptedtest2/ dotrtest.Test # echo ":quit" | ./dist-bootstrapped/target/pack/bin/dotr # not supported by CI mkdir -p _site && ./bin/dotd -project Hello -siteroot _site tests/run/hello.scala