Swift: reorder generic type param children in nominal types

This commit is contained in:
Paolo Tranquilli
2022-08-31 10:57:34 +02:00
parent 66e6c7bb13
commit c0f477e5c1
4 changed files with 11 additions and 11 deletions

View File

@@ -72,8 +72,8 @@ ExtensionDecl:
NominalTypeDecl:
_extends:
- IterableDeclContext
- GenericTypeDecl
- IterableDeclContext
type: Type
AstNode:

View File

@@ -4650,21 +4650,21 @@ private module Impl {
private Element getImmediateChildOfNominalTypeDecl(
NominalTypeDecl e, int index, string partialPredicateCall
) {
exists(int b, int bIterableDeclContext, int bGenericTypeDecl, int n |
exists(int b, int bGenericTypeDecl, int bIterableDeclContext, int n |
b = 0 and
bIterableDeclContext =
b + 1 + max(int i | i = -1 or exists(getImmediateChildOfIterableDeclContext(e, i, _)) | i) and
bGenericTypeDecl =
bIterableDeclContext + 1 +
max(int i | i = -1 or exists(getImmediateChildOfGenericTypeDecl(e, i, _)) | i) and
n = bGenericTypeDecl and
b + 1 + max(int i | i = -1 or exists(getImmediateChildOfGenericTypeDecl(e, i, _)) | i) and
bIterableDeclContext =
bGenericTypeDecl + 1 +
max(int i | i = -1 or exists(getImmediateChildOfIterableDeclContext(e, i, _)) | i) and
n = bIterableDeclContext and
(
none()
or
result = getImmediateChildOfIterableDeclContext(e, index - b, partialPredicateCall)
result = getImmediateChildOfGenericTypeDecl(e, index - b, partialPredicateCall)
or
result =
getImmediateChildOfGenericTypeDecl(e, index - bIterableDeclContext, partialPredicateCall)
getImmediateChildOfIterableDeclContext(e, index - bGenericTypeDecl, partialPredicateCall)
)
)
}

View File

@@ -1480,7 +1480,7 @@ module Raw {
string getStringValue() { integer_literal_exprs(this, result) }
}
class NominalTypeDecl extends @nominal_type_decl, IterableDeclContext, GenericTypeDecl {
class NominalTypeDecl extends @nominal_type_decl, GenericTypeDecl, IterableDeclContext {
Type getType() { nominal_type_decls(this, result) }
}

View File

@@ -5,7 +5,7 @@ import codeql.swift.elements.decl.GenericTypeDecl
import codeql.swift.elements.decl.IterableDeclContext
import codeql.swift.elements.type.Type
class NominalTypeDeclBase extends Synth::TNominalTypeDecl, IterableDeclContext, GenericTypeDecl {
class NominalTypeDeclBase extends Synth::TNominalTypeDecl, GenericTypeDecl, IterableDeclContext {
Type getImmediateType() {
result =
Synth::convertTypeFromRaw(Synth::convertNominalTypeDeclToRaw(this)