Skip to content

Opaque types don't seem to support strictEquality #5546

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
SethTisue opened this issue Nov 29, 2018 · 0 comments
Closed

Opaque types don't seem to support strictEquality #5546

SethTisue opened this issue Nov 29, 2018 · 0 comments

Comments

@SethTisue
Copy link
Member

SethTisue commented Nov 29, 2018

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

odersky added a commit that referenced this issue Dec 17, 2018
Fix #5546: Disallow comparing opaque types under -language:strictEqua…
nicolasstucki pushed a commit to dotty-staging/dotty that referenced this issue Jan 5, 2019
…tEquality

Disallow comparing different opaque types under -language:strictEquality
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant