Skip to content

Instantly share code, notes, and snippets.

@retronym
Created January 24, 2010 11:15
Show Gist options
  • Select an option

  • Save retronym/285147 to your computer and use it in GitHub Desktop.

Select an option

Save retronym/285147 to your computer and use it in GitHub Desktop.
Determing Type Equality
trait T
trait U extends U
implicitly[T =:= T]
// compile error
// implicitly[T =:= U]
def typesEqual[A, B](implicit ev: A =:= B = null) = ev ne null
assert(typesEqual[T, T] == true)
assert(typesEqual[T, U] == false)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment