Skip to content

Commit 60ced9f

Browse files
committed
Stop treating macro declaring init identifier as producing initializers
Unwind a temporary workaround we put into the compiler that treated the escaped identifier "init" as an initializer in the set of names introduced by a macro. We've addressed the underlying issues. Fixes rdar://108589649.
1 parent d12674a commit 60ced9f

File tree

2 files changed

+4
-11
lines changed

2 files changed

+4
-11
lines changed

lib/AST/Decl.cpp

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10752,15 +10752,6 @@ void MacroDecl::getIntroducedNames(MacroRole role, ValueDecl *attachedTo,
1075210752
switch (expandedName.getKind()) {
1075310753
case MacroIntroducedDeclNameKind::Named: {
1075410754
names.push_back(DeclName(expandedName.getName()));
10755-
10756-
// Temporary hack: we previously allowed named(`init`) to mean the same
10757-
// thing as named(init), before the latter was supported. Smooth over the
10758-
// difference by treating the former as the latter, for a short time.
10759-
if (expandedName.getName().isSimpleName() &&
10760-
!expandedName.getName().getBaseName().isSpecial() &&
10761-
expandedName.getName().getBaseIdentifier().is("init"))
10762-
names.push_back(DeclName(DeclBaseName::createConstructor()));
10763-
1076410755
break;
1076510756
}
1076610757

test/Macros/macro_expand_synthesized_members.swift

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
//
33
// RUN: %empty-directory(%t)
44
// RUN: %host-build-swift -swift-version 5 -emit-library -o %t/%target-library-name(MacroDefinition) -module-name=MacroDefinition %S/Inputs/syntax_macro_definitions.swift -g -no-toolchain-stdlib-rpath
5-
// RUN: %target-typecheck-verify-swift -swift-version 5 -load-plugin-library %t/%target-library-name(MacroDefinition) -module-name MacroUser -DTEST_DIAGNOSTICS -swift-version 5
5+
// RUN: %target-typecheck-verify-swift -swift-version 5 -load-plugin-library %t/%target-library-name(MacroDefinition) -module-name MacroUser -DTEST_DIAGNOSTICS -swift-version 5 -verify-ignore-unknown
66
// RUN: %target-build-swift -g -swift-version 5 -load-plugin-library %t/%target-library-name(MacroDefinition) %s -o %t/main -module-name MacroUser -swift-version 5
77
// RUN: %target-codesign %t/main
88
// RUN: %target-run %t/main | %FileCheck %s
@@ -96,10 +96,12 @@ enum ElementType {
9696

9797
print(ElementType.paper.unknown())
9898

99+
#if TEST_DIAGNOSTICS
99100
@addMembersQuotedInit
100-
struct S2 {
101+
struct S2 { // expected-note{{in expansion of macro 'addMembersQuotedInit' here}}
101102
func useSynthesized() {
102103
S.method()
103104
print(type(of: getStorage()))
104105
}
105106
}
107+
#endif

0 commit comments

Comments
 (0)