Skip to content

Commit 0a8c602

Browse files
committed
AST: add Type.interfaceTypeOfArchetype and some related APIs
1 parent 6942742 commit 0a8c602

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()
@@ -134,6 +136,8 @@ extension TypeProperties {
134136
public var isArchetype: Bool { rawType.bridged.isArchetype() }
135137
public var isExistentialArchetype: Bool { rawType.bridged.isExistentialArchetype() }
136138
public var isExistentialArchetypeWithError: Bool { rawType.bridged.isExistentialArchetypeWithError() }
139+
public var isRootArchetype: Bool { rawType.interfaceTypeOfArchetype.isGenericTypeParameter }
140+
public var isRootExistentialArchetype: Bool { isExistentialArchetype && isRootArchetype }
137141
public var isExistential: Bool { rawType.bridged.isExistential() }
138142
public var isClassExistential: Bool { rawType.bridged.isClassExistential() }
139143
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
@@ -3009,6 +3009,7 @@ struct BridgedASTType {
30093009
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE OptionalBridgedDeclObj getAnyNominal() const;
30103010
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedASTType getInstanceTypeOfMetatype() const;
30113011
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedASTType getStaticTypeOfDynamicSelf() const;
3012+
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedASTType getInterfaceTypeOfArchetype() const;
30123013
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedASTType getSuperClassType() const;
30133014
BRIDGED_INLINE MetatypeRepresentation getRepresentationOfMetatype() const;
30143015
BRIDGED_INLINE BridgedOptionalInt getValueOfIntegerType() const;

include/swift/AST/ASTBridgingImpl.h

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

578+
BridgedASTType BridgedASTType::getInterfaceTypeOfArchetype() const {
579+
return {unbridged()->getAs<swift::ArchetypeType>()->getInterfaceType().getPointer()};
580+
}
581+
578582
BridgedASTType BridgedASTType::getSuperClassType() const {
579583
return {unbridged()->getSuperclass().getPointer()};
580584
}

0 commit comments

Comments
 (0)