You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Tweak redecl checking’s handling of generated code
Macro expansions are now treated like a part of the source file they belong to, for purposes of the “second declaration is the one that’s diagnosed” rule. This helps stabilize a behavior that was easy to perturb.
Copy file name to clipboardExpand all lines: test/Macros/macro_expand.swift
+18Lines changed: 18 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -134,6 +134,24 @@ class HasStoredPropertyClassInvalid {
134
134
#AddStoredProperty((Self.self,0).1) // expected-note {{in expansion of macro 'AddStoredProperty' here}}
135
135
// CHECK-DIAGS: @__swiftmacro_9MacroUser0023macro_expandswift_elFCffMX[[@LINE-2]]_2_33_{{.*}}AddStoredPropertyfMf_.swift:1:22: error: covariant 'Self' type cannot be referenced from a stored property initializer
136
136
}
137
+
138
+
// Redeclaration checking should behave as though expansions are part of the
139
+
// source file.
140
+
structRedeclChecking{
141
+
#varValue
142
+
143
+
// expected-error@+1 {{invalid redeclaration of 'value'}}
144
+
varvalue:Int{0}
145
+
}
146
+
147
+
// CHECK-DIAGS: macro_expand.swift:[[@LINE-3]]:7: error: invalid redeclaration of 'value'
148
+
// CHECK-DIAGS: @__swiftmacro_9MacroUser0023macro_expandswift_elFCffMX[[@LINE-8]]_2_33_4361AD9339943F52AE6186DD51E04E91Ll8varValuefMf_.swift:1:5: note: 'value' previously declared here
149
+
// CHECK-DIAGS: CONTENTS OF FILE @__swiftmacro_9MacroUser0023macro_expandswift_elFCffMX[[@LINE-9]]_2_33_4361AD9339943F52AE6186DD51E04E91Ll8varValuefMf_.swift:
0 commit comments