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: NominalTypeDecl:
_extends: _extends:
- IterableDeclContext
- GenericTypeDecl - GenericTypeDecl
- IterableDeclContext
type: Type type: Type
AstNode: AstNode:

View File

@@ -4650,21 +4650,21 @@ private module Impl {
private Element getImmediateChildOfNominalTypeDecl( private Element getImmediateChildOfNominalTypeDecl(
NominalTypeDecl e, int index, string partialPredicateCall 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 b = 0 and
bIterableDeclContext =
b + 1 + max(int i | i = -1 or exists(getImmediateChildOfIterableDeclContext(e, i, _)) | i) and
bGenericTypeDecl = bGenericTypeDecl =
bIterableDeclContext + 1 + b + 1 + max(int i | i = -1 or exists(getImmediateChildOfGenericTypeDecl(e, i, _)) | i) and
max(int i | i = -1 or exists(getImmediateChildOfGenericTypeDecl(e, i, _)) | i) and bIterableDeclContext =
n = bGenericTypeDecl and bGenericTypeDecl + 1 +
max(int i | i = -1 or exists(getImmediateChildOfIterableDeclContext(e, i, _)) | i) and
n = bIterableDeclContext and
( (
none() none()
or or
result = getImmediateChildOfIterableDeclContext(e, index - b, partialPredicateCall) result = getImmediateChildOfGenericTypeDecl(e, index - b, partialPredicateCall)
or or
result = 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) } 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) } 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.decl.IterableDeclContext
import codeql.swift.elements.type.Type import codeql.swift.elements.type.Type
class NominalTypeDeclBase extends Synth::TNominalTypeDecl, IterableDeclContext, GenericTypeDecl { class NominalTypeDeclBase extends Synth::TNominalTypeDecl, GenericTypeDecl, IterableDeclContext {
Type getImmediateType() { Type getImmediateType() {
result = result =
Synth::convertTypeFromRaw(Synth::convertNominalTypeDeclToRaw(this) Synth::convertTypeFromRaw(Synth::convertNominalTypeDeclToRaw(this)