You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import org.checkerframework.checker.nullness.qual.KeyFor;
import java.util.List;
import java.util.Map;
public class PatternVariableDemo {
public void doSomething(final Type type) {
if (type instanceof ClassOrInterfaceType ct) {
//final var ct = (ClassOrInterfaceType) type;
List<Map.Entry<@KeyFor("ct.getFields()") String, Field>> finalFields = ct.getFields().entrySet().stream()
.filter(entry -> entry.getValue().getModifiers().contains(Modifier.FINAL))
.toList();
}
}
}
Results in the following error:
error: [expression.unparsable] Expression invalid in dependent type annotation: [error for expression: ct.getFields(); error: Invalid 'ct' because identifier not found]
A workaround is not using a pattern variable.
The text was updated successfully, but these errors were encountered:
mernst
added a commit
to mernst/checker-framework
that referenced
this issue
Aug 4, 2022
Using checkerframework vesion 3.24.0 with Java 17
The following code:
Results in the following error:
error: [expression.unparsable] Expression invalid in dependent type annotation: [error for expression: ct.getFields(); error: Invalid 'ct' because identifier not found]
A workaround is not using a pattern variable.
The text was updated successfully, but these errors were encountered: