mirror of
https://github.com/github/codeql.git
synced 2026-04-27 17:55:19 +02:00
Swift: make type optional in TypeRepr
A type representation may not have a type in unresolved things, which for example pop up in inactive `#if` clauses.
This commit is contained in:
@@ -184,7 +184,7 @@ Stmt:
|
||||
|
||||
TypeRepr:
|
||||
_extends: AstNode
|
||||
type: Type
|
||||
type: Type? # type can be absent on unresolved entities
|
||||
|
||||
FunctionType:
|
||||
_extends: AnyFunctionType
|
||||
|
||||
@@ -11,7 +11,7 @@ void TypeVisitor::visit(swift::TypeBase* type) {
|
||||
|
||||
codeql::TypeRepr TypeVisitor::translateTypeRepr(const swift::TypeRepr& typeRepr, swift::Type type) {
|
||||
auto entry = dispatcher_.createEntry(typeRepr);
|
||||
entry.type = dispatcher_.fetchLabel(type);
|
||||
entry.type = dispatcher_.fetchOptionalLabel(type);
|
||||
return entry;
|
||||
}
|
||||
|
||||
|
||||
@@ -7,8 +7,10 @@ class TypeReprBase extends @type_repr, AstNode {
|
||||
|
||||
Type getType() {
|
||||
exists(Type x |
|
||||
type_reprs(this, x) and
|
||||
type_repr_types(this, x) and
|
||||
result = x.resolve()
|
||||
)
|
||||
}
|
||||
|
||||
predicate hasType() { exists(getType()) }
|
||||
}
|
||||
|
||||
@@ -473,7 +473,12 @@ expr_types( //dir=expr
|
||||
;
|
||||
|
||||
type_reprs( //dir=type
|
||||
unique int id: @type_repr,
|
||||
unique int id: @type_repr
|
||||
);
|
||||
|
||||
#keyset[id]
|
||||
type_repr_types( //dir=type
|
||||
int id: @type_repr ref,
|
||||
int type_: @type ref
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user