-
-
Save OlivierBlanvillain/41b66f22593093091d4308c40bebc396 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
trait C { type M; val m: M } | |
object Test { | |
// Arity 1 ------------------------------------------------------------------ | |
// Function1 | |
def m1(i: Int): Int = 1 | |
val f1Expected: Int => Int = m1 | |
val f1_Expected: Int => Int = m1 _ | |
val f1_Inferred = m1 _ | |
val f1Inferred = m1 | |
identity[Int => Int](f1_Inferred) | |
identity[Int => Int](f1Inferred) | |
// ImplicitFunction1 | |
def m4(implicit i: Int): Int = 4 | |
val f4Expected: implicit Int => Int = m4 | |
val f4_Expected: implicit Int => Int = m4 _ | |
val f4_Inferred = m4 _ | |
val f4Inferred = m4 | |
identity[implicit Int => Int](f4_Inferred) | |
identity[implicit Int => Int](f4Inferred) | |
// DependentFunction1 | |
def m7(c: C): c.M = c.m | |
val f7Expected: (c: C) => c.M = m7 | |
val f7_Expected: (c: C) => c.M = m7 _ | |
val f7_Inferred = m7 _ | |
val f7Inferred = m7 | |
identity[(c: C) => c.M](f7_Inferred) | |
identity[(c: C) => c.M](f7Inferred) | |
// Arity 2 ------------------------------------------------------------------ | |
// Function2 | |
def m2(i: Int, s: String): Int = 2 | |
val f2Expected: (Int, String) => Int = m2 | |
val f2_IExpected: (Int, String) => Int = m2 _ | |
val f2_Inferred = m2 _ | |
val f2Inferred = m2 | |
identity[(Int, String) => Int](f2_Inferred) | |
identity[(Int, String) => Int](f2Inferred) | |
// ImplicitFunction2 | |
def m5(implicit i: Int, s: String): Int = 5 | |
val f5Expected: implicit (Int, String) => Int = m5 | |
val f5_Expected: implicit (Int, String) => Int = m5 _ | |
val f5_Inferred = m5 _ | |
val f5Inferred = m5 | |
identity[implicit (Int, String) => Int](f5_Inferred) | |
identity[implicit (Int, String) => Int](f5Inferred) | |
// DependentFunction2 | |
def m9(c1: C, c2: C): c1.M | c2.M = c1.m | |
val f9Expected: (c1: C, c2: C) => c1.M | c2.M = m9 | |
val f9_Expected: (c1: C, c2: C) => c1.M | c2.M = m9 _ | |
val f9_Inferred = m9 _ | |
val f9Inferred = m9 | |
identity[(c1: C, c2: C) => c1.M | c2.M](f9_Inferred) | |
identity[(c1: C, c2: C) => c1.M | c2.M](f9Inferred) | |
// Function1[Function1] | |
def m8(i: Int)(s: String): Int = 8 | |
val f8Expected: Int => String => Int = m8 | |
val f8_Expected: Int => String => Int = m8 _ | |
val f8_Inferred = m8 _ | |
val f8Inferred = m8 | |
identity[Int => String => Int](f8_Inferred) | |
identity[Int => String => Int](f8Inferred) | |
// Function1[ImplicitFunction1] | |
def m6(i: Int)(implicit s: String): Int = 6 | |
val f6Expected: Int => implicit String => Int = m6 | |
val f6_Expected: Int => implicit String => Int = m6 _ | |
val f6_Inferred = m6 _ | |
val f6Inferred = m6 | |
identity[Int => implicit String => Int](f6_Inferred) | |
identity[Int => implicit String => Int](f6Inferred) | |
// Function1[DependentFunction1] | |
def mA(i: Int)(c: C): c.M = c.m | |
val fAExpected: Int => (c: C) => c.M = mA | |
val fA_Expected: Int => (c: C) => c.M = mA _ | |
val fA_Inferred = mA _ | |
val fAInferred = mA | |
identity[Int => (c: C) => c.M](fA_Inferred) | |
identity[Int => (c: C) => c.M](fAInferred) | |
// ImplicitFunction1[ImplicitFunction1] -- Can't be expressed as a method... | |
// ImplicitFunction1[Function1] -- Can't be expressed as a method... | |
// ImplicitFunction1[DependentFunction1] -- Can't be expressed as a method... | |
// DependentFunction1[Function1] | |
def mB(c: C)(s: String): C.M = c.m | |
val fBExpected: (c: C) => String => c.M = mB | |
val fB_Expected: (c: C) => String => c.M = mB _ | |
val fB_Inferred = mB _ | |
val fBInferred = mB | |
identity[(c: C) => String => c.M](fB_Inferred) | |
identity[(c: C) => String => c.M](fBInferred) | |
// DependentFunction1[ImplicitFunction1] | |
def mC(c: C)(implicit s: String): c.M = c.m | |
val fCExpected: (c: C) => implicit String => c.m = mC | |
val fC_Expected: (c: C) => implicit String => c.m = mC _ | |
val fC_Inferred = mC _ | |
val fCInferred = mC | |
identity[(c: C) => implicit String => c.m](fC_Inferred) | |
identity[(c: C) => implicit String => c.m](fCInferred) | |
// DependentFunction1[DependentFunction1] | |
def mD(c1: C)(c2: C): c1.M | c2.M = c1.m | |
val fDExpected: (c1: C) => (c2: C) => c1.M | c2.M = mD | |
val fD_Expected: (c1: C) => (c2: C) => c1.M | c2.M = mD _ | |
val fD_Inferred = mD _ | |
val fDInferred = mD | |
identity[(c1: C) => (c2: C) => c1.M | c2.M](fD_Inferred) | |
identity[(c1: C) => (c2: C) => c1.M | c2.M](fDInferred) | |
// Missing from the above: | |
// - interactions with by name | |
// - interactions with default arguments | |
// - interactions with inline method | |
// - interactions with inline arguments | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment