Skip to content

Opaque types don't seem to support strictEquality #5546

Closed
@SethTisue

Description

@SethTisue

with 0.11.0-RC1, this prints true:

import language.strictEquality

object O {

  opaque type Meters = Double
  object Meters { def apply(d: Double): Meters = d }
  implicit def eqM: Eq[Meters, Meters] = Eq

  opaque type Feet = Double
  object Feet { def apply(d: Double): Feet = d }
  implicit def eqF: Eq[Feet, Feet] = Eq

  def main(args: Array[String]): Unit =
    println(Feet(3) == Meters(3))

}

I'd hoped for a compile error ("Values of types Feet and Meters cannot be compared with == or !=")

happens in the REPL too, without the object wrapper, but I made this version too to make sure it wasn't a REPL artifact.

/cc @tpolecat

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