-
Notifications
You must be signed in to change notification settings - Fork 10.5k
stdlib: Adopt ExtensionImportVisibility
experimental feature
#72871
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
77c0aae
Tests: Remove unnecessary public modifier on extensions.
tshortli 2af24b2
Tests: Verify ExtensionImportVisibility works for @_exported imports.
tshortli 78cd114
stdlib: Adopt `ExtensionImportVisibility` experimental feature.
tshortli d0571af
Tests: Add Obj-C interop tests for ExtensionImportVisibility.
tshortli File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
@import Foundation; | ||
|
||
@interface X | ||
@end | ||
|
||
@interface X (A) | ||
- (void)fromA; | ||
@end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
@_exported import Categories_A | ||
|
||
extension X { | ||
public func fromOverlayForA() {} | ||
@objc public func fromOverlayForAObjC() {} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
@import Categories_A; | ||
|
||
@interface X (B) | ||
- (void)fromB; | ||
@end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
@_exported import Categories_B | ||
|
||
extension X { | ||
public func fromOverlayForB() {} | ||
@objc public func fromOverlayForBObjC() {} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
@import Categories_A; | ||
|
||
@interface X (C) | ||
- (void)fromC; | ||
@end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
@_exported import Categories_C | ||
|
||
extension X { | ||
public func fromOverlayForC() {} | ||
@objc public func fromOverlayForCObjC() {} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
import Categories_C |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
module Categories_A { | ||
header "Categories_A.h" | ||
export * | ||
} | ||
|
||
module Categories_B { | ||
header "Categories_B.h" | ||
export * | ||
} | ||
|
||
module Categories_C { | ||
header "Categories_C.h" | ||
export * | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,10 @@ | ||
import extensions_A | ||
|
||
public extension X { | ||
extension X { | ||
public func XinB() { } | ||
} | ||
|
||
public extension Y { | ||
extension Y { | ||
public func YinB() { } | ||
} | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
import extensions_A | ||
@_exported import extensions_A | ||
import extensions_B | ||
|
||
public extension X { | ||
extension X { | ||
public func XinC() { } | ||
} | ||
|
||
public extension Y { | ||
extension Y { | ||
public func YinC() { } | ||
} | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
// RUN: %empty-directory(%t) | ||
// RUN: %target-swift-frontend -emit-module -I %t -I %S/Inputs/Categories -o %t %S/Inputs/Categories/Categories_A.swift | ||
// RUN: %target-swift-frontend -emit-module -I %t -I %S/Inputs/Categories -o %t %S/Inputs/Categories/Categories_B.swift | ||
// RUN: %target-swift-frontend -emit-module -I %t -I %S/Inputs/Categories -o %t %S/Inputs/Categories/Categories_C.swift | ||
// RUN: %target-swift-frontend -emit-module -I %t -I %S/Inputs/Categories -o %t %S/Inputs/Categories/Categories_D.swift | ||
// RUN: %target-swift-frontend -typecheck %s -I %t -I %S/Inputs/Categories -verify -enable-experimental-feature ExtensionImportVisibility | ||
|
||
// REQUIRES: objc_interop | ||
|
||
import Categories_B | ||
import Categories_D | ||
// expected-note 2 {{add import of module 'Categories_C'}}{{1-1=import Categories_C\n}} | ||
func test(x: X) { | ||
x.fromA() | ||
x.fromOverlayForA() | ||
x.fromB() | ||
x.fromOverlayForB() | ||
x.fromC() // expected-error {{class method 'fromC()' is not available due to missing import of defining module 'Categories_C'}} | ||
x.fromOverlayForC() // expected-error {{instance method 'fromOverlayForC()' is not available due to missing import of defining module 'Categories_C'}} | ||
} | ||
|
||
func testAnyObject(a: AnyObject) { | ||
a.fromA() | ||
a.fromOverlayForAObjC() | ||
a.fromB() | ||
a.fromOverlayForBObjC() | ||
// FIXME: Better diagnostics? | ||
// Name lookup for AnyObject already ignored transitive imports, so | ||
// ExtensionImportVisibility has no effect on these diagnostics. | ||
a.fromC() // expected-error {{value of type 'AnyObject' has no member 'fromC'}} | ||
a.fromOverlayForCObjC() // expected-error {{value of type 'AnyObject' has no member 'fromOverlayForCObjC'}} | ||
} |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TIL