File tree Expand file tree Collapse file tree 1 file changed +15
-6
lines changed Expand file tree Collapse file tree 1 file changed +15
-6
lines changed Original file line number Diff line number Diff line change 1
1
object Test extends App {
2
2
3
+ // toplevel contra
3
4
implicit def f : String => String = x => " f"
4
-
5
5
implicit def g : Object => String = x => " g"
6
-
7
6
def h (implicit x : String => String ) = x(" " )
7
+ assert(h == " f" , h)
8
8
9
+ // nested contra
9
10
implicit def fs : List [String => String ] = List (f)
10
-
11
11
implicit def gs : List [Object => String ] = List (g)
12
-
13
12
def hs (implicit xs : List [String => String ]) = xs.head(" " )
13
+ assert(hs == " f" , hs)
14
+
15
+ // covariant subapplication nested in toplevel contra
16
+ implicit def f2 : (Unit => String ) => String = x => " f2"
17
+ implicit def g2 : (Unit => Object ) => String = x => " g2"
18
+ def h2 (implicit x : (Unit => String ) => String ) = x(_ => " " )
19
+ assert(h2 == " f2" , h2)
14
20
15
- assert(h == " f" )
16
- assert(hs == " f" )
21
+ // covariant subapplication nested in nested contra
22
+ implicit def fs2 : List [(Unit => String ) => String ] = List (f2)
23
+ implicit def gs2 : List [(Unit => Object ) => String ] = List (g2)
24
+ def hs2 (implicit xs : List [(Unit => String ) => String ]) = xs.head(_ => " " )
25
+ assert(hs2 == " f2" , hs2)
17
26
}
You can’t perform that action at this time.
0 commit comments