Skip to content

Commit c78f5ce

Browse files
committed
Swift: Move NominalType.getABaseType() implementation out from NominalType (inconsistent, difficult to find) to Type.
1 parent b048268 commit c78f5ce

File tree

2 files changed

+5
-8
lines changed

2 files changed

+5
-8
lines changed
Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
11
private import codeql.swift.generated.type.NominalType
2-
private import codeql.swift.elements.decl.NominalTypeDecl
3-
private import codeql.swift.elements.type.Type
42

53
/**
64
* A class, struct, enum or protocol.
75
*/
8-
class NominalType extends Generated::NominalType {
9-
override Type getABaseType() { result = this.getDeclaration().(NominalTypeDecl).getABaseType() }
10-
11-
NominalType getADerivedType() { result.getABaseType() = this }
12-
}
6+
class NominalType extends Generated::NominalType { }

swift/ql/lib/codeql/swift/elements/type/Type.qll

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
private import codeql.swift.generated.type.Type
2+
private import codeql.swift.elements.type.AnyGenericType
23

34
/**
45
* A Swift type.
@@ -53,5 +54,7 @@ class Type extends Generated::Type {
5354
* typealias B_alias = B
5455
* ```
5556
*/
56-
Type getABaseType() { none() }
57+
Type getABaseType() { result = this.(AnyGenericType).getDeclaration().getABaseType() }
58+
59+
Type getADerivedType() { result.getABaseType() = this }
5760
}

0 commit comments

Comments
 (0)