Skip to content

Generation of semanticdb for dotty codebase fails #8954

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

Closed
kpbochenek opened this issue May 11, 2020 · 2 comments · Fixed by #8983
Closed

Generation of semanticdb for dotty codebase fails #8954

kpbochenek opened this issue May 11, 2020 · 2 comments · Fixed by #8983

Comments

@kpbochenek
Copy link
Contributor

enable flag "-Ysemanticdb" for compilation of dotty. It will cause build to fail.

Semanticdb is needed by metals to provide basic functionality for editors(find references/goto definition).

Here I created a branch showing where things fail what workarounds I did to make compilation succeed -> generate .semanticdb to let metals provide minimal support and how I enabled semanticdb generation(in case I messed up something :P).
https://github.com/kpbochenek/dotty/pull/1/files

Problem 1:
There is a function
file:ExtractSemanticDB.scala: private def adjustSpanToName(span: Span, qualSpan: Span, name: Name)(using Context) =
It throws exception that tries to access characters outside of current source file. It happens for a file:
dotty/library/src/scala/quoted/autolift.scala 261 with 862 FOR [834..844..863] AND FunctionalInterface
(it means autolift.scala file with 261 characters but it tries to access Span in range 834-863 of name FunctionalInterface)

Problem 2:
When problem1 is fixed(or worked around) you hit problem 2.

[error] ## Exception when compiling 444 sources to <...>/dotty/compiler/target/scala-0.24/classes
[error] java.lang.AssertionError: NoDenotation.owner
[error] dotty.tools.dotc.core.SymDenotations$NoDenotation$.owner(SymDenotations.scala:2330)
[error] dotty.tools.dotc.semanticdb.ExtractSemanticDB$Extractor.traverseTpt$1$$anonfun$1(ExtractSemanticDB.scala:119)
[error] dotty.runtime.function.JProcedure1.apply(JProcedure1.java:15)
[error] dotty.runtime.function.JProcedure1.apply(JProcedure1.java:10)
[error] dotty.tools.dotc.semanticdb.ExtractSemanticDB$Extractor.traverse$$anonfun$17$$anonfun$1(ExtractSemanticDB.scala:576)
[error] dotty.runtime.function.JProcedure1.apply(JProcedure1.java:15)
[error] dotty.runtime.function.JProcedure1.apply(JProcedure1.java:10)
[error] scala.collection.immutable.List.foreach(List.scala:333)
[error] dotty.tools.dotc.semanticdb.ExtractSemanticDB$Extractor.traverse$$anonfun$7(ExtractSemanticDB.scala:576)
...

This one I have not checked more but workaround with try catch shows for now there is no more compilation error issues.

@bishabosha
Copy link
Member

bishabosha commented May 12, 2020

so sometimes the source associated with a tree is not the same as the compilation unit, which can solve the span issue, The knock on effect of stopping the span crash is then a separate bug

@bishabosha
Copy link
Member

whats more weird is that the issue with compiling dotty/library/src/scala/quoted/autolift.scala is that apparently it only crashes with a clean compile of dotty, and not just dotc on that file alone, perhaps some other flags are interfering

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants