Skip to content
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

SemanticDB does not include symbol occurrence of constructor #18319

Closed
swachter opened this issue Aug 1, 2023 · 1 comment · Fixed by #18325
Closed

SemanticDB does not include symbol occurrence of constructor #18319

swachter opened this issue Aug 1, 2023 · 1 comment · Fixed by #18325

Comments

@swachter
Copy link
Contributor

swachter commented Aug 1, 2023

Compiler version

3.3.0

Minimized code

case class Test(i: Int)

Output

The semanticdb file contains no symbol occurrence for the constructor when compiled under Scala 3.3.0. When compiled under Scala 2.13.11 and using the semanticdb-scalac plugin a symbol occurrence is included for the constructor.

Output of the metap utility (cf. semanticdb-guide):

Semanticdb file produced by Scala 3.3.0:

src/main/scala/simple/Test.scala
--------------------------------

Summary:
Schema => SemanticDB v4
Uri => src/main/scala/simple/Test.scala
Text => non-empty
Language => Scala
Symbols => 14 entries
Occurrences => 3 entries

Symbols:
_empty_/Test# => case class Test extends Object with Product with Serializable { self: Test => +5 decls }
_empty_/Test#_1(). => method _1=> Int
_empty_/Test#`<init>`(). => primary ctor <init>(val i: Int): Test
_empty_/Test#`<init>`().(i) => val param i: Int
_empty_/Test#copy$default$1(). => method copy$default$1=> Int @uncheckedVariance
_empty_/Test#copy(). => method copy(i: Int): Test
_empty_/Test#copy().(i) => param i: Int
_empty_/Test#i. => val method iInt
_empty_/Test. => final object Test extends Object { self: Test.type => +4 decls }
_empty_/Test.apply(). => method apply(i: Int): Test
_empty_/Test.apply().(i) => param i: Int
_empty_/Test.toString(). => method toString=> String <: scala/Any#toString().
_empty_/Test.unapply(). => method unapply(x$1: Test): Test
_empty_/Test.unapply().(x$1) => param x$1: Test

Occurrences:
[0:11..0:15): Test <= _empty_/Test#
[0:16..0:17): i <= _empty_/Test#i.
[0:19..0:22): Int => scala/Int#

Semanticdb file produced by semanticdb-scalac plugin under Scala 2.13.11:

src/main/scala/simple/Test.scala
--------------------------------

Summary:
Schema => SemanticDB v4
Uri => src/main/scala/simple/Test.scala
Text => non-empty
Language => Scala
Symbols => 29 entries
Occurrences => 4 entries

Symbols:
_empty_/Test# => case class Test extends AnyRef with Product with Serializable { +13 decls }
_empty_/Test#`<init>`(). => primary ctor <init>(val i: Int)
_empty_/Test#`<init>`().(i) => val param i: Int
_empty_/Test#canEqual(). => method canEqual(x$1: Any): Boolean <: scala/Equals#canEqual().
_empty_/Test#canEqual().(x$1) => param x$1: Any
_empty_/Test#copy$default$1(). => method copy$default$1: Int @uncheckedVariance
_empty_/Test#copy(). => method copy(i: Int): Test
_empty_/Test#copy().(i) => default param i: Int
_empty_/Test#equals(). => method equals(x$1: Any): Boolean <: scala/Equals#equals()., java/lang/Object#equals()., scala/Any#equals().
_empty_/Test#equals().(x$1) => param x$1: Any
_empty_/Test#hashCode(). => method hashCode(): Int <: java/lang/Object#hashCode()., scala/Any#hashCode().
_empty_/Test#i. => val method i: Int
_empty_/Test#productArity(). => method productArity: Int <: scala/Product#productArity().
_empty_/Test#productElement(). => method productElement(x$1: Int): Any <: scala/Product#productElement().
_empty_/Test#productElement().(x$1) => param x$1: Int
_empty_/Test#productElementName(). => method productElementName(x$1: Int): String <: scala/Product#productElementName().
_empty_/Test#productElementName().(x$1) => param x$1: Int
_empty_/Test#productIterator(). => method productIterator: Iterator[Any] <: scala/Product#productIterator().
_empty_/Test#productPrefix(). => method productPrefix: String <: scala/Product#productPrefix().
_empty_/Test#toString(). => method toString(): String <: java/lang/Object#toString()., scala/Any#toString().
_empty_/Test. => final object Test extends AbstractFunction1[Int, Test] with Serializable { +4 decls }
_empty_/Test.apply(). => method apply(i: Int): Test <: scala/Function1#apply().
_empty_/Test.apply().(i) => param i: Int
_empty_/Test.toString(). => final method toString(): String <: scala/Function1#toString()., java/lang/Object#toString()., scala/Any#toString().
_empty_/Test.unapply(). => method unapply(x$0: Test): Option[Int]
_empty_/Test.unapply().(x$0) => param x$0: Test
_empty_/Test.writeReplace(). => private method writeReplace(): Object
local0 => var local acc: Int
local1 => val local Test$1: Test

Occurrences:
[0:11..0:15): Test <= _empty_/Test#
[0:15..0:15):  <= _empty_/Test#`<init>`().
[0:16..0:17): i <= _empty_/Test#i.
[0:19..0:22): Int => scala/Int#

Expectation

The symbol occurrence for the constructor should be present.

[0:15..0:15):  <= _empty_/Test#`<init>`().
@swachter swachter added itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label labels Aug 1, 2023
@dwijnand dwijnand added area:semanticdb and removed stat:needs triage Every issue needs to have an "area" and "itype" label labels Aug 1, 2023
@bishabosha bishabosha assigned bishabosha and unassigned bishabosha Aug 2, 2023
@bishabosha
Copy link
Member

bishabosha commented Aug 2, 2023

primary cause: didn't check for primary constructor in the namePresentInSource check.

bishabosha added a commit that referenced this issue Aug 3, 2023
fixes #18319

note that we still do not produce occurrences for the primary
constructor's own parameters, it seems in scala 2 implementation only
the local backing field has occurrences.
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.

3 participants