Skip to content

Instantly share code, notes, and snippets.

@paulp
Created March 15, 2015 00:09
Show Gist options
  • Save paulp/c53f9820578a9ed773c9 to your computer and use it in GitHub Desktop.
Save paulp/c53f9820578a9ed773c9 to your computer and use it in GitHub Desktop.
// 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