-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Don't add initializers to final fields assigned by a target construct…
…or (#333) ~~Should~~Does fix na-347 (confirmed locally that na-347 passes).
- Loading branch information
Showing
6 changed files
with
96 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
src/test/java/org/checkerframework/specimin/FinalFieldAssignTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package org.checkerframework.specimin; | ||
|
||
import java.io.IOException; | ||
import org.junit.Test; | ||
|
||
/** | ||
* This test checks that when Specimin targets a constructor that assigns a final field, it doesn't | ||
* introduce an incorrect and unneeded assignment to that field. | ||
*/ | ||
public class FinalFieldAssignTest { | ||
@Test | ||
public void runTest() throws IOException { | ||
SpeciminTestExecutor.runTestWithoutJarPaths( | ||
"finalfieldassign", | ||
new String[] {"com/example/Simple.java"}, | ||
new String[] {"com.example.Simple#Simple(int)"}); | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
src/test/resources/finalfieldassign/expected/com/example/Simple.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package com.example; | ||
|
||
class Simple { | ||
|
||
private final int x; | ||
|
||
private final int y; | ||
|
||
private Simple(int x) { | ||
this.x = x; | ||
y = 4; | ||
} | ||
} |
13 changes: 13 additions & 0 deletions
13
src/test/resources/finalfieldassign/input/com/example/Simple.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package com.example; | ||
|
||
class Simple { | ||
|
||
private final int x; | ||
|
||
private final int y; | ||
|
||
private Simple(int x) { | ||
this.x = x; | ||
y = 4; | ||
} | ||
} |