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

Issue/4717 #576

Merged
merged 4 commits into from
May 21, 2012
Merged

Issue/4717 #576

merged 4 commits into from
May 21, 2012

Conversation

axel22
Copy link
Contributor

@axel22 axel22 commented May 18, 2012

Fixes SI-4717.
A lazy val declared inside an anonymous class inside a specialized
context no longer crashes Duplicators.

Previously, a duplicated lazy val was assigned to the wrong owner
in Duplicators:

class Foo[@specialized(Boolean) A] {
  def x[B >: A]: Unit = new Bounds[B] {
    lazy val it = ???  // def or val okay
  }
}

Above, the it in $anon in x$mcZ$sp had its owner set to x$mcZ$sp
instead of $anon. This crashed the typer when it had to retype its
lazy accessor, because there was no lazy var it in $anon.
Furthermore, the duplicated symbol wasn't being added to the list of
declarations of $anon.

Changes:

  1. invalidate in Duplicators takes an additional parameter which is
    the new owner of the new symbol that has to be duplicated. If this parameter
    is set to NoSymbol, then the new owner is context.owner, as before.
  2. the newly created lazy val symbol is being added to the list of
    declarations of its new owner, provided that the owner is a class.

Review by dragos.
@mention dragos
review by @dragos

Aleksandar Prokopec added 4 commits May 15, 2012 15:50
A lazy val declared inside an anonymous class inside a specialized
context no longer crashes Duplicators.

Previously, a duplicated lazy val was assigned to the wrong owner
in Duplicators:

    def x[B >: A]: Unit = new Bounds[B] {
      lazy val it = ???  // def or val okay
    }

Above, the `it` in `$anon` in `x$mcZ$sp` had its owner set to `x$mcZ$sp`
instead of `$anon`. This crashed the typer when it had to retype its
lazy accessor, because there was no `lazy var it` in `$anon$`.
Furthermore, the duplicated symbol wasn't being added to the list of
declarations of `$anon`.

Changes:
1) `invalidate` in Duplicators takes an additional parameter which is
the new owner of the new symbol that has to be duplicated. If this parameter
is set to `NoSymbol`, then the new owner is `context.owner`, as before.
2) the newly created lazy val symbol is being added to the list of
declarations of its new owner.

Removes debugging output from the previous commit.

Review by dragos.
@mention dragos
Only adding a lazy val into list of declarations if the owner is a class.

Review by dragos.
@mention dragos
Should be checking if the owner of the new symbol is a class, not the new symbol itself.
@scala-jenkins
Copy link

jenkins job pr-scala-testsuite-linux-opt: Success - https://scala-webapps.epfl.ch/jenkins/job/pr-scala-testsuite-linux-opt/124/

@dragos
Copy link
Contributor

dragos commented May 21, 2012

Looks good to me! Thanks!

adriaanm added a commit that referenced this pull request May 21, 2012
Fix SI-4717: lazy val declared inside an anonymous class inside a specialized
context no longer crashes Duplicators.
@adriaanm adriaanm merged commit 08334b0 into scala:master May 21, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants