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

RemoveUnused: detect unused function parameters in Scala 3 #1937

Open
bjaglin opened this issue Feb 21, 2024 · 0 comments · May be fixed by #1951
Open

RemoveUnused: detect unused function parameters in Scala 3 #1937

bjaglin opened this issue Feb 21, 2024 · 0 comments · May be fixed by #1951

Comments

@bjaglin
Copy link
Collaborator

bjaglin commented Feb 21, 2024

Despite the presence of -Wunused:params and the explicit mention of it in scala/scala3#16157, I did not manage to get diagnostics (nor warnings) for unused parameters with scala 3.4.0-RC2, so the feature is currently documented/tested as Scala2-only.

We probably need to report this upstream.

$ metap ./scalafix-tests/input/target/jvm-3.4.0-RC2/meta/META-INF/semanticdb/scalafix-tests/input/src/main/scala/test/removeUnused/RemoveUnusedParams.scala.semanticdb 
scalafix-tests/input/src/main/scala/test/removeUnused/RemoveUnusedParams.scala
------------------------------------------------------------------------------

Summary:
Schema => SemanticDB v4
Uri => scalafix-tests/input/src/main/scala/test/removeUnused/RemoveUnusedParams.scala
Text => empty
Language => Scala
Symbols => 11 entries
Occurrences => 28 entries

Symbols:
local0 => param unused: String
local1 => param unused: String
local2 => param used: String
local3 => param unused: Long
local4 => implicit param string: String
test/removeUnused/UnusedParams. => final object UnusedParams extends Object { self: UnusedParams.type => +5 decls }
test/removeUnused/UnusedParams.f. => val method fFunction1[String, Unit]
test/removeUnused/UnusedParams.ff. => val method ffFunction1[String, Unit]
test/removeUnused/UnusedParams.fs. => val method fsFunction2[String, Long, Unit]
test/removeUnused/UnusedParams.g(). => method g(x: Function1[String, Unit]): Unit
test/removeUnused/UnusedParams.g().(x) => param x: Function1[String, Unit]

Occurrences:
[3:8..3:12) => test/
[3:13..3:25) <= test/removeUnused/
[5:7..5:19) <= test/removeUnused/UnusedParams.
[6:6..6:7) <= test/removeUnused/UnusedParams.f.
[6:9..6:15) => scala/Predef.String#
[6:19..6:23) => scala/Unit#
[6:26..6:32) <= local0
[6:36..6:43) => scala/Predef.println(+1).
[7:6..7:8) <= test/removeUnused/UnusedParams.ff.
[7:12..7:18) <= local1
[7:20..7:26) => scala/Predef.String#
[7:31..7:38) => scala/Predef.println(+1).
[8:6..8:8) <= test/removeUnused/UnusedParams.fs.
[8:12..8:16) <= local2
[8:18..8:24) => scala/Predef.String#
[8:26..8:32) <= local3
[8:34..8:38) => scala/Long#
[8:43..8:50) => scala/Predef.println(+1).
[8:51..8:55) => local2
[9:6..9:7) <= test/removeUnused/UnusedParams.g().
[9:8..9:9) <= test/removeUnused/UnusedParams.g().(x)
[9:11..9:17) => scala/Predef.String#
[9:21..9:25) => scala/Unit#
[9:28..9:32) => scala/Unit#
[9:35..9:38) => scala/Predef.`???`().
[10:2..10:3) => test/removeUnused/UnusedParams.g().
[10:13..10:19) <= local4
[10:23..10:30) => scala/Predef.println(+1).

Originally posted by @bjaglin in #1728 (comment)

@bjaglin bjaglin changed the title Despite the presence of -Wunused:params and the explicit mention of it in https://github.com/lampepfl/dotty/pull/16157, I did not manage to get diagnostics (nor warnings), so I am leaving this out for now RemoveUnused: detect unused function parameters in Scala 3 Feb 21, 2024
@bjaglin bjaglin linked a pull request Mar 3, 2024 that will close this issue
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.

1 participant