mirror of
https://github.com/github/codeql.git
synced 2025-12-20 18:56:32 +01:00
Fix test cases featuring primitive arrays
Previously we couldn't print the name of types like `byte[]` for example.
This commit is contained in:
@@ -44,7 +44,7 @@ private class CallableToTest extends Callable {
|
|||||||
summaryModel(namespace, type, subtypes, name, signature, ext, _, _, _) and
|
summaryModel(namespace, type, subtypes, name, signature, ext, _, _, _) and
|
||||||
this = interpretElement(namespace, type, subtypes, name, signature, ext) and
|
this = interpretElement(namespace, type, subtypes, name, signature, ext) and
|
||||||
this.isPublic() and
|
this.isPublic() and
|
||||||
getRootType(this.getDeclaringType()).isPublic()
|
getRootType(this.getDeclaringType()).(RefType).isPublic()
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ private import FlowTestCase
|
|||||||
*/
|
*/
|
||||||
Type getRootSourceDeclaration(Type t) {
|
Type getRootSourceDeclaration(Type t) {
|
||||||
if t instanceof RefType
|
if t instanceof RefType
|
||||||
then result = getRootType(replaceTypeVariable(t)).getSourceDeclaration()
|
then result = getRootType(replaceTypeVariable(t)).(RefType).getSourceDeclaration()
|
||||||
else result = t
|
else result = t
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -77,7 +77,7 @@ predicate mayBeAmbiguous(Callable c) {
|
|||||||
/**
|
/**
|
||||||
* Returns the outermost type enclosing type `t` (which may be `t` itself).
|
* Returns the outermost type enclosing type `t` (which may be `t` itself).
|
||||||
*/
|
*/
|
||||||
RefType getRootType(RefType t) {
|
Type getRootType(Type t) {
|
||||||
if t instanceof NestedType
|
if t instanceof NestedType
|
||||||
then result = getRootType(t.(NestedType).getEnclosingType())
|
then result = getRootType(t.(NestedType).getEnclosingType())
|
||||||
else
|
else
|
||||||
@@ -95,9 +95,9 @@ string getShortNameIfPossible(Type t) {
|
|||||||
if t instanceof Array
|
if t instanceof Array
|
||||||
then result = getShortNameIfPossible(t.(Array).getComponentType()) + "[]"
|
then result = getShortNameIfPossible(t.(Array).getComponentType()) + "[]"
|
||||||
else (
|
else (
|
||||||
getRootSourceDeclaration(t) = any(TestCase tc).getADesiredImport() and
|
|
||||||
if t instanceof RefType
|
if t instanceof RefType
|
||||||
then
|
then
|
||||||
|
getRootSourceDeclaration(t) = any(TestCase tc).getADesiredImport() and
|
||||||
exists(RefType replaced, string nestedName |
|
exists(RefType replaced, string nestedName |
|
||||||
replaced = replaceTypeVariable(t).getSourceDeclaration() and
|
replaced = replaceTypeVariable(t).getSourceDeclaration() and
|
||||||
nestedName = replaced.nestedName().replaceAll("$", ".")
|
nestedName = replaced.nestedName().replaceAll("$", ".")
|
||||||
|
|||||||
Reference in New Issue
Block a user