@@ -116,33 +116,26 @@ RequirementEnvironment::RequirementEnvironment(
116
116
InFlightSubstitution &IFS, Type type, ProtocolDecl *proto)
117
117
-> ProtocolConformanceRef {
118
118
// The protocol 'Self' conforms concretely to the conforming type.
119
- if (type->isEqual (ctx.TheSelfType )) {
120
- auto replacement = type.subst (IFS);
121
- ASSERT (covariantSelf || replacement->isEqual (substConcreteType));
122
-
123
- if (conformance) {
124
- ProtocolConformance *specialized = conformance;
125
-
126
- if (conformance->getGenericSignature ()) {
127
- auto concreteSubs =
128
- substConcreteType->getContextSubstitutionMap (conformanceDC);
129
- specialized =
130
- ctx.getSpecializedConformance (substConcreteType,
131
- cast<NormalProtocolConformance>(conformance),
132
- concreteSubs);
133
- }
134
-
135
- // findWitnessedObjCRequirements() does a weird thing by passing in a
136
- // DC that is not the conformance DC. Work around it here.
137
- if (!specialized->getType ()->isEqual (replacement)) {
138
- ASSERT (specialized->getType ()->isExactSuperclassOf (substConcreteType));
139
- ASSERT (covariantSelf ? replacement->is <GenericTypeParamType>()
140
- : replacement->isEqual (substConcreteType));
141
- specialized = ctx.getInheritedConformance (replacement, specialized);
142
- }
143
-
144
- return ProtocolConformanceRef (specialized);
119
+ if (type->isEqual (ctx.TheSelfType ) && !covariantSelf && conformance) {
120
+ ProtocolConformance *specialized = conformance;
121
+
122
+ if (conformance->getGenericSignature ()) {
123
+ auto concreteSubs =
124
+ substConcreteType->getContextSubstitutionMap (conformanceDC);
125
+ specialized =
126
+ ctx.getSpecializedConformance (substConcreteType,
127
+ cast<NormalProtocolConformance>(conformance),
128
+ concreteSubs);
129
+ }
130
+
131
+ // findWitnessedObjCRequirements() does a weird thing by passing in a
132
+ // DC that is not the conformance DC. Work around it here.
133
+ if (!specialized->getType ()->isEqual (substConcreteType)) {
134
+ ASSERT (specialized->getType ()->isExactSuperclassOf (substConcreteType));
135
+ specialized = ctx.getInheritedConformance (substConcreteType, specialized);
145
136
}
137
+
138
+ return ProtocolConformanceRef (specialized);
146
139
}
147
140
148
141
// All other generic parameters come from the requirement itself
0 commit comments