Skip to content

Commit b38a23d

Browse files
committed
Fix test cases featuring primitive arrays
Previously we couldn't print the name of types like `byte[]` for example.
1 parent f94d8c3 commit b38a23d

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

java/ql/src/utils/FlowTestCase.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ private class CallableToTest extends Callable {
4444
summaryModel(namespace, type, subtypes, name, signature, ext, _, _, _) and
4545
this = interpretElement(namespace, type, subtypes, name, signature, ext) and
4646
this.isPublic() and
47-
getRootType(this.getDeclaringType()).isPublic()
47+
getRootType(this.getDeclaringType()).(RefType).isPublic()
4848
)
4949
}
5050
}

java/ql/src/utils/FlowTestCaseUtils.qll

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ private import FlowTestCase
1212
*/
1313
Type getRootSourceDeclaration(Type t) {
1414
if t instanceof RefType
15-
then result = getRootType(replaceTypeVariable(t)).getSourceDeclaration()
15+
then result = getRootType(replaceTypeVariable(t)).(RefType).getSourceDeclaration()
1616
else result = t
1717
}
1818

@@ -77,7 +77,7 @@ predicate mayBeAmbiguous(Callable c) {
7777
/**
7878
* Returns the outermost type enclosing type `t` (which may be `t` itself).
7979
*/
80-
RefType getRootType(RefType t) {
80+
Type getRootType(Type t) {
8181
if t instanceof NestedType
8282
then result = getRootType(t.(NestedType).getEnclosingType())
8383
else
@@ -95,9 +95,9 @@ string getShortNameIfPossible(Type t) {
9595
if t instanceof Array
9696
then result = getShortNameIfPossible(t.(Array).getComponentType()) + "[]"
9797
else (
98-
getRootSourceDeclaration(t) = any(TestCase tc).getADesiredImport() and
9998
if t instanceof RefType
10099
then
100+
getRootSourceDeclaration(t) = any(TestCase tc).getADesiredImport() and
101101
exists(RefType replaced, string nestedName |
102102
replaced = replaceTypeVariable(t).getSourceDeclaration() and
103103
nestedName = replaced.nestedName().replaceAll("$", ".")

0 commit comments

Comments
 (0)