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

Correct implementation of IdentityMostlySingleton. #3550

Merged
merged 7 commits into from
Aug 5, 2020
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.checkerframework.dataflow.util;

import java.util.ArrayList;
import java.util.Collections;
import java.util.IdentityHashMap;
import org.checkerframework.javacutil.BugInCF;

/**
Expand Down Expand Up @@ -29,7 +30,7 @@ public boolean add(T e) {
return true;
case SINGLETON:
state = State.ANY;
set = new ArrayList<>();
set = Collections.newSetFromMap(new IdentityHashMap<>());
assert value != null : "@AssumeAssertion(nullness): previous add is non-null";
set.add(value);
value = null;
Expand Down
20 changes: 20 additions & 0 deletions framework/tests/nontopdefault/TestCasting.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import testlib.nontopdefault.qual.NTDMiddle;

@SuppressWarnings("inconsistent.constructor.type") // Not the point of this test
public class TestCasting {
void repro(@NTDMiddle long startTime) {
try {
System.out.println("Inside try");
return;
} catch (Exception ex) {
long timeTaken = startTime;
@NTDMiddle double dblTimeTaken = timeTaken;

throw new IllegalArgumentException();
} finally {
long timeTaken2 = startTime;
// This assignment used to fail.
@NTDMiddle double dblTimeTaken2 = timeTaken2;
}
}
}