Skip to content

Commit 9f806bb

Browse files
committed
Fix trees not being loaded from tasty when class symbol has NoCompleter
1 parent 3365ed3 commit 9f806bb

File tree

2 files changed

+58
-59
lines changed

2 files changed

+58
-59
lines changed

compiler/src/dotty/tools/dotc/core/Symbols.scala

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -638,22 +638,22 @@ object Symbols {
638638
* For Tasty trees this means consulting whether the name table defines `id`.
639639
* For already loaded trees, we maintain the referenced ids in an attachment.
640640
*/
641-
def treeContaining(id: String)(implicit ctx: Context): Tree = denot.infoOrCompleter match {
642-
case _: NoCompleter =>
643-
tpd.EmptyTree
644-
case _ =>
645-
denot.ensureCompleted()
646-
myTree match {
647-
case fn: TreeProvider =>
648-
if (id.isEmpty || fn.mightContain(id)) {
649-
val tree = fn.tree
650-
myTree = tree
651-
tree
652-
}
653-
else tpd.EmptyTree
654-
case tree: Tree @ unchecked =>
655-
if (id.isEmpty || mightContain(tree, id)) tree else tpd.EmptyTree
656-
}
641+
def treeContaining(id: String)(implicit ctx: Context): Tree = {
642+
denot.infoOrCompleter match {
643+
case _: NoCompleter =>
644+
case _ => denot.ensureCompleted()
645+
}
646+
myTree match {
647+
case fn: TreeProvider =>
648+
if (id.isEmpty || fn.mightContain(id)) {
649+
val tree = fn.tree
650+
myTree = tree
651+
tree
652+
}
653+
else tpd.EmptyTree
654+
case tree: Tree @ unchecked =>
655+
if (id.isEmpty || mightContain(tree, id)) tree else tpd.EmptyTree
656+
}
657657
}
658658

659659
def treeOrProvider: TreeOrProvider = myTree

project/scripts/cmdTests

Lines changed: 42 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -18,46 +18,46 @@ else
1818
fi
1919

2020
# check that `sbt dotc` compiles and `sbt dotr` runs it
21-
#echo "testing sbt dotc -from-tasty and dotr -classpath"
22-
#mkdir out/scriptedtest1
23-
#mkdir out/scriptedtest2
24-
#./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
25-
#cat sbtdotr2.out
26-
#if grep -e "dotr test ok" sbtdotr2.out; then
27-
# echo "output ok"
28-
#else
29-
# echo "failed output check"
30-
# exit -1
31-
#fi
21+
echo "testing sbt dotc -from-tasty and dotr -classpath"
22+
mkdir out/scriptedtest1
23+
mkdir out/scriptedtest2
24+
./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
25+
cat sbtdotr2.out
26+
if grep -e "dotr test ok" sbtdotr2.out; then
27+
echo "output ok"
28+
else
29+
echo "failed output check"
30+
exit -1
31+
fi
3232

3333
# check that `sbt dotc -decompile` runs
34-
#echo "testing sbt dotc -decompile"
35-
#./project/scripts/sbt ";dotc -decompile -color:never -classpath out/scriptedtest1 dotrtest.Test" > sbtdotc3.out
36-
#cat sbtdotc3.out
37-
#if grep -e "def main(args: Array\[String\]): Unit =" sbtdotc3.out; then
38-
# echo "output ok"
39-
#else
40-
# echo "failed output check"
41-
# exit -1
42-
#fi
43-
#echo "testing sbt dotr with no -classpath"
44-
#./project/scripts/sbt ";dotc tests/pos/sbtDotrTest.scala; dotr dotrtest.Test" > sbtdotr3.out
45-
#cat sbtdotr3.out
46-
#if grep -e "dotr test ok" sbtdotr3.out; then
47-
# echo "output ok"
48-
#else
49-
# exit -1
50-
#fi
34+
echo "testing sbt dotc -decompile"
35+
./project/scripts/sbt ";dotc -decompile -color:never -classpath out/scriptedtest1 dotrtest.Test" > sbtdotc3.out
36+
cat sbtdotc3.out
37+
if grep -e "def main(args: Array\[String\]): Unit =" sbtdotc3.out; then
38+
echo "output ok"
39+
else
40+
echo "failed output check"
41+
exit -1
42+
fi
43+
echo "testing sbt dotr with no -classpath"
44+
./project/scripts/sbt ";dotc tests/pos/sbtDotrTest.scala; dotr dotrtest.Test" > sbtdotr3.out
45+
cat sbtdotr3.out
46+
if grep -e "dotr test ok" sbtdotr3.out; then
47+
echo "output ok"
48+
else
49+
exit -1
50+
fi
5151

5252
#echo "testing loading tasty from .tasty file in jar"
53-
#./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
54-
#cat sbtdot4.out
55-
#if grep -e "def main(args: Array\[String\]): Unit =" sbtdot4.out; then
56-
# echo "output ok"
57-
#else
58-
# echo "failed output check"
59-
# exit -1
60-
#fi
53+
./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
54+
cat sbtdot4.out
55+
if grep -e "def main(args: Array\[String\]): Unit =" sbtdot4.out; then
56+
echo "output ok"
57+
else
58+
echo "failed output check"
59+
exit -1
60+
fi
6161

6262
echo "testing scala.quoted.Expr.run from sbt dotr"
6363
./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
8383
./bin/dotr -classpath out/scriptedtest0 dotrtest.Test
8484

8585
# check that `dotc -from-tasty` compiles and `dotr` runs it
86-
#
87-
#echo "testing ./bin/dotc -from-tasty and dotr -classpath"
88-
#mkdir -p out/scriptedtest1
89-
#mkdir -p out/scriptedtest2
90-
#./bin/dotc tests/pos/sbtDotrTest.scala -d out/scriptedtest1/
91-
#./bin/dotc -from-tasty -classpath out/scriptedtest1/ -d out/scriptedtest2/ dotrtest.Test
92-
#./bin/dotr -classpath out/scriptedtest2/ dotrtest.Test
86+
echo "testing ./bin/dotc -from-tasty and dotr -classpath"
87+
mkdir -p out/scriptedtest1
88+
mkdir -p out/scriptedtest2
89+
./bin/dotc tests/pos/sbtDotrTest.scala -d out/scriptedtest1/
90+
./bin/dotc -from-tasty -classpath out/scriptedtest1/ -d out/scriptedtest2/ dotrtest.Test
91+
./bin/dotr -classpath out/scriptedtest2/ dotrtest.Test
9392

9493
# echo ":quit" | ./dist-bootstrapped/target/pack/bin/dotr # not supported by CI
9594
mkdir -p _site && ./bin/dotd -project Hello -siteroot _site tests/run/hello.scala

0 commit comments

Comments
 (0)