ghik / silencer

Scala compiler plugin for warning suppression
Apache License 2.0
255 stars 33 forks source link

cannot suppress scala 2.12.2 -Ywarn-unused:params for Scala.js js.native method #4

Closed kwisatzook closed 7 years ago

kwisatzook commented 7 years ago

See JsCryptoNative.getRandomValues at the bottom. @silent doesn't seem to work no matter where I put it.

import scala.scalajs.js
import scala.scalajs.js.annotation._
import scala.scalajs.js.typedarray.ArrayBufferView

import com.github.ghik.silencer.silent

@js.native
@JSGlobalScope
object WindowGlobalScope extends js.Object {
  def window: js.UndefOr[JsWindowNative] = js.native
}

@js.native
trait JsWindowNative extends js.Object {
  def crypto: js.UndefOr[JsCryptoNative] = js.native
  def msCrypto: js.UndefOr[JsCryptoNative] = js.native
}

@js.native
@silent
trait JsCryptoNative extends js.Object {
  @silent
  def getRandomValues( // linter:ignore UnusedParameter
      @silent t: ArrayBufferView @silent
    ): Unit @silent = js.native
}

Any idea as to why and any suggestions on a workaround? Much thanks.

ghik commented 7 years ago

Hello @kwisatzook

I can't reproduce your problem. For me putting @silent annotation on the parameter works just fine. Please look for any problems with your project's setup. Maybe somehow the silencer plugin was not picked up by the build tool or IDE.

Here's a minimal project where I tried to reproduce it: scalajs-silencer-bug.zip. sbt compile works just fine and yields no warnings. When the @silent annotation is removed, the warning appears, as expected.

kwisatzook commented 7 years ago

Ah, thanks. It wasn't set up properly. Even though the plugin was downloaded and the library was available, the compiler plugin wasn't enabled because the setting didn't propagate to the cross project. I figured out how to make that happen. Thanks.