mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
When sorting imports for uniquing purposes, use full module names
Fixes a longstanding issue where submodules with the same name in different top-level modules weren't being sorted deterministically. This doesn't come up very much in practice, and it would have been hard to notice anything wrong, but it's good to be right.
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
module X {
|
||||
explicit module Submodule {}
|
||||
}
|
||||
|
||||
module Y {
|
||||
explicit module Submodule {}
|
||||
}
|
||||
22
test/ModuleInterface/imports-submodule-order.swift
Normal file
22
test/ModuleInterface/imports-submodule-order.swift
Normal file
@@ -0,0 +1,22 @@
|
||||
// RUN: %target-swift-frontend -emit-interface-path - -emit-module -o /dev/null %s -I %S/Inputs/imports-submodule-order/ | %FileCheck %s
|
||||
// RUN: %target-swift-frontend -emit-interface-path - -emit-module -o /dev/null %s -I %S/Inputs/imports-submodule-order/ -D XY | %FileCheck %s
|
||||
|
||||
#if XY
|
||||
@_exported import X.Submodule
|
||||
@_exported import Y.Submodule
|
||||
|
||||
#else
|
||||
@_exported import Y.Submodule
|
||||
@_exported import X.Submodule
|
||||
|
||||
#endif
|
||||
|
||||
// The order below is not alphabetical, just deterministic given a set of
|
||||
// imports across any number of files and in any order.
|
||||
|
||||
// CHECK-NOT: import
|
||||
// CHECK: import X.Submodule{{$}}
|
||||
// CHECK-NEXT: import Y.Submodule{{$}}
|
||||
// CHECK-NEXT: import X{{$}}
|
||||
// CHECK-NEXT: import Y{{$}}
|
||||
// CHECK-NOT: import
|
||||
Reference in New Issue
Block a user