Skip to content

Instantly share code, notes, and snippets.

@cvogt
Forked from paulp/nope.scala
Last active August 29, 2015 14:17
Show Gist options
  • Save cvogt/bebe358488d7c0be42e5 to your computer and use it in GitHub Desktop.
Save cvogt/bebe358488d7c0be42e5 to your computer and use it in GitHub Desktop.
import Predef.{any2stringadd => _,_}
// 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
/*
Foo.scala:12: error: type mismatch;
found : String
required: Int
def ys = xs + foo
^
one error found
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment