-
-
Save cvogt/bebe358488d7c0be42e5 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 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