Skip to content

Commit

Permalink
Exclude synthesized parseArgument(given_FromString_Int) by @main
Browse files Browse the repository at this point in the history
By checking if the template's owner module symbol has an Invisible flag.
  • Loading branch information
tanishiking committed Aug 27, 2021
1 parent aef23bc commit a4f1400
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,10 @@ class ExtractSemanticDB extends Phase:
registerUseGuarded(None, privateWithin, spanOfSymbol(privateWithin, tree.span, tree.source), tree.source)
else if !excludeSymbol(tree.symbol) then
registerSymbol(tree.symbol, symbolKinds(tree))
case tree: Template if tree.symbol.owner.is(Invisible) =>
// do nothing
// exclude the symbols and synthetics generated by @main annotation
// (main class generated by @main has `Invisible` flag, see `MainProxies.scala`).
case tree: Template =>
val ctorSym = tree.constr.symbol
for parent <- tree.parentsOrDerived if parent.span.hasLength do
Expand Down
1 change: 1 addition & 0 deletions tests/semanticdb/expect/toplevel.expect.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ def combine/*<-_empty_::toplevel$package.combine(+1).*/(x/*<-_empty_::toplevel$p
def combine/*<-_empty_::toplevel$package.combine(+2).*/ = 0
def foo/*<-_empty_::toplevel$package.foo().*/ = "foo"
@main/*->scala::main#*/ def MyProgram/*<-_empty_::toplevel$package.MyProgram().*/(times/*<-_empty_::toplevel$package.MyProgram().(times)*/: Int/*->scala::Int#*/): Unit/*->scala::Unit#*/ = (1 to/*->scala::runtime::RichInt#to().*/ times/*->_empty_::toplevel$package.MyProgram().(times)*/) foreach/*->scala::collection::immutable::Range#foreach().*/ (_ => println/*->scala::Predef.println(+1).*/("hello"))
@main/*->scala::main#*/ def readInts/*<-_empty_::toplevel$package.readInts().*/(ints/*<-_empty_::toplevel$package.readInts().(ints)*/: Int/*->scala::Int#*/*): Unit/*->scala::Unit#*/ = println/*->scala::Predef.println(+1).*/(ints/*->_empty_::toplevel$package.readInts().(ints)*/.mkString/*->scala::collection::IterableOnceOps#mkString(+1).*/(","))
def fooRef/*<-_empty_::toplevel$package.fooRef().*/ = toplevel$package.foo/*->_empty_::toplevel$package.foo().*/
1 change: 1 addition & 0 deletions tests/semanticdb/expect/toplevel.scala
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ def combine(x: Int, y: Int, z: Int) = x + y + z
def combine = 0
def foo = "foo"
@main def MyProgram(times: Int): Unit = (1 to times) foreach (_ => println("hello"))
@main def readInts(ints: Int*): Unit = println(ints.mkString(","))
def fooRef = toplevel$package.foo
28 changes: 17 additions & 11 deletions tests/semanticdb/metac.expect
Original file line number Diff line number Diff line change
Expand Up @@ -4607,16 +4607,14 @@ Schema => SemanticDB v4
Uri => toplevel.scala
Text => empty
Language => Scala
Symbols => 19 entries
Occurrences => 34 entries
Synthetics => 2 entries
Symbols => 18 entries
Occurrences => 42 entries
Synthetics => 1 entries

Symbols:
_empty_/MyProgram# => final class MyProgram extends Object { self: MyProgram => +2 decls }
_empty_/MyProgram#`<init>`(). => primary ctor <init> (): MyProgram
_empty_/MyProgram#main(). => static method main (param args: Array[String]): Unit
_empty_/MyProgram#main().(args) => param args: Array[String]
_empty_/toplevel$package. => final package object _empty_ extends Object { self: _empty_.type => +8 decls }
_empty_/readInts# => final class readInts extends Object { self: readInts => +2 decls }
_empty_/toplevel$package. => final package object _empty_ extends Object { self: _empty_.type => +9 decls }
_empty_/toplevel$package.MyProgram(). => method MyProgram (param times: Int): Unit
_empty_/toplevel$package.MyProgram().(times) => param times: Int
_empty_/toplevel$package.a. => val inline method a ""
Expand All @@ -4630,7 +4628,8 @@ _empty_/toplevel$package.combine(+1).(z) => param z: Int
_empty_/toplevel$package.combine(+2). => method combine => Int
_empty_/toplevel$package.foo(). => method foo => String
_empty_/toplevel$package.fooRef(). => method fooRef => String
local0 => val local error: ParseError
_empty_/toplevel$package.readInts(). => method readInts (param ints: Int*): Unit
_empty_/toplevel$package.readInts().(ints) => param ints: Int*

Occurrences:
[0:11..0:12): a <- _empty_/toplevel$package.a.
Expand Down Expand Up @@ -4665,10 +4664,17 @@ Occurrences:
[5:46..5:51): times -> _empty_/toplevel$package.MyProgram().(times)
[5:53..5:60): foreach -> scala/collection/immutable/Range#foreach().
[5:67..5:74): println -> scala/Predef.println(+1).
[6:4..6:10): fooRef <- _empty_/toplevel$package.fooRef().
[6:30..6:33): foo -> _empty_/toplevel$package.foo().
[6:1..6:5): main -> scala/main#
[6:10..6:18): readInts <- _empty_/toplevel$package.readInts().
[6:19..6:23): ints <- _empty_/toplevel$package.readInts().(ints)
[6:25..6:28): Int -> scala/Int#
[6:32..6:36): Unit -> scala/Unit#
[6:39..6:46): println -> scala/Predef.println(+1).
[6:47..6:51): ints -> _empty_/toplevel$package.readInts().(ints)
[6:52..6:60): mkString -> scala/collection/IterableOnceOps#mkString(+1).
[7:4..7:10): fooRef <- _empty_/toplevel$package.fooRef().
[7:30..7:33): foo -> _empty_/toplevel$package.foo().

Synthetics:
[5:0..5:0): => *(given_FromString_Int)
[5:41..5:42):1 => intWrapper(*)

0 comments on commit a4f1400

Please sign in to comment.