Skip to content

Commit 8a33705

Browse files
authored
Merge pull request #70251 from CodaFi/mangle-tangle
2 parents 6ca57e3 + ea49d13 commit 8a33705

File tree

4 files changed

+39
-1
lines changed

4 files changed

+39
-1
lines changed

lib/AST/ASTDemangler.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1031,7 +1031,14 @@ ASTBuilder::createTypeDecl(NodePointer node,
10311031
ModuleDecl *
10321032
ASTBuilder::findModule(NodePointer node) {
10331033
assert(node->getKind() == Demangle::Node::Kind::Module);
1034-
const auto &moduleName = node->getText();
1034+
const auto moduleName = node->getText();
1035+
// Respect the main module's ABI name when we're trying to resolve
1036+
// mangled names. But don't touch anything under the Swift stdlib's
1037+
// umbrella.
1038+
if (Ctx.MainModule && Ctx.MainModule->getABIName().is(moduleName))
1039+
if (!Ctx.MainModule->getABIName().is(STDLIB_NAME))
1040+
return Ctx.MainModule;
1041+
10351042
return Ctx.getModuleByName(moduleName);
10361043
}
10371044

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// swift-interface-format-version: 1.0
2+
// swift-module-flags: -module-name Bottom -module-abi-name Top -module-interface-preserve-types-as-written
3+
4+
import Swift
5+
6+
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
7+
public protocol Aspect {
8+
associatedtype Orientation : Bottom.Aspect
9+
var orientation: Self.Orientation { get }
10+
}
11+
12+
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
13+
public struct Parameter {
14+
}
15+
16+
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
17+
public struct ReferencesTop {
18+
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
19+
public func orientation(of parameter: Bottom.Parameter) -> some Bottom.Aspect
20+
21+
@available(macOS 10.15, iOS 13, tvOS 13, watchOS 6, *)
22+
public typealias Orientation = @_opaqueReturnTypeOf("$s3Top13ReferencesTopV11orientation2ofQrAA9ParameterV_tF", 0) __
23+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// swift-interface-format-version: 1.0
2+
// swift-module-flags: -module-name Top -module-interface-preserve-types-as-written
3+
4+
@_exported import Bottom
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
// RUN: %empty-directory(%t)
2+
3+
// RUN: %target-swift-typecheck-module-from-interface(%S/Inputs/opaque-type-abi-name/Bottom.swiftinterface) -module-name Bottom -o %t/Bottom.swiftmodule -verify
4+
// RUN: %target-swift-typecheck-module-from-interface(%S/Inputs/opaque-type-abi-name/Top.swiftinterface) -module-name Top -o %t/Top.swiftmodule -verify -I %S/Inputs/opaque-type-abi-name

0 commit comments

Comments
 (0)