Skip to content

Commit e1df94a

Browse files
authored
Merge pull request #34642 from kavon/shadowing-concurrency-lib
2 parents d7c6c00 + 5468b2e commit e1df94a

File tree

3 files changed

+33
-0
lines changed

3 files changed

+33
-0
lines changed

lib/AST/NameLookup.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -510,6 +510,21 @@ static void recordShadowedDeclsAfterTypeMatch(
510510
}
511511
}
512512

513+
// Next, prefer any other module over the _Concurrency module.
514+
if (auto concurModule = ctx.getLoadedModule(ctx.Id_Concurrency)) {
515+
if ((firstModule == concurModule) != (secondModule == concurModule)) {
516+
// If second module is _Concurrency, then it is shadowed by first.
517+
if (secondModule == concurModule) {
518+
shadowed.insert(secondDecl);
519+
continue;
520+
}
521+
522+
// Otherwise, the first declaration is shadowed by the second.
523+
shadowed.insert(firstDecl);
524+
break;
525+
}
526+
}
527+
513528
// The Foundation overlay introduced Data.withUnsafeBytes, which is
514529
// treated as being ambiguous with SwiftNIO's Data.withUnsafeBytes
515530
// extension. Apply a special-case name shadowing rule to use the
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
2+
public struct Task {
3+
public var someProperty : String = "123"
4+
public init() { }
5+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// RUN: %empty-directory(%t)
2+
// RUN: %target-swift-frontend -emit-module -emit-module-path %t/ShadowsConcur.swiftmodule -module-name ShadowsConcur %S/Inputs/ShadowsConcur.swift
3+
// RUN: %target-typecheck-verify-swift -I %t -enable-experimental-concurrency
4+
// REQUIRES: concurrency
5+
6+
7+
import ShadowsConcur
8+
9+
func f(_ t : Task) -> Bool {
10+
return t.someProperty == "123"
11+
}
12+
13+
func g(_: _Concurrency.Task) {}

0 commit comments

Comments
 (0)