Skip to content

Commit fda96eb

Browse files
committed
[Serialization] Skip opaque types nested in skipped function bodies
Opaque types are gathered and visited separately. As with local types, only serialize them if they are not within a skipped function body. Fixes a crash caused when compiling the primary file, where delayed parsing is explictly disabled. Resolves rdar://73167790
1 parent 727baf1 commit fda96eb

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

lib/Serialization/Serialization.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5273,6 +5273,11 @@ void Serializer::writeAST(ModuleOrSourceFile DC) {
52735273
}
52745274

52755275
for (auto OTD : opaqueReturnTypeDecls) {
5276+
// FIXME: We should delay parsing function bodies so these type decls
5277+
// don't even get added to the file.
5278+
if (OTD->getDeclContext()->getInnermostSkippedFunctionContext())
5279+
continue;
5280+
52765281
hasOpaqueReturnTypes = true;
52775282
Mangle::ASTMangler Mangler;
52785283
auto MangledName = Mangler.mangleOpaqueTypeDecl(OTD);
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// RUN: %target-build-swift -Xfrontend -disable-availability-checking -emit-module -module-name A -Xfrontend -experimental-skip-all-function-bodies -Xfrontend -debug-forbid-typecheck-prefix -Xfrontend NEVERTYPECHECK %s
2+
// RUN: %target-build-swift -Xfrontend -disable-availability-checking -emit-module -module-name A -Xfrontend -experimental-skip-non-inlinable-function-bodies -Xfrontend -debug-forbid-typecheck-prefix -Xfrontend NEVERTYPECHECK %s
3+
4+
protocol Base {
5+
func anything()
6+
}
7+
8+
func test() {
9+
struct Nested : Base {
10+
let NEVERTYPECHECK_property = 1
11+
12+
func anything() {
13+
let NEVERTYPECHECK_local = 1
14+
}
15+
16+
func opaqueReturnType() -> some Base {
17+
let NEVERTYPECHECK_local = 1
18+
return Nested()
19+
}
20+
}
21+
}

0 commit comments

Comments
 (0)