forked from scala/scala
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9ba5196
commit d948e27
Showing
1 changed file
with
38 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
//Copied from Scalaz - http://scalaz.googlecode.com/svn/continuous/latest/browse.sxr/scalaz/PartialApplys.scala.html | ||
trait PartialApply1Of2[T[_, _], A] { | ||
type Apply[B] = T[A, B] | ||
|
||
type Flip[B] = T[B, A] | ||
} | ||
|
||
object Test { | ||
trait TypeWithHigherKindParam[D[_]] | ||
implicit def function[D[_]](t: TypeWithHigherKindParam[D]) = 1 | ||
val param: TypeWithHigherKindParam[PartialApply1Of2[Tuple2, Int]#Apply] = null | ||
|
||
function[PartialApply1Of2[Tuple2, Int]#Apply](param): Int //Compiles | ||
function(param) //Does not compile | ||
param: Int //Does not compile | ||
} | ||
|
||
object Test2 { | ||
//More complex variations of the same problem: | ||
trait Exp[+T] | ||
|
||
trait TypeWithHigherKindParam[D[_]] | ||
def function[D[_]](t: Exp[TypeWithHigherKindParam[D]]) = null | ||
val param: Exp[TypeWithHigherKindParam[PartialApply1Of2[Tuple2, Int]#Apply]] = null | ||
function[PartialApply1Of2[Tuple2, Int]#Apply](param) | ||
function(param) | ||
} | ||
|
||
object Test3 { | ||
trait Exp[+T] | ||
|
||
trait TypeWithHigherKindParam[C[X] <: Traversable[X], D[_]] | ||
|
||
def function[C[X] <: Traversable[X], D[_]](t: Exp[TypeWithHigherKindParam[C,D]]) = null | ||
val param: Exp[TypeWithHigherKindParam[Traversable, PartialApply1Of2[Tuple2, Int]#Apply]] = null | ||
function[Traversable, PartialApply1Of2[Tuple2, Int]#Apply](param) | ||
function(param) | ||
} |