Skip to content

Commit 9dfe540

Browse files
committed
AST: add Type.interfaceTypeOfArchetype and some related APIs
1 parent 0f485b6 commit 9dfe540

File tree

3 files changed

+9
-0
lines changed

3 files changed

+9
-0
lines changed

SwiftCompilerSources/Sources/AST/Type.swift

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ public struct Type: TypeProperties, CustomStringConvertible, NoReflectionChildre
5050

5151
public var staticTypeOfDynamicSelf: Type { Type(bridged: bridged.getStaticTypeOfDynamicSelf()) }
5252

53+
public var interfaceTypeOfArchetype: Type { Type(bridged: bridged.getInterfaceTypeOfArchetype()) }
54+
5355
public var superClassType: Type? {
5456
precondition(isClass)
5557
let bridgedSuperClassTy = bridged.getSuperClassType()
@@ -141,6 +143,8 @@ extension TypeProperties {
141143
public var isArchetype: Bool { rawType.bridged.isArchetype() }
142144
public var isExistentialArchetype: Bool { rawType.bridged.isExistentialArchetype() }
143145
public var isExistentialArchetypeWithError: Bool { rawType.bridged.isExistentialArchetypeWithError() }
146+
public var isRootArchetype: Bool { rawType.interfaceTypeOfArchetype.isGenericTypeParameter }
147+
public var isRootExistentialArchetype: Bool { isExistentialArchetype && isRootArchetype }
144148
public var isExistential: Bool { rawType.bridged.isExistential() }
145149
public var isClassExistential: Bool { rawType.bridged.isClassExistential() }
146150
public var isGenericTypeParameter: Bool { rawType.bridged.isGenericTypeParam() }

include/swift/AST/ASTBridging.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3133,6 +3133,7 @@ struct BridgedASTType {
31333133
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE OptionalBridgedDeclObj getAnyNominal() const;
31343134
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedASTType getInstanceTypeOfMetatype() const;
31353135
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedASTType getStaticTypeOfDynamicSelf() const;
3136+
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedASTType getInterfaceTypeOfArchetype() const;
31363137
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedASTType getSuperClassType() const;
31373138
BRIDGED_INLINE MetatypeRepresentation getRepresentationOfMetatype() const;
31383139
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedSubstitutionMap getContextSubstitutionMap() const;

include/swift/AST/ASTBridgingImpl.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -567,6 +567,10 @@ BridgedASTType BridgedASTType::getStaticTypeOfDynamicSelf() const {
567567
return {unbridged()->getAs<swift::DynamicSelfType>()->getSelfType().getPointer()};
568568
}
569569

570+
BridgedASTType BridgedASTType::getInterfaceTypeOfArchetype() const {
571+
return {unbridged()->getAs<swift::ArchetypeType>()->getInterfaceType().getPointer()};
572+
}
573+
570574
BridgedASTType BridgedASTType::getSuperClassType() const {
571575
return {unbridged()->getSuperclass().getPointer()};
572576
}

0 commit comments

Comments
 (0)