forked from typetools/checker-framework
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
51 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// Test case for https://github.com/typetools/checker-framework/issues/6030 | ||
|
||
import java.util.*; | ||
import org.checkerframework.checker.mustcall.qual.Owning; | ||
|
||
public class Issue6030 { | ||
|
||
interface CloseableIterator<T> extends Iterator<T>, java.io.Closeable {} | ||
|
||
static class MyScanner<T, I extends MyScanner<T, I>> implements CloseableIterator<T> { | ||
@Owning I iterator; | ||
|
||
// :: error: missing.creates.mustcall.for | ||
public boolean hasNext() { | ||
if (iterator == null) iterator = createIterator(); | ||
return iterator.hasNext(); | ||
} | ||
|
||
public T next() { | ||
return null; | ||
} | ||
|
||
private I createIterator() { | ||
return null; | ||
} | ||
|
||
public void close() {} | ||
} | ||
} |
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,15 @@ | ||
// a test case that @Owning @MustCallUnknown fields do not cause a crash. Of course, | ||
// such fields should never exist. But, better to be safe. Relevant GitHub issue with | ||
// discussion: https://github.com/typetools/checker-framework/issues/6030. | ||
|
||
import org.checkerframework.checker.mustcall.qual.*; | ||
|
||
public class OwningMCU { | ||
|
||
@Owning @MustCallUnknown Object foo; | ||
|
||
// :: error: missing.creates.mustcall.for | ||
void test() { | ||
foo = new Object(); | ||
} | ||
} |