Skip to content

Commit

Permalink
fix: semanticdb symbol creation when targetName set (#20950)
Browse files Browse the repository at this point in the history
  • Loading branch information
tgodzik authored Jul 3, 2024
2 parents 06c6a71 + 05f45b1 commit ea1116d
Show file tree
Hide file tree
Showing 4 changed files with 55 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ class SemanticSymbolBuilder:
case _ =>
end find
val sig = sym.signature
find(_.signature == sig)
val targetName = sym.targetName
find(sym => sym.signature == sig && sym.targetName == targetName)

def addDescriptor(sym: Symbol): Unit =
if sym.is(ModuleClass) then
Expand Down
8 changes: 8 additions & 0 deletions tests/semanticdb/expect/TargetName.expect.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package example

object TargetName/*<-example::TargetName.*/:
@annotation.targetName/*->scala::annotation::targetName#*/("m1")
def m/*<-example::TargetName.m().*/(i/*<-example::TargetName.m().(i)*/: Int/*->scala::Int#*/) = 1
@annotation.targetName/*->scala::annotation::targetName#*/("m2")
def m/*<-example::TargetName.m(+1).*/(i/*<-example::TargetName.m(+1).(i)*/: Int/*->scala::Int#*/) = 1
def m1/*<-example::TargetName.m1().*/(i/*<-example::TargetName.m1().(i)*/: String/*->scala::Predef.String#*/) = 1
8 changes: 8 additions & 0 deletions tests/semanticdb/expect/TargetName.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package example

object TargetName:
@annotation.targetName("m1")
def m(i: Int) = 1
@annotation.targetName("m2")
def m(i: Int) = 1
def m1(i: String) = 1
37 changes: 37 additions & 0 deletions tests/semanticdb/metac.expect
Original file line number Diff line number Diff line change
Expand Up @@ -3799,6 +3799,43 @@ Synthetics:
.map => *[Int]
[3:1..3:5):List => *.apply[Int]

expect/TargetName.scala
-----------------------

Summary:
Schema => SemanticDB v4
Uri => TargetName.scala
Text => empty
Language => Scala
Symbols => 7 entries
Occurrences => 15 entries

Symbols:
example/TargetName. => final object TargetName extends Object { self: TargetName.type => +4 decls }
example/TargetName.m(). => @targetName method m (param i: Int): Int
example/TargetName.m().(i) => param i: Int
example/TargetName.m(+1). => @targetName method m (param i: Int): Int
example/TargetName.m(+1).(i) => param i: Int
example/TargetName.m1(). => method m1 (param i: String): Int
example/TargetName.m1().(i) => param i: String

Occurrences:
[0:8..0:15): example <- example/
[2:7..2:17): TargetName <- example/TargetName.
[3:3..3:13): annotation -> scala/annotation/
[3:14..3:24): targetName -> scala/annotation/targetName#
[4:6..4:7): m <- example/TargetName.m().
[4:8..4:9): i <- example/TargetName.m().(i)
[4:11..4:14): Int -> scala/Int#
[5:3..5:13): annotation -> scala/annotation/
[5:14..5:24): targetName -> scala/annotation/targetName#
[6:6..6:7): m <- example/TargetName.m(+1).
[6:8..6:9): i <- example/TargetName.m(+1).(i)
[6:11..6:14): Int -> scala/Int#
[7:6..7:8): m1 <- example/TargetName.m1().
[7:9..7:10): i <- example/TargetName.m1().(i)
[7:12..7:18): String -> scala/Predef.String#

expect/Traits.scala
-------------------

Expand Down

0 comments on commit ea1116d

Please sign in to comment.