File tree Expand file tree Collapse file tree 5 files changed +45
-0
lines changed
Expand file tree Collapse file tree 5 files changed +45
-0
lines changed Original file line number Diff line number Diff line change @@ -125,6 +125,8 @@ IDENTIFIER(objectAtIndexedSubscript)
125125IDENTIFIER(objectForKeyedSubscript)
126126IDENTIFIER(ObjectiveC)
127127IDENTIFIER_(ObjectiveCType)
128+ IDENTIFIER(Observation)
129+ IDENTIFIER_WITH_NAME(Observation_, " _Observation" )
128130IDENTIFIER(oldValue)
129131IDENTIFIER(Optional)
130132IDENTIFIER_(OptionalNilComparisonType)
Original file line number Diff line number Diff line change @@ -680,6 +680,25 @@ static void recordShadowedDeclsAfterTypeMatch(
680680 }
681681 }
682682
683+ // Next, prefer any other module over the (_)Observation module.
684+ auto obsModule = ctx.getLoadedModule (ctx.Id_Observation );
685+ if (!obsModule)
686+ obsModule = ctx.getLoadedModule (ctx.Id_Observation_ );
687+ if (obsModule) {
688+ if ((firstModule == obsModule) != (secondModule == obsModule)) {
689+ // If second module is (_)Observation, then it is shadowed by
690+ // first.
691+ if (secondModule == obsModule) {
692+ shadowed.insert (secondDecl);
693+ continue ;
694+ }
695+
696+ // Otherwise, the first declaration is shadowed by the second.
697+ shadowed.insert (firstDecl);
698+ break ;
699+ }
700+ }
701+
683702 // The Foundation overlay introduced Data.withUnsafeBytes, which is
684703 // treated as being ambiguous with SwiftNIO's Data.withUnsafeBytes
685704 // extension. Apply a special-case name shadowing rule to use the
Original file line number Diff line number Diff line change 1+ public enum Observable < Value> {
2+ case just( Value )
3+ }
Original file line number Diff line number Diff line change 1+ @_exported import _Observation
2+
Original file line number Diff line number Diff line change 1+ // RUN: %empty-directory(%t)
2+ // RUN: %target-swift-frontend -emit-module -o %t %S/Inputs/HasObservable.swift
3+ // RUN: %target-swift-frontend -emit-module -o %t %S/Inputs/ReexportsObservation.swift
4+ // RUN: %target-swift-frontend -typecheck %s -I %t -verify
5+ // RUN: %target-swift-frontend -typecheck %s -I %t -verify -DVIA_REEXPORT
6+
7+ // REQUIRES: observation
8+
9+ import HasObservable
10+
11+ #if VIA_REEXPORT
12+ import ReexportsObservation
13+ #else
14+ import _Observation
15+ #endif
16+
17+ func foo( ) -> Observable < Int > {
18+ return . just( 42 )
19+ }
You can’t perform that action at this time.
0 commit comments