[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
This commit is contained in:
Ben Barham
2021-01-14 16:37:23 +10:00
parent 727baf19cd
commit fda96eb8a0
2 changed files with 26 additions and 0 deletions

View File

@@ -5273,6 +5273,11 @@ void Serializer::writeAST(ModuleOrSourceFile DC) {
}
for (auto OTD : opaqueReturnTypeDecls) {
// FIXME: We should delay parsing function bodies so these type decls
// don't even get added to the file.
if (OTD->getDeclContext()->getInnermostSkippedFunctionContext())
continue;
hasOpaqueReturnTypes = true;
Mangle::ASTMangler Mangler;
auto MangledName = Mangler.mangleOpaqueTypeDecl(OTD);

View File

@@ -0,0 +1,21 @@
// 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
// 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
protocol Base {
func anything()
}
func test() {
struct Nested : Base {
let NEVERTYPECHECK_property = 1
func anything() {
let NEVERTYPECHECK_local = 1
}
func opaqueReturnType() -> some Base {
let NEVERTYPECHECK_local = 1
return Nested()
}
}
}