8000 [SUPERSEDED] Constructor keeps ref to private local field by som-snytt · Pull Request #7611 · scala/scala · GitHub
[go: up one dir, main page]

Skip to content

[SUPERSEDED] Constructor keeps ref to private local field #7611

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
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Constructor keeps ref to private local field
Don't change reference to parameter.
The previous stability check omitted this case.
  • Loading branch information
som-snytt committed Jan 7, 2019
commit 4990b842c4976544c50df9ab0727cdb297a61cde
3 changes: 2 additions & 1 deletion src/compiler/scala/tools/nsc/transform/Constructors.scala
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,8 @@ abstract class Constructors extends Statics with Transform with TypingTransforme
private def isStationaryParamRef(sym: Symbol) = (
isParamRef(sym) &&
!(sym.isGetter && sym.accessed.isVariable) &&
!sym.isSetter
!sym.isSetter &&
!sym.isPrivateLocal
)

/*
Expand Down
1 change: 1 addition & 0 deletions test/files/run/t6880.check
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
good
8 changes: 8 additions & 0 deletions test/files/run/t6880.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

class C(private[this] var c: String) { c = "good" ; def f = c }

object Test {
def main(args: Array[String]) = println {
new C("bad").f
}
}
0