AST: add Type.interfaceTypeOfArchetype and some related APIs

This commit is contained in:
Erik Eckstein
2025-08-25 15:59:59 +02:00
parent e84228baf4
commit 62e4cfbea7
3 changed files with 9 additions and 0 deletions

View File

@@ -50,6 +50,8 @@ public struct Type: TypeProperties, CustomStringConvertible, NoReflectionChildre
public var staticTypeOfDynamicSelf: Type { Type(bridged: bridged.getStaticTypeOfDynamicSelf()) }
public var interfaceTypeOfArchetype: Type { Type(bridged: bridged.getInterfaceTypeOfArchetype()) }
public var superClassType: Type? {
precondition(isClass)
let bridgedSuperClassTy = bridged.getSuperClassType()
@@ -141,6 +143,8 @@ extension TypeProperties {
public var isArchetype: Bool { rawType.bridged.isArchetype() }
public var isExistentialArchetype: Bool { rawType.bridged.isExistentialArchetype() }
public var isExistentialArchetypeWithError: Bool { rawType.bridged.isExistentialArchetypeWithError() }
public var isRootArchetype: Bool { rawType.interfaceTypeOfArchetype.isGenericTypeParameter }
public var isRootExistentialArchetype: Bool { isExistentialArchetype && isRootArchetype }
public var isExistential: Bool { rawType.bridged.isExistential() }
public var isClassExistential: Bool { rawType.bridged.isClassExistential() }
public var isGenericTypeParameter: Bool { rawType.bridged.isGenericTypeParam() }

View File

@@ -3133,6 +3133,7 @@ struct BridgedASTType {
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE OptionalBridgedDeclObj getAnyNominal() const;
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedASTType getInstanceTypeOfMetatype() const;
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedASTType getStaticTypeOfDynamicSelf() const;
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedASTType getInterfaceTypeOfArchetype() const;
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedASTType getSuperClassType() const;
BRIDGED_INLINE MetatypeRepresentation getRepresentationOfMetatype() const;
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedSubstitutionMap getContextSubstitutionMap() const;

View File

@@ -567,6 +567,10 @@ BridgedASTType BridgedASTType::getStaticTypeOfDynamicSelf() const {
return {unbridged()->getAs<swift::DynamicSelfType>()->getSelfType().getPointer()};
}
BridgedASTType BridgedASTType::getInterfaceTypeOfArchetype() const {
return {unbridged()->getAs<swift::ArchetypeType>()->getInterfaceType().getPointer()};
}
BridgedASTType BridgedASTType::getSuperClassType() const {
return {unbridged()->getSuperclass().getPointer()};
}