@@ -1930,11 +1930,17 @@ static void addPropertyWrapperAccessorAvailability(VarDecl *var, AccessorKind ac
19301930 SmallVectorImpl<const Decl *> &asAvailableAs) {
19311931 AccessorDecl *synthesizedFrom = nullptr ;
19321932 if (var->hasAttachedPropertyWrapper ()) {
1933+ AbstractStorageDecl *wrappedValueImpl;
1934+ if (auto access = getEnclosingSelfPropertyWrapperAccess (var, /* forProjected=*/ false )) {
1935+ wrappedValueImpl = access->subscript ;
1936+ } else {
1937+ wrappedValueImpl = var->getAttachedPropertyWrapperTypeInfo (0 ).valueVar ;
1938+ }
1939+
19331940 // The property wrapper info may not actually link back to a wrapper
19341941 // implementation, if there was a semantic error checking the wrapper.
1935- auto info = var->getAttachedPropertyWrapperTypeInfo (0 );
1936- if (info.valueVar ) {
1937- synthesizedFrom = info.valueVar ->getOpaqueAccessor (accessorKind);
1942+ if (wrappedValueImpl) {
1943+ synthesizedFrom = wrappedValueImpl->getOpaqueAccessor (accessorKind);
19381944 }
19391945 } else if (auto wrapperSynthesizedKind
19401946 = var->getPropertyWrapperSynthesizedPropertyKind ()) {
@@ -1944,11 +1950,17 @@ static void addPropertyWrapperAccessorAvailability(VarDecl *var, AccessorKind ac
19441950
19451951 case PropertyWrapperSynthesizedPropertyKind::Projection: {
19461952 if (auto origVar = var->getOriginalWrappedProperty (wrapperSynthesizedKind)) {
1953+ AbstractStorageDecl *projectedValueImpl;
1954+ if (auto access = getEnclosingSelfPropertyWrapperAccess (origVar, /* forProjected=*/ true )) {
1955+ projectedValueImpl = access->subscript ;
1956+ } else {
1957+ projectedValueImpl = origVar->getAttachedPropertyWrapperTypeInfo (0 ).projectedValueVar ;
1958+ }
1959+
19471960 // The property wrapper info may not actually link back to a wrapper
19481961 // implementation, if there was a semantic error checking the wrapper.
1949- auto info = origVar->getAttachedPropertyWrapperTypeInfo (0 );
1950- if (info.projectedValueVar ) {
1951- synthesizedFrom = info.projectedValueVar ->getOpaqueAccessor (accessorKind);
1962+ if (projectedValueImpl) {
1963+ synthesizedFrom = projectedValueImpl->getOpaqueAccessor (accessorKind);
19521964 }
19531965 }
19541966 break ;
0 commit comments