Created
January 28, 2016 13:34
-
-
Save SohumB/49da049fd69a7331ece0 to your computer and use it in GitHub Desktop.
This file contains 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
import scala.reflect.runtime.universe.{TypeTag, typeOf} | |
trait Foo[T] | |
class Baz extends Foo[String] | |
def foo[T <: String:TypeTag]: Class[_ <: Foo[T]] = typeOf[T] match { | |
case t if t =:= typeOf[String] => classOf[Baz] | |
} | |
// [error] ...: type mismatch; | |
// [error] found : Class[Baz](classOf[Baz]) | |
// [error] required: Class[? <: Foo[T]] | |
// [error] Note: Baz >: ? <: Foo[T], but Java-defined class Class is invariant in type T. | |
// [error] You may wish to investigate a wildcard type such as `_ >: ? <: Foo[T]`. (SLS 3.2.10) | |
// [error] case t if t =:= typeOf[String] => classOf[Baz] | |
// [error] ^ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment