Created
January 24, 2010 11:15
-
-
Save retronym/285147 to your computer and use it in GitHub Desktop.
Determing Type Equality
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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