@@ -47,13 +47,9 @@ TypeConverter::getAbstractionPattern(AbstractStorageDecl *decl,
4747
4848AbstractionPattern
4949TypeConverter::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);
5753}
5854
5955static const clang::Type *getClangType (const clang::Decl *decl) {
@@ -78,30 +74,27 @@ static Bridgeability getClangDeclBridgeability(const clang::Decl *decl) {
7874
7975AbstractionPattern
8076TypeConverter::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 ());
8981
9082 if (isNonObjC)
91- return AbstractionPattern (genericSig , swiftType);
83+ return AbstractionPattern (sig , swiftType);
9284
9385 if (auto clangDecl = var->getClangDecl ()) {
9486 auto clangType = getClangType (clangDecl);
9587 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);
10295 }
10396
104- return AbstractionPattern (genericSig , swiftType);
97+ return AbstractionPattern (sig , swiftType);
10598}
10699
107100AbstractionPattern TypeConverter::getAbstractionPattern (EnumElementDecl *decl) {
@@ -113,15 +106,12 @@ AbstractionPattern TypeConverter::getAbstractionPattern(EnumElementDecl *decl) {
113106 " Optional.Some does not have a unique abstraction pattern because "
114107 " optionals are re-abstracted" );
115108
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 ());
123113
124- return AbstractionPattern (genericSig , type);
114+ return AbstractionPattern (sig , type);
125115}
126116
127117AbstractionPattern::EncodedForeignInfo
0 commit comments