@@ -47,13 +47,9 @@ TypeConverter::getAbstractionPattern(AbstractStorageDecl *decl,
47
47
48
48
AbstractionPattern
49
49
TypeConverter::getAbstractionPattern (SubscriptDecl *decl, bool isNonObjC) {
50
- auto type = decl->getElementInterfaceType ()->getCanonicalType ();
51
- CanGenericSignature genericSig;
52
- if (auto sig = decl->getGenericSignatureOfContext ()) {
53
- genericSig = sig.getCanonicalSignature ();
54
- type = sig->getCanonicalTypeInContext (type);
55
- }
56
- return AbstractionPattern (genericSig, type);
50
+ auto sig = decl->getGenericSignatureOfContext ().getCanonicalSignature ();
51
+ auto type = sig.getCanonicalTypeInContext (decl->getElementInterfaceType ());
52
+ return AbstractionPattern (sig, type);
57
53
}
58
54
59
55
static const clang::Type *getClangType (const clang::Decl *decl) {
@@ -78,30 +74,27 @@ static Bridgeability getClangDeclBridgeability(const clang::Decl *decl) {
78
74
79
75
AbstractionPattern
80
76
TypeConverter::getAbstractionPattern (VarDecl *var, bool isNonObjC) {
81
- CanType swiftType = var->getInterfaceType ()
82
- ->getCanonicalType ();
83
-
84
- CanGenericSignature genericSig;
85
- if (auto sig = var->getDeclContext ()->getGenericSignatureOfContext ()) {
86
- genericSig = sig.getCanonicalSignature ();
87
- swiftType = genericSig->getCanonicalTypeInContext (swiftType);
88
- }
77
+ auto sig = var->getDeclContext ()
78
+ ->getGenericSignatureOfContext ()
79
+ .getCanonicalSignature ();
80
+ auto swiftType = sig.getCanonicalTypeInContext (var->getInterfaceType ());
89
81
90
82
if (isNonObjC)
91
- return AbstractionPattern (genericSig , swiftType);
83
+ return AbstractionPattern (sig , swiftType);
92
84
93
85
if (auto clangDecl = var->getClangDecl ()) {
94
86
auto clangType = getClangType (clangDecl);
95
87
auto contextType = var->getDeclContext ()->mapTypeIntoContext (swiftType);
96
- swiftType = getLoweredBridgedType (
97
- AbstractionPattern (genericSig, swiftType, clangType),
98
- contextType, getClangDeclBridgeability (clangDecl),
99
- SILFunctionTypeRepresentation::CFunctionPointer,
100
- TypeConverter::ForMemory)->getCanonicalType ();
101
- return AbstractionPattern (genericSig, swiftType, clangType);
88
+ swiftType =
89
+ getLoweredBridgedType (AbstractionPattern (sig, swiftType, clangType),
90
+ contextType, getClangDeclBridgeability (clangDecl),
91
+ SILFunctionTypeRepresentation::CFunctionPointer,
92
+ TypeConverter::ForMemory)
93
+ ->getCanonicalType ();
94
+ return AbstractionPattern (sig, swiftType, clangType);
102
95
}
103
96
104
- return AbstractionPattern (genericSig , swiftType);
97
+ return AbstractionPattern (sig , swiftType);
105
98
}
106
99
107
100
AbstractionPattern TypeConverter::getAbstractionPattern (EnumElementDecl *decl) {
@@ -113,15 +106,12 @@ AbstractionPattern TypeConverter::getAbstractionPattern(EnumElementDecl *decl) {
113
106
" Optional.Some does not have a unique abstraction pattern because "
114
107
" optionals are re-abstracted" );
115
108
116
- CanType type = decl->getArgumentInterfaceType ()->getCanonicalType ();
117
-
118
- CanGenericSignature genericSig;
119
- if (auto sig = decl->getParentEnum ()->getGenericSignatureOfContext ()) {
120
- genericSig = sig.getCanonicalSignature ();
121
- type = genericSig->getCanonicalTypeInContext (type);
122
- }
109
+ auto sig = decl->getParentEnum ()
110
+ ->getGenericSignatureOfContext ()
111
+ .getCanonicalSignature ();
112
+ auto type = sig.getCanonicalTypeInContext (decl->getArgumentInterfaceType ());
123
113
124
- return AbstractionPattern (genericSig , type);
114
+ return AbstractionPattern (sig , type);
125
115
}
126
116
127
117
AbstractionPattern::EncodedForeignInfo
0 commit comments