Skip to content

Commit 3aa1c1a

Browse files
committed
[Frontend] Support underlying module for an aliased module
1 parent 5dbdb87 commit 3aa1c1a

File tree

2 files changed

+33
-1
lines changed

2 files changed

+33
-1
lines changed

lib/Sema/ImportResolution.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,8 @@ getModuleImpl(ImportPath::Module modulePath, ModuleDecl *loadingModule,
371371
//
372372
// FIXME: We'd like to only use this in SIL mode, but unfortunately we use it
373373
// for clang overlays as well.
374-
if (moduleID.Item == loadingModule->getName() && modulePath.size() == 1) {
374+
if (ctx.getRealModuleName(moduleID.Item) == loadingModule->getName() &&
375+
modulePath.size() == 1) {
375376
if (auto importer = ctx.getClangModuleLoader())
376377
return importer->loadModule(moduleID.Loc, modulePath);
377378
return nullptr;
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
// RUN: %empty-directory(%t)
2+
// RUN: split-file %s %t
3+
4+
// RUN: %target-swift-frontend -typecheck -module-name MyModule \
5+
// RUN: -swift-version 5 \
6+
// RUN: -o %t/MyModule.swiftmodule \
7+
// RUN: %t/MyModuleOk.swift -I%t
8+
9+
// RUN: %target-swift-frontend -typecheck -module-name MyModule \
10+
// RUN: -swift-version 5 \
11+
// RUN: -o %t/MyModule.swiftmodule \
12+
// RUN: %t/MyModule.swift -I%t \
13+
// RUN: -module-alias Mod___MyModule=MyModule
14+
15+
//--- module.modulemap
16+
module MyModule {
17+
header "MyModule.h"
18+
}
19+
20+
//--- MyModule.h
21+
struct UnderlyingType {};
22+
23+
//--- MyModuleOk.swift
24+
25+
@_exported import MyModule
26+
public func refToUnderlying(_ a: MyModule.UnderlyingType) {}
27+
28+
//--- MyModule.swift
29+
30+
@_exported import Mod___MyModule
31+
public func refToUnderlying(_ a: Mod___MyModule.UnderlyingType) {}

0 commit comments

Comments
 (0)