Created
March 15, 2015 00:09
-
-
Save paulp/c53f9820578a9ed773c9 to your computer and use it in GitHub Desktop.
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
// GUESS THE INFERRED TYPE FOR ys! | |
class :=[T,Q] | |
object := { | |
/** Ignore default */ | |
implicit def useProvided[P, D] : P := D = new (P := D) | |
/** Infer type argument to default */ | |
implicit def useDefault[D] : D := D = new (D := D) | |
} | |
object Test { | |
def foo[T](implicit default: T := String, tag: scala.reflect.ClassTag[T]): T = null.asInstanceOf[T] | |
def xs: Set[Int] = Set() | |
def ys = xs + foo | |
} | |
// SPOILER SPACE | |
// def xs: Set[Int] | |
// def ys: String |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment