diff --git a/SwiftCompilerSources/Sources/AST/Type.swift b/SwiftCompilerSources/Sources/AST/Type.swift index c48280f7444..9ee616e9c0d 100644 --- a/SwiftCompilerSources/Sources/AST/Type.swift +++ b/SwiftCompilerSources/Sources/AST/Type.swift @@ -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() } diff --git a/include/swift/AST/ASTBridging.h b/include/swift/AST/ASTBridging.h index 01d83ff1c6e..115d6849866 100644 --- a/include/swift/AST/ASTBridging.h +++ b/include/swift/AST/ASTBridging.h @@ -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; diff --git a/include/swift/AST/ASTBridgingImpl.h b/include/swift/AST/ASTBridgingImpl.h index 7bafd04bc1d..ac96ef1cc98 100644 --- a/include/swift/AST/ASTBridgingImpl.h +++ b/include/swift/AST/ASTBridgingImpl.h @@ -567,6 +567,10 @@ BridgedASTType BridgedASTType::getStaticTypeOfDynamicSelf() const { return {unbridged()->getAs()->getSelfType().getPointer()}; } +BridgedASTType BridgedASTType::getInterfaceTypeOfArchetype() const { + return {unbridged()->getAs()->getInterfaceType().getPointer()}; +} + BridgedASTType BridgedASTType::getSuperClassType() const { return {unbridged()->getSuperclass().getPointer()}; }