Skip to content

Early definition with private[this] val crashes scalac #6309

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

Closed
scabug opened this issue Sep 2, 2012 · 4 comments
Closed

Early definition with private[this] val crashes scalac #6309

scabug opened this issue Sep 2, 2012 · 4 comments
Assignees
Milestone

Comments

@scabug
Copy link

scabug commented Sep 2, 2012

Sorry in advance if this is disallowed, but the following crashes when the field is object-private:

package eyeshadow

trait A {
  def a: Int
}

object Test {
  def f(a: Int) = new {
    //private val b = a
    private[this] val b = a // crashes, sorry scalac
  } with A {
    def a = b
  }

  def main(args: Array[String]) {
    println(f(7).a)
  }
}

There is a failed assert
at scala.tools.nsc.transform.Constructors$ConstructorTransformer$$anonfun$transformClassTemplate$1.apply(Constructors.scala:160)
or
assert(fields.length == 1)

@scabug
Copy link
Author

scabug commented Sep 2, 2012

Imported From: https://issues.scala-lang.org/browse/SI-6309?orig=1
Reporter: @som-snytt
Affected Versions: 2.10.0-M7

@scabug
Copy link
Author

scabug commented Apr 21, 2013

@som-snytt said:
The sample code does not crash as of 2.11.0-M3.

@scabug
Copy link
Author

scabug commented May 30, 2013

@retronym said (edited on May 30, 2013 8:07:38 PM UTC):
Thanks for reporting the progression. We like to hear to hear those now and then.

Test case: scala/scala#2613

@scabug
Copy link
Author

scabug commented May 30, 2013

@som-snytt said:
You're welcome. Real gratitude would be an upvote on
http://stackoverflow.com/a/12239654/1296806
Why do my dumb easy answers get upvotes while interesting answers get crickets?

Maybe I make easy stuff sound hard and interesting stuff sound like cricket bait.

It's OK if you don't support the speculative import syntax in the comment. I'd forgotten about that.

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