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

case class cyclic instantiation error #4758

Closed
scabug opened this issue Jul 2, 2011 · 4 comments
Closed

case class cyclic instantiation error #4758

scabug opened this issue Jul 2, 2011 · 4 comments
Assignees
Milestone

Comments

@scabug
Copy link

scabug commented Jul 2, 2011

The following code fails to compile:

trait M[F[_]]  
case class S[X[_] <: M[X], A](x:X[A])

error: constructor of type S[X,A] cannot be uniquely instantiated to expected type Any
 --- because ---
cyclic instantiation
       case class S[X[_] <: M[X], A](x:X[A])                ^

The issue is specific to case classes because the workaround below is accepted without any cyclic instantiation error:

trait M[F[_]]  
class S[X[_] <: M[X], A](val x:X[A])
  
object S {
  def apply[X[_] <: M[X], A](x:X[A]):S[X, A] = new S[X, A](x)
}
@scabug
Copy link
Author

scabug commented Jul 2, 2011

Imported From: https://issues.scala-lang.org/browse/SI-4758?orig=1
Reporter: @sbocq
Affected Versions: 2.8.1, 2.9.0, 2.9.2

@scabug
Copy link
Author

scabug commented Jul 2, 2011

@paulp said:
Looks like synthetic method creation not dealing correctly with higher kinded types, something that completely redlines the concept of unsurprising.

What do you think adriaan, you or me?

// works
trait M[F[_]]  
class S[X[_] <: M[X], A](val x:X[A])
object S {
  def apply[X[_] <: M[X], A](x: X[A]): S[X, A] = new S[X, A](x)
  def unapply[X[_] <: M[X], A](p: S[X, A]) = Some(p.x)  
}
// seemingly equivalent, doesn't work
trait M[F[_]]  
case class S[X[_] <: M[X], A](x: X[A])

@scabug
Copy link
Author

scabug commented Jul 2, 2011

@paulp said:
Going with "you", bounce back to me if you like.

@scabug
Copy link
Author

scabug commented Dec 20, 2011

@paulp said:
Test case in aa41db72a4c4a50b .

@scabug scabug closed this as completed Dec 20, 2011
@scabug scabug added the quickfix label Apr 7, 2017
@scabug scabug added this to the 2.10.0 milestone Apr 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants