@@ -4114,29 +4114,31 @@ class SILVerifier : public SILVerifierBase<SILVerifier> {
4114
4114
== F.getModule ().Types .getProtocolWitnessRepresentation (protocol),
4115
4115
" result of witness_method must have correct representation for protocol" );
4116
4116
4117
- require (methodType->isPolymorphic (),
4118
- " result of witness_method must be polymorphic" );
4119
-
4120
- auto genericSig = methodType->getInvocationGenericSignature ();
4121
-
4122
- auto selfGenericParam = genericSig.getGenericParams ()[0 ];
4123
- require (selfGenericParam->getDepth () == 0
4124
- && selfGenericParam->getIndex () == 0 ,
4125
- " method should be polymorphic on Self parameter at depth 0 index 0" );
4126
- std::optional<Requirement> selfRequirement;
4127
- for (auto req : genericSig.getRequirements ()) {
4128
- if (req.getKind () != RequirementKind::SameType) {
4129
- selfRequirement = req;
4130
- break ;
4117
+ if (methodType->isPolymorphic ()) {
4118
+ require (methodType->isPolymorphic (),
4119
+ " result of witness_method must be polymorphic" );
4120
+
4121
+ auto genericSig = methodType->getInvocationGenericSignature ();
4122
+
4123
+ auto selfGenericParam = genericSig.getGenericParams ()[0 ];
4124
+ require (selfGenericParam->getDepth () == 0
4125
+ && selfGenericParam->getIndex () == 0 ,
4126
+ " method should be polymorphic on Self parameter at depth 0 index 0" );
4127
+ std::optional<Requirement> selfRequirement;
4128
+ for (auto req : genericSig.getRequirements ()) {
4129
+ if (req.getKind () != RequirementKind::SameType) {
4130
+ selfRequirement = req;
4131
+ break ;
4132
+ }
4131
4133
}
4132
- }
4133
4134
4134
- require (selfRequirement &&
4135
- selfRequirement->getKind () == RequirementKind::Conformance,
4136
- " first non-same-typerequirement should be conformance requirement" );
4137
- const auto protos = genericSig->getRequiredProtocols (selfGenericParam);
4138
- require (std::find (protos.begin (), protos.end (), protocol) != protos.end (),
4139
- " requirement Self parameter must conform to called protocol" );
4135
+ require (selfRequirement &&
4136
+ selfRequirement->getKind () == RequirementKind::Conformance,
4137
+ " first non-same-typerequirement should be conformance requirement" );
4138
+ const auto protos = genericSig->getRequiredProtocols (selfGenericParam);
4139
+ require (std::find (protos.begin (), protos.end (), protocol) != protos.end (),
4140
+ " requirement Self parameter must conform to called protocol" );
4141
+ }
4140
4142
4141
4143
auto lookupType = AMI->getLookupType ();
4142
4144
if (getLocalArchetypeOf (lookupType) || lookupType->hasDynamicSelfType ()) {
0 commit comments