Skip to content

Commit 6c0c384

Browse files
authored
Merge pull request scala#241 from scala/backport-lts-3.3-22573
Backport "fix: don't add `()` to semanticdb symbol for java variables" to 3.3 LTS
2 parents 16ffa97 + 31b57b3 commit 6c0c384

File tree

5 files changed

+47
-1
lines changed

5 files changed

+47
-1
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ class SemanticSymbolBuilder:
111111
addName(b, sym.name)
112112
if sym.is(Package) then b.append('/')
113113
else if sym.isType || sym.isAllOf(JavaModule) then b.append('#')
114-
else if sym.isOneOf(Method | Mutable)
114+
else if sym.is(Method) || (sym.is(Mutable) && !sym.is(JavaDefined))
115115
&& (!sym.is(StableRealizable) || sym.isConstructor) then
116116
b.append('('); addOverloadIdx(sym); b.append(").")
117117
else b.append('.')
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package example
2+
3+
import com.javacp.JavaStaticVar/*->com::javacp::JavaStaticVar#*/
4+
5+
class ScalaFoo/*<-example::ScalaFoo#*/ {
6+
val javaStaticVarFoo/*<-example::ScalaFoo#javaStaticVarFoo.*/ = JavaStaticVar/*->com::javacp::JavaStaticVar#*/.foo/*->com::javacp::JavaStaticVar#foo.*/
7+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
package example
2+
3+
import com.javacp.JavaStaticVar
4+
5+
class ScalaFoo {
6+
val javaStaticVarFoo = JavaStaticVar.foo
7+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
package com.javacp;
2+
3+
public class JavaStaticVar {
4+
public static int foo = 0;
5+
}

tests/semanticdb/metac.expect

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2249,6 +2249,33 @@ Synthetics:
22492249
[8:2..8:10):(x1, x1) => *(Tuple2(Int, Int))
22502250
[8:10..8:10): => *(Int, Int)
22512251

2252+
expect/JavaStaticVar.scala
2253+
--------------------------
2254+
2255+
Summary:
2256+
Schema => SemanticDB v4
2257+
Uri => JavaStaticVar.scala
2258+
Text => empty
2259+
Language => Scala
2260+
Symbols => 3 entries
2261+
Occurrences => 9 entries
2262+
2263+
Symbols:
2264+
example/ScalaFoo# => class ScalaFoo extends Object { self: ScalaFoo => +2 decls }
2265+
example/ScalaFoo#`<init>`(). => primary ctor <init> (): ScalaFoo
2266+
example/ScalaFoo#javaStaticVarFoo. => val method javaStaticVarFoo Int
2267+
2268+
Occurrences:
2269+
[0:8..0:15): example <- example/
2270+
[2:7..2:10): com -> com/
2271+
[2:11..2:17): javacp -> com/javacp/
2272+
[2:18..2:31): JavaStaticVar -> com/javacp/JavaStaticVar#
2273+
[4:6..4:14): ScalaFoo <- example/ScalaFoo#
2274+
[5:2..5:2): <- example/ScalaFoo#`<init>`().
2275+
[5:6..5:22): javaStaticVarFoo <- example/ScalaFoo#javaStaticVarFoo.
2276+
[5:25..5:38): JavaStaticVar -> com/javacp/JavaStaticVar#
2277+
[5:39..5:42): foo -> com/javacp/JavaStaticVar#foo.
2278+
22522279
expect/Local.scala
22532280
------------------
22542281

0 commit comments

Comments
 (0)