Skip to content

Commit 38cb838

Browse files
authored
Merge pull request #738 from japgolly/topic/nowarn
Fix #735: New Reusability.derive emits warnings with -Wunused:nowarn
2 parents ad4aad5 + aa688c7 commit 38cb838

File tree

9 files changed

+17
-17
lines changed

9 files changed

+17
-17
lines changed

core/src/main/scala/japgolly/scalajs/react/internal/ReusabilityMacros.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ class ReusabilityMacros(val c: Context) extends MacroUtils {
9393
val typ = weakTypeOf[A]
9494
val ra = ReusabilityA(typ)
9595
val prep = init1.varDef(ra, q"new Reusability(null)")
96-
lazies += q"""@_root_.scala.annotation.nowarn("cat=unused") implicit lazy val ${TermName("_" + prep.decodedName)}: $ra = $Reusability.byName($prep)"""
96+
lazies += q"""implicit lazy val ${TermName("_" + prep.decodedName)}: $ra = $Reusability.byName($prep)"""
9797
lazy val completed: c.Expr[Reusability[A]] = {
9898
val inner = complete
9999
val impl = q"$prep = $inner"

core/src/main/scala/japgolly/scalajs/react/raw/Profiler.scala

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,10 @@ import scala.scalajs.js.annotation.JSGlobal
66
import scalajs.js
77

88
@js.native
9-
@nowarn("cat=unused")
109
trait Interaction extends js.Object {
11-
val __count : Int = js.native
12-
val id : Int = js.native
13-
val name : String = js.native
10+
val __count : Int = js.native
11+
val id : Int = js.native
12+
val name : String = js.native
1413
val timestamp: Double = js.native
1514
}
1615

core/src/main/scala/japgolly/scalajs/react/raw/events.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import scala.scalajs.js.annotation.JSName
77

88
/** https://facebook.github.io/react/docs/events.html */
99
@js.native
10-
@nowarn("cat=unused")
1110
trait SyntheticEvent[+DOMEventTarget <: dom.Node] extends js.Object {
1211
val bubbles : Boolean = js.native
1312
val cancelable : Boolean = js.native

doc/changelog/1.7.2.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# 1.7.2
2+
3+
* Fix: no longer generate warnings when `-Wunused:nowarn` is enabled

monocle-scalaz/src/main/scala/japgolly/scalajs/react/internal/MonocleExtStateSnapshot.scala

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@ trait MonocleExtStateSnapshot {
2222

2323
object MonocleExtStateSnapshot {
2424

25-
final class ObjectWithoutReuse(@nowarn("cat=unused") private val ε: StateSnapshot.type) extends AnyVal {
25+
final class ObjectWithoutReuse(private val ε: StateSnapshot.type) extends AnyVal {
2626
def zoomL[S, T](lens: monocle.Lens[S, T]) =
2727
StateSnapshot.zoom(lens.get)(lens.set)
2828
}
2929

30-
final class ObjectWithReuse(@nowarn("cat=unused") private val ε: StateSnapshot.withReuse.type) extends AnyVal {
30+
final class ObjectWithReuse(private val ε: StateSnapshot.withReuse.type) extends AnyVal {
3131
def zoomL[S, T](lens: monocle.Lens[S, T]) =
3232
StateSnapshot.withReuse.zoom(lens.get)(lens.set)
3333
}
@@ -61,7 +61,6 @@ object MonocleExtStateSnapshot {
6161
self.zoomStateOption(o.getOption)(o.set)
6262
}
6363

64-
@nowarn("cat=unused")
6564
final class InstanceWithReuse[A](private val self: StateSnapshot.InstanceMethodsWithReuse[A]) extends AnyVal {
6665

6766
@deprecated("This ability doesn't work. See https://github.com/japgolly/scalajs-react/issues/721 for an explanation, and https://japgolly.github.io/scalajs-react/#examples/state-snapshot-2 for the alternative.", "1.7.1")

monocle/src/main/scala/japgolly/scalajs/react/internal/MonocleExtStateSnapshot.scala

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,12 @@ trait MonocleExtStateSnapshot {
2222

2323
object MonocleExtStateSnapshot {
2424

25-
final class ObjectWithoutReuse(@nowarn("cat=unused") private val ε: StateSnapshot.type) extends AnyVal {
25+
final class ObjectWithoutReuse(private val ε: StateSnapshot.type) extends AnyVal {
2626
def zoomL[S, T](lens: monocle.Lens[S, T]) =
2727
StateSnapshot.zoom(lens.get)(lens.set)
2828
}
2929

30-
final class ObjectWithReuse(@nowarn("cat=unused") private val ε: StateSnapshot.withReuse.type) extends AnyVal {
30+
final class ObjectWithReuse(private val ε: StateSnapshot.withReuse.type) extends AnyVal {
3131
def zoomL[S, T](lens: monocle.Lens[S, T]) =
3232
StateSnapshot.withReuse.zoom(lens.get)(lens.set)
3333
}
@@ -54,7 +54,6 @@ object MonocleExtStateSnapshot {
5454
self.zoomState(lens.get)(lens.set)
5555
}
5656

57-
@nowarn("cat=unused")
5857
final class InstanceWithReuse[A](private val self: StateSnapshot.InstanceMethodsWithReuse[A]) extends AnyVal {
5958

6059
@deprecated("This ability doesn't work. See https://github.com/japgolly/scalajs-react/issues/721 for an explanation, and https://japgolly.github.io/scalajs-react/#examples/state-snapshot-2 for the alternative.", "1.7.1")

project/Build.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ object ScalajsReact {
6565
"-Wunused:implicits", // Warn if an implicit parameter is unused.
6666
"-Wunused:imports", // Warn if an import selector is not referenced.
6767
"-Wunused:locals", // Warn if a local definition is unused.
68+
"-Wunused:nowarn", // Warn if a @nowarn annotation does not suppress any warnings.
6869
"-Wunused:patvars", // Warn if a variable bound in a pattern is unused.
6970
"-Wunused:privates", // Warn if a private member is unused.
7071
"-Xlint:adapted-args", // An argument list was modified to match the receiver.

test/src/test/scala/japgolly/scalajs/react/core/RefTest.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ object RefTest extends TestSuite {
241241
def withRef() = {
242242
class Backend {
243243
val ref = Ref.toScalaComponent(InnerScala)
244-
@nowarn def render = Forwarder.withRef(ref)("noice")
244+
def render = Forwarder.withRef(ref)("noice")
245245
}
246246
val C = ScalaComponent.builder[Unit]("X").renderBackend[Backend].build
247247
ReactTestUtils.withNewBodyElement { mountNode =>
@@ -254,7 +254,7 @@ object RefTest extends TestSuite {
254254
def withRef2() = {
255255
class Backend {
256256
val ref = Ref.toScalaComponent[Int, Unit, InnerScalaBackend]
257-
@nowarn def render = Forwarder.withRef(ref)("noice")
257+
def render = Forwarder.withRef(ref)("noice")
258258
}
259259
val C = ScalaComponent.builder[Unit]("X").renderBackend[Backend].build
260260
ReactTestUtils.withNewBodyElement { mountNode =>
@@ -267,7 +267,7 @@ object RefTest extends TestSuite {
267267
def mappedRef() = {
268268
class Backend {
269269
val ref = Ref.toScalaComponent(InnerScala).map(_.backend.gimmeHtmlNow())
270-
@nowarn def render = Forwarder.withRef(ref)("noice")
270+
def render = Forwarder.withRef(ref)("noice")
271271
}
272272
val C = ScalaComponent.builder[Unit]("X").renderBackend[Backend].build
273273
ReactTestUtils.withNewBodyElement { mountNode =>

test/src/test/scala/japgolly/scalajs/react/core/ReusabilityTest.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,15 +81,15 @@ object ReusabilityTest extends TestSuite {
8181
final case class Suite[+Z](bms: Vector[BM[Z]]) extends Item[Z]
8282
final case class Blah1[+B](blah: Option[Blah1[B]]) extends Item[B]
8383
final case class Blah2[+C](blah: Option[Blah2[C]], i: Int) extends Item[C]
84+
final case class Blah3(i: Int) extends Item[Nothing]
8485

8586
final case class BM[+W](value: W)
8687

8788
implicit def reusabilityBM[A: Reusability]: Reusability[BM[A]] =
8889
Reusability.derive
8990

90-
implicit def reusability[H: Reusability]: Reusability[Item[H]] = {
91+
implicit def reusability[H: Reusability]: Reusability[Item[H]] =
9192
Reusability.derive
92-
}
9393
}
9494
}
9595

0 commit comments

Comments
 (0)