Skip to content

eq null returns false for NewtypeWrapped #201

Description

@kamilkloch

Compare it with the wrapping via normal case class:

import monix.newtypes.{NewsubtypeWrapped, NewtypeWrapped}

import java.util.concurrent.atomic.AtomicReference

object NewTypeNull extends App {
  case class W1(value: String)

  type W2 = W2.Type
  object W2 extends NewtypeWrapped[String]

  type W3 = W3.Type
  object W3 extends NewsubtypeWrapped[String]

  val a1 = new AtomicReference[W1]()
  val a2 = new AtomicReference[W2]()
  val a3 = new AtomicReference[W3]()

  println(s"[a1.get(): ${a1.get()}], [a1.get() == null: ${a1.get() == null}], [a1.get() eq null: ${a1.get() eq null}]")
  println(s"[a2.get(): ${a2.get()}], [a2.get() == null: ${a2.get() == null}], [a2.get() eq null: ${a2.get() eq null}]")
  println(s"[a3.get(): ${a3.get()}], [a3.get() == null: ${a3.get() == null}], [a3.get() eq null: ${a3.get() eq null}]")
}

prints

[a1.get(): null], [a1.get() == null: true], [a1.get() eq null: true]
[a2.get(): null], [a2.get() == null: true], [a2.get() eq null: false]
[a3.get(): null], [a3.get() == null: true], [a3.get() eq null: true]

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions