File tree Expand file tree Collapse file tree 3 files changed +22
-5
lines changed Expand file tree Collapse file tree 3 files changed +22
-5
lines changed Original file line number Diff line number Diff line change @@ -938,7 +938,24 @@ void swift::expandAccessors(
938
938
// Trigger parsing of the sequence of accessor declarations. This has the
939
939
// side effect of registering those accessor declarations with the storage
940
940
// declaration, so there is nothing further to do.
941
- (void )macroSourceFile->getTopLevelItems ();
941
+ for (auto decl : macroSourceFile->getTopLevelItems ()) {
942
+ auto accessor = dyn_cast_or_null<AccessorDecl>(decl.dyn_cast <Decl *>());
943
+ if (!accessor)
944
+ continue ;
945
+
946
+ if (accessor->isObservingAccessor ())
947
+ continue ;
948
+
949
+ // If any non-observing accessor was added, remove the initializer if
950
+ // there is one.
951
+ if (auto var = dyn_cast<VarDecl>(storage)) {
952
+ if (auto binding = var->getParentPatternBinding ()) {
953
+ unsigned index = binding->getPatternEntryIndexForVarDecl (var);
954
+ binding->setInit (index, nullptr );
955
+ break ;
956
+ }
957
+ }
958
+ }
942
959
}
943
960
944
961
bool swift::expandAttributes (CustomAttr *attr, MacroDecl *macro, Decl *member) {
Original file line number Diff line number Diff line change @@ -2657,10 +2657,10 @@ getActualMacroRole(uint8_t context) {
2657
2657
CASE (Declaration)
2658
2658
CASE (Accessor)
2659
2659
CASE (MemberAttribute)
2660
+ CASE (Member)
2660
2661
#undef CASE
2661
- default :
2662
- return None;
2663
2662
}
2663
+ return None;
2664
2664
}
2665
2665
2666
2666
static Optional<swift::MacroIntroducedDeclNameKind>
Original file line number Diff line number Diff line change 2
2
// RUN: %target-build-swift -I %swift-host-lib-dir -L %swift-host-lib-dir -emit-library -o %t/%target-library-name(MacroDefinition) -module-name=MacroDefinition %S/Inputs/syntax_macro_definitions.swift -g -no-toolchain-stdlib-rpath
3
3
4
4
// First check for no errors.
5
- // RUN: %target-typecheck-verify-swift -enable-experimental-feature Macros -enable-experimental-feature Macros -load-plugin-library %t/%target-library-name(MacroDefinition) -I %swift-host-lib-dir %s
5
+ // RUN: %target-typecheck-verify-swift -enable-experimental-feature Macros -enable-experimental-feature Macros -load-plugin-library %t/%target-library-name(MacroDefinition) -I %swift-host-lib-dir
6
6
7
7
// Check that the expansion buffer are as expected.
8
8
// RUN: %target-swift-frontend -typecheck -enable-experimental-feature Macros -enable-experimental-feature Macros -load-plugin-library %t/%target-library-name(MacroDefinition) -I %swift-host-lib-dir %s -dump-macro-expansions > %t/expansions-dump.txt 2>&1
@@ -53,7 +53,7 @@ struct MyStruct {
53
53
// CHECK-DUMP: }
54
54
55
55
@myPropertyWrapper
56
- var birthDate : Date ?
56
+ var birthDate : Date ? = nil
57
57
// CHECK-DUMP: macro:birthDate@myPropertyWrapper
58
58
// CHECK-DUMP: get {
59
59
// CHECK-DUMP: _birthDate.wrappedValue
You can’t perform that action at this time.
0 commit comments