question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Eq should extend AnyVal until Phantom types (now Erased terms) are ready

See original GitHub issue

That way, at least you can’t pass null as an instance. The suggestion is not mine, it comes from https://www.reddit.com/r/programming/comments/6elim6/announcing_dotty_012rc1_a_major_step_towards/dimg0nz/.

import dotty.DottyPredef.{eqAny => _, _}
class Foo
object Main {
  def bar[T](value: T)(implicit teq: Eq[T,T]) = value == value
  def main(args: Array[String]): Unit = bar(new Foo)(null) //<--
}

@nicolasstucki , can Eq be made a phantom type, now or later? I’m asking this at the design level for now.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
nicolasstuckicommented, May 28, 2018

Phantom types do not exist anymore.

With erased, now we can just do

def bar[T](value: T)(erased implicit teq: Eq[T,T]) = value == value
1reaction
oderskycommented, Jan 22, 2018

Hi Paolo, I am scanning the issues and thought maybe you want to take over some of the Eq stuff when you are here. So I am assigning issues as I see them.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Erased Definitions - Scala 3 - EPFL
We introduce erased terms to overcome this limitation: we are able to enforce the right constrains on terms at compile time. These terms...
Read more >
typelevel/theory - Gitter
Is there a concept of 'uninhabited' types in Haskell? yes and no. Logically speaking, data Void is the closest, but haskell is non...
Read more >
Existential types in Scala - Pedro Rodriguez
In this article we will be exploring existential types via a specific use case you may encounter in production code. But before we...
Read more >
Constraining future extensions of immutable classes
This means that for final classes, which can't be extended, immutability can be in- ferred from the type. The same is not true...
Read more >
Scala Reflection Library 2.13.1 - scala.reflect.runtime.JavaUniverse
Should not be instantiated directly, use scala.reflect.runtime.universe instead. Self Type: JavaUniverse; Source: JavaUniverse.scala. Linear Supertypes.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found