Skip to content

Commit 54c2c62

Browse files
authored
Merge pull request #66339 from DougGregor/local-types-in-macro-expansions-5.9
2 parents 66ae480 + 406549d commit 54c2c62

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

lib/Parse/ParseDecl.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5100,7 +5100,7 @@ void Parser::recordLocalType(TypeDecl *TD) {
51005100
return;
51015101

51025102
if (!InInactiveClauseEnvironment)
5103-
SF.LocalTypeDecls.insert(TD);
5103+
SF.getOutermostParentSourceFile()->LocalTypeDecls.insert(TD);
51045104
}
51055105

51065106
/// Set the original declaration in `@differentiable` attributes.

test/Macros/macro_expand.swift

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -234,11 +234,17 @@ func testStringifyWithThrows() throws {
234234

235235
// CHECK-DIAGS: @__swiftmacro_9MacroUser23testStringifyWithThrowsyyKF9stringifyfMf1_.swift:1:2: error: call can throw but is not marked with 'try'
236236
#endif
237-
237+
238238
// The macro adds the 'try' for us.
239239
_ = #stringifyAndTry(maybeThrowing())
240240
}
241241

242+
func testStringifyWithLocalType() throws {
243+
_ = #stringify({
244+
struct QuailError: Error {}
245+
throw QuailError()
246+
})
247+
}
242248
243249
@freestanding(expression) macro addBlocker<T>(_ value: T) -> T = #externalMacro(module: "MacroDefinition", type: "AddBlocker")
244250

@@ -495,7 +501,7 @@ func testHasEqualsSelf(
495501
_ = (y == true) // expected-error{{referencing operator function '=='}}
496502
_ = (z == true) // expected-error{{referencing operator function '=='}}
497503
_ = (w == true) // expected-error{{referencing operator function '=='}}
498-
#endif
504+
#endif
499505

500506
// These should be found through the protocol.
501507
_ = (xP == true)

0 commit comments

Comments
 (0)