Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inference of HK constructor type argument fails #4347

Closed
scabug opened this issue Mar 17, 2011 · 2 comments
Closed

Inference of HK constructor type argument fails #4347

scabug opened this issue Mar 17, 2011 · 2 comments

Comments

@scabug
Copy link

scabug commented Mar 17, 2011

scala> class W[C[_], A](c: C[A])
defined class W

scala> def f[C[_], A](c: C[A]) = new W(c)
<console>:6: error: kinds of the type arguments (C[_],A) do not conform to the expected kinds of the type parameters (type C,type A) in class W.
C[_]'s type parameters do not match type C's expected parameters: type C has one type parameter, but type C (in class W) has one
       def f[C[_], A](c: C[A]) = new W(c)
           ^
<console>:6: error: kinds of the type arguments (C[_],A) do not conform to the expected kinds of the type parameters (type C,type A) in class W.
C[_]'s type parameters do not match type C's expected parameters: type C has one type parameter, but type C (in class W) has one
       def f[C[_], A](c: C[A]) = new W(c)
                                     ^

Specifying type parameters explicitly works:

scala> def f[C[_], A](c: C[A]) = new W[C, A](c)
f: [C[_],A](c: C[A])W[C,A]

Making W a case class also works:

scala> case class W[C[_], A](c: C[A])          
defined class W

scala> def f[C[_], A](c: C[A]) = W(c)    
f: [C[_],A](c: C[A])W[C,A]

Using f in the same context is ok too:

scala> def g[C[_], A](c: C[A]) = f(c)
g: [C[_],A](c: C[A])W[C,A]

So I guess inference fails only for constructors.
Tested on 2.8.1 and 2.9.0.r24471-b20110317020039

@scabug
Copy link
Author

scabug commented Mar 17, 2011

Imported From: https://issues.scala-lang.org/browse/SI-4347?orig=1
Reporter: Mikhail Vorozhtsov (mikhail.vorozhtsov)

@scabug
Copy link
Author

scabug commented Mar 17, 2011

@retronym said:
Duplicate of #4018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant