diff --git a/lib/AST/ASTDemangler.cpp b/lib/AST/ASTDemangler.cpp index 846d43d126d..a62747201c3 100644 --- a/lib/AST/ASTDemangler.cpp +++ b/lib/AST/ASTDemangler.cpp @@ -1032,8 +1032,12 @@ ModuleDecl * ASTBuilder::findModule(NodePointer node) { assert(node->getKind() == Demangle::Node::Kind::Module); const auto moduleName = node->getText(); + // Respect the main module's ABI name when we're trying to resolve + // mangled names. But don't touch anything under the Swift stdlib's + // umbrella. if (Ctx.MainModule && Ctx.MainModule->getABIName().is(moduleName)) - return Ctx.MainModule; + if (!Ctx.MainModule->getABIName().is(STDLIB_NAME)) + return Ctx.MainModule; return Ctx.getModuleByName(moduleName); } diff --git a/test/ModuleInterface/Inputs/opaque-type-abi-name/Bottom.swiftinterface b/test/ModuleInterface/Inputs/opaque-type-abi-name/Bottom.swiftinterface index 33a166f7788..f6b754dff7f 100644 --- a/test/ModuleInterface/Inputs/opaque-type-abi-name/Bottom.swiftinterface +++ b/test/ModuleInterface/Inputs/opaque-type-abi-name/Bottom.swiftinterface @@ -3,16 +3,21 @@ import Swift +@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) public protocol Aspect { associatedtype Orientation : Bottom.Aspect var orientation: Self.Orientation { get } } +@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) public struct Parameter { } +@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) public struct ReferencesTop { + @available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) public func orientation(of parameter: Bottom.Parameter) -> some Bottom.Aspect + @available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *) public typealias Orientation = @_opaqueReturnTypeOf("$s3Top13ReferencesTopV11orientation2ofQrAA9ParameterV_tF", 0) __ } diff --git a/test/ModuleInterface/Inputs/opaque-type-abi-name/test.sh b/test/ModuleInterface/Inputs/opaque-type-abi-name/test.sh deleted file mode 100644 index 78ae28cbdad..00000000000 --- a/test/ModuleInterface/Inputs/opaque-type-abi-name/test.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh - -/Users/rwidmann/SwiftInternal/build/Ninja-Release/swift-macosx-arm64/bin/swift-frontend -sdk $(xcrun --show-sdk-path) -compile-module-from-interface -module-name Bottom -o Bottom.swiftmodule Bottom.swiftinterface -verify