Skip to content

Generation of semanticdb for dotty codebase fails #8954

Closed
@kpbochenek

Description

@kpbochenek

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.

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions