-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[Diagnostics] Mark invalid ‘@testable import’ as fatal #22191
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
// RUN: %empty-directory(%t) | ||
// RUN: %target-swift-frontend -emit-module -o %t/single_int.swiftmodule %S/Inputs/single_int.swift | ||
// RUN: not %target-swift-frontend -typecheck %s -I %t 2>&1 | %FileCheck %s | ||
|
||
@testable import single_int // CHECK: module 'single_int' was not compiled for testing | ||
|
||
x = 8 // CHECK-NOT: unresolved identifier |
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,14 +1,24 @@ | ||
// RUN: %empty-directory(%t) | ||
// RUN: %target-swift-frontend -emit-module -enable-testing -o %t %S/../Inputs/empty.swift | ||
|
||
// Make sure we don't get any errors when importing the modules that were compiled for testing | ||
// RUN: %target-swift-frontend -typecheck -I %t -I %S/Inputs/custom-modules %s -verify | ||
// RUN: %target-swift-frontend -typecheck -I %t -I %S/Inputs/custom-modules %s -disable-testable-attr-requires-testable-module -DIMPORTS_ONLY | ||
|
||
@testable import Swift // expected-error {{module 'Swift' was not compiled for testing}} | ||
// Make sure no errors are thrown if we disable the @testable check | ||
// RUN: %target-swift-frontend -typecheck -I %t -I %S/Inputs/custom-modules %s -verify -disable-testable-attr-requires-testable-module | ||
|
||
// Make sure we get the one fatal error for the stdlib not being compiled for testing | ||
// RUN: not %target-swift-frontend -typecheck -I %t -I %S/Inputs/custom-modules %s 2>&1 -DINCLUDE_STDLIB | %FileCheck %s | ||
|
||
|
||
#if INCLUDE_STDLIB | ||
// CHECK: module 'Swift' was not compiled for testing | ||
@testable import Swift | ||
#endif | ||
|
||
// CHECK-NOT: module 'empty' was not compiled for testing | ||
@testable import empty // no-error | ||
// CHECK-NOT: module 'Testable_ClangModule' was not compiled for testing | ||
@testable import Testable_ClangModule // no-error | ||
|
||
_ = clangGlobal | ||
|
||
#if !IMPORTS_ONLY | ||
@testable func foo() {} // expected-error {{@testable may only be used on 'import' declarations}} {{1-11=}} | ||
#endif |
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,3 @@ | ||
// RUN: %target-swift-frontend -typecheck -verify %s | ||
|
||
@testable func foo() {} // expected-error {{@testable may only be used on 'import' declarations}} {{1-11=}} |
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.
Now these aren't being checked anymore.
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.
How about now? I'm trying to be a bit more explicit than before.