Skip to content

Don't generate outer accessors for classes transitively nested in terms #11411

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

Merged
merged 3 commits into from
Feb 25, 2021

Conversation

odersky
Copy link
Contributor

@odersky odersky commented Feb 14, 2021

Fixes #11367

@odersky odersky requested a review from retronym February 14, 2021 12:14
@odersky
Copy link
Contributor Author

odersky commented Feb 14, 2021

Who can add a bytecode test for this? Or some other way to verify that no outer field is generated?

@retronym
Copy link
Member

You could assert the absence of the outer field using Java reflection:

class C { 
  def foo = {
    class D {
      class E
    }
    class F
    val outerFields = classOf[F].getDeclaredFields.filter(_.getName.contains("$outer"))
    assert(outerFields.isEmpty, outerFields.toString)
  }
}
object Test {
  def main(args: Array[String]): Unit = {
    new C().foo
  }
}

@odersky
Copy link
Contributor Author

odersky commented Feb 15, 2021

Thanks for the suggestion, Jason!

@odersky odersky merged commit 7967eac into scala:master Feb 25, 2021
@odersky odersky deleted the fix-11367 branch February 25, 2021 09:02
@Kordyjan Kordyjan added this to the 3.0.0 milestone Aug 2, 2023
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.

Outer field suppression based on "local instantiation" should consider transitive owners
3 participants