mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
[Sema] Name the decl in the error on package level without a package
This commit is contained in:
@@ -1935,9 +1935,9 @@ WARNING(access_control_non_objc_open_member,none,
|
||||
"non-'@objc' %0 in extensions cannot be overridden; use 'public' instead",
|
||||
(DescriptiveDeclKind))
|
||||
ERROR(access_control_requires_package_name, none,
|
||||
"the package access level requires a package name; "
|
||||
"set it with the compiler flag -package-name",
|
||||
())
|
||||
"the package access level %select{|used on %1 }0"
|
||||
"requires a package name; set it with the compiler flag -package-name",
|
||||
(bool, const Decl*))
|
||||
ERROR(invalid_decl_attribute,none,
|
||||
"'%0' attribute cannot be applied to this declaration", (DeclAttribute))
|
||||
ERROR(attr_invalid_on_decl_kind,none,
|
||||
|
||||
@@ -1023,7 +1023,8 @@ bool AttributeChecker::visitAbstractAccessControlAttr(
|
||||
D->getASTContext().LangOpts.PackageName.empty() &&
|
||||
File && File->Kind != SourceFileKind::Interface) {
|
||||
// `package` modifier used outside of a package.
|
||||
diagnose(attr->getLocation(), diag::access_control_requires_package_name);
|
||||
diagnose(attr->getLocation(), diag::access_control_requires_package_name,
|
||||
isa<ValueDecl>(D), D);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -16,8 +16,8 @@ public struct PackageImportType {}
|
||||
//--- Client.swift
|
||||
package import PackageLib // expected-error {{the package access level requires a package name; set it with the compiler flag -package-name}}
|
||||
|
||||
package struct PackageStruct { // expected-error {{the package access level requires a package name; set it with the compiler flag -package-name}}
|
||||
package func explicitlyPackage() {} // expected-error {{the package access level requires a package name; set it with the compiler flag -package-name}}
|
||||
package struct PackageStruct { // expected-error {{the package access level used on 'PackageStruct' requires a package name; set it with the compiler flag -package-name}}
|
||||
package func explicitlyPackage() {} // expected-error {{the package access level used on 'explicitlyPackage()' requires a package name; set it with the compiler flag -package-name}}
|
||||
}
|
||||
|
||||
public struct PublicStruct {}
|
||||
|
||||
@@ -3,11 +3,11 @@
|
||||
// Package name should not be empty
|
||||
// RUN: not %target-swift-frontend -typecheck %s -package-name "" 2>&1 | %FileCheck %s -check-prefix CHECK-EMPTY
|
||||
// CHECK-EMPTY: error: package-name is empty
|
||||
// CHECK-EMPTY: error: the package access level requires a package name; set it with the compiler flag -package-name
|
||||
// CHECK-EMPTY: error: the package access level used on 'log()' requires a package name; set it with the compiler flag -package-name
|
||||
|
||||
// If package access level is used but no package-name is passed, it should error
|
||||
// RUN: not %target-swift-frontend -typecheck %s 2>&1 | %FileCheck %s -check-prefix CHECK-MISSING
|
||||
// CHECK-MISSING: error: the package access level requires a package name; set it with the compiler flag -package-name
|
||||
// CHECK-MISSING: error: the package access level used on 'log()' requires a package name; set it with the compiler flag -package-name
|
||||
|
||||
// Package name can be same as the module name
|
||||
// RUN: %target-swift-frontend -module-name Logging -package-name Logging %s -emit-module -emit-module-path %t/Logging.swiftmodule
|
||||
|
||||
Reference in New Issue
Block a user