Created
May 6, 2015 19:11
-
-
Save paulp/6e95cbda72e845c63da6 to your computer and use it in GitHub Desktop.
classic scala
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
// Wherein scala assigns the constant type String("a") to a string "b". | |
// Idea by retronym in https://issues.scala-lang.org/browse/SI-7730 | |
scala> def f[A <: AnyRef: scala.reflect.ClassTag](x: Any) = x match { case (a: A, x: (a.type forSome { type T })) => ((a, x)) } | |
warning: there was one feature warning; re-run with -feature for details | |
f: [A <: AnyRef](x: Any)(implicit evidence$1: scala.reflect.ClassTag[A])(A, A) | |
scala> final val x = "a" | |
x: String("a") = a | |
scala> f[x.type](x -> x) | |
res0: (String("a"), String("a")) = (a,a) | |
scala> f[x.type](x -> "b") | |
res1: (String("a"), String("a")) = (a,b) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment