Skip to content

Fix trees not being loaded from tasty when class symbol has NoCompleter #4001

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 16 additions & 16 deletions compiler/src/dotty/tools/dotc/core/Symbols.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not simply denot.ensureCompleted()? I expect it to be NoOp if infoOrCompleter returns NoCompleter.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apparently I am wrong

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will revert that change

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
Expand Down
85 changes: 42 additions & 43 deletions project/scripts/cmdTests
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down