[TypeChecker] NFC: Add a dedicated method to get outermost attached wrapper

The outermost wrapper is the one at index `0` in the wrapper list
but it's easy for humans to make a reverse assumption since outermost
is the back of the list. Let's add a dedicated method to reduce error
probability of the property wrapper APIs.
This commit is contained in:
Pavel Yaskevich
2022-08-04 17:29:59 -07:00
parent 0989f43bb1
commit 5ee5a22cf1
7 changed files with 23 additions and 9 deletions

View File

@@ -6433,9 +6433,9 @@ void ConstraintSystem::diagnoseFailureFor(SolutionApplicationTarget target) {
DE.diagnose(expr->getLoc(), diag::type_of_expression_is_ambiguous)
.highlight(expr->getSourceRange());
} else if (auto *wrappedVar = target.getAsUninitializedWrappedVar()) {
auto *wrapper = wrappedVar->getAttachedPropertyWrappers().back();
auto *outerWrapper = wrappedVar->getOutermostAttachedPropertyWrapper();
Type propertyType = wrappedVar->getInterfaceType();
Type wrapperType = wrapper->getType();
Type wrapperType = outerWrapper->getType();
// Emit the property wrapper fallback diagnostic
wrappedVar->diagnose(diag::property_wrapper_incompatible_property,