@@ -4604,7 +4604,7 @@ void AdjointEmitter::materializeAdjointIndirectHelper(
4604
4604
4605
4605
void AdjointEmitter::emitZeroIndirect (CanType type, SILValue bufferAccess,
4606
4606
SILLocation loc) {
4607
- // Lookup `AdditiveArithmetic.zero.getter`.
4607
+ // Look up `AdditiveArithmetic.zero.getter`.
4608
4608
auto *additiveArithmeticProto =
4609
4609
getASTContext ().getProtocol (KnownProtocolKind::AdditiveArithmetic);
4610
4610
auto initDeclLookup =
@@ -4615,20 +4615,21 @@ void AdjointEmitter::emitZeroIndirect(CanType type, SILValue bufferAccess,
4615
4615
SILDeclRef accessorDeclRef (accessorDecl, SILDeclRef::Kind::Func);
4616
4616
auto methodType =
4617
4617
getContext ().getTypeConverter ().getConstantType (accessorDeclRef);
4618
- // Lookup conformance to `AdditiveArithmetic`.
4618
+ // Look up conformance to `AdditiveArithmetic`.
4619
4619
auto *swiftMod = getModule ().getSwiftModule ();
4620
- auto conf = swiftMod->lookupConformance (type, additiveArithmeticProto);
4621
- assert (conf.hasValue () && " No conformance to AdditiveArithmetic?" );
4622
- ProtocolConformanceRef confRef (*conf);
4620
+ auto confRef = swiftMod->lookupConformance (type, additiveArithmeticProto);
4621
+ // TODO(TF-202): Diagnose no `AdditiveArithmetic` due to generic signature
4622
+ // minimization bug.
4623
+ assert (confRef.hasValue () && " Missing conformance to `AdditiveArithmetic`" );
4623
4624
// %wm = witness_method ...
4624
- auto *getter = builder.createWitnessMethod (loc, type, confRef,
4625
+ auto *getter = builder.createWitnessMethod (loc, type, * confRef,
4625
4626
accessorDeclRef, methodType);
4626
4627
// %metatype = metatype $T
4627
4628
auto metatypeType = CanMetatypeType::get (type, MetatypeRepresentation::Thick);
4628
4629
auto metatype = builder.createMetatype (
4629
4630
loc, SILType::getPrimitiveObjectType (metatypeType));
4630
4631
auto subMap = SubstitutionMap::getProtocolSubstitutions (
4631
- additiveArithmeticProto, type, confRef);
4632
+ additiveArithmeticProto, type, * confRef);
4632
4633
builder.createApply (loc, getter, subMap, {bufferAccess, metatype},
4633
4634
/* isNonThrowing*/ false );
4634
4635
}
@@ -4838,14 +4839,18 @@ void AdjointEmitter::accumulateIndirect(
4838
4839
auto adjointParentModule = cotangentSpace->getNominal ()
4839
4840
? cotangentSpace->getNominal ()->getModuleContext ()
4840
4841
: getModule ().getSwiftModule ();
4841
- auto confRef = *adjointParentModule->lookupConformance (adjointASTTy, proto);
4842
+ auto confRef = adjointParentModule->lookupConformance (adjointASTTy, proto);
4843
+ // TODO(TF-202): Diagnose no `AdditiveArithmetic` due to generic signature
4844
+ // minimization bug.
4845
+ assert (confRef.hasValue () && " Missing conformance to `AdditiveArithmetic`" );
4842
4846
SILDeclRef declRef (combinerFuncDecl, SILDeclRef::Kind::Func);
4843
4847
auto silFnTy = getContext ().getTypeConverter ().getConstantType (declRef);
4844
4848
// %0 = witness_method @+
4845
4849
auto witnessMethod = builder.createWitnessMethod (loc, adjointASTTy,
4846
- confRef, declRef, silFnTy);
4847
- auto subMap =
4848
- SubstitutionMap::getProtocolSubstitutions (proto, adjointASTTy, confRef);
4850
+ *confRef, declRef,
4851
+ silFnTy);
4852
+ auto subMap = SubstitutionMap::getProtocolSubstitutions (
4853
+ proto, adjointASTTy, *confRef);
4849
4854
// %1 = metatype $T.Type
4850
4855
auto metatypeType =
4851
4856
CanMetatypeType::get (adjointASTTy, MetatypeRepresentation::Thick);
@@ -4891,14 +4896,15 @@ void AdjointEmitter::accumulateIndirect(SILValue lhsDestAccess,
4891
4896
auto *proto = getContext ().getAdditiveArithmeticProtocol ();
4892
4897
auto *accumulatorFuncDecl = getContext ().getPlusEqualDecl ();
4893
4898
// Call the combiner function and return.
4894
- auto confRef = *swiftMod->lookupConformance (astType, proto);
4899
+ auto confRef = swiftMod->lookupConformance (astType, proto);
4900
+ assert (confRef.hasValue () && " Missing conformance to `AdditiveArithmetic`" );
4895
4901
SILDeclRef declRef (accumulatorFuncDecl, SILDeclRef::Kind::Func);
4896
4902
auto silFnTy = getContext ().getTypeConverter ().getConstantType (declRef);
4897
4903
// %0 = witness_method @+=
4898
4904
auto witnessMethod =
4899
- builder.createWitnessMethod (loc, astType, confRef, declRef, silFnTy);
4905
+ builder.createWitnessMethod (loc, astType, * confRef, declRef, silFnTy);
4900
4906
auto subMap =
4901
- SubstitutionMap::getProtocolSubstitutions (proto, astType, confRef);
4907
+ SubstitutionMap::getProtocolSubstitutions (proto, astType, * confRef);
4902
4908
// %1 = metatype $T.Type
4903
4909
auto metatypeType =
4904
4910
CanMetatypeType::get (astType, MetatypeRepresentation::Thick);
0 commit comments