mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Improve some diagnostic with @_implementationOnly violations from internal bridging headers
This commit is contained in:
@@ -2702,8 +2702,8 @@ NOTE(module_imported_here,none,
|
||||
NOTE(decl_import_via_here,none,
|
||||
"%kind0 imported as "
|
||||
"'%select{private|fileprivate|internal|package|%ERROR|%ERROR}1' "
|
||||
"from %2 here",
|
||||
(const Decl *, AccessLevel, const ModuleDecl*))
|
||||
"from %select{%2 here|bridging header}3",
|
||||
(const Decl *, AccessLevel, const ModuleDecl*, bool))
|
||||
NOTE(decl_import_via_local,none,
|
||||
"%kind0 is imported by this file as "
|
||||
"'%select{private|fileprivate|internal|package|%ERROR|%ERROR}1' "
|
||||
|
||||
@@ -133,7 +133,9 @@ bool TypeChecker::diagnoseInlinableDeclRefAccess(SourceLoc loc,
|
||||
Context.Diags.diagnose(problematicImport->importLoc,
|
||||
diag::decl_import_via_here, D,
|
||||
problematicImport->accessLevel,
|
||||
problematicImport->module.importedModule);
|
||||
problematicImport->module.importedModule,
|
||||
problematicImport->module.importedModule
|
||||
->isClangHeaderImportModule());
|
||||
}
|
||||
|
||||
return (downgradeToWarning == DowngradeToWarning::No);
|
||||
@@ -213,7 +215,9 @@ static bool diagnoseTypeAliasDeclRefExportability(SourceLoc loc,
|
||||
ctx.Diags.diagnose(limitImport->importLoc,
|
||||
diag::decl_import_via_here, D,
|
||||
limitImport->accessLevel,
|
||||
limitImport->module.importedModule);
|
||||
limitImport->module.importedModule,
|
||||
limitImport->module.importedModule
|
||||
->isClangHeaderImportModule());
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -368,7 +372,9 @@ static bool diagnoseValueDeclRefExportability(SourceLoc loc, const ValueDecl *D,
|
||||
ctx.Diags.diagnose(import->importLoc,
|
||||
diag::decl_import_via_here, D,
|
||||
import->accessLevel,
|
||||
import->module.importedModule);
|
||||
import->module.importedModule,
|
||||
import->module.importedModule
|
||||
->isClangHeaderImportModule());
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -454,7 +460,9 @@ TypeChecker::diagnoseConformanceExportability(SourceLoc loc,
|
||||
ctx.Diags.diagnose(limitImport->importLoc,
|
||||
diag::decl_import_via_here, ext,
|
||||
limitImport->accessLevel,
|
||||
limitImport->module.importedModule);
|
||||
limitImport->module.importedModule,
|
||||
limitImport->module.importedModule
|
||||
->isClangHeaderImportModule());
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@@ -461,7 +461,9 @@ static void noteLimitingImport(const Decl *userDecl, ASTContext &ctx,
|
||||
if (limitImport->importLoc.isValid())
|
||||
ctx.Diags.diagnose(limitImport->importLoc, diag::decl_import_via_here,
|
||||
complainDecl, limitImport->accessLevel,
|
||||
limitImport->module.importedModule);
|
||||
limitImport->module.importedModule,
|
||||
limitImport->module.importedModule
|
||||
->isClangHeaderImportModule());
|
||||
} else if (limitImport->importLoc.isValid()) {
|
||||
ctx.Diags.diagnose(limitImport->importLoc, diag::module_imported_here,
|
||||
limitImport->module.importedModule,
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
// RUN: %empty-directory(%t)
|
||||
// RUN: mkdir -p %t/tmp
|
||||
|
||||
// Test with the normal bridging header.
|
||||
// RUN: %target-typecheck-verify-swift -internal-import-bridging-header %S/../Inputs/c-bridging-header.h -sdk %clang-importer-sdk -verify-ignore-unknown
|
||||
|
||||
// RUN: not %target-swift-frontend -typecheck -internal-import-bridging-header %S/../Inputs/c-bridging-header.h -sdk %clang-importer-sdk %s 2>&1 | %FileCheck %s
|
||||
|
||||
// Test with a precompiled bridging header.
|
||||
// RUN: %target-swift-frontend -emit-pch -o %t/c-bridging-header.pch %S/../Inputs/c-bridging-header.h -sdk %clang-importer-sdk
|
||||
// RUN: %target-typecheck-verify-swift -internal-import-bridging-header %t/c-bridging-header.pch -sdk %clang-importer-sdk -verify-ignore-unknown
|
||||
|
||||
|
||||
@inlinable
|
||||
public func f() -> Any {
|
||||
return red
|
||||
// expected-error@-1{{var 'red' is internal and cannot be referenced from an '@inlinable' function}}
|
||||
// expected-warning@-2{{getter for var 'red' is internal and should not be referenced from an '@inlinable' function}}
|
||||
}
|
||||
|
||||
// CHECK: var 'red' imported as 'internal' from bridging header
|
||||
Reference in New Issue
Block a user