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 13
13
import AST
14
14
import SILBridging
15
15
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
+
16
23
extension CanonicalType {
17
24
// This can yield nil if the AST type is not a lowered type.
18
25
// For example, if the AST type is a `AnyFunctionType` for which the lowered type would be a `SILFunctionType`.
19
26
public var silType : Type ? {
20
27
BridgedType . createSILType ( bridged) . typeOrNil
21
28
}
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
+ }
22
39
}
23
40
24
41
extension Decl {
Original file line number Diff line number Diff line change @@ -528,7 +528,7 @@ struct BridgedFunction {
528
528
BRIDGED_INLINE void setNeedStackProtection (bool needSP) const ;
529
529
BRIDGED_INLINE void setIsPerformanceConstraint (bool isPerfConstraint) const ;
530
530
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 ;
532
532
SWIFT_IMPORT_UNSAFE BRIDGED_INLINE BridgedType getLoweredType (BridgedType type) const ;
533
533
BRIDGED_INLINE BridgedLinkage getLinkage () const ;
534
534
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 {
912
912
getFunction ()->getResilienceExpansion ());
913
913
}
914
914
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
+ }
916
919
return BridgedType (getFunction ()->getLoweredType (type.type ));
917
920
}
918
921
You can’t perform that action at this time.
0 commit comments