Skip to content

Commit 535b45c

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 940870e commit 535b45c

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
@@ -10764,15 +10764,6 @@ void MacroDecl::getIntroducedNames(MacroRole role, ValueDecl *attachedTo,
1076410764
switch (expandedName.getKind()) {
1076510765
case MacroIntroducedDeclNameKind::Named: {
1076610766
names.push_back(DeclName(expandedName.getName()));
10767-
10768-
// Temporary hack: we previously allowed named(`init`) to mean the same
10769-
// thing as named(init), before the latter was supported. Smooth over the
10770-
// difference by treating the former as the latter, for a short time.
10771-
if (expandedName.getName().isSimpleName() &&
10772-
!expandedName.getName().getBaseName().isSpecial() &&
10773-
expandedName.getName().getBaseIdentifier().is("init"))
10774-
names.push_back(DeclName(DeclBaseName::createConstructor()));
10775-
1077610767
break;
1077710768
}
1077810769

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
@@ -102,10 +102,12 @@ enum ElementType {
102102

103103
print(ElementType.paper.unknown())
104104

105+
#if TEST_DIAGNOSTICS
105106
@addMembersQuotedInit
106-
struct S2 {
107+
struct S2 { // expected-note{{in expansion of macro 'addMembersQuotedInit' here}}
107108
func useSynthesized() {
108109
S.method()
109110
print(type(of: getStorage()))
110111
}
111112
}
113+
#endif

0 commit comments

Comments
 (0)