Skip to content

Do not ignore anonymous ValDefs if they are givens #11570

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

Merged
merged 1 commit into from
Mar 3, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ class ExtractSemanticDB extends Phase:
tree match
case tree: DefDef =>
tree.paramss.foreach(_.foreach(param => registerSymbolSimple(param.symbol)))
case tree: ValDef if tree.symbol.is(Given) => traverse(tree.tpt)
case _ =>
if !tree.symbol.isGlobal then
localBodies(tree.symbol) = tree.rhs
Expand Down
5 changes: 5 additions & 0 deletions tests/semanticdb/expect/AnonymousGiven.expect.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package angiven

trait Foo/*<-angiven::Foo#*/

/*<-angiven::AnonymousGiven$package.*/def bar/*<-angiven::AnonymousGiven$package.bar().*/(using Foo/*->angiven::Foo#*/) = 42
5 changes: 5 additions & 0 deletions tests/semanticdb/expect/AnonymousGiven.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package angiven

trait Foo

def bar(using Foo) = 42
26 changes: 26 additions & 0 deletions tests/semanticdb/metac.expect
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,32 @@ Occurrences:
[18:6..18:9): foo <- example/Anonymous#foo.
[18:16..18:19): Foo -> example/Anonymous#Foo#

expect/AnonymousGiven.scala
---------------------------

Summary:
Schema => SemanticDB v4
Uri => AnonymousGiven.scala
Text => empty
Language => Scala
Symbols => 5 entries
Occurrences => 6 entries

Symbols:
angiven/AnonymousGiven$package. => final package object angiven
angiven/AnonymousGiven$package.bar(). => method bar
angiven/AnonymousGiven$package.bar().(x$1) => implicit param x$1
angiven/Foo# => trait Foo
angiven/Foo#`<init>`(). => primary ctor <init>

Occurrences:
[0:8..0:15): angiven <- angiven/
[2:0..2:0): <- angiven/Foo#`<init>`().
[2:6..2:9): Foo <- angiven/Foo#
[4:0..4:0): <- angiven/AnonymousGiven$package.
[4:4..4:7): bar <- angiven/AnonymousGiven$package.bar().
[4:14..4:17): Foo -> angiven/Foo#

expect/Classes.scala
--------------------

Expand Down