framework/tests/all-systems/java8/memberref/Purity.java
raw| 1 | import org.checkerframework.dataflow.qual.*; |
| 2 | |
| 3 | interface PureFunc { |
| 4 | @Pure |
| 5 | String doNothing(); |
| 6 | } |
| 7 | |
| 8 | class TestPure { |
| 9 | |
| 10 | static String myMethod() { |
| 11 | return ""; |
| 12 | } |
| 13 | |
| 14 | @Pure |
| 15 | static String myPureMethod() { |
| 16 | return ""; |
| 17 | } |
| 18 | |
| 19 | void context() { |
| 20 | PureFunc f1 = TestPure::myPureMethod; |
| 21 | // :: error: (purity.invalid.methodref) |
| 22 | PureFunc f2 = TestPure::myMethod; |
| 23 | } |
| 24 | } |