Skip to content

Instantly share code, notes, and snippets.

@paulp
Created October 22, 2014 03:33
Show Gist options
  • Save paulp/66678e9b36e6883503dc to your computer and use it in GitHub Desktop.
Save paulp/66678e9b36e6883503dc to your computer and use it in GitHub Desktop.
trait Show[A]
// These formulations all compile.
class A {
implicit def z1[A]: Show[A] = null
def f[A](implicit z: Show[A]): String = null
f
f[Int]
f[Int](implicitly)
f(implicitly[Show[Int]])
}
// f(implicitly) requires that we mask out three implicit values, otherwise e.g.
// a.scala:23: error: ambiguous implicit values:
// both value StringCanBuildFrom in object Predef of type => scala.collection.generic.CanBuildFrom[String,Char,String]
// and method $conforms in object Predef of type [A]=> <:<[A,A]
// match expected type T
// f(implicitly)
// ^
// one error found
class B {
val fallbackStringCanBuildFrom = null
val StringCanBuildFrom = null
val $conforms = null
implicit def z1[A]: Show[A] = null
def f[A](implicit z: Show[A]): String = null
f(implicitly)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment