Skip to content

Don't emit unused explicit parameter for ScalaJS facades #17240

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

Closed
rochala opened this issue Apr 13, 2023 · 3 comments
Closed

Don't emit unused explicit parameter for ScalaJS facades #17240

rochala opened this issue Apr 13, 2023 · 3 comments
Labels
area:linting Linting warnings enabled with -W or -Xlint area:scala.js itype:enhancement

Comments

@rochala
Copy link
Contributor

rochala commented Apr 13, 2023

Compiler version

3.3.1-RC1-bin-20230411-d577300-NIGHTLY

Minimized code

ScalaJS allows interoperability with Javascript by creating the facades. The definitions require to provide proper argument list, but the implementation never uses them and is always a call to js.native

@js.native
@JSImport("paper", "Rectangle")
class Rectangle() extends js.Object {
  def this(x1: Double, y1: Double, x2: Double, y2: Double) = this()
}

Output

@js.native
@JSImport("paper", "Rectangle")
class Rectangle() extends js.Object {
  def this(x1: Double, y1: Double, x2: Double, y2: Double) = this() // unused explicit parameter
}

Expectation

Unused warning is not thrown when js.native annotation is present in scope of the tree.

@rochala rochala added itype:enhancement area:scala.js area:linting Linting warnings enabled with -W or -Xlint labels Apr 13, 2023
@szymon-rd
Copy link
Contributor

It will be fixed with #17223

@sjrd
Copy link
Member

sjrd commented Apr 16, 2023

#17223 was merged, so I assume this is fixed. It also should make its way into 3.3.0 via #17280.

@keynmol
Copy link
Contributor

keynmol commented Mar 13, 2024

Did this make into 3.4.0?
I think the fix wasn't enough for class parameters:

//> using scala 3.4.0
//> using platform scala-js
//> using option -Wunused:all
//> using dep org.scala-js::scalajs-dom::2.8.0

import scala.scalajs.js.annotation.JSImport
import scalajs.js

@JSImport("chart.js/auto", "Chart")
@js.native
class Chart(ctx: String, config: js.Any) extends js.Any:
  def destroy(): Unit = js.native
  def update(): Unit  = js.native
Compiling project (Scala 3.4.0, Scala.js 1.15.0)
[warn] ./test.scala:11:13
[warn] unused explicit parameter
[warn] class Chart(ctx: String, config: js.Any) extends js.Any:
[warn]             ^^^
[warn] ./test.scala:11:26
[warn] unused explicit parameter
[warn] class Chart(ctx: String, config: js.Any) extends js.Any:
[warn]                          ^^^^^^
Compiled project (Scala 3.4.0, Scala.js 1.15.0)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:linting Linting warnings enabled with -W or -Xlint area:scala.js itype:enhancement
Projects
None yet
Development

No branches or pull requests

4 participants