From 3375b362ebe6b4677deef859ee7a272f44317fc6 Mon Sep 17 00:00:00 2001 From: Robert Widmann Date: Thu, 30 Jan 2020 14:15:38 -0800 Subject: [PATCH] Search nested types tables in parent modules Add another cross-cutting module configuration to the nested types table search path. A module can have no overlay but also contain a nested types table suitable for finding a given member name. UIKit is the sharpest example of this state of affairs. UIKit currently defines an overlay in Swift where we find some nested types. But it also defines an inner module that has some other nested types tables. Resolves rdar://58940989 --- lib/Serialization/Deserialization.cpp | 4 ++++ test/Serialization/multi-file-nested-type-extension.swift | 8 +++++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/lib/Serialization/Deserialization.cpp b/lib/Serialization/Deserialization.cpp index 4c62bb3728b1a..8e9d098532b23 100644 --- a/lib/Serialization/Deserialization.cpp +++ b/lib/Serialization/Deserialization.cpp @@ -1468,6 +1468,10 @@ ModuleFile::resolveCrossReference(ModuleID MID, uint32_t pathLen) { if (auto overlayModule = LF->getOverlayModule()) { nestedType = findNestedTypeDeclInModule(getFile(), overlayModule, memberName, baseType); + } else if (LF->getParentModule() != extensionModule) { + nestedType = findNestedTypeDeclInModule(getFile(), + LF->getParentModule(), + memberName, baseType); } } } diff --git a/test/Serialization/multi-file-nested-type-extension.swift b/test/Serialization/multi-file-nested-type-extension.swift index fd2d139a25009..181fc38b72c52 100644 --- a/test/Serialization/multi-file-nested-type-extension.swift +++ b/test/Serialization/multi-file-nested-type-extension.swift @@ -10,7 +10,7 @@ // REQUIRES: asserts // CHECK: Statistics -// CHECK: 1 Serialization - # of nested types resolved without full lookup +// CHECK: 2 Serialization - # of nested types resolved without full lookup // Note the Optional here and below; this was once necessary to produce a crash. // Without it, the type of the parameter is initialized "early" enough to not @@ -21,3 +21,9 @@ extension Outer { public func useTypes(_: Outer.Callback?) {} } + +extension OuterClass.Inner { + public static var instance: OuterClass.Inner { + return OuterClass.Inner() + } +}