Skip to content

Commit 8ff61d6

Browse files
committed
When we are performing SIL substitution, and we reach a type that
needs to be lowered, use an opaque abstraction pattern. As I argue in the comment, we know that the orig type is now either an opaque type or a type with high-level structure that is invariant to lowering. Substitution will not change the latter property, and an opaque abstraction pattern is correct for the former. Attempting to create a "truer" abstraction pattern that preserves more structure from the orig type is both pointless and problematic. The substitutions we just did may have replaced pack references with non-pack types if there are active expansions in progress; this cannot be easily explained in terms of substitutions. (In theory, we could pass a more opaque concept of substitutions through AbstractionPattern, which might help with this. That would also make it harder to catch bugs with signature mismatches, though.)
1 parent f99efc2 commit 8ff61d6

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

lib/SIL/IR/SILFunctionType.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4748,7 +4748,17 @@ class SILTypeSubstituter :
47484748
return origType;
47494749
}
47504750

4751-
AbstractionPattern abstraction(Sig, origType);
4751+
// We've looked through all the top-level structure in the orig
4752+
// type that's affected by type lowering. If substitution has
4753+
// given us a type with top-level structure that's affected by
4754+
// type lowering, it must be because the orig type was a type
4755+
// variable of some sort, and we should lower using an opaque
4756+
// abstraction pattern. If substitution hasn't given us such a
4757+
// type, it doesn't matter what abstraction pattern we use,
4758+
// lowering will just come back with substType. So we can just
4759+
// use an opaque abstraction pattern here and not put any effort
4760+
// into computing a more "honest" abstraction pattern.
4761+
AbstractionPattern abstraction = AbstractionPattern::getOpaque();
47524762
return TC.getLoweredRValueType(typeExpansionContext, abstraction,
47534763
substType);
47544764
}

0 commit comments

Comments
 (0)