Skip to content

WeakReference content can't be compared with null. #1793

Closed
@nicolasstucki

Description

@nicolasstucki
def unapply[T <: AnyRef](wr: WeakReference[T]): Option[T] = {
    val x = wr.underlying.get
    if (x != null) Some(x) else None
  }

fails with

 33 |    if (x != null) Some(x) else None
    |       ^^^^^^^^^^^
    |       Values of types wr.underlying.java$lang$ref$WeakReference$$T and Null cannot be compared with == or !=

This happens when whitelisting scala/ref/WeakReference.scala.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions