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 misbehaves with only implicit parameter list #10097

Closed
scabug opened this issue Dec 6, 2016 · 3 comments
Closed

case class misbehaves with only implicit parameter list #10097

scabug opened this issue Dec 6, 2016 · 3 comments
Assignees
Milestone

Comments

@scabug
Copy link

scabug commented Dec 6, 2016

Comment stolen from paulp’s explanation:

It should fail the compile with error: case classes without a parameter list are not allowed but the implicit parameter list fools it. Then it proceeds to act in a very confused manner, for instance turning all the explicitly written implicit parameters into case accessors.

scala> case class Bip(implicit x: Int, y: Int)
defined class Bip

scala> Bip()(1, 2).productArity
res4: Int = 2

But naturally it eventually inserts the empty parameter list, as seen above. Whereas:

scala> case class Bip2()(implicit x: Int, y: Int)
defined class Bip2

scala> Bip2()(1, 2).productArity
res5: Int = 0
@scabug
Copy link
Author

scabug commented Dec 6, 2016

Imported From: https://issues.scala-lang.org/browse/SI-10097?orig=1
Reporter: Greg Pfeil (sellout)
Affected Versions: 2.12.0
See #9494
Duplicates #8643

@scabug
Copy link
Author

scabug commented Dec 7, 2016

@som-snytt said:
Inconsistent, yet it's almost a feature, except for pattern matching:

scala> case class C(implicit c: Int)
defined class C

scala> implicit val i: Int = 42
i: Int = 42

scala> C() match { case x @ C() => x }
res0: C = C(42)

scala> C() match { case x @ C(i) => i }
<console>:15: error: wrong number of arguments for pattern C()
       C() match { case x @ C(i) => i }
                             ^

@scabug
Copy link
Author

scabug commented Dec 8, 2016

@som-snytt said:
scala/scala#5585

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

2 participants