@@ -74,7 +74,6 @@ TypeResolution::forInterface(DeclContext *dc, TypeResolutionOptions options,
74
74
HandlePlaceholderTypeReprFn placeholderHandler) {
75
75
TypeResolution result (dc, TypeResolutionStage::Interface, options,
76
76
unboundTyOpener, placeholderHandler);
77
- result.genericSig = dc->getGenericSignatureOfContext ();
78
77
return result;
79
78
}
80
79
@@ -100,7 +99,6 @@ TypeResolution::forContextual(DeclContext *dc, GenericEnvironment *genericEnv,
100
99
TypeResolution TypeResolution::withOptions (TypeResolutionOptions opts) const {
101
100
TypeResolution result (dc, stage, opts, unboundTyOpener, placeholderHandler);
102
101
result.genericEnv = genericEnv;
103
- result.genericSig = genericSig;
104
102
return result;
105
103
}
106
104
@@ -109,20 +107,14 @@ ASTContext &TypeResolution::getASTContext() const {
109
107
}
110
108
111
109
GenericSignature TypeResolution::getGenericSignature () const {
112
- switch (stage) {
113
- case TypeResolutionStage::Contextual:
114
- return dc->getGenericSignatureOfContext ();
115
-
116
- case TypeResolutionStage::Interface:
117
- if (genericSig)
118
- return genericSig;
110
+ assert (
111
+ stage > TypeResolutionStage::Structural &&
112
+ " Structural resolution shouldn't require generic signature computation" );
119
113
120
- return dc->getGenericSignatureOfContext ();
114
+ if (genericEnv)
115
+ return genericEnv->getGenericSignature ();
121
116
122
- case TypeResolutionStage::Structural:
123
- return GenericSignature ();
124
- }
125
- llvm_unreachable (" unhandled stage" );
117
+ return dc->getGenericSignatureOfContext ();
126
118
}
127
119
128
120
bool TypeResolution::usesArchetypes () const {
@@ -330,16 +322,17 @@ bool TypeResolution::areSameType(Type type1, Type type2) const {
330
322
return false ;
331
323
}
332
324
333
- // If we have a generic signature, canonicalize using it.
334
- if (auto genericSig = getGenericSignature ()) {
335
- // If both are type parameters, we can use a cheaper check
336
- // that avoids transforming the type and computing anchors.
337
- if (type1->isTypeParameter () &&
338
- type2->isTypeParameter ()) {
339
- return genericSig->areSameTypeParameterInContext (type1, type2);
325
+ if (stage == TypeResolutionStage::Interface) {
326
+ // If we have a generic signature, canonicalize using it.
327
+ if (auto genericSig = getGenericSignature ()) {
328
+ // If both are type parameters, we can use a cheaper check
329
+ // that avoids transforming the type and computing anchors.
330
+ if (type1->isTypeParameter () && type2->isTypeParameter ()) {
331
+ return genericSig->areSameTypeParameterInContext (type1, type2);
332
+ }
333
+ return genericSig.getCanonicalTypeInContext (type1) ==
334
+ genericSig.getCanonicalTypeInContext (type2);
340
335
}
341
- return genericSig.getCanonicalTypeInContext (type1) ==
342
- genericSig.getCanonicalTypeInContext (type2);
343
336
}
344
337
345
338
// Otherwise, perform a structural check.
0 commit comments