Skip to content

Commit

Permalink
Test case for issue #3281
Browse files Browse the repository at this point in the history
  • Loading branch information
mernst authored Sep 26, 2020
1 parent 3d4fc01 commit b6b12df
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 3 deletions.
66 changes: 66 additions & 0 deletions checker/tests/regex/Issue3281.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
// Test case for Issue 3281:
// https://github.com/typetools/checker-framework/issues/3281

// @skip-test until the bug is fixed

import org.checkerframework.checker.regex.RegexUtil;
import org.checkerframework.checker.regex.qual.Regex;

public class Issue3281 {

@Regex String f = null;

public boolean b = false;

void m1(String s) {
if (true) {
// :: error: (argument.type.incompatible)
Pattern.compile(s);
}
}

void m2(String s) {
RegexUtil.isRegex(s);
if (true) {
// :: error: (argument.type.incompatible)
Pattern.compile(s);
}
}

void m2f(String s) {
RegexUtil.isRegex(s);
if (true) {
// :: error: (assignment.type.incompatible)
f = s;
}
}

void m3(String s) {
if (RegexUtil.isRegex(s)) {
Pattern.compile(s);
}
}

void m4(String s, String s2) {
RegexUtil.isRegex(s);
if (RegexUtil.isRegex(s2)) {
Pattern.compile(s);
}
}

void m4f(String s, String s2) {
RegexUtil.isRegex(s);
if (RegexUtil.isRegex(s2)) {
// :: error: (assignment.type.incompatible)
f = s;
}
}

void m5f(String s, String s2) {
RegexUtil.isRegex(s);
if (b) {
// :: error: (assignment.type.incompatible)
f = s;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2718,9 +2718,6 @@ public MethodInvocationNode visitMethodInvocation(MethodInvocationTree tree, Voi
return null;
}

// TODO? Variable wasn't used.
// boolean isBooleanMethod = TypesUtils.isBooleanType(method.getReturnType());

ExpressionTree methodSelect = tree.getMethodSelect();
assert TreeUtils.isMethodAccess(methodSelect)
: "Expected a method access, but got: " + methodSelect;
Expand Down

0 comments on commit b6b12df

Please sign in to comment.