-
Notifications
You must be signed in to change notification settings - Fork 356
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Changed the name of the method, enhanced the body, and transferred th…
…e method to NullnessAnnotatedTypeFactory.java to make it local for Nullness-related inference rather than for all checkers. Also added a test case for the corresponding issue in the ainfer-nullness tests.
- Loading branch information
1 parent
5b642c3
commit d7acb57
Showing
6 changed files
with
293 additions
and
25 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
94 changes: 94 additions & 0 deletions
94
.../input-annotation-files/Game-org.checkerframework.checker.nullness.KeyForSubchecker.ajava
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,94 @@ | ||
import org.checkerframework.checker.initialization.qual.*; | ||
import org.checkerframework.checker.nullness.qual.*; | ||
|
||
@org.checkerframework.framework.qual.AnnotatedFor("org.checkerframework.checker.nullness.KeyForSubchecker") | ||
interface Game { | ||
|
||
@org.checkerframework.dataflow.qual.SideEffectFree | ||
void newGame(); | ||
} | ||
|
||
@org.checkerframework.framework.qual.AnnotatedFor("org.checkerframework.checker.nullness.KeyForSubchecker") | ||
class // package-private | ||
GameImpl implements // package-private | ||
Game { | ||
|
||
private MoveValidator moveValidator; | ||
|
||
@org.checkerframework.dataflow.qual.Impure | ||
public GameImpl(MoveValidator mValidator) { | ||
mValidator.setGame(this); | ||
moveValidator = mValidator; | ||
} | ||
|
||
@org.checkerframework.dataflow.qual.SideEffectFree | ||
public GameImpl() { | ||
} | ||
|
||
@org.checkerframework.dataflow.qual.SideEffectFree | ||
public void newGame( // package-private | ||
GameImpl this) { | ||
// Implementation of starting a new game | ||
} | ||
} | ||
|
||
@org.checkerframework.framework.qual.AnnotatedFor("org.checkerframework.checker.nullness.KeyForSubchecker") | ||
interface MoveValidator { | ||
|
||
@org.checkerframework.dataflow.qual.Impure | ||
void setGame( MoveValidator this, Game game); | ||
} | ||
|
||
@org.checkerframework.framework.qual.AnnotatedFor("org.checkerframework.checker.nullness.KeyForSubchecker") | ||
class // package-private | ||
PlayerDependentMoveValidator implements // package-private | ||
MoveValidator { | ||
|
||
private Game game; | ||
|
||
private MoveValidator blackMoveValidator = new SimpleMoveValidator(); | ||
|
||
@org.checkerframework.dataflow.qual.Impure | ||
public void setGame( // package-private | ||
PlayerDependentMoveValidator this, Game game) { | ||
this.game = game; | ||
} | ||
|
||
@org.checkerframework.dataflow.qual.SideEffectFree | ||
public PlayerDependentMoveValidator() { | ||
} | ||
|
||
@org.checkerframework.dataflow.qual.Impure | ||
public PlayerDependentMoveValidator( Game game) { | ||
this.setGame(game); | ||
blackMoveValidator.setGame(game); | ||
} | ||
} | ||
|
||
@org.checkerframework.framework.qual.AnnotatedFor("org.checkerframework.checker.nullness.KeyForSubchecker") | ||
class // package-private | ||
SimpleMoveValidator implements // package-private | ||
MoveValidator { | ||
|
||
private Game game; | ||
|
||
@org.checkerframework.dataflow.qual.Impure | ||
public void setGame( // package-private | ||
SimpleMoveValidator this, Game game) { | ||
this.game = game; | ||
} | ||
|
||
@org.checkerframework.dataflow.qual.SideEffectFree | ||
public SimpleMoveValidator() { | ||
} | ||
|
||
@org.checkerframework.dataflow.qual.Pure | ||
public MoveValidator createMoveValidator() { | ||
return new PlayerDependentMoveValidator(game); | ||
} | ||
public void test(){ | ||
PlayerDependentMoveValidator g1 = | ||
new PlayerDependentMoveValidator(game); | ||
this.game = g1.game; | ||
} | ||
} |
101 changes: 101 additions & 0 deletions
101
...s/input-annotation-files/Game-org.checkerframework.checker.nullness.NullnessChecker.ajava
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,101 @@ | ||
import org.checkerframework.checker.initialization.qual.*; | ||
import org.checkerframework.checker.nullness.qual.*; | ||
|
||
@org.checkerframework.framework.qual.AnnotatedFor("org.checkerframework.checker.nullness.NullnessChecker") | ||
interface Game { | ||
|
||
@org.checkerframework.dataflow.qual.SideEffectFree | ||
void newGame(); | ||
} | ||
|
||
@org.checkerframework.framework.qual.AnnotatedFor("org.checkerframework.checker.nullness.NullnessChecker") | ||
class // package-private | ||
GameImpl implements // package-private | ||
Game { | ||
|
||
private @org.checkerframework.checker.initialization.qual.Initialized @org.checkerframework.checker.nullness.qual.MonotonicNonNull MoveValidator moveValidator; | ||
|
||
@org.checkerframework.checker.nullness.qual.EnsuresNonNull({ "this.moveValidator" }) | ||
@org.checkerframework.dataflow.qual.Impure | ||
public GameImpl(MoveValidator mValidator) { | ||
mValidator.setGame(this); | ||
moveValidator = mValidator; | ||
} | ||
|
||
@org.checkerframework.dataflow.qual.SideEffectFree | ||
public GameImpl() { | ||
} | ||
|
||
@org.checkerframework.framework.qual.EnsuresQualifier(expression = { "this.moveValidator" }, qualifier = org.checkerframework.checker.nullness.qual.Nullable.class) | ||
@org.checkerframework.dataflow.qual.SideEffectFree | ||
public void newGame(@org.checkerframework.checker.initialization.qual.Initialized @org.checkerframework.checker.nullness.qual.NonNull // package-private | ||
GameImpl this) { | ||
// Implementation of starting a new game | ||
} | ||
} | ||
|
||
@org.checkerframework.framework.qual.AnnotatedFor("org.checkerframework.checker.nullness.NullnessChecker") | ||
interface MoveValidator { | ||
|
||
@org.checkerframework.dataflow.qual.Impure | ||
void setGame(@org.checkerframework.checker.initialization.qual.UnknownInitialization(GameImpl.class) @org.checkerframework.checker.nullness.qual.Nullable Game game); | ||
} | ||
|
||
@org.checkerframework.framework.qual.AnnotatedFor("org.checkerframework.checker.nullness.NullnessChecker") | ||
class // package-private | ||
PlayerDependentMoveValidator implements // package-private | ||
MoveValidator { | ||
|
||
private @org.checkerframework.checker.initialization.qual.UnknownInitialization(GameImpl.class) @org.checkerframework.checker.nullness.qual.Nullable Game game; | ||
|
||
private @org.checkerframework.checker.initialization.qual.Initialized @org.checkerframework.checker.nullness.qual.NonNull MoveValidator blackMoveValidator = new SimpleMoveValidator(); | ||
|
||
@org.checkerframework.framework.qual.EnsuresQualifier(expression = { "this.game" }, qualifier = org.checkerframework.checker.nullness.qual.Nullable.class) | ||
@org.checkerframework.dataflow.qual.Impure | ||
public void setGame(@org.checkerframework.checker.initialization.qual.Initialized @org.checkerframework.checker.nullness.qual.NonNull // package-private | ||
PlayerDependentMoveValidator this, @org.checkerframework.checker.initialization.qual.UnknownInitialization(GameImpl.class) @org.checkerframework.checker.nullness.qual.Nullable Game game) { | ||
this.game = game; | ||
} | ||
|
||
@org.checkerframework.dataflow.qual.SideEffectFree | ||
public PlayerDependentMoveValidator() { | ||
} | ||
|
||
@org.checkerframework.checker.nullness.qual.EnsuresNonNull({ "#1" }) | ||
@org.checkerframework.checker.nullness.qual.EnsuresNonNull({ "this.game" }) | ||
@org.checkerframework.dataflow.qual.Impure | ||
public PlayerDependentMoveValidator(@org.checkerframework.checker.initialization.qual.UnknownInitialization(java.lang.Object.class) @org.checkerframework.checker.nullness.qual.Nullable Game game) { | ||
this.setGame(game); | ||
blackMoveValidator.setGame(game); | ||
} | ||
} | ||
|
||
@org.checkerframework.framework.qual.AnnotatedFor("org.checkerframework.checker.nullness.NullnessChecker") | ||
class // package-private | ||
SimpleMoveValidator implements // package-private | ||
MoveValidator { | ||
|
||
private @org.checkerframework.checker.initialization.qual.UnknownInitialization(GameImpl.class) @org.checkerframework.checker.nullness.qual.MonotonicNonNull Game game; | ||
|
||
@org.checkerframework.checker.nullness.qual.EnsuresNonNull({ "this.game" }) | ||
@org.checkerframework.dataflow.qual.Impure | ||
public void setGame(@org.checkerframework.checker.initialization.qual.Initialized @org.checkerframework.checker.nullness.qual.NonNull // package-private | ||
SimpleMoveValidator this, @org.checkerframework.checker.initialization.qual.UnknownInitialization(GameImpl.class) @org.checkerframework.checker.nullness.qual.NonNull Game game) { | ||
this.game = game; | ||
} | ||
|
||
@org.checkerframework.dataflow.qual.SideEffectFree | ||
public SimpleMoveValidator() { | ||
} | ||
|
||
@org.checkerframework.checker.nullness.qual.EnsuresNonNull({ "this.game" }) | ||
@org.checkerframework.dataflow.qual.Pure | ||
public @org.checkerframework.checker.initialization.qual.UnderInitialization(PlayerDependentMoveValidator.class) @org.checkerframework.checker.nullness.qual.NonNull MoveValidator createMoveValidator() { | ||
return new PlayerDependentMoveValidator(game); | ||
} | ||
public void test(){ | ||
PlayerDependentMoveValidator g1 = | ||
new PlayerDependentMoveValidator(game); | ||
this.game = g1.game; | ||
} | ||
} |
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,73 @@ | ||
import org.checkerframework.checker.initialization.qual.*; | ||
import org.checkerframework.checker.nullness.qual.*; | ||
|
||
interface Game { | ||
void newGame(); | ||
} | ||
|
||
class GameImpl implements Game { // package-private | ||
private MoveValidator moveValidator; | ||
|
||
public GameImpl(MoveValidator mValidator) { | ||
mValidator.setGame(this); | ||
moveValidator = mValidator; | ||
} | ||
|
||
public GameImpl() {} | ||
|
||
@Override | ||
public void newGame() { | ||
// Implementation of starting a new game | ||
} | ||
} | ||
|
||
interface MoveValidator { | ||
void setGame(Game game); | ||
} | ||
|
||
class PlayerDependentMoveValidator implements MoveValidator { // package-private | ||
public Game game; | ||
private MoveValidator blackMoveValidator = new SimpleMoveValidator(); | ||
|
||
@SuppressWarnings({"override.param", "contracts.postcondition"}) | ||
@Override | ||
public void setGame(Game game) { | ||
this.game = game; | ||
} | ||
|
||
public PlayerDependentMoveValidator() {} | ||
|
||
@SuppressWarnings({"contracts.postcondition", "argument", "method.invocation"}) | ||
public PlayerDependentMoveValidator(Game game) { | ||
this.setGame(game); | ||
blackMoveValidator.setGame(game); | ||
} | ||
} | ||
|
||
class SimpleMoveValidator implements MoveValidator { // package-private | ||
private Game game; | ||
|
||
@SuppressWarnings({"override.param", "contracts.postcondition"}) | ||
@Override | ||
public void setGame(Game game) { | ||
this.game = game; | ||
} | ||
|
||
public SimpleMoveValidator() {} | ||
|
||
@SuppressWarnings({ | ||
"purity.not.deterministic.object.creation", | ||
"purity" + ".not.sideeffectfree.call", | ||
"contracts.postcondition", | ||
"return" | ||
}) | ||
public MoveValidator createMoveValidator() { | ||
return new PlayerDependentMoveValidator(game); | ||
} | ||
|
||
public void test() { | ||
PlayerDependentMoveValidator g1 = new PlayerDependentMoveValidator(game); | ||
// :: warning: (assignment) | ||
this.game = g1.game; | ||
} | ||
} |
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