Compared to the scala pattern, lowercase letters are used for variables that must be matched by match. Top variables or backlinks are used for an existing variable to be used by the connector.
Try this instead:
def check[T: Manifest] = manifest[T] match { case `stringManifest` => "string" case `intManifest` => "int" case _ => "something else" }
The reason you get the "Unreachable code" stringManifest is stringManifest there is a variable in your stringManifest code that will always be bound to all manifest . Since it will always bind, this case will always be used, and the intManifest and _ cases will never be used.
Here's a short demo showing the behavior
val a = 1 val A = 3 List(1,2,3).foreach { case `a` => println("matched a") case A => println("matched A") case a => println("found " + a) }
This gives:
matched a found 2 matched A
source share