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

partial function defined in value class method results in spurious implementation restriction #7571

Closed
scabug opened this issue Jun 11, 2013 · 5 comments
Assignees
Milestone

Comments

@scabug
Copy link

scabug commented Jun 11, 2013

{code}
scala> class Foo(val a: Int) extends AnyVal { def foo = { {case x => x}: PartialFunction[Int, Int]; () }}
:7: error: implementation restriction: nested class is not allowed in value class
This restriction is planned to be removed in subsequent releases.
class Foo(val a: Int) extends AnyVal { def foo = { {case x => x}: PartialFunction[Int, Int]; () }}{code}

@scabug
Copy link
Author

scabug commented Jun 11, 2013

Imported From: https://issues.scala-lang.org/browse/SI-7571?orig=1
Reporter: @ijuma
Affected Versions: 2.10.0

@scabug
Copy link
Author

scabug commented Jun 11, 2013

@paulp said:
It's "spurious" in the sense that you shouldn't have to know that partial functions are implemented with anonymous objects; but it's genuine in the sense that partial functions are implemented with anonymous objects.

@scabug
Copy link
Author

scabug commented Jun 11, 2013

@retronym said:
I'm trying to remember exactly why the restriction exists (5d9cde105e); I suspect it is because we can't define an $outer pointer. But I don't think that is relevant for this case.

class Foo extends AnyVal {
  def foo = () => 0 // okay
  def bar = {case x => x} : PartialFunction[Int, Int] // should also be okay IMO
}

@scabug
Copy link
Author

scabug commented Jun 11, 2013

@retronym said:
scala/scala#2648

@scabug
Copy link
Author

scabug commented Jun 11, 2013

@paulp said:

I'm trying to remember exactly why the restriction exists (5d9cde105e); I suspect it is because we can't define an $outer pointer.

Yes, that's why.

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