@@ -722,10 +722,20 @@ CheckRedeclarationRequest::evaluate(Evaluator &eval, ValueDecl *current) const {
722
722
// 'other' is implicit, we diagnose 'current'.
723
723
const auto *declToDiagnose = currentDC->getAsDecl ();
724
724
if (current->isImplicit () && other->isImplicit ()) {
725
- // Get the nearest non-implicit decl context
726
- while (declToDiagnose && declToDiagnose->isImplicit () &&
727
- declToDiagnose->getDeclContext ()) {
728
- declToDiagnose = declToDiagnose->getDeclContext ()->getAsDecl ();
725
+ // If 'current' is a property wrapper backing storage property
726
+ // or projected value property, then diagnose the wrapped
727
+ // property instead of the nearest non-implicit DC.
728
+ if (auto VD = dyn_cast<VarDecl>(current)) {
729
+ if (auto originalWrappedProperty =
730
+ VD->getOriginalWrappedProperty ()) {
731
+ declToDiagnose = originalWrappedProperty;
732
+ }
733
+ } else {
734
+ // Get the nearest non-implicit decl context
735
+ while (declToDiagnose && declToDiagnose->isImplicit () &&
736
+ declToDiagnose->getDeclContext ()) {
737
+ declToDiagnose = declToDiagnose->getDeclContext ()->getAsDecl ();
738
+ }
729
739
}
730
740
} else {
731
741
declToDiagnose = current->isImplicit () ? other : current;
@@ -748,7 +758,7 @@ CheckRedeclarationRequest::evaluate(Evaluator &eval, ValueDecl *current) const {
748
758
// Emit a specialized note if the one of the declarations is
749
759
// the backing storage property ('_foo') or projected value
750
760
// property ('$foo') for a wrapped property. The backing or
751
- // storage var has the same source location as the wrapped
761
+ // projected var has the same source location as the wrapped
752
762
// property we diagnosed above, so we don't need to extract
753
763
// the original property.
754
764
const VarDecl *varToDiagnose = nullptr ;
0 commit comments