Skip to content

value class restrictions should honor self type #5962

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

Open
scabug opened this issue Jun 21, 2012 · 5 comments
Open

value class restrictions should honor self type #5962

scabug opened this issue Jun 21, 2012 · 5 comments

Comments

@scabug
Copy link

scabug commented Jun 21, 2012

trait Foo {
  self: bar.type =>
  
  final class V(val x: Int) extends AnyVal
  // ./a.scala:4: error: value class may not be a member of another class
  //   final class V(val x: Int) extends AnyVal
  //               ^
  // one error found
}

object bar extends Foo { }

This should compile, else we are robbed of all the mechanisms by which one normally can partition a large object into its constituent parts.

@scabug
Copy link
Author

scabug commented Jun 21, 2012

Imported From: https://issues.scala-lang.org/browse/SI-5962?orig=1
Reporter: @paulp

@scabug
Copy link
Author

scabug commented Jul 3, 2012

@adriaanm said (edited on Jul 3, 2012 4:07:00 PM UTC):
This would be hard to spec: "a class with a self type that's a singleton type referring to an accessible symbol does not need an outer pointer, and may thus serve as an outer class of a value class (which cannot accommodate an outer pointer)".

Instead, it seems more likely that we'll at one point support multi-field value classes,
only to then realize that the outer pointer is in fact not needed here and fall back to single-field value class.

(I hope I correctly paraphrased Martin's thoughts from today's meeting.)

@scabug
Copy link
Author

scabug commented Jul 3, 2012

@paulp said:
Right now the spec says "C is either a toplevel class or is a member of a statically accessible object." In what sense is V not a member of a statically accessible object? If there is a V, is V not a member of bar, the statically accessible object?

@scabug
Copy link
Author

scabug commented Oct 30, 2012

@paulp said:
I'm not sure by what route this ended up on the blockers for 2.10.0 list, but as the opener, I say it can certainly wait. (Nor does it look especially easy to fix, at least not in the face of separate compilation.)

@scabug
Copy link
Author

scabug commented Oct 30, 2012

@adriaanm said:
it ended up here so we could discuss it -- i agree it's not a blocker

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