Closed
Description
Discovered in #2500 (comment). This code:
trait Type { type T }
object Type { implicit def Type[S]: Type { type T = S } = new Type { type T = S } }
trait Type1 { type T[_] }
object Type1 { implicit def Type1[S[_]]: Type1 { type T[A] = S[A] } = new Type1 { type T[A] = S[A] } }
trait Functor[F[_]] { def map[A,B](x: F[A])(f: A => B): F[B] }
object Functor { implicit object listFun extends Functor[List] { def map[A,B](ls: List[A])(f: A => B) = ls.map(f) } }
val map: implicit (A:Type,B:Type,F:Type1) => implicit (Functor[F.T]) => (F.T[A.T]) => (A.T => B.T) => F.T[B.T] =
implicit fun => x => f => fun.map(x)(f)
crashes the compiler with:
java.lang.IndexOutOfBoundsException: 2
Not sure if it should be in a separate issue, but this version:
val map: implicit (A:Type,B:Type,F:Type1,fun:Functor[F.T]) => (F.T[A.T]) => (A.T => B.T) => F.T[B.T] =
implicit (A:Type,B:Type,F:Type1,fun:Functor[F.T]) => x => f => fun.map(x)(f)
crashes the compiler with:
java.lang.Error: internal error: cannot turn method type (implicit A: Type, B: Type, F: Type1, fun: Functor[F.T]):
<error missing parameter type
The argument types of an anonymous function must be fully known. (SLS 8.5)
Expected type: ?
Missing type for parameter x>
=> Any => Any => F.T[Any] into closure
because it has internal parameter dependencies,
position = <1409..1409>, raw type = MethodType(List(A, B, F, fun), ...