File tree Expand file tree Collapse file tree 2 files changed +12
-0
lines changed Expand file tree Collapse file tree 2 files changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -574,6 +574,8 @@ DeclContext *Decl::getInnermostDeclContext() const {
574
574
return const_cast <ExtensionDecl*>(ext);
575
575
if (auto topLevel = dyn_cast<TopLevelCodeDecl>(this ))
576
576
return const_cast <TopLevelCodeDecl*>(topLevel);
577
+ if (auto macro = dyn_cast<MacroDecl>(this ))
578
+ return const_cast <MacroDecl*>(macro);
577
579
578
580
return getDeclContext ();
579
581
}
Original file line number Diff line number Diff line change @@ -169,3 +169,13 @@ func test() {
169
169
let _: [ MacroOrType . Nested ] = [ ]
170
170
_ = [ MacroOrType . Nested] ( )
171
171
}
172
+
173
+ // Make sure we have the right declaration context for type-checking the result
174
+ // types of macros. At one point, we would reject the following macro.
175
+ protocol MyProto {
176
+ }
177
+ struct MyStruct < T: MyProto > {
178
+ }
179
+
180
+ @freestanding ( expression) macro myMacro< T : MyProto > ( _ value: MyStruct < T > ) -> MyStruct < T > = #externalMacro( module: " A " , type: " B " )
181
+ // expected-warning@-1{{external macro implementation type}}
You can’t perform that action at this time.
0 commit comments