@@ -2733,17 +2733,28 @@ class SILVerifier : public SILVerifierBase<SILVerifier> {
2733
2733
require (AI->getModule ().getStage () == SILStage::Raw,
2734
2734
" assign_or_init can only exist in raw SIL" );
2735
2735
2736
- // The init and set functions have the same type: (Src type) -> Void
2737
-
2738
2736
SILValue initFn = AI->getInitializer ();
2737
+ SILValue setterFn = AI->getSetter ();
2738
+
2739
2739
CanSILFunctionType initTy = initFn->getType ().castTo <SILFunctionType>();
2740
- SILFunctionConventions initConv (initTy, AI->getModule ());
2741
- require (initConv.getNumIndirectSILResults () ==
2742
- AI->getInitializedProperties ().size (),
2743
- " init function has invalid number of indirect results" );
2744
- checkAssigOrInitInstAccessorArgs (Src->getType (), initConv);
2740
+ // Check init - it's an unapplied reference that takes property addresses
2741
+ // and `initialValue`.
2742
+ {
2743
+ // We need to map un-applied function reference into context before
2744
+ // check `initialValue` argument.
2745
+ auto subs = cast<PartialApplyInst>(setterFn)->getSubstitutionMap ();
2746
+ initTy = initTy->substGenericArgs (F.getModule (), subs,
2747
+ F.getTypeExpansionContext ());
2745
2748
2746
- SILValue setterFn = AI->getSetter ();
2749
+ SILFunctionConventions initConv (initTy, AI->getModule ());
2750
+ require (initConv.getNumIndirectSILResults () ==
2751
+ AI->getInitializedProperties ().size (),
2752
+ " init function has invalid number of indirect results" );
2753
+ checkAssigOrInitInstAccessorArgs (Src->getType (), initConv);
2754
+ }
2755
+
2756
+ // Check setter - it's a partially applied reference which takes
2757
+ // `initialValue`.
2747
2758
CanSILFunctionType setterTy = setterFn->getType ().castTo <SILFunctionType>();
2748
2759
SILFunctionConventions setterConv (setterTy, AI->getModule ());
2749
2760
require (setterConv.getNumIndirectSILResults () == 0 ,
0 commit comments