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

Value class defined in a method gives spurious error. #6357

Closed
scabug opened this issue Sep 11, 2012 · 8 comments
Closed

Value class defined in a method gives spurious error. #6357

scabug opened this issue Sep 11, 2012 · 8 comments
Assignees
Milestone

Comments

@scabug
Copy link

scabug commented Sep 11, 2012

object K {
   def q = {
      final class Y(val j: Int) extends AnyVal
      3
   }
}
K.scala:3: error: recursive method q needs result type
      final class Y(val j: Int) extends AnyVal
                  ^

If the result type of q is explicitly annotated, the expected error message "value class may not be a local class" results.

@scabug
Copy link
Author

scabug commented Sep 11, 2012

Imported From: https://issues.scala-lang.org/browse/SI-6357?orig=1
Reporter: @harrah
Affected Versions: 2.10.0-M7
Other Milestones: 2.11.0-M1

@scabug
Copy link
Author

scabug commented Sep 13, 2012

@jsuereth said:
Another value class issue.

@scabug
Copy link
Author

scabug commented Sep 16, 2012

@odersky said:
Throwing this back, as it seems not critical and fairly type-checker generic. No doubt something triggered the recursion check.

@scabug
Copy link
Author

scabug commented Nov 14, 2012

@paulp said:
Took a casual stab with scala/scala#1626

@scabug
Copy link
Author

scabug commented Nov 17, 2012

@adriaanm said (edited on Nov 17, 2012 1:23:04 AM UTC):
Paul's patch also avoids a crash on this code, reported by Mirco in https://groups.google.com/d/msg/scala-internals/Cp-YuueuqAs/JvSU9LncdjwJ

object Foo {
  def main(args: Array[String]) = execute {
    class VInt(val v: Int) extends AnyVal
  }

  def execute(body: => Unit): Unit = body
} 

Is this something we want to support in 2.10.0?

@scabug
Copy link
Author

scabug commented Nov 17, 2012

@adriaanm said:
(Note that Mirco says this would hamper experimenting with value classes in the worksheet.)

@scabug
Copy link
Author

scabug commented Nov 17, 2012

@harrah said:
Note that Paul's patch avoids the crash, but will still report an error. It doesn't add support for local value classes, which are disallowed as a current implementation restriction.

@scabug
Copy link
Author

scabug commented Nov 19, 2012

@adriaanm said:
fixed in master by scala/scala#1626
backport for 2.10.1 pending as scala/scala#1647

@scabug scabug closed this as completed Nov 19, 2012
@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
Projects
None yet
Development

No branches or pull requests

2 participants