@@ -704,7 +704,7 @@ CheckRedeclarationRequest::evaluate(Evaluator &eval, ValueDecl *current) const {
704
704
// If both declarations are implicit, we do not diagnose anything
705
705
// as it would lead to misleading diagnostics and it's likely that
706
706
// there's nothing actionable about it due to its implicit nature.
707
- // One special case for this is property wrappers.
707
+ // Special case for this is property wrappers or lazy variables .
708
708
//
709
709
// Otherwise, if 'current' is implicit, then we diagnose 'other'
710
710
// since 'other' is a redeclaration of 'current'. Similarly, if
@@ -719,6 +719,22 @@ CheckRedeclarationRequest::evaluate(Evaluator &eval, ValueDecl *current) const {
719
719
VD->getOriginalWrappedProperty ()) {
720
720
declToDiagnose = originalWrappedProperty;
721
721
}
722
+
723
+ // If 'current' is a synthesized lazy storage variable and
724
+ // 'other' is synthesized projected value variable, then
725
+ // diagnose the wrapped property.
726
+ //
727
+ // TODO: We should probably emit a diagnostic note on the lazy
728
+ // variable as well, but there is currently no way to grab the
729
+ // lazy property from its backing storage.
730
+ if (VD->isLazyStorageProperty ()) {
731
+ if (auto otherVar = dyn_cast<VarDecl>(other)) {
732
+ if (auto originalWrappedProperty =
733
+ otherVar->getOriginalWrappedProperty ()) {
734
+ declToDiagnose = originalWrappedProperty;
735
+ }
736
+ }
737
+ }
722
738
}
723
739
} else {
724
740
declToDiagnose = current->isImplicit () ? other : current;
0 commit comments