[Diagnostics] handle ‘open’ access control; introduce %error modifier

This commit is contained in:
Jacob Bandes-Storch
2016-11-19 02:50:32 -08:00
parent 96f2a04f55
commit 32635696bd
6 changed files with 128 additions and 104 deletions

View File

@@ -202,7 +202,7 @@ ERROR(enum_case_dot_prefix,none,
// Variable getters/setters // Variable getters/setters
ERROR(static_var_decl_global_scope,none, ERROR(static_var_decl_global_scope,none,
"%select{ERROR|static properties|class properties}0 may only be declared on a type", "%select{%error|static properties|class properties}0 may only be declared on a type",
(StaticSpellingKind)) (StaticSpellingKind))
ERROR(computed_property_no_accessors, none, ERROR(computed_property_no_accessors, none,
"computed property must have accessors specified", ()) "computed property must have accessors specified", ())
@@ -222,7 +222,7 @@ ERROR(conflicting_property_addressor,none,
"%select{variable|subscript}0 already has a " "%select{variable|subscript}0 already has a "
"%select{addressor|mutable addressor}1", (unsigned, unsigned)) "%select{addressor|mutable addressor}1", (unsigned, unsigned))
ERROR(expected_accessor_name,none, ERROR(expected_accessor_name,none,
"expected %select{GETTER|setter|willSet|didSet}0 parameter name", "expected %select{%error|setter|willSet|didSet}0 parameter name",
(unsigned)) (unsigned))
ERROR(expected_rparen_set_name,none, ERROR(expected_rparen_set_name,none,
"expected ')' after setter parameter name",()) "expected ')' after setter parameter name",())
@@ -292,7 +292,7 @@ ERROR(associated_type_generic_parameter_list,PointsToFirstBadToken,
ERROR(func_decl_without_paren,PointsToFirstBadToken, ERROR(func_decl_without_paren,PointsToFirstBadToken,
"expected '(' in argument list of function declaration", ()) "expected '(' in argument list of function declaration", ())
ERROR(static_func_decl_global_scope,none, ERROR(static_func_decl_global_scope,none,
"%select{ERROR|static methods|class methods}0 may only be declared on a type", "%select{%error|static methods|class methods}0 may only be declared on a type",
(StaticSpellingKind)) (StaticSpellingKind))
ERROR(func_decl_expected_arrow,none, ERROR(func_decl_expected_arrow,none,
"expected '->' after function parameter tuple", ()) "expected '->' after function parameter tuple", ())

View File

@@ -119,17 +119,17 @@ ERROR(could_not_use_member_on_existential,none,
ERROR(candidate_inaccessible,none, ERROR(candidate_inaccessible,none,
"%0 is inaccessible due to " "%0 is inaccessible due to "
"'%select{private|fileprivate|internal|PUBLIC}1' protection level", "'%select{private|fileprivate|internal|%error|%error}1' protection level",
(DeclName, Accessibility)) (DeclName, Accessibility))
NOTE(note_candidate_inaccessible,none, NOTE(note_candidate_inaccessible,none,
"%0 is inaccessible due to " "%0 is inaccessible due to "
"'%select{private|fileprivate|internal|PUBLIC}1' protection level", "'%select{private|fileprivate|internal|%error|%error}1' protection level",
(DeclName, Accessibility)) (DeclName, Accessibility))
ERROR(init_candidate_inaccessible,none, ERROR(init_candidate_inaccessible,none,
"%0 initializer is inaccessible due to " "%0 initializer is inaccessible due to "
"'%select{private|fileprivate|internal|PUBLIC}1' protection level", "'%select{private|fileprivate|internal|%error|%error}1' protection level",
(Type, Accessibility)) (Type, Accessibility))
ERROR(all_candidates_inaccessible,none, ERROR(all_candidates_inaccessible,none,
@@ -623,12 +623,12 @@ ERROR(unsupported_existential_type,none,
"Self or associated type requirements", (Identifier)) "Self or associated type requirements", (Identifier))
ERROR(decl_does_not_exist_in_module,none, ERROR(decl_does_not_exist_in_module,none,
"%select{**MODULE**|type|struct|class|enum|protocol|variable|function}0 " "%select{%error|type|struct|class|enum|protocol|variable|function}0 "
"%1 does not exist in module %2", "%1 does not exist in module %2",
(/*ImportKind*/ unsigned, Identifier, Identifier)) (/*ImportKind*/ unsigned, Identifier, Identifier))
ERROR(imported_decl_is_wrong_kind,none, ERROR(imported_decl_is_wrong_kind,none,
"%0 was imported as '%1', but is a " "%0 was imported as '%1', but is a "
"%select{**MODULE**|type|struct|class|enum|protocol|variable|function}2", "%select{%error|type|struct|class|enum|protocol|variable|function}2",
(Identifier, StringRef, /*ImportKind*/ unsigned)) (Identifier, StringRef, /*ImportKind*/ unsigned))
ERROR(ambiguous_decl_in_module,none, ERROR(ambiguous_decl_in_module,none,
"ambiguous name %0 in module %1", (Identifier, Identifier)) "ambiguous name %0 in module %1", (Identifier, Identifier))
@@ -1022,31 +1022,31 @@ ERROR(attr_methods_only,none,
ERROR(access_control_in_protocol,none, ERROR(access_control_in_protocol,none,
"%0 modifier cannot be used in protocols", (DeclAttribute)) "%0 modifier cannot be used in protocols", (DeclAttribute))
ERROR(access_control_setter,none, ERROR(access_control_setter,none,
"'%select{private|fileprivate|internal|public}0(set)' modifier can only " "'%select{private|fileprivate|internal|public|open}0(set)' modifier can only "
"be applied to variables and subscripts", "be applied to variables and subscripts",
(Accessibility)) (Accessibility))
ERROR(access_control_setter_read_only,none, ERROR(access_control_setter_read_only,none,
"'%select{private|fileprivate|internal|public}0(set)' modifier cannot be " "'%select{private|fileprivate|internal|public|%error}0(set)' modifier cannot be "
"applied to %select{constants|read-only variables|read-only properties" "applied to %select{constants|read-only variables|read-only properties"
"|read-only subscripts}1", "|read-only subscripts}1",
(Accessibility, unsigned)) (Accessibility, unsigned))
ERROR(access_control_setter_more,none, ERROR(access_control_setter_more,none,
"%select{private|fileprivate|internal|PUBLIC}0 " "%select{private|fileprivate|internal|public|%error}0 "
"%select{variable|property|subscript}1 cannot have " "%select{variable|property|subscript}1 cannot have "
"%select{PRIVATE|a fileprivate|an internal|a public}2 setter", "%select{%error|a fileprivate|an internal|a public|an open}2 setter",
(Accessibility, unsigned, Accessibility)) (Accessibility, unsigned, Accessibility))
WARNING(access_control_ext_member_more,none, WARNING(access_control_ext_member_more,none,
"declaring %select{PRIVATE|a fileprivate|an internal|a public}0 %1 in " "declaring %select{%error|a fileprivate|an internal|a public|open}0 %1 in "
"%select{a private|a fileprivate|an internal|PUBLIC}2 extension", "%select{a private|a fileprivate|an internal|public|%error}2 extension",
(Accessibility, DescriptiveDeclKind, Accessibility)) (Accessibility, DescriptiveDeclKind, Accessibility))
ERROR(access_control_ext_requirement_member_more,none, ERROR(access_control_ext_requirement_member_more,none,
"cannot declare %select{PRIVATE|a fileprivate|an internal|a public}0 %1 " "cannot declare %select{%error|a fileprivate|an internal|a public|an open}0 %1 "
"in an extension with %select{private|fileprivate|internal|PUBLIC}2 " "in an extension with %select{private|fileprivate|internal|public|%error}2 "
"requirements", "requirements",
(Accessibility, DescriptiveDeclKind, Accessibility)) (Accessibility, DescriptiveDeclKind, Accessibility))
ERROR(access_control_extension_more,none, ERROR(access_control_extension_more,none,
"extension of %select{private|fileprivate|internal|PUBLIC}0 %1 cannot " "extension of %select{private|fileprivate|internal|%error|%error}0 %1 cannot "
"be declared %select{PRIVATE|fileprivate|internal|public}2", "be declared %select{%error|fileprivate|internal|public|%error}2",
(Accessibility, DescriptiveDeclKind, Accessibility)) (Accessibility, DescriptiveDeclKind, Accessibility))
ERROR(access_control_extension_open,none, ERROR(access_control_extension_open,none,
"extensions cannot use 'open' as their default access; use 'public'", "extensions cannot use 'open' as their default access; use 'public'",
@@ -1134,39 +1134,39 @@ ERROR(observingprop_requires_initializer,none,
"non-member observing properties require an initializer", ()) "non-member observing properties require an initializer", ())
ERROR(global_requires_initializer,none, ERROR(global_requires_initializer,none,
"global '%select{var|let}0' declaration requires an initializer expression" "global '%select{var|let}0' declaration requires an initializer expression"
"%select{ or getter/setter specifier}0", (bool)) "%select{ or getter/setter specifier|}0", (bool))
ERROR(static_requires_initializer,none, ERROR(static_requires_initializer,none,
"%select{ERROR|'static var'|'class var'|}0 declaration requires an initializer " "%select{ERROR|'static var'|'class var'|}0 declaration requires an initializer "
"expression or getter/setter specifier", (StaticSpellingKind)) "expression or getter/setter specifier", (StaticSpellingKind))
ERROR(pattern_type_access,none, ERROR(pattern_type_access,none,
"%select{%select{variable|constant}0|property}1 " "%select{%select{variable|constant}0|property}1 "
"%select{must be declared %select{" "%select{must be declared %select{"
"%select{private|fileprivate|internal|PUBLIC}3|private or fileprivate}4" "%select{private|fileprivate|internal|%error|%error}3|private or fileprivate}4"
"|cannot be declared %select{PRIVATE|fileprivate|internal|public}3}2 " "|cannot be declared %select{%error|fileprivate|internal|public|open}3}2 "
"because its type uses " "because its type uses "
"%select{a private|a fileprivate|an internal|PUBLIC}5 type", "%select{a private|a fileprivate|an internal|%error|%error}5 type",
(bool, bool, bool, Accessibility, bool, Accessibility)) (bool, bool, bool, Accessibility, bool, Accessibility))
WARNING(pattern_type_access_warn,none, WARNING(pattern_type_access_warn,none,
"%select{%select{variable|constant}0|property}1 " "%select{%select{variable|constant}0|property}1 "
"%select{should be declared %select{private|fileprivate|internal|PUBLIC}5" "%select{should be declared %select{private|fileprivate|internal|%error|%error}5"
"|should not be declared %select{in this context|fileprivate|internal|public}3}2 " "|should not be declared %select{in this context|fileprivate|internal|public|open}3}2 "
"because its type uses " "because its type uses "
"%select{a private|a fileprivate|an internal|PUBLIC}5 type", "%select{a private|a fileprivate|an internal|%error|%error}5 type",
(bool, bool, bool, Accessibility, bool, Accessibility)) (bool, bool, bool, Accessibility, bool, Accessibility))
ERROR(pattern_type_access_inferred,none, ERROR(pattern_type_access_inferred,none,
"%select{%select{variable|constant}0|property}1 " "%select{%select{variable|constant}0|property}1 "
"%select{must be declared %select{" "%select{must be declared %select{"
"%select{private|fileprivate|internal|PUBLIC}3|private or fileprivate}4" "%select{private|fileprivate|internal|%error|%error}3|private or fileprivate}4"
"|cannot be declared %select{PRIVATE|fileprivate|internal|public}3}2 " "|cannot be declared %select{%error|fileprivate|internal|public|open}3}2 "
"because its type %6 uses " "because its type %6 uses "
"%select{a private|a fileprivate|an internal|PUBLIC}5 type", "%select{a private|a fileprivate|an internal|%error|%error}5 type",
(bool, bool, bool, Accessibility, bool, Accessibility, Type)) (bool, bool, bool, Accessibility, bool, Accessibility, Type))
WARNING(pattern_type_access_inferred_warn,none, WARNING(pattern_type_access_inferred_warn,none,
"%select{%select{variable|constant}0|property}1 " "%select{%select{variable|constant}0|property}1 "
"%select{should be declared %select{private|fileprivate|internal|PUBLIC}5" "%select{should be declared %select{private|fileprivate|internal|%error|%error}5"
"|should not be declared %select{in this context|fileprivate|internal|public}3}2 " "|should not be declared %select{in this context|fileprivate|internal|public|open}3}2 "
"because its type %6 uses " "because its type %6 uses "
"%select{a private|a fileprivate|an internal|PUBLIC}5 type", "%select{a private|a fileprivate|an internal|%error|%error}5 type",
(bool, bool, bool, Accessibility, bool, Accessibility, Type)) (bool, bool, bool, Accessibility, bool, Accessibility, Type))
ERROR(pattern_binds_no_variables,none, ERROR(pattern_binds_no_variables,none,
"%select{property|global variable}0 declaration does not bind any " "%select{property|global variable}0 declaration does not bind any "
@@ -1191,50 +1191,50 @@ ERROR(unsupported_nested_protocol,none,
// Type aliases // Type aliases
ERROR(type_alias_underlying_type_access,none, ERROR(type_alias_underlying_type_access,none,
"type alias %select{must be declared %select{" "type alias %select{must be declared %select{"
"%select{private|fileprivate|internal|PUBLIC}2|private or fileprivate}3" "%select{private|fileprivate|internal|%error|%error}2|private or fileprivate}3"
"|cannot be declared %select{PRIVATE|fileprivate|internal|public}1}0 " "|cannot be declared %select{%error|fileprivate|internal|public|open}1}0 "
"because its underlying type uses " "because its underlying type uses "
"%select{a private|a fileprivate|an internal|PUBLIC}2 type", "%select{a private|a fileprivate|an internal|%error|%error}2 type",
(bool, Accessibility, Accessibility, bool)) (bool, Accessibility, Accessibility, bool))
WARNING(type_alias_underlying_type_access_warn,none, WARNING(type_alias_underlying_type_access_warn,none,
"type alias %select{should be declared " "type alias %select{should be declared "
"%select{private|fileprivate|internal|PUBLIC}2" "%select{private|fileprivate|internal|%error|%error}2"
"|should not be declared %select{PRIVATE|fileprivate|internal|public}1}0 " "|should not be declared %select{%error|fileprivate|internal|public|open}1}0 "
"because its underlying type uses " "because its underlying type uses "
"%select{a private|a fileprivate|an internal|PUBLIC}2 type", "%select{a private|a fileprivate|an internal|%error|%error}2 type",
(bool, Accessibility, Accessibility, bool)) (bool, Accessibility, Accessibility, bool))
// Subscripts // Subscripts
ERROR(subscript_type_access,none, ERROR(subscript_type_access,none,
"subscript %select{must be declared " "subscript %select{must be declared "
"%select{private|fileprivate|internal|PUBLIC}1" "%select{private|fileprivate|internal|%error|%error}1"
"|cannot be declared %select{PRIVATE|fileprivate|internal|public}1}0 " "|cannot be declared %select{%error|fileprivate|internal|public|open}1}0 "
"because its %select{index|element type}3 uses " "because its %select{index|element type}3 uses "
"%select{a private|a fileprivate|an internal|PUBLIC}2 type", "%select{a private|a fileprivate|an internal|%error|%error}2 type",
(bool, Accessibility, Accessibility, bool)) (bool, Accessibility, Accessibility, bool))
WARNING(subscript_type_access_warn,none, WARNING(subscript_type_access_warn,none,
"subscript %select{should be declared " "subscript %select{should be declared "
"%select{private|fileprivate|internal|PUBLIC}2" "%select{private|fileprivate|internal|%error|%error}2"
"|should not be declared %select{in this context|fileprivate|internal|public}1}0 " "|should not be declared %select{in this context|fileprivate|internal|public|open}1}0 "
"because its %select{index|element type}3 uses " "because its %select{index|element type}3 uses "
"%select{a private|a fileprivate|an internal|PUBLIC}2 type", "%select{a private|a fileprivate|an internal|%error|%error}2 type",
(bool, Accessibility, Accessibility, bool)) (bool, Accessibility, Accessibility, bool))
// Functions // Functions
ERROR(function_type_access,none, ERROR(function_type_access,none,
"%select{function|method|initializer}4 " "%select{function|method|initializer}4 "
"%select{must be declared %select{" "%select{must be declared %select{"
"%select{private|fileprivate|internal|PUBLIC}1|private or fileprivate}2" "%select{private|fileprivate|internal|%error|%error}1|private or fileprivate}2"
"|cannot be declared %select{PRIVATE|fileprivate|internal|public}1}0 " "|cannot be declared %select{%error|fileprivate|internal|public|open}1}0 "
"because its %select{parameter|result}5 uses " "because its %select{parameter|result}5 uses "
"%select{a private|a fileprivate|an internal|PUBLIC}3 type", "%select{a private|a fileprivate|an internal|%error|%error}3 type",
(bool, Accessibility, bool, Accessibility, unsigned, bool)) (bool, Accessibility, bool, Accessibility, unsigned, bool))
WARNING(function_type_access_warn,none, WARNING(function_type_access_warn,none,
"%select{function|method|initializer}4 " "%select{function|method|initializer}4 "
"%select{should be declared %select{private|fileprivate|internal|PUBLIC}3" "%select{should be declared %select{private|fileprivate|internal|%error|%error}3"
"|should not be declared %select{in this context|fileprivate|internal|public}1}0 " "|should not be declared %select{in this context|fileprivate|internal|public|open}1}0 "
"because its %select{parameter|result}5 uses " "because its %select{parameter|result}5 uses "
"%select{a private|a fileprivate|an internal|PUBLIC}3 type", "%select{a private|a fileprivate|an internal|%error|%error}3 type",
(bool, Accessibility, bool, Accessibility, unsigned, bool)) (bool, Accessibility, bool, Accessibility, unsigned, bool))
WARNING(non_trailing_closure_before_default_args,none, WARNING(non_trailing_closure_before_default_args,none,
"closure parameter prior to parameters with default arguments will " "closure parameter prior to parameters with default arguments will "
@@ -1348,8 +1348,8 @@ ERROR(witness_requires_dynamic_self,none,
ERROR(witness_not_accessible_proto,none, ERROR(witness_not_accessible_proto,none,
"%select{initializer %1|method %1|%select{|setter for }2property %1" "%select{initializer %1|method %1|%select{|setter for }2property %1"
"|subscript%select{| setter}2}0 must be declared " "|subscript%select{| setter}2}0 must be declared "
"%select{PRIVATE|fileprivate|internal|public}3 because it matches a " "%select{%error|fileprivate|internal|public|%error}3 because it matches a "
"requirement in %select{private|fileprivate|internal|public}4 protocol " "requirement in %select{private|fileprivate|internal|public|%error}4 protocol "
"%5", "%5",
(RequirementKind, DeclName, bool, Accessibility, Accessibility, DeclName)) (RequirementKind, DeclName, bool, Accessibility, Accessibility, DeclName))
ERROR(witness_not_accessible_type,none, ERROR(witness_not_accessible_type,none,
@@ -1358,9 +1358,9 @@ ERROR(witness_not_accessible_type,none,
"type because it matches a requirement in protocol %5", "type because it matches a requirement in protocol %5",
(RequirementKind, DeclName, bool, Accessibility, Accessibility, DeclName)) (RequirementKind, DeclName, bool, Accessibility, Accessibility, DeclName))
ERROR(type_witness_not_accessible_proto,none, ERROR(type_witness_not_accessible_proto,none,
"%0 %1 must be declared %select{PRIVATE|fileprivate|internal|public}2 " "%0 %1 must be declared %select{%error|fileprivate|internal|public|%error}2 "
"because it matches a requirement in " "because it matches a requirement in "
"%select{PRIVATE|fileprivate|internal|public}2 protocol %3", "%select{%error|fileprivate|internal|public|%error}2 protocol %3",
(DescriptiveDeclKind, DeclName, Accessibility, DeclName)) (DescriptiveDeclKind, DeclName, Accessibility, DeclName))
ERROR(type_witness_not_accessible_type,none, ERROR(type_witness_not_accessible_type,none,
"%0 %1 must be as accessible as its enclosing type because it " "%0 %1 must be as accessible as its enclosing type because it "
@@ -1369,16 +1369,16 @@ ERROR(type_witness_not_accessible_type,none,
ERROR(protocol_refine_access,none, ERROR(protocol_refine_access,none,
"%select{protocol must be declared %select{" "%select{protocol must be declared %select{"
"%select{private|fileprivate|internal|PUBLIC}2" "%select{private|fileprivate|internal|%error|%error}2"
"|private or fileprivate}3 because it refines" "|private or fileprivate}3 because it refines"
"|%select{PRIVATE|fileprivate|internal|public}1 protocol cannot " "|%select{%error|fileprivate|internal|public|%error}1 protocol cannot "
"refine}0 %select{a private|a fileprivate|an internal|PUBLIC}2 protocol", "refine}0 %select{a private|a fileprivate|an internal|%error|%error}2 protocol",
(bool, Accessibility, Accessibility, bool)) (bool, Accessibility, Accessibility, bool))
WARNING(protocol_refine_access_warn,none, WARNING(protocol_refine_access_warn,none,
"%select{protocol should be declared " "%select{protocol should be declared "
"%select{private|fileprivate|internal|PUBLIC}2 because it refines" "%select{private|fileprivate|internal|%error|%error}2 because it refines"
"|%select{in this context|fileprivate|internal|public}1 protocol should not " "|%select{in this context|fileprivate|internal|public|%error}1 protocol should not "
"refine}0 %select{a private|a fileprivate|an internal|PUBLIC}2 protocol", "refine}0 %select{a private|a fileprivate|an internal|%error|%error}2 protocol",
(bool, Accessibility, Accessibility, bool)) (bool, Accessibility, Accessibility, bool))
ERROR(protocol_property_must_be_computed_var,none, ERROR(protocol_property_must_be_computed_var,none,
"immutable property requirement must be declared as 'var' with a " "immutable property requirement must be declared as 'var' with a "
@@ -1409,14 +1409,14 @@ NOTE(default_associated_type_req_fail,none,
(Type, DeclName, Type, Type, bool)) (Type, DeclName, Type, Type, bool))
ERROR(associated_type_access,none, ERROR(associated_type_access,none,
"associated type in " "associated type in "
"%select{PRIVATE|a fileprivate|an internal|a public}0 protocol uses " "%select{%error|a fileprivate|an internal|a public|%error}0 protocol uses "
"%select{a private|a fileprivate|an internal|PUBLIC}1 type in its " "%select{a private|a fileprivate|an internal|%error|%error}1 type in its "
"%select{default definition|requirement}2 ", "%select{default definition|requirement}2 ",
(Accessibility, Accessibility, unsigned)) (Accessibility, Accessibility, unsigned))
WARNING(associated_type_access_warn,none, WARNING(associated_type_access_warn,none,
"associated type in " "associated type in "
"%select{a private|a fileprivate|an internal|a public}0 protocol uses " "%select{a private|a fileprivate|an internal|a public|%error}0 protocol uses "
"%select{a private|a fileprivate|an internal|PUBLIC}1 type in its " "%select{a private|a fileprivate|an internal|%error|%error}1 type in its "
"%select{default definition|requirement}2 ", "%select{default definition|requirement}2 ",
(Accessibility, Accessibility, unsigned)) (Accessibility, Accessibility, unsigned))
@@ -1519,7 +1519,7 @@ NOTE(optional_req_near_match_move,none,
NOTE(optional_req_near_match_nonobjc,none, NOTE(optional_req_near_match_nonobjc,none,
"add '@nonobjc' to silence this %select{warning|error}0", (bool)) "add '@nonobjc' to silence this %select{warning|error}0", (bool))
NOTE(optional_req_near_match_accessibility,none, NOTE(optional_req_near_match_accessibility,none,
"make %0 %select{ERROR|private|private|non-public}1 to silence this " "make %0 %select{ERROR|private|private|non-public|non-public}1 to silence this "
"warning", (DeclName, Accessibility)) "warning", (DeclName, Accessibility))
// Protocols and existentials // Protocols and existentials
@@ -1578,17 +1578,17 @@ ERROR(requires_generic_param_same_type_does_not_conform,none,
ERROR(generic_param_access,none, ERROR(generic_param_access,none,
"%0 %select{must be declared %select{" "%0 %select{must be declared %select{"
"%select{private|fileprivate|internal|PUBLIC}3|private or fileprivate}4" "%select{private|fileprivate|internal|%error|%error}3|private or fileprivate}4"
"|cannot be declared %select{PRIVATE|fileprivate|internal|public}2}1 " "|cannot be declared %select{%error|fileprivate|internal|public|open}2}1 "
"because its generic %select{parameter|requirement}5 uses " "because its generic %select{parameter|requirement}5 uses "
"%select{a private|a fileprivate|an internal|PUBLIC}3 type", "%select{a private|a fileprivate|an internal|%error|%error}3 type",
(DescriptiveDeclKind, bool, Accessibility, Accessibility, bool, bool)) (DescriptiveDeclKind, bool, Accessibility, Accessibility, bool, bool))
WARNING(generic_param_access_warn,none, WARNING(generic_param_access_warn,none,
"%0 %select{should be declared " "%0 %select{should be declared "
"%select{private|fileprivate|internal|PUBLIC}3" "%select{private|fileprivate|internal|%error|%error}3"
"|should not be declared %select{in this context|fileprivate|internal|public}2}1 " "|should not be declared %select{in this context|fileprivate|internal|public|open}2}1 "
"because its generic %select{parameter|requirement}5 uses " "because its generic %select{parameter|requirement}5 uses "
"%select{a private|a fileprivate|an internal|PUBLIC}3 type", "%select{a private|a fileprivate|an internal|%error|%error}3 type",
(DescriptiveDeclKind, bool, Accessibility, Accessibility, bool, bool)) (DescriptiveDeclKind, bool, Accessibility, Accessibility, bool, bool))
ERROR(override_multiple_decls_base,none, ERROR(override_multiple_decls_base,none,
@@ -1784,12 +1784,12 @@ ERROR(inheritance_from_objc_runtime_visible_class,none,
// Enums // Enums
ERROR(enum_case_access,none, ERROR(enum_case_access,none,
"enum case in %select{PRIVATE|a fileprivate|an internal|a public}0 enum " "enum case in %select{%error|a fileprivate|an internal|a public|%error}0 enum "
"uses %select{a private|a fileprivate|an internal|PUBLIC}1 type", "uses %select{a private|a fileprivate|an internal|%error|%error}1 type",
(Accessibility, Accessibility)) (Accessibility, Accessibility))
WARNING(enum_case_access_warn,none, WARNING(enum_case_access_warn,none,
"enum case in %select{a private|a fileprivate|an internal|a public}0 enum " "enum case in %select{a private|a fileprivate|an internal|a public|%error}0 enum "
"uses %select{a private|a fileprivate|an internal|PUBLIC}1 type", "uses %select{a private|a fileprivate|an internal|%error|%error}1 type",
(Accessibility, Accessibility)) (Accessibility, Accessibility))
ERROR(enum_stored_property,none, ERROR(enum_stored_property,none,
"enums may not contain stored properties", ()) "enums may not contain stored properties", ())
@@ -1814,17 +1814,17 @@ NOTE(enum_declares_rawrep_with_raw_type,none,
"%0 declares raw type %1, which implies RawRepresentable", (Type, Type)) "%0 declares raw type %1, which implies RawRepresentable", (Type, Type))
ERROR(enum_raw_type_access,none, ERROR(enum_raw_type_access,none,
"enum %select{must be declared %select{" "enum %select{must be declared %select{"
"%select{private|fileprivate|internal|PUBLIC}2|private or fileprivate}3" "%select{private|fileprivate|internal|%error|%error}2|private or fileprivate}3"
"|cannot be declared %select{PRIVATE|fileprivate|internal|public}1}0 " "|cannot be declared %select{%error|fileprivate|internal|public|open}1}0 "
"because its raw type uses " "because its raw type uses "
"%select{a private|a fileprivate|an internal|PUBLIC}2 type", "%select{a private|a fileprivate|an internal|%error|%error}2 type",
(bool, Accessibility, Accessibility, bool)) (bool, Accessibility, Accessibility, bool))
WARNING(enum_raw_type_access_warn,none, WARNING(enum_raw_type_access_warn,none,
"enum %select{should be declared " "enum %select{should be declared "
"%select{private|fileprivate|internal|PUBLIC}2" "%select{private|fileprivate|internal|%error|%error}2"
"|should not be declared %select{in this context|fileprivate|internal|public}1}0 " "|should not be declared %select{in this context|fileprivate|internal|public|open}1}0 "
"because its raw type uses " "because its raw type uses "
"%select{a private|a fileprivate|an internal|PUBLIC}2 type", "%select{a private|a fileprivate|an internal|%error|%error}2 type",
(bool, Accessibility, Accessibility, bool)) (bool, Accessibility, Accessibility, bool))
NOTE(enum_here,none, NOTE(enum_here,none,
@@ -2772,17 +2772,17 @@ ERROR(self_in_nominal,none,
"method in a class; did you mean %0?", (Identifier)) "method in a class; did you mean %0?", (Identifier))
ERROR(class_super_access,none, ERROR(class_super_access,none,
"class %select{must be declared %select{" "class %select{must be declared %select{"
"%select{private|fileprivate|internal|PUBLIC}2|private or fileprivate}3" "%select{private|fileprivate|internal|%error|%error}2|private or fileprivate}3"
"|cannot be declared %select{PRIVATE|fileprivate|internal|public}1}0 " "|cannot be declared %select{%error|fileprivate|internal|public|open}1}0 "
"because its superclass is " "because its superclass is "
"%select{private|fileprivate|internal|PUBLIC}2", "%select{private|fileprivate|internal|%error|%error}2",
(bool, Accessibility, Accessibility, bool)) (bool, Accessibility, Accessibility, bool))
WARNING(class_super_access_warn,none, WARNING(class_super_access_warn,none,
"class %select{should be declared " "class %select{should be declared "
"%select{private|fileprivate|internal|PUBLIC}2" "%select{private|fileprivate|internal|%error|%error}2"
"|should not be declared %select{in this context|fileprivate|internal|public}1}0 " "|should not be declared %select{in this context|fileprivate|internal|public|open}1}0 "
"because its superclass is " "because its superclass is "
"%select{private|fileprivate|internal|PUBLIC}2", "%select{private|fileprivate|internal|%error|%error}2",
(bool, Accessibility, Accessibility, bool)) (bool, Accessibility, Accessibility, bool))
ERROR(dot_protocol_on_non_existential,none, ERROR(dot_protocol_on_non_existential,none,
"cannot use 'Protocol' with non-protocol type %0", (Type)) "cannot use 'Protocol' with non-protocol type %0", (Type))

View File

@@ -63,7 +63,7 @@ class CodeCompletionStringChunk {
public: public:
enum class ChunkKind { enum class ChunkKind {
/// "public", "internal", "fileprivate", or "private". /// "open", "public", "internal", "fileprivate", or "private".
AccessControlKeyword, AccessControlKeyword,
/// such as @"availability". /// such as @"availability".

View File

@@ -250,15 +250,18 @@ bool DiagnosticEngine::isDiagnosticPointsToFirstBadToken(DiagID ID) const {
/// \param Text The text to search through, which will be updated to point /// \param Text The text to search through, which will be updated to point
/// just after the delimiter. /// just after the delimiter.
/// ///
/// \param Delim1 The first character delimiter to search for. /// \param Delim The first character delimiter to search for.
/// ///
/// \param Delim2 The second character delimiter to search for. /// \param FoundDelim On return, true if the delimiter was found, or false
/// if the end of the string was reached.
/// ///
/// \returns The string leading up to the delimiter, or the empty string /// \returns The string leading up to the delimiter, or the empty string
/// if no delimiter is found. /// if no delimiter is found.
static StringRef static StringRef
skipToDelimiter(StringRef &Text, char Delim1, char Delim2 = 0) { skipToDelimiter(StringRef &Text, char Delim, bool *FoundDelim = nullptr) {
unsigned Depth = 0; unsigned Depth = 0;
if (FoundDelim)
*FoundDelim = false;
unsigned I = 0; unsigned I = 0;
for (unsigned N = Text.size(); I != N; ++I) { for (unsigned N = Text.size(); I != N; ++I) {
@@ -272,9 +275,12 @@ skipToDelimiter(StringRef &Text, char Delim1, char Delim2 = 0) {
continue; continue;
} }
if (Text[I] == Delim1 || Text[I] == Delim2) if (Text[I] == Delim) {
if (FoundDelim)
*FoundDelim = true;
break; break;
} }
}
assert(Depth == 0 && "Unbalanced {} set in diagnostic text"); assert(Depth == 0 && "Unbalanced {} set in diagnostic text");
StringRef Result = Text.substr(0, I); StringRef Result = Text.substr(0, I);
@@ -295,8 +301,11 @@ static void formatSelectionArgument(StringRef ModifierArguments,
ArrayRef<DiagnosticArgument> Args, ArrayRef<DiagnosticArgument> Args,
unsigned SelectedIndex, unsigned SelectedIndex,
llvm::raw_ostream &Out) { llvm::raw_ostream &Out) {
bool foundPipe = false;
do { do {
StringRef Text = skipToDelimiter(ModifierArguments, '|'); assert((!ModifierArguments.empty() || foundPipe) &&
"Index beyond bounds in %select modifier");
StringRef Text = skipToDelimiter(ModifierArguments, '|', &foundPipe);
if (SelectedIndex == 0) { if (SelectedIndex == 0) {
formatDiagnosticText(Text, Args, Out); formatDiagnosticText(Text, Args, Out);
break; break;
@@ -468,13 +477,17 @@ static void formatDiagnosticText(StringRef InText,
// Parse an optional modifier. // Parse an optional modifier.
StringRef Modifier; StringRef Modifier;
{ {
unsigned Length = 0; size_t Length = InText.find_if_not(isalpha);
while (isalpha(InText[Length]))
++Length;
Modifier = InText.substr(0, Length); Modifier = InText.substr(0, Length);
InText = InText.substr(Length); InText = InText.substr(Length);
} }
if (Modifier == "error") {
assert(false && "encountered %error in diagnostic text");
Out << StringRef("<<ERROR>>");
break;
}
// Parse the optional argument list for a modifier, which is brace-enclosed. // Parse the optional argument list for a modifier, which is brace-enclosed.
StringRef ModifierArguments; StringRef ModifierArguments;
if (InText[0] == '{') { if (InText[0] == '{') {
@@ -482,14 +495,8 @@ static void formatDiagnosticText(StringRef InText,
ModifierArguments = skipToDelimiter(InText, '}'); ModifierArguments = skipToDelimiter(InText, '}');
} }
// Find the digit sequence. // Find the digit sequence, and parse it into an argument index.
unsigned Length = 0; size_t Length = InText.find_if_not(isdigit);
for (size_t N = InText.size(); Length != N; ++Length) {
if (!isdigit(InText[Length]))
break;
}
// Parse the digit sequence into an argument index.
unsigned ArgIndex; unsigned ArgIndex;
bool Result = InText.substr(0, Length).getAsInteger(10, ArgIndex); bool Result = InText.substr(0, Length).getAsInteger(10, ArgIndex);
assert(!Result && "Unparseable argument index value?"); assert(!Result && "Unparseable argument index value?");

View File

@@ -156,6 +156,14 @@ public class Base {
public subscript () -> () { return () } public subscript () -> () { return () }
} }
public extension Base {
open func extMemberPublic() {} // expected-warning {{declaring open instance method in public extension}}
}
internal extension Base {
open func extMemberInternal() {} // expected-warning {{declaring open instance method in an internal extension}}
}
public class PublicSub: Base { public class PublicSub: Base {
required init() {} // expected-error {{'required' initializer must be as accessible as its enclosing type}} {{12-12=public }} required init() {} // expected-error {{'required' initializer must be as accessible as its enclosing type}} {{12-12=public }}
override func foo() {} // expected-error {{overriding instance method must be as accessible as the declaration it overrides}} {{12-12=public }} override func foo() {} // expected-error {{overriding instance method must be as accessible as the declaration it overrides}} {{12-12=public }}
@@ -358,7 +366,8 @@ public struct Initializers {
public class PublicClass {} public class PublicClass {}
// expected-note@+1 * {{type declared here}} // expected-note@+2 * {{type declared here}}
// expected-note@+1 * {{superclass is declared here}}
internal class InternalClass {} internal class InternalClass {}
// expected-note@+1 * {{type declared here}} // expected-note@+1 * {{type declared here}}
private class PrivateClass {} private class PrivateClass {}
@@ -408,6 +417,7 @@ public enum MultipleConformance : PrivateProto, PrivateInt { // expected-error {
func privateReq() {} func privateReq() {}
} }
open class OpenSubclassInternal : InternalClass {} // expected-error {{class cannot be declared open because its superclass is internal}} expected-error {{superclass 'InternalClass' of open class must be open}}
public class PublicSubclassPublic : PublicClass {} public class PublicSubclassPublic : PublicClass {}
public class PublicSubclassInternal : InternalClass {} // expected-error {{class cannot be declared public because its superclass is internal}} public class PublicSubclassInternal : InternalClass {} // expected-error {{class cannot be declared public because its superclass is internal}}
public class PublicSubclassPrivate : PrivateClass {} // expected-error {{class cannot be declared public because its superclass is private}} public class PublicSubclassPrivate : PrivateClass {} // expected-error {{class cannot be declared public because its superclass is private}}

View File

@@ -120,6 +120,7 @@ public struct Properties {
} }
private(set) let constant = 42 // expected-error {{'private(set)' modifier cannot be applied to read-only properties}} {{3-16=}} private(set) let constant = 42 // expected-error {{'private(set)' modifier cannot be applied to read-only properties}} {{3-16=}}
public(set) var defaultVis = 0 // expected-error {{internal property cannot have a public setter}} public(set) var defaultVis = 0 // expected-error {{internal property cannot have a public setter}}
open(set) var defaultVis2 = 0 // expected-error {{internal property cannot have an open setter}}
public(set) subscript(a a: Int) -> Int { // expected-error {{internal subscript cannot have a public setter}} public(set) subscript(a a: Int) -> Int { // expected-error {{internal subscript cannot have a public setter}}
get { return 0 } get { return 0 }
@@ -146,6 +147,10 @@ private extension Properties {
get { return 42 } get { return 42 }
set { } set { }
} }
open(set) var extProp2: Int { // expected-error {{private property cannot have an open setter}}
get { return 42 }
set { }
}
} }
internal protocol EmptyProto {} internal protocol EmptyProto {}
@@ -184,12 +189,14 @@ private extension PublicProto where Assoc == PrivateStruct {}
extension PublicProto where Assoc == InternalStruct { extension PublicProto where Assoc == InternalStruct {
public func foo() {} // expected-error {{cannot declare a public instance method in an extension with internal requirements}} {{3-9=internal}} public func foo() {} // expected-error {{cannot declare a public instance method in an extension with internal requirements}} {{3-9=internal}}
open func bar() {} // expected-error {{cannot declare an open instance method in an extension with internal requirements}} {{3-7=internal}}
} }
extension InternalProto { extension InternalProto {
public func foo() {} // no effect, but no warning public func foo() {} // no effect, but no warning
} }
extension InternalProto where Assoc == PublicStruct { extension InternalProto where Assoc == PublicStruct {
public func foo() {} // expected-error {{cannot declare a public instance method in an extension with internal requirements}} {{3-9=internal}} public func foo() {} // expected-error {{cannot declare a public instance method in an extension with internal requirements}} {{3-9=internal}}
open func bar() {} // expected-error {{cannot declare an open instance method in an extension with internal requirements}} {{3-7=internal}}
} }
public struct GenericStruct<Param> {} public struct GenericStruct<Param> {}