Closed
Description
Below is the output of the REPL when pasting the content of the attached file. First of all, I wouldn't expect any error. Second, this error message is confusing:
class Option has one type parameter, but type F has one
$ ./scala-2.12.0-RC1/bin/scala
Welcome to Scala 2.12.0-RC1 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_102).
Type in expressions for evaluation. Or try :help.
scala> :paste
// Entering paste mode (ctrl-D to finish)
import scala.language.higherKinds
trait Foo[A] {
type F[_]
}
object Foo {
// two identical auxiliary type aliases
type Aux1[A, F0[_]] = Foo[A] { type F[X] = F0[X] }
type Aux2[A, F0[_]] = Foo[A] { type F[X] = F0[X] }
def bar[A, F[_]](a: A)(implicit ev: Foo.Aux1[A, F]): Foo.Aux1[A, F] = ev
implicit def ev: Foo.Aux1[String, Option] = new Foo[String] { type F[X] = Option[X] }
val fooStringOption: Foo.Aux2[String, Option] = bar("hi")
}
// Exiting paste mode, now interpreting.
<console>:26: error: inferred kinds of the type arguments (String,Option[X]) do not conform to the expected kinds of the type parameters (type A,type F).
Option[X]'s type parameters do not match type F's expected parameters:
class Option has one type parameter, but type F has one
val fooStringOption: Foo.Aux2[String, Option] = bar("hi")
^
<console>:26: error: type mismatch;
found : String("hi")
required: A
val fooStringOption: Foo.Aux2[String, Option] = bar("hi")
^
scala>
Metadata
Metadata
Assignees
Labels
No labels