File tree Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -60,7 +60,7 @@ static llvm::cl::opt<bool> SkipUnreachableMustBeLastErrors(
60
60
61
61
// / Returns true if A is an opened existential type or is equal to an
62
62
// / archetype from F's generic context.
63
- static bool isArchetypeValidInFunction (ArchetypeType *A, SILFunction *F) {
63
+ static bool isArchetypeValidInFunction (ArchetypeType *A, const SILFunction *F) {
64
64
if (!A->getOpenedExistentialType ().isNull ())
65
65
return true ;
66
66
@@ -825,6 +825,19 @@ class SILVerifier : public SILVerifierBase<SILVerifier> {
825
825
require (fnTy->isPolymorphic (),
826
826
" callee of apply with substitutions must be polymorphic" );
827
827
828
+ // Each archetype occurring in the substitutions list should belong to the
829
+ // current function.
830
+ for (auto sub : subs) {
831
+ sub.getReplacement ()->getCanonicalType ().visit ([&](CanType t) {
832
+ auto A = dyn_cast<ArchetypeType>(t);
833
+ if (!A)
834
+ return ;
835
+ require (isArchetypeValidInFunction (A, &F),
836
+ " Replacment type of a substitution contains an ArchetypeType "
837
+ " that does not exist in the Caller's generic param list." );
838
+ });
839
+ }
840
+
828
841
// Apply the substitutions.
829
842
return fnTy->substGenericArgs (F.getModule (), subs);
830
843
}
You can’t perform that action at this time.
0 commit comments