Skip to content

Commit 6c52046

Browse files
authored
Merge pull request #11570 from Kordyjan/semanticdb-givens-occurence
Do not ignore anonymous ValDefs if they are givens
2 parents 302b186 + a557537 commit 6c52046

File tree

4 files changed

+37
-0
lines changed

4 files changed

+37
-0
lines changed

compiler/src/dotty/tools/dotc/semanticdb/ExtractSemanticDB.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ class ExtractSemanticDB extends Phase:
169169
tree match
170170
case tree: DefDef =>
171171
tree.paramss.foreach(_.foreach(param => registerSymbolSimple(param.symbol)))
172+
case tree: ValDef if tree.symbol.is(Given) => traverse(tree.tpt)
172173
case _ =>
173174
if !tree.symbol.isGlobal then
174175
localBodies(tree.symbol) = tree.rhs
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package angiven
2+
3+
trait Foo/*<-angiven::Foo#*/
4+
5+
/*<-angiven::AnonymousGiven$package.*/def bar/*<-angiven::AnonymousGiven$package.bar().*/(using Foo/*->angiven::Foo#*/) = 42
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package angiven
2+
3+
trait Foo
4+
5+
def bar(using Foo) = 42

tests/semanticdb/metac.expect

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,32 @@ Occurrences:
329329
[18:6..18:9): foo <- example/Anonymous#foo.
330330
[18:16..18:19): Foo -> example/Anonymous#Foo#
331331

332+
expect/AnonymousGiven.scala
333+
---------------------------
334+
335+
Summary:
336+
Schema => SemanticDB v4
337+
Uri => AnonymousGiven.scala
338+
Text => empty
339+
Language => Scala
340+
Symbols => 5 entries
341+
Occurrences => 6 entries
342+
343+
Symbols:
344+
angiven/AnonymousGiven$package. => final package object angiven
345+
angiven/AnonymousGiven$package.bar(). => method bar
346+
angiven/AnonymousGiven$package.bar().(x$1) => implicit param x$1
347+
angiven/Foo# => trait Foo
348+
angiven/Foo#`<init>`(). => primary ctor <init>
349+
350+
Occurrences:
351+
[0:8..0:15): angiven <- angiven/
352+
[2:0..2:0): <- angiven/Foo#`<init>`().
353+
[2:6..2:9): Foo <- angiven/Foo#
354+
[4:0..4:0): <- angiven/AnonymousGiven$package.
355+
[4:4..4:7): bar <- angiven/AnonymousGiven$package.bar().
356+
[4:14..4:17): Foo -> angiven/Foo#
357+
332358
expect/Classes.scala
333359
--------------------
334360

0 commit comments

Comments
 (0)