Skip to content

Commit a186a51

Browse files
authored
Merge pull request #71478 from hamishknight/user-land
Remove special case for stdlib in IsNonUserModuleRequest
2 parents e380c66 + 05612bf commit a186a51

File tree

3 files changed

+43
-5
lines changed

3 files changed

+43
-5
lines changed

lib/AST/Module.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3906,10 +3906,6 @@ FrontendStatsTracer::getTraceFormatter<const SourceFile *>() {
39063906
}
39073907

39083908
bool IsNonUserModuleRequest::evaluate(Evaluator &evaluator, ModuleDecl *mod) const {
3909-
// stdlib is non-user by definition
3910-
if (mod->isStdlibModule())
3911-
return true;
3912-
39133909
// If there's no SDK path, fallback to checking whether the module was
39143910
// in the system search path or a clang system module
39153911
SearchPathOptions &searchPathOpts = mod->getASTContext().SearchPathOpts;

test/IDE/complete_diagnostics.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ import MyModule
7777
import #^IMPORT^#;
7878
// IMPORT-DAG: Decl[Module]/None/NotRecommended: MyModule[#Module#]; name=MyModule; diagnostics=warning:module 'MyModule' is already imported{{$}}
7979
// IMPORT-DAG: Decl[Module]/None/NotRecommended: OtherModule[#Module#]; name=OtherModule; diagnostics=note:module 'OtherModule' is already imported via another module import{{$}}
80-
// IMPORT-DAG: Decl[Module]/None/NotRecommended/IsSystem: Swift[#Module#]; name=Swift; diagnostics=warning:module 'Swift' is already imported{{$}}
80+
// IMPORT-DAG: Decl[Module]/None/NotRecommended: Swift[#Module#]; name=Swift; diagnostics=warning:module 'Swift' is already imported{{$}}
8181

8282
func test(foo: Foo) {
8383
foo.#^MEMBER^#
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
// This test ensures that we don't consider the stdlib as a system library if
2+
// it's a module that we're building outside of the resource path.
3+
4+
//--- Swift.swift
5+
public enum E {
6+
case a, b, c
7+
}
8+
9+
//--- Client.swift
10+
func test(_ x: E) {
11+
if case .a = x {}
12+
}
13+
14+
// RUN: %empty-directory(%t)
15+
// RUN: split-file --leading-lines %s %t
16+
17+
// RUN: %empty-directory(%t/modules)
18+
// RUN: %empty-directory(%t/modulecache)
19+
20+
// RUN: %target-swift-frontend -emit-module -module-name Swift -parse-stdlib -swift-version 5 -enable-library-evolution -emit-module-interface-path %t/modules/Swift.swiftinterface -emit-module-source-info-path %t/modules/Swift.swiftsourceinfo %t/Swift.swift -o /dev/null
21+
22+
// RUN: %sourcekitd-test -req=cursor -pos=10:16 %t/Client.swift -- -I %t/modules -module-cache-path %t/modulecache -target %target-triple %t/Client.swift | %FileCheck %s -check-prefix=CHECK1
23+
// CHECK1: source.lang.swift.ref.enum ({{.*}}Swift.swift:5:13-5:14)
24+
// CHECK1-NEXT: E
25+
// CHECK1-NEXT: s:s1EO
26+
// CHECK1-NOT: SYSTEM
27+
28+
// RUN: %sourcekitd-test -req=cursor -pos=11:12 %t/Client.swift -- -I %t/modules -module-cache-path %t/modulecache -target %target-triple %t/Client.swift | %FileCheck %s -check-prefix=CHECK2
29+
// CHECK2: source.lang.swift.ref.enumelement ({{.*}}Swift.swift:6:8-6:9)
30+
// CHECK2-NEXT: a
31+
// CHECK2-NEXT: s:s1EO1ayA2BmF
32+
// CHECK2-NOT: SYSTEM
33+
34+
// Now try again with a swiftmodule.
35+
36+
// RUN: %empty-directory(%t/modules)
37+
// RUN: %empty-directory(%t/modulecache)
38+
39+
// RUN: %target-swift-frontend -emit-module -module-name Swift -parse-stdlib -swift-version 5 -enable-library-evolution %t/Swift.swift -emit-module-path %t/modules/Swift.swiftmodule -emit-module-source-info-path %t/modules/Swift.swiftsourceinfo
40+
41+
// RUN: %sourcekitd-test -req=cursor -pos=10:16 %t/Client.swift -- -I %t/modules -target %target-triple %t/Client.swift | %FileCheck %s -check-prefix=CHECK1
42+
// RUN: %sourcekitd-test -req=cursor -pos=11:12 %t/Client.swift -- -I %t/modules -target %target-triple %t/Client.swift | %FileCheck %s -check-prefix=CHECK2

0 commit comments

Comments
 (0)