File tree Expand file tree Collapse file tree 3 files changed +22
-2
lines changed
SwiftCompilerSources/Sources/SIL Expand file tree Collapse file tree 3 files changed +22
-2
lines changed Original file line number Diff line number Diff line change 1313import AST
1414import SILBridging
1515
16+ extension AST . `Type` {
17+ // See `CanonicalType.loweredType(in:)`.
18+ public func loweredType( in function: Function , maximallyAbstracted: Bool = false ) -> Type {
19+ function. bridged. getLoweredType ( bridged, maximallyAbstracted) . type. objectType
20+ }
21+ }
22+
1623extension CanonicalType {
1724 // This can yield nil if the AST type is not a lowered type.
1825 // For example, if the AST type is a `AnyFunctionType` for which the lowered type would be a `SILFunctionType`.
1926 public var silType : Type ? {
2027 BridgedType . createSILType ( bridged) . typeOrNil
2128 }
29+
30+ // Lowers the AST type to a SIL type - in a specific function.
31+ // In contrast to `silType` this always succeeds. Still, it's not allowed to do this for certain AST types
32+ // which are not present in SIL, like an `InOut` or LValue types.
33+ //
34+ // If `maximallyAbstracted` is true, the lowering is done with a completely opaque abstraction pattern
35+ // (see AbstractionPattern for details).
36+ public func loweredType( in function: Function , maximallyAbstracted: Bool = false ) -> Type {
37+ type. loweredType ( in: function, maximallyAbstracted: maximallyAbstracted)
38+ }
2239}
2340
2441extension Decl {
Original file line number Diff line number Diff line change @@ -528,7 +528,7 @@ struct BridgedFunction {
528528 BRIDGED_INLINE void setNeedStackProtection (bool needSP) const ;
529529 BRIDGED_INLINE void setIsPerformanceConstraint (bool isPerfConstraint) const ;
530530 BRIDGED_INLINE bool isResilientNominalDecl (BridgedDeclObj decl) const ;
531- BRIDGED_INLINE BridgedType getLoweredType (BridgedASTType type) const ;
531+ SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedType getLoweredType (BridgedASTType type, bool maximallyAbstracted ) const ;
532532 SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedType getLoweredType (BridgedType type) const ;
533533 BRIDGED_INLINE BridgedLinkage getLinkage () const ;
534534 BRIDGED_INLINE void setLinkage (BridgedLinkage linkage) const ;
Original file line number Diff line number Diff line change @@ -912,7 +912,10 @@ bool BridgedFunction::isResilientNominalDecl(BridgedDeclObj decl) const {
912912 getFunction ()->getResilienceExpansion ());
913913}
914914
915- BridgedType BridgedFunction::getLoweredType (BridgedASTType type) const {
915+ BridgedType BridgedFunction::getLoweredType (BridgedASTType type, bool maximallyAbstracted) const {
916+ if (maximallyAbstracted) {
917+ return BridgedType (getFunction ()->getLoweredType (swift::Lowering::AbstractionPattern::getOpaque (), type.type ));
918+ }
916919 return BridgedType (getFunction ()->getLoweredType (type.type ));
917920}
918921
You can’t perform that action at this time.
0 commit comments