Created
July 11, 2012 07:34
-
-
Save tonymorris/3088749 to your computer and use it in GitHub Desktop.
Scala WTF
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
case class Person(name: String, age: Int) | |
object Person | |
case class OtherPerson(name: String, age: Int) | |
object T { | |
def ap[A, B, C](f: (A, B) => C)(a: A, b: B): C = | |
f(a, b) | |
// This fails the compiler[1]... | |
// val p = ap(Person)("Fred", 20) | |
val q = ap(Person(_: String, _: Int))("Fred", 20) | |
// ...but this doesn't. Why? | |
val op = ap(OtherPerson)("Fred", 20) | |
} | |
/* | |
[1] | |
error: type mismatch; | |
found : Person.type (with underlying type object Person) | |
required: (?, ?) => ? | |
val p = ap(Person)("Fred", 20) | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
https://issues.scala-lang.org/browse/SI-3664