//===--- DiagnosticsSema.def - Diagnostics Text -----------------*- C++ -*-===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2017 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See https://swift.org/LICENSE.txt for license information
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//
//
//  This file defines diagnostics emitted during semantic analysis and type
//  checking.
//  Each diagnostic is described using one of three kinds (error, warning, or
//  note) along with a unique identifier, category, options, and text, and is
//  followed by a signature describing the diagnostic argument kinds.
//
//===----------------------------------------------------------------------===//

#if !(defined(DIAG) || (defined(ERROR) && defined(WARNING) && defined(NOTE)))
#  error Must define either DIAG or the set {ERROR,WARNING,NOTE}
#endif

#ifndef ERROR
#  define ERROR(ID,Options,Text,Signature)   \
  DIAG(ERROR,ID,Options,Text,Signature)
#endif

#ifndef WARNING
#  define WARNING(ID,Options,Text,Signature) \
  DIAG(WARNING,ID,Options,Text,Signature)
#endif

#ifndef NOTE
#  define NOTE(ID,Options,Text,Signature) \
  DIAG(NOTE,ID,Options,Text,Signature)
#endif


NOTE(type_declared_here,none,
     "type declared here", ())
NOTE(decl_declared_here,none,
     "%0 declared here", (DeclName))
NOTE(extended_type_declared_here,none,
     "extended type declared here", ())

//------------------------------------------------------------------------------
// Constraint solver diagnostics
//------------------------------------------------------------------------------

ERROR(ambiguous_member_overload_set,none,
      "ambiguous reference to member %0", (DeclName))

ERROR(ambiguous_subscript,none,
      "ambiguous subscript with base type %0 and index type %1",
      (Type, Type))
ERROR(type_not_subscriptable,none,
      "type %0 has no subscript members",
      (Type))

ERROR(could_not_find_tuple_member,none,
      "value of tuple type %0 has no member %1", (Type, DeclName))

ERROR(could_not_find_value_member,none,
      "value of type %0 has no member %1", (Type, DeclName))
ERROR(could_not_find_type_member,none,
      "type %0 has no member %1", (Type, DeclName))

ERROR(could_not_find_enum_case,none,
      "enum type %0 has no case %1; did you mean %2", (Type, DeclName, DeclName))

NOTE(did_you_mean_raw_type,none,
     "did you mean to specify a raw type on the enum declaration?", ())

NOTE(any_as_anyobject_fixit, none,
     "cast 'Any' to 'AnyObject' or use 'as!' to force downcast to a more specific type to access members", ())

ERROR(expected_argument_in_contextual_member,none,
      "member %0 expects argument of type %1", (DeclName, Type))
ERROR(expected_parens_in_contextual_member,none,
      "member %0 is a function; did you mean to call it?", (DeclName))

ERROR(expected_result_in_contextual_member,none,
      "member %0 in %2 produces result of type %1, but context expects %2",
      (DeclName, Type, Type))

ERROR(unexpected_argument_in_contextual_member,none,
      "member %0 takes no arguments", (DeclName))
ERROR(unexpected_parens_in_contextual_member,none,
      "member %0 is not a function", (DeclName))

ERROR(could_not_use_value_member,none,
      "member %1 cannot be used on value of type %0", (Type, DeclName))
ERROR(could_not_use_type_member,none,
      "member %1 cannot be used on type %0", (Type, DeclName))

ERROR(could_not_use_type_member_on_instance,none,
      "static member %1 cannot be used on instance of type %0",
      (Type, DeclName))
ERROR(could_not_use_enum_element_on_instance,none,
      "enum element %0 cannot be referenced as an instance member",
      (DeclName))
ERROR(could_not_use_type_member_on_protocol_metatype,none,
      "static member %1 cannot be used on protocol metatype %0",
      (Type, DeclName))
ERROR(could_not_use_instance_member_on_type,none,
      "instance member %1 cannot be used on type %0",
      (Type, DeclName))
ERROR(could_not_use_member_on_existential,none,
      "member %1 cannot be used on value of protocol type %0; use a generic"
      " constraint instead",
      (Type, DeclName))

ERROR(candidate_inaccessible,none,
      "%0 is inaccessible due to "
      "'%select{private|fileprivate|internal|%error|%error}1' protection level",
      (DeclName, Accessibility))

NOTE(note_candidate_inaccessible,none,
     "%0 is inaccessible due to "
     "'%select{private|fileprivate|internal|%error|%error}1' protection level",
     (DeclName, Accessibility))

ERROR(init_candidate_inaccessible,none,
      "%0 initializer is inaccessible due to "
      "'%select{private|fileprivate|internal|%error|%error}1' protection level",
      (Type, Accessibility))

ERROR(all_candidates_inaccessible,none,
      "all %0 candidates are inaccessible",
      (DeclName))

ERROR(cannot_pass_rvalue_mutating_subelement,none,
      "cannot use mutating member on immutable value: %0",
      (StringRef))
ERROR(cannot_pass_rvalue_mutating,none,
      "cannot use mutating member on immutable value of type %0",
      (Type))
ERROR(cannot_pass_rvalue_mutating_getter_subelement,none,
      "cannot use mutating getter on immutable value: %0",
      (StringRef))
ERROR(cannot_pass_rvalue_mutating_getter,none,
      "cannot use mutating getter on immutable value of type %0",
      (Type))

ERROR(expression_too_complex,none,
      "expression was too complex to be solved in reasonable time; "
      "consider breaking up the expression into distinct sub-expressions", ())

ERROR(value_type_comparison_with_nil_illegal_did_you_mean,none,
      "value of type %0 cannot be compared by reference; "
      "did you mean to compare by value?",
      (Type))
ERROR(value_type_comparison_with_nil_illegal,none,
      "type %0 is not optional, value can never be nil",
      (Type))

ERROR(cannot_match_expr_pattern_with_value,none,
      "expression pattern of type %0 cannot match values of type %1",
      (Type, Type))
ERROR(cannot_match_unresolved_expr_pattern_with_value,none,
      "pattern cannot match values of type %0",
      (Type))

ERROR(cannot_reference_compare_types,none,
      "cannot check reference equality of functions; operands here have types "
      "%1 and %2",
      (StringRef, Type, Type))

ERROR(cannot_apply_binop_to_args,none,
      "binary operator '%0' cannot be applied to operands of type "
      "%1 and %2",
      (StringRef, Type, Type))

ERROR(cannot_apply_binop_to_same_args,none,
      "binary operator '%0' cannot be applied to two %1 operands",
      (StringRef, Type))

ERROR(cannot_apply_unop_to_arg,none,
      "unary operator '%0' cannot be applied to an operand of type %1",
      (StringRef, Type))

ERROR(cannot_apply_lvalue_unop_to_subelement,none,
      "cannot pass immutable value to mutating operator: %0",
      (StringRef))
ERROR(cannot_apply_lvalue_unop_to_rvalue,none,
      "cannot pass immutable value of type %0 to mutating operator",
      (Type))


ERROR(cannot_apply_lvalue_binop_to_subelement,none,
      "left side of mutating operator isn't mutable: %0", (StringRef))
ERROR(cannot_apply_lvalue_binop_to_rvalue,none,
      "left side of mutating operator has immutable type %0", (Type))

ERROR(cannot_subscript_with_index,none,
      "cannot subscript a value of type %0 with an index of type %1",
      (Type, Type))

ERROR(cannot_subscript_base,none,
      "cannot subscript a value of type %0",
      (Type))

ERROR(cannot_subscript_ambiguous_base,none,
      "cannot subscript a value of incorrect or ambiguous type", ())

ERROR(cannot_subscript_nil_literal,none,
      "cannot subscript a nil literal value", ())

ERROR(cannot_pass_rvalue_inout_subelement,none,
      "cannot pass immutable value as inout argument: %0",
      (StringRef))
ERROR(cannot_pass_rvalue_inout,none,
      "cannot pass immutable value of type %0 as inout argument",
      (Type))

ERROR(cannot_assign_to_literal,none,
      "cannot assign to a literal value", ())

ERROR(cannot_call_with_no_params,none,
      "cannot invoke %select{|initializer for type }1'%0' with no arguments",
      (StringRef, bool))

ERROR(cannot_call_with_params, none,
      "cannot invoke %select{|initializer for type }2'%0' with an argument list"
      " of type '%1'", (StringRef, StringRef, bool))

NOTE(pointer_init_to_type,none,
      "Pointer conversion restricted: use '.assumingMemoryBound(to:)' or '.bindMemory(to:capacity:)' to view memory as a type.", ())

ERROR(cannot_call_non_function_value,none,
      "cannot call value of non-function type %0", (Type))

ERROR(wrong_argument_labels_overload,none,
      "argument labels '%0' do not match any available overloads", (StringRef))

ERROR(no_candidates_match_result_type,none,
      "no '%0' candidates produce the expected contextual result type %1",
      (StringRef, Type))

ERROR(candidates_no_match_result_type,none,
      "'%0' produces %1, not the expected contextual result type %2",
      (StringRef, Type, Type))



ERROR(invalid_callee_result_type,none,
      "cannot convert call result type %0 to expected type %1",
      (Type, Type))


ERROR(cannot_invoke_closure,none,
      "cannot invoke closure expression with an argument list of type '%0'",
      (StringRef))
ERROR(cannot_invoke_closure_type,none,
      "cannot invoke closure of type %0 with an argument list of type '%1'",
      (Type, StringRef))

ERROR(cannot_infer_closure_type,none,
      "unable to infer closure type in the current context", ())
ERROR(cannot_infer_closure_result_type,none,
      "unable to infer complex closure return type; "
      "add explicit type to disambiguate", ())

ERROR(incorrect_explicit_closure_result,none,
      "declared closure result %0 is incompatible with contextual type %1",
      (Type, Type))

ERROR(err_noescape_param_call,none,
      "passing a %select{|closure which captures a }1non-escaping function "
      "parameter %0 to a call to a non-escaping function parameter can allow "
      "re-entrant modification of a variable",
      (DeclName, unsigned))
WARNING(warn_noescape_param_call,none,
      "passing a %select{|closure which captures a }1non-escaping function "
      "parameter %0 to a call to a non-escaping function parameter can allow "
      "re-entrant modification of a variable and will be illegal in Swift 4",
      (DeclName, unsigned))

ERROR(cannot_call_function_value,none,
      "cannot invoke value of function type with argument list '%0'",
      (StringRef))
ERROR(cannot_call_value_of_function_type,none,
      "cannot invoke value of type %0 with argument list '%1'",
      (Type, StringRef))

NOTE(suggest_expected_match,none,
     "%select{expected an argument list|produces result}0 of type '%1'",
     (bool, StringRef))

NOTE(suggest_partial_overloads,none,
      "overloads for '%1' exist with these %select{"
      "partially matching parameter lists|result types}0: %2",
      (bool, StringRef, StringRef))

NOTE(no_binary_op_overload_for_enum_with_payload,none,
      "binary operator '%0' cannot be synthesized for enums "
      "with associated values",
      (StringRef))

ERROR(cannot_convert_initializer_value,none,
      "cannot convert value of type %0 to specified type %1", (Type,Type))
ERROR(cannot_convert_initializer_value_protocol,none,
      "value of type %0 does not conform to specified type %1", (Type,Type))
ERROR(cannot_convert_initializer_value_nil,none,
      "nil cannot initialize specified type %0", (Type))

ERROR(cannot_convert_to_return_type,none,
      "cannot convert return expression of type %0 to return type %1",
      (Type,Type))
ERROR(cannot_convert_to_return_type_protocol,none,
      "return expression of type %0 does not conform to %1", (Type,Type))
ERROR(cannot_convert_to_return_type_nil,none,
      "nil is incompatible with return type %0", (Type))

ERROR(cannot_convert_thrown_type,none,
      "thrown expression type %0 does not conform to 'Error'", (Type))
ERROR(cannot_throw_error_code,none,
      "thrown error code type %0 does not conform to 'Error'; construct an %1 "
      "instance", (Type, Type))

ERROR(cannot_throw_nil,none,
      "cannot infer concrete Error for thrown 'nil' value", ())


ERROR(cannot_convert_raw_initializer_value,none,
      "cannot convert value of type %0 to raw type %1", (Type,Type))
ERROR(cannot_convert_raw_initializer_value_nil,none,
      "cannot convert nil to raw type %0", (Type))

ERROR(cannot_convert_default_arg_value,none,
      "default argument value of type %0 cannot be converted to type %1",
      (Type,Type))
ERROR(cannot_convert_default_arg_value_protocol,none,
      "default argument value of type %0 does not conform to %1", (Type,Type))
ERROR(cannot_convert_default_arg_value_nil,none,
      "nil default argument value of cannot be converted to type %0", (Type))

ERROR(cannot_convert_argument_value,none,
      "cannot convert value of type %0 to expected argument type %1",
      (Type,Type))
ERROR(cannot_convert_argument_value_protocol,none,
      "argument type %0 does not conform to expected type %1", (Type, Type))
ERROR(cannot_convert_partial_argument_value_protocol,none,
      "in argument type %0, %1 does not conform to expected type %2", (Type, Type, Type))

ERROR(cannot_convert_argument_value_nil,none,
      "nil is not compatible with expected argument type %0", (Type))

ERROR(cannot_convert_closure_result,none,
      "cannot convert value of type %0 to closure result type %1",
      (Type,Type))
ERROR(cannot_convert_closure_result_protocol,none,
      "result value of type %0 does not conform to closure result type %1",
      (Type, Type))
ERROR(cannot_convert_closure_result_nil,none,
      "nil is not compatible with closure result type %0", (Type))

ERROR(destructor_not_accessible,none,
      "deinitializers cannot be accessed", ())

// Array Element
ERROR(cannot_convert_array_element,none,
      "cannot convert value of type %0 to expected element type %1",
      (Type,Type))
ERROR(cannot_convert_array_element_protocol,none,
      "value of type %0 does not conform to expected element type %1",
      (Type, Type))
ERROR(cannot_convert_array_element_nil,none,
      "nil is not compatible with expected element type %0", (Type))

// Dictionary Key
ERROR(cannot_convert_dict_key,none,
      "cannot convert value of type %0 to expected dictionary key type %1",
      (Type,Type))
ERROR(cannot_convert_dict_key_protocol,none,
      "value of type %0 does not conform to expected dictionary key type %1",
      (Type, Type))
ERROR(cannot_convert_dict_key_nil,none,
      "nil is not compatible with expected dictionary key type %0", (Type))

// Dictionary Value
ERROR(cannot_convert_dict_value,none,
      "cannot convert value of type %0 to expected dictionary value type %1",
      (Type,Type))
ERROR(cannot_convert_dict_value_protocol,none,
      "value of type %0 does not conform to expected dictionary value type %1",
      (Type, Type))
ERROR(cannot_convert_dict_value_nil,none,
      "nil is not compatible with expected dictionary value type %0", (Type))

// Coerce Expr
ERROR(cannot_convert_coerce,none,
      "cannot convert value of type %0 to type %1 in coercion",
      (Type,Type))
ERROR(cannot_convert_coerce_protocol,none,
      "value of type %0 does not conform to %1 in coercion",
      (Type, Type))
ERROR(cannot_convert_coerce_nil,none,
      "nil is not compatible with type %0 in coercion", (Type))

// Assign Expr
ERROR(cannot_convert_assign,none,
      "cannot assign value of type %0 to type %1",
      (Type,Type))
ERROR(cannot_convert_assign_protocol,none,
      "value of type %0 does not conform to %1 in assignment",
      (Type, Type))
ERROR(cannot_convert_assign_nil,none,
      "nil cannot be assigned to type %0", (Type))


ERROR(throws_functiontype_mismatch,none,
      "invalid conversion from throwing function of type %0 to "
      "non-throwing function type %1", (Type, Type))
ERROR(noescape_functiontype_mismatch,none,
      "invalid conversion from non-escaping function of type %0 to "
      "potentially escaping function type %1", (Type, Type))

// Key-path expressions.
ERROR(expr_keypath_no_objc_runtime,none,
      "'#keyPath' can only be used with the Objective-C runtime", ())
ERROR(expression_unused_keypath_result,none,
      "result of key path is unused", ())
ERROR(expr_keypath_non_objc_property,none,
      "argument of '#keyPath' refers to non-'@objc' property %0",
      (DeclName))
WARNING(expr_keypath_swift3_objc_inference,none,
        "argument of '#keyPath' refers to property %0 in %1 that depends on "
        "'@objc' inference deprecated in Swift 4",
        (DeclName, Identifier))
ERROR(expr_keypath_type_of_property,none,
      "cannot refer to type member %0 within instance of type %1",
      (DeclName, Type))
ERROR(expr_keypath_generic_type,none,
      "key path cannot refer to generic type %0", (DeclName))
ERROR(expr_keypath_not_property,none,
      "key path cannot refer to %0 %1", (DescriptiveDeclKind, DeclName))
ERROR(expr_keypath_mutating_getter,none,
      "key path cannot refer to %0, which has a mutating getter",
      (DeclName))
ERROR(expr_keypath_static_member,none,
      "key path cannot refer to static member %0",
      (DeclName))
ERROR(expr_keypath_empty,none,
      "empty key path does not refer to a property", ())
ERROR(expr_unsupported_objc_key_path_component,none,
      "an Objective-C key path cannot contain "
      "%select{BAD|subscript|BAD|BAD|optional-forcing|optional-chaining|BAD} "
      "components",
      (unsigned))
ERROR(expr_unsupported_objc_key_path_compound_name,none,
      "an Objective-C key path cannot reference a declaration with a "
      "compound name", ())
ERROR(expr_keypath_no_keypath_type,none,
      "broken standard library: no 'KeyPath' type found", ())
ERROR(expr_swift_keypath_invalid_component,none,
      "invalid component of Swift key path", ())
ERROR(expr_swift_keypath_not_starting_with_type,none,
      "a Swift key path must begin with a type", ())
ERROR(expr_swift_keypath_unimplemented_component,none,
      "key path support for %0 components is not implemented", (StringRef))
ERROR(expr_smart_keypath_value_covert_to_contextual_type,none,
      "key path value type %0 cannot be converted to contextual type %1",
      (Type, Type))
ERROR(expr_swift_keypath_empty, none,
      "key path must have at least one component", ())
ERROR(expr_string_interpolation_outside_string,none,
      "string interpolation can only appear inside a string literal", ())
ERROR(unsupported_keypath_tuple_element_reference,none,
      "key path cannot reference tuple elements", ())

// Selector expressions.
ERROR(expr_selector_no_objc_runtime,none,
      "'#selector' can only be used with the Objective-C runtime", ())
ERROR(expr_selector_module_missing,none,
      "import the 'ObjectiveC' module to use '#selector'", ())
ERROR(expr_selector_no_declaration,none,
      "argument of '#selector' does not refer to an '@objc' method, property, "
      "or initializer", ())
ERROR(expr_selector_not_method,none,
      "argument of '#selector' cannot refer to %select{local|global}0 "
      "function %1", (bool, DeclName))
ERROR(expr_selector_expected_property,none,
      "cannot reference %1 %2 as a property; remove '%select{getter|setter}0:'",
      (bool, DescriptiveDeclKind, DeclName))
ERROR(expr_selector_not_property,none,
      "argument of '#selector' cannot refer to %select{variable|parameter}0 %1",
      (bool, DeclName))
ERROR(expr_selector_expected_method,none,
      "use 'getter:'%select{| or 'setter:'}0 to refer to the Objective-C getter"
      "%select{| or setter}0 of property %1%select{|, respectively}0",
      (bool, DeclName))
NOTE(expr_selector_add_modifier,none,
     "add '%select{getter|setter}0:' to reference the Objective-C "
     "%select{getter|setter}0 for %1", (bool, DeclName))
ERROR(expr_selector_property_not_settable,none,
      "argument of '#selector(setter:)' refers to non-settable %0 %1",
      (DescriptiveDeclKind, DeclName))
ERROR(expr_selector_property_setter_inaccessible,none,
      "setter of %0 %1 is inaccessible", (DescriptiveDeclKind, DeclName))
ERROR(expr_selector_not_objc,none,
      "argument of '#selector' refers to %0 %1 that is not exposed to "
      "Objective-C",
      (DescriptiveDeclKind, DeclName))
NOTE(make_decl_objc,none,
     "add '@objc' to expose this %0 to Objective-C",
     (DescriptiveDeclKind))
WARNING(expr_selector_swift3_objc_inference,none,
        "argument of '#selector' refers to %0 %1 in %2 that depends on "
        "'@objc' inference deprecated in Swift 4",
        (DescriptiveDeclKind, DeclName, Identifier))

// Selectors-as-string-literals.
WARNING(selector_literal_invalid,none,
        "string literal is not a valid Objective-C selector", ())
WARNING(selector_literal_undeclared,none,
        "no method declared with Objective-C selector %0", (ObjCSelector))
WARNING(selector_literal_deprecated,none,
        "use of string literal for Objective-C selectors is deprecated; "
        "use '#selector' or explicitly construct a 'Selector'", ())
WARNING(selector_literal_deprecated_suggest,none,
        "use of string literal for Objective-C selectors is deprecated; "
        "use '#selector' instead", ())
WARNING(selector_construction_suggest,none,
        "use '#selector' instead of explicitly constructing a 'Selector'", ())
NOTE(selector_construction_suppress_warning,none,
     "wrap the selector name in parentheses to suppress this warning", ())

ERROR(cannot_return_value_from_void_func,none,
      "unexpected non-void return value in void function", ())

//------------------------------------------------------------------------------
// Name Binding
//------------------------------------------------------------------------------

ERROR(sema_no_import,Fatal,
      "no such module '%0'", (StringRef))
ERROR(sema_no_import_repl,none,
      "no such module '%0'", (StringRef))
NOTE(sema_no_import_no_sdk,none,
     "did you forget to set an SDK using -sdk or SDKROOT?", ())
NOTE(sema_no_import_no_sdk_xcrun,none,
     "use \"xcrun swiftc\" to select the default macOS SDK "
     "installed with Xcode", ())
WARNING(sema_import_current_module,none,
        "this file is part of module %0; ignoring import", (Identifier))
WARNING(sema_import_current_module_with_file,none,
        "file '%0' is part of module %1; ignoring import",
        (StringRef, Identifier))
ERROR(sema_opening_import,Fatal,
      "opening import file for module %0: %1", (Identifier, StringRef))

ERROR(serialization_load_failed,Fatal,
      "failed to load module %0", (Identifier))
ERROR(serialization_malformed_module,Fatal,
      "malformed module file: %0", (StringRef))
ERROR(serialization_module_too_new,Fatal,
      "module file was created by a newer version of the compiler: %0",
      (StringRef))
ERROR(serialization_module_language_version_mismatch,Fatal,
      "module compiled with Swift %0 cannot be imported in Swift %1: %2",
      (StringRef, StringRef, StringRef))
ERROR(serialization_module_too_old,Fatal,
      "module file was created by an older version of the compiler; "
      "rebuild %0 and try again: %1",
      (Identifier, StringRef))
ERROR(serialization_missing_single_dependency,Fatal,
      "missing required module '%0'", (StringRef))
ERROR(serialization_missing_dependencies,Fatal,
      "missing required modules: %0", (StringRef))
ERROR(serialization_missing_shadowed_module,Fatal,
      "cannot load underlying module for %0", (Identifier))
ERROR(serialization_name_mismatch,Fatal,
      "cannot load module '%0' as %1", (StringRef, Identifier))
ERROR(serialization_name_mismatch_repl,none,
      "cannot load module '%0' as %1", (StringRef, Identifier))
ERROR(serialization_target_incompatible,Fatal,
      "module file was created for incompatible target %0: %1",
      (StringRef, StringRef))
ERROR(serialization_target_incompatible_repl,none,
      "module file was created for incompatible target %0: %1",
      (StringRef, StringRef))
ERROR(serialization_target_too_new,Fatal,
      "module file's minimum deployment target is %0 v%1.%2%select{|.%3}3: %4",
      (StringRef, unsigned, unsigned, unsigned, StringRef))
ERROR(serialization_target_too_new_repl,none,
      "module file's minimum deployment target is %0 v%1.%2%select{|.%3}3: %4",
      (StringRef, unsigned, unsigned, unsigned, StringRef))

ERROR(serialization_fatal,Fatal,
      "fatal error encountered while reading from module '%0'; "
      "please file a bug report with your project and the crash log",
      (StringRef))
NOTE(serialization_compatibility_version_mismatch,none,
     "compiling as Swift %0, with '%1' built as Swift %2 "
     "(this is supported but may expose additional compiler issues)",
     (StringRef, StringRef, StringRef))

ERROR(reserved_member_name,none,
      "type member may not be named %0, since it would conflict with the"
      " 'foo.%1' expression", (DeclName, StringRef))

ERROR(invalid_redecl,none,"invalid redeclaration of %0", (DeclName))
NOTE(invalid_redecl_prev,none,
     "%0 previously declared here", (DeclName))

ERROR(ambiguous_type_base,none,
      "%0 is ambiguous for type lookup in this context", (Identifier))
ERROR(invalid_member_type,none,
      "%0 is not a member type of %1", (Identifier, Type))
ERROR(invalid_member_type_suggest,none,
      "%0 does not have a member type named %1; did you mean %2?",
      (Type, Identifier, Identifier))
ERROR(invalid_member_reference,none,
      "%0 %1 is not a member type of %2",
      (DescriptiveDeclKind, Identifier, Type))
ERROR(ambiguous_member_type,none,
      "ambiguous type name %0 in %1", (Identifier, Type))
ERROR(no_module_type,none,
      "no type named %0 in module %1", (Identifier, Identifier))
ERROR(ambiguous_module_type,none,
      "ambiguous type name %0 in module %1", (Identifier, Identifier))
ERROR(use_nonmatching_operator,none,
      "%0 is not a %select{binary|prefix unary|postfix unary}1 operator",
      (Identifier, unsigned))
ERROR(broken_associated_type_witness,none,
      "reference to invalid associated type %0 of type %1", (DeclName, Type))

ERROR(unspaced_binary_operator_fixit,none,
      "missing whitespace between %0 and %1 operators",
      (Identifier, Identifier, bool))
ERROR(unspaced_binary_operator,none,
      "ambiguous missing whitespace between unary and binary operators", ())
NOTE(unspaced_binary_operators_candidate,none,
     "could be %select{binary|postfix}2 %0 and %select{prefix|binary}2 %1",
     (Identifier, Identifier, bool))
ERROR(unspaced_unary_operator,none,
      "unary operators may not be juxtaposed; parenthesize inner expression",
      ())


ERROR(use_unresolved_identifier,none,
      "use of unresolved %select{identifier|operator}1 %0", (DeclName, bool))
NOTE(confusable_character,none,
      "%select{identifier|operator}0 '%1' contains possibly confused characters; "
      "did you mean to use '%2'?",
      (bool, StringRef, StringRef))
ERROR(use_undeclared_type,none,
      "use of undeclared type %0", (Identifier))
ERROR(use_undeclared_type_did_you_mean,none,
      "use of undeclared type %0; did you mean to use '%1'?", (Identifier, StringRef))
NOTE(note_typo_candidate_implicit_member,none,
     "did you mean the implicitly-synthesized %1 '%0'?", (StringRef, StringRef))
NOTE(note_remapped_type,none,
     "did you mean to use '%0'?", (StringRef))
ERROR(identifier_init_failure,none,
      "could not infer type for %0", (Identifier))
ERROR(pattern_used_in_type,none,
      "%0 used within its own type", (Identifier))
NOTE(note_module_as_type,none,
     "cannot use module %0 as a type", (Identifier))

ERROR(use_unknown_object_literal_protocol,none,
     "cannot deduce protocol for %0 literal", (StringRef))
ERROR(object_literal_default_type_missing,none,
     "could not infer type of %0 literal", (StringRef))
NOTE(object_literal_resolve_import,none,
     "import %0 to use '%1' as the default %2 literal type",
     (StringRef, StringRef, StringRef))

ERROR(use_local_before_declaration,none,
      "use of local variable %0 before its declaration", (DeclName))
ERROR(unsupported_existential_type,none,
      "protocol %0 can only be used as a generic constraint because it has "
      "Self or associated type requirements", (Identifier))

ERROR(decl_does_not_exist_in_module,none,
      "%select{%error|type|struct|class|enum|protocol|variable|function}0 "
      "%1 does not exist in module %2",
      (/*ImportKind*/ unsigned, Identifier, Identifier))
ERROR(imported_decl_is_wrong_kind,none,
      "%0 was imported as '%1', but is a "
      "%select{%error|type|struct|class|enum|protocol|variable|function}2",
      (Identifier, StringRef, /*ImportKind*/ unsigned))
ERROR(ambiguous_decl_in_module,none,
      "ambiguous name %0 in module %1", (Identifier, Identifier))

ERROR(module_not_testable,none,
      "module %0 was not compiled for testing", (Identifier))

// Operator decls
ERROR(ambiguous_operator_decls,none,
      "ambiguous operator declarations found for operator", ())
NOTE(found_this_operator_decl,none,
     "found this matching operator declaration", ())
ERROR(operator_redeclared,none,
      "operator redeclared", ())
NOTE(previous_operator_decl,none,
     "previous operator declaration here", ())
ERROR(declared_operator_without_operator_decl,none,
      "operator implementation without matching operator declaration", ())
ERROR(declared_unary_op_without_attribute,none,
      "unary operator implementation must have a 'prefix' or 'postfix' modifier", ())
ERROR(unary_op_missing_prepos_attribute,none,
      "%select{prefix|postfix}0 unary operator missing "
      "'%select{prefix|postfix}0' modifier", (bool))
NOTE(unary_operator_declaration_here,none,
   "%select{prefix|postfix}0 operator found here", (bool))
ERROR(invalid_arg_count_for_operator,none,
      "operators must have one or two arguments", ())
ERROR(operator_in_local_scope,none,
      "operator functions can only be declared at global or in type scope", ())
ERROR(nonstatic_operator_in_type,none,
      "operator %0 declared in type %1 must be 'static'", (Identifier, Type))
ERROR(nonfinal_operator_in_class,none,
      "operator %0 declared in non-final class %1 must be 'final'",
      (Identifier, Type))
ERROR(operator_in_unrelated_type,none,
      "member operator %2%select{| of protocol %0}1 must have at least one "
      "argument of type %select{%0|'Self'}1", (Type, bool, DeclName))

// Precedence groups
ERROR(ambiguous_precedence_groups,none,
      "multiple precedence groups found", ())
NOTE(found_this_precedence_group,none,
     "found this matching precedence group", ())
ERROR(unknown_precedence_group,none,
      "unknown precedence group %0", (Identifier))
ERROR(precedence_group_cycle,none,
      "cycle in higherThan relation: %0", (StringRef))
ERROR(precedence_group_lower_within_module,none,
      "precedence group cannot be given lower precedence than group in same"
      " module; make the other precedence group higher than this one instead",
      ())
NOTE(precedence_group_declared_here,none,"precedence group declared here",
      ())
ERROR(precedence_group_redeclared,none,
      "precedence group redeclared", ())
NOTE(previous_precedence_group_decl,none,
     "previous precedence group declaration here", ())

//------------------------------------------------------------------------------
// Type Check Coercions
//------------------------------------------------------------------------------

ERROR(tuple_conversion_not_expressible,none,
      "cannot express tuple conversion %0 to %1", (Type, Type))
ERROR(load_of_explicit_lvalue,none,
      "%0 variable is not being passed by reference", (Type))

//------------------------------------------------------------------------------
// Expression Type Checking Errors
//------------------------------------------------------------------------------
ERROR(types_not_convertible,none,
      "%1 is not %select{convertible to|a subtype of}0 %2",
      (bool, Type, Type))
NOTE(in_cast_expr_types,none,
      "in cast from type %0 to %1",
      (Type, Type))

ERROR(types_not_convertible_use_bool_value,none,
      "%0 is not convertible to %1; did you mean %0.boolValue", (Type, Type))

ERROR(tuple_types_not_convertible_nelts,none,
      "%0 is not convertible to %1, "
      "tuples have a different number of elements", (Type, Type))

ERROR(tuple_types_not_convertible,none,
      "tuple type %0 is not convertible to tuple %1", (Type, Type))

ERROR(invalid_force_unwrap,none,
      "cannot force unwrap value of non-optional type %0", (Type))
ERROR(invalid_optional_chain,none,
      "cannot use optional chaining on non-optional value of type %0",
      (Type))
ERROR(if_expr_cases_mismatch,none,
      "result values in '? :' expression have mismatching types %0 and %1",
      (Type, Type))

ERROR(did_not_call_function_value,none,
      "function value was used as a property; add () to call it",
      ())
ERROR(did_not_call_function,none,
      "function %0 was used as a property; add () to call it",
      (Identifier))
ERROR(did_not_call_method,none,
      "method %0 was used as a property; add () to call it",
      (Identifier))

ERROR(init_not_instance_member,none,
      "'init' is a member of the type; use 'type(of: ...)' to initialize "
      "a new object of the same dynamic type", ())
ERROR(super_initializer_not_in_initializer,none,
      "'super.init' cannot be called outside of an initializer", ())

WARNING(isa_is_always_true,none, "'%0' test is always true",
        (StringRef))
WARNING(isa_is_foreign_check,none,
      "'is' test is always true because %0 is a Core Foundation type",
      (Type))
WARNING(conditional_downcast_coercion,none,
      "conditional cast from %0 to %1 always succeeds",
      (Type, Type))

WARNING(forced_downcast_noop,none,
        "forced cast of %0 to same type has no effect", (Type))

WARNING(forced_downcast_coercion,none,
      "forced cast from %0 to %1 always succeeds; did you mean to use 'as'?",
      (Type, Type))

// Note: the Boolean at the end indicates whether bridging is required after
// the cast.
WARNING(downcast_same_type,none,
        "forced cast from %0 to %1 %select{only unwraps optionals|only unwraps "
        "and bridges}3; did you mean to use '%2'%select{| with 'as'}3?",
        (Type, Type, StringRef, bool))

// The unsigned value can be 0 (types are equal), 1 (types implicitly convert),
// or 2 (types bridge).
WARNING(conditional_downcast_same_type,none,
        "conditional downcast from %0 to %1 %select{does nothing|"
        "is equivalent to an implicit conversion to an optional %1|is a "
        "bridging conversion; did you mean to use 'as'?}2",
        (Type, Type, unsigned))
WARNING(is_expr_same_type,none,
        "checking a value with optional type %0 against dynamic type %1 "
        "succeeds whenever the value is non-'nil'; did you mean to use "
        "'!= nil'?", (Type, Type))
WARNING(downcast_to_unrelated,none,
        "cast from %0 to unrelated type %1 always fails", (Type, Type))
ERROR(downcast_to_more_optional,none,
      "cannot downcast from %0 to a more optional type %1",
      (Type, Type))
ERROR(optional_chain_noop,none,
      "optional chain has no effect, expression already produces %0",
      (Type))
ERROR(optional_chain_isnt_chaining,none,
      "'?' must be followed by a call, member lookup, or subscript",
      ())
ERROR(pattern_in_expr,none,
      "%0 cannot appear in an expression", (PatternKind))
NOTE(note_call_to_operator,none,
     "in call to operator %0", (Identifier))
NOTE(note_call_to_func,none,
     "in call to function %0", (Identifier))
NOTE(note_call_to_initializer,none,
     "in call to initializer", ())
NOTE(note_init_parameter,none,
     "in initialization of parameter %0", (Identifier))


ERROR(missing_nullary_call,none,
     "function produces expected type %0; did you mean to call it with '()'?",
     (Type))
ERROR(missing_unwrap_optional,none,
      "value of optional type %0 not unwrapped; did you mean to use '!' "
      "or '?'?",
     (Type))
ERROR(missing_unwrap_optional_try,none,
      "value of optional type %0 not unwrapped; did you mean to use 'try!' "
      "or chain with '?'?",
     (Type))
ERROR(missing_forced_downcast,none,
      "%0 is not convertible to %1; "
      "did you mean to use 'as!' to force downcast?", (Type, Type))
WARNING(missing_forced_downcast_swift3_compat_warning,none,
        "bridging %0 to %1 may fail at runtime and will become a checked "
        "cast in Swift 4; did you mean to use 'as!' to force downcast?",
        (Type, Type))
ERROR(missing_explicit_conversion,none,
      "%0 is not implicitly convertible to %1; "
      "did you mean to use 'as' to explicitly convert?", (Type, Type))
ERROR(missing_address_of,none,
      "passing value of type %0 to an inout parameter requires explicit '&'",
      (Type))
ERROR(extra_address_of,none,
      "'&' used with non-inout argument of type %0",
      (Type))
ERROR(extra_address_of_unsafepointer,none,
      "'&' is not allowed passing array value as %0 argument",
      (Type))

ERROR(missing_init_on_metatype_initialization,none,
      "initializing from a metatype value must reference 'init' explicitly",
      ())
ERROR(extra_argument_labels,none,
      "extraneous argument label%select{|s}0 '%1' in %select{call|subscript}2",
      (bool, StringRef, bool))
ERROR(missing_argument_labels,none,
      "missing argument label%select{|s}0 '%1' in %select{call|subscript}2",
      (bool, StringRef, bool))
ERROR(wrong_argument_labels,none,
      "incorrect argument label%select{|s}0 in %select{call|subscript}3 "
      "(have '%1', expected '%2')",
      (bool, StringRef, StringRef, bool))
ERROR(extra_named_single_element_tuple,none,
      "cannot treat single-element named tuple as a scalar; use '.%0' to "
      "access its element", (StringRef))
ERROR(argument_out_of_order_named_named,none,
      "argument %0 must precede argument %1", (Identifier, Identifier))
ERROR(argument_out_of_order_named_unnamed,none,
      "argument %0 must precede unnamed argument #%1", (Identifier, unsigned))
ERROR(argument_out_of_order_unnamed_named,none,
      "unnamed argument #%0 must precede argument %1", (unsigned, Identifier))
ERROR(argument_out_of_order_unnamed_unnamed,none,
      "unnamed argument #%0 must precede unnamed argument #%1",
      (unsigned, unsigned))

ERROR(member_shadows_global_function,none,
      "use of %0 refers to %1 %2 rather than %3 %4 in %5 %6",
      (DeclName, DescriptiveDeclKind, DeclName, DescriptiveDeclKind, DeclName,
       DescriptiveDeclKind, DeclName))
ERROR(member_shadows_global_function_near_match,none,
      "use of %0 nearly matches %3 %4 in %5 %6 rather than %1 %2",
      (DeclName, DescriptiveDeclKind, DeclName, DescriptiveDeclKind, DeclName,
      DescriptiveDeclKind, DeclName))

ERROR(instance_member_use_on_type,none,
      "instance member %1 cannot be used on type %0; "
      "did you mean to use a value of this type instead?", (Type, DeclName))
ERROR(instance_member_in_initializer,none,
      "cannot use instance member %0 within property initializer; "
      "property initializers run before 'self' is available", (DeclName))
ERROR(instance_member_in_default_parameter,none,
      "cannot use instance member %0 as a default parameter", (DeclName))

ERROR(invalid_initialization_parameter_same_type,none,
      "invalid initializer call with same type %0 as parameter", (Type))

ERROR(missing_argument_named,none,
      "missing argument for parameter %0 in call", (Identifier))
ERROR(missing_argument_positional,none,
      "missing argument for parameter #%0 in call", (unsigned))
ERROR(extra_argument_named,none,
      "extra argument %0 in call", (Identifier))
ERROR(extra_argument_positional,none,
      "extra argument in call", ())
ERROR(extra_argument_to_nullary_call,none,
      "argument passed to call that takes no arguments", ())
ERROR(extra_trailing_closure_in_call,none,
      "extra trailing closure passed in call", ())
ERROR(no_accessible_initializers,none,
      "%0 cannot be constructed because it has no accessible initializers",
      (Type))
ERROR(non_nominal_no_initializers,none,
      "non-nominal type %0 does not support explicit initialization",
      (Type))
ERROR(unbound_generic_parameter,none,
      "generic parameter %0 could not be inferred", (Type))
ERROR(unbound_generic_parameter_cast,none,
      "generic parameter %0 could not be inferred in cast to %1", (Type, Type))
NOTE(archetype_declared_in_type,none,
     "%0 declared as parameter to type %1", (Type, Type))
NOTE(unbound_generic_parameter_explicit_fix,none,
     "explicitly specify the generic arguments to fix this issue", ())


ERROR(string_index_not_integer,none,
      "String may not be indexed with %0, it has variable size elements",
      (Type))
NOTE(string_index_not_integer_note,none,
     "consider using an existing high level algorithm, "
     "str.startIndex.advanced(by: n), or a projection like str.utf8", ())

ERROR(invalid_c_function_pointer_conversion_expr,none,
      "a C function pointer can only be formed from a reference to a 'func' or "
      "a literal closure", ())
ERROR(c_function_pointer_from_method,none,
      "a C function pointer cannot be formed from a method", ())
ERROR(c_function_pointer_from_generic_function,none,
      "a C function pointer cannot be formed from a reference to a generic "
      "function", ())
ERROR(c_function_pointer_from_function_with_context,none,
      "a C function pointer cannot be formed from a "
      "%select{local function|closure}0 that captures "
      "%select{context|generic parameters|dynamic Self type}1",
      (bool, unsigned))

//------------------------------------------------------------------------------
// Type Check Declarations
//------------------------------------------------------------------------------

ERROR(var_type_not_materializable,none,
      "variable has type %0 which includes nested inout parameters",
      (Type))
ERROR(param_type_non_materializable_tuple,none,
      "named parameter has type %0 which includes nested inout parameters",
      (Type))
ERROR(enum_element_not_materializable,none,
      "enum case has type %0 which includes nested inout parameters",
      (Type))

ERROR(missing_initializer_def,PointsToFirstBadToken,
      "initializer requires a body", ())

// Attributes
ERROR(attr_decl_attr_now_on_type,none,
      "%0 is now an attribute on a parameter type, "
      "instead of on the parameter itself", (StringRef))

ERROR(operator_not_func,none,
      "operators must be declared with 'func'", ())
ERROR(redefining_builtin_operator,none,
      "cannot declare a custom %0 '%1' operator", (StringRef, StringRef))
ERROR(attribute_requires_operator_identifier,none,
      "'%0' requires a function with an operator identifier", (StringRef))
ERROR(attribute_requires_single_argument,none,
      "'%0' requires a function with one argument", (StringRef))

ERROR(var_parameter_not_allowed,none,
      "parameters may not have the 'var' specifier", ())


ERROR(mutating_invalid_global_scope,none,
      "'mutating' is only valid on methods", ())
ERROR(mutating_invalid_classes,none,
      "'mutating' isn't valid on methods in classes or class-bound protocols",
      ())
ERROR(functions_mutating_and_not,none,
      "method may not be declared both mutating and nonmutating", ())
ERROR(static_functions_not_mutating,none,
      "static functions may not be declared mutating", ())

ERROR(transparent_stored_property,none,
      "@_transparent cannot be applied to stored properties", ())
ERROR(transparent_in_protocols_not_supported,none,
      "@_transparent is not supported on declarations within protocols", ())
ERROR(transparent_in_classes_not_supported,none,
      "@_transparent is not supported on declarations within classes", ())

ERROR(invalid_iboutlet,none,
      "only instance properties can be declared @IBOutlet", ())
ERROR(iboutlet_nonobjc_class,none,
      "@IBOutlet property cannot %select{have|be an array of}0 "
      "non-'@objc' class type %1", (bool, Type))
ERROR(iboutlet_nonobjc_protocol,none,
      "@IBOutlet property cannot %select{have|be an array of}0 "
      "non-'@objc' protocol type %1", (bool, Type))
ERROR(iboutlet_nonobject_type,none,
      "@IBOutlet property cannot %select{have|be an array of}0 "
      "non-object type %1", (bool, Type))
ERROR(iboutlet_only_mutable,none,
      "@IBOutlet attribute requires property to be mutable", ())
ERROR(iboutlet_non_optional,none,
      "@IBOutlet property has non-optional type %0", (Type))
NOTE(note_make_optional,none,
      "add '?' to form the optional type %0", (Type))
NOTE(note_make_implicitly_unwrapped_optional,none,
      "add '!' to form the implicitly unwrapped optional type %0", (Type))

ERROR(invalid_ibdesignable_extension,none,
      "@IBDesignable can only be applied to classes and extensions "
      "of classes", ())
ERROR(invalid_ibinspectable,none,
      "only instance properties can be declared @%0", (StringRef))
ERROR(invalid_ibaction_decl,none,
      "only instance methods can be declared @IBAction", ())
ERROR(invalid_ibaction_result,none,
      "methods declared @IBAction must return 'Void' (not %0)", (Type))
ERROR(invalid_ibaction_argument_count,none,
      "@IBAction methods %select{must have a single argument"
      "|can only have up to 2 arguments}0", (bool))
ERROR(ibaction_nonobjc_class_argument,none,
      "argument to @IBAction method cannot have non-'@objc' class type %0",
      (Type))
ERROR(ibaction_nonobject_argument,none,
      "argument to @IBAction method cannot have non-object type %0", (Type))
ERROR(no_objc_tagged_pointer_not_class_protocol,none,
      "@unsafe_no_objc_tagged_pointer can only be applied to class protocols",
      ())
ERROR(swift_native_objc_runtime_base_not_on_root_class,none,
      "@_swift_native_objc_runtime_base_not_on_root_class can only be applied "
      "to root classes", ())

ERROR(cdecl_not_at_top_level,none,
      "@_cdecl can only be applied to global functions", ())
ERROR(cdecl_empty_name,none,
      "@_cdecl symbol name cannot be empty", ())
ERROR(cdecl_throws,none,
      "raising errors from @_cdecl functions is not supported", ())

ERROR(attr_methods_only,none,
      "only methods can be declared %0", (DeclAttribute))
ERROR(access_control_in_protocol,none,
      "%0 modifier cannot be used in protocols", (DeclAttribute))
ERROR(access_control_setter,none,
      "'%select{private|fileprivate|internal|public|open}0(set)' modifier can only "
      "be applied to variables and subscripts",
      (Accessibility))
ERROR(access_control_setter_read_only,none,
      "'%select{private|fileprivate|internal|public|%error}0(set)' modifier cannot be "
      "applied to %select{constants|read-only variables|read-only properties"
      "|read-only subscripts}1",
      (Accessibility, unsigned))
ERROR(access_control_setter_more,none,
      "%select{private|fileprivate|internal|public|%error}0 "
      "%select{variable|property|subscript}1 cannot have "
      "%select{%error|a fileprivate|an internal|a public|an open}2 setter",
      (Accessibility, unsigned, Accessibility))
WARNING(access_control_ext_member_more,none,
    "declaring %select{%error|a fileprivate|an internal|a public|open}0 %1 in "
    "%select{a private|a fileprivate|an internal|public|%error}2 extension",
    (Accessibility, DescriptiveDeclKind, Accessibility))
ERROR(access_control_ext_requirement_member_more,none,
    "cannot declare %select{%error|a fileprivate|an internal|a public|an open}0 %1 "
    "in an extension with %select{private|fileprivate|internal|public|%error}2 "
    "requirements",
    (Accessibility, DescriptiveDeclKind, Accessibility))
ERROR(access_control_extension_more,none,
      "extension of %select{private|fileprivate|internal|%error|%error}0 %1 cannot "
      "be declared %select{%error|fileprivate|internal|public|%error}2",
      (Accessibility, DescriptiveDeclKind, Accessibility))
ERROR(access_control_extension_open,none,
      "extensions cannot use 'open' as their default access; use 'public'",
      ())
ERROR(access_control_open_bad_decl,none,
      "only classes and overridable class members can be declared 'open';"
      " use 'public'", ())

ERROR(invalid_decl_attribute_simple,none,
      "attribute cannot be applied to declaration", ())
ERROR(invalid_decl_attribute,none,
      "%0 cannot be applied to this declaration", (DeclAttribute))
ERROR(invalid_decl_modifier,none,
      "%0 modifier cannot be applied to this declaration", (DeclAttribute))
ERROR(attribute_does_not_apply_to_type,none,
      "attribute does not apply to type", ())
ERROR(optional_attribute_non_protocol,none,
      "'optional' can only be applied to protocol members", ())
ERROR(optional_attribute_non_objc_protocol,none,
      "'optional' can only be applied to members of an @objc protocol", ())
ERROR(optional_attribute_missing_explicit_objc,none,
      "'optional' requirements are an Objective-C compatibility feature; add '@objc'",
      ())
ERROR(objcmembers_attribute_nonclass,none,
      "'@objcMembers' attribute can only be applied to a class", ())
ERROR(optional_attribute_initializer,none,
      "'optional' cannot be applied to an initializer", ())
ERROR(unavailable_method_non_objc_protocol,none,
      "protocol members can only be marked unavailable in an @objc protocol",
      ())
ERROR(missing_in_class_init_1,none,
      "stored property %0 requires an initial value%select{| or should be "
      "@NSManaged}1", (Identifier, bool))
ERROR(missing_in_class_init_2,none,
      "stored properties %0 and %1 require initial values%select{| or should "
      "be @NSManaged}2",
      (Identifier, Identifier, bool))
ERROR(missing_in_class_init_3plus,none,
      "stored properties %0, %1, %select{and %2|%2, and others}3 "
      "require initial values%select{| or should be @NSManaged}4",
      (Identifier, Identifier, Identifier, bool, bool))
NOTE(requires_stored_property_inits_here,none,
     "%select{superclass|class}1 %0 requires all stored properties to have "
     "initial values%select{| or use @NSManaged}2", (Type, bool, bool))
ERROR(class_without_init,none,
      "class %0 has no initializers", (Type))
NOTE(note_no_in_class_init_1,none,
     "stored property %0 without initial value prevents synthesized "
     "initializers",
     (Identifier))
NOTE(note_no_in_class_init_2,none,
     "stored properties %0 and %1 without initial values prevent synthesized "
     "initializers",
     (Identifier, Identifier))
NOTE(note_no_in_class_init_3plus,none,
     "stored properties %0, %1, %select{and %2|%2, and others}3 "
     "without initial values prevent synthesized initializers",
     (Identifier, Identifier, Identifier, bool))
ERROR(missing_unimplemented_init_runtime,none,
      "standard library error: missing _unimplementedInitializer", ())
ERROR(missing_undefined_runtime,none,
      "standard library error: missing _undefined", ())
WARNING(unsupported_synthesize_init_variadic,none,
        "synthesizing a variadic inherited initializer for subclass %0 is "
        "unsupported",
        (Type))
NOTE(variadic_superclass_init_here,none,
     "variadic superclass initializer defined here", ())

WARNING(expr_dynamic_lookup_swift3_objc_inference,none,
        "reference to %0 %1 of %2 depends on '@objc' inference "
        "deprecated in Swift 4",
        (DescriptiveDeclKind, DeclName, Identifier))

// Alignment attribute
ERROR(alignment_not_power_of_two,none,
      "alignment value must be a power of two", ())

// Indirect enums
ERROR(indirect_case_without_payload,none,
      "enum case %0 without associated value cannot be 'indirect'", (Identifier))
ERROR(indirect_case_in_indirect_enum,none,
      "enum case in 'indirect' enum cannot also be 'indirect'", ())

// Variables (var and let).
ERROR(unimplemented_static_var,none,
      "%select{ERROR|static|class}1 stored properties not supported"
      "%select{ in this context| in generic types| in classes}0"
      "%select{|; did you mean 'static'?}2",
      (unsigned, StaticSpellingKind, unsigned))
ERROR(observingprop_requires_initializer,none,
      "non-member observing properties require an initializer", ())
ERROR(global_requires_initializer,none,
      "global '%select{var|let}0' declaration requires an initializer expression"
      "%select{ or getter/setter specifier|}0", (bool))
ERROR(static_requires_initializer,none,
      "%select{ERROR|'static var'|'class var'|}0 declaration requires an initializer "
      "expression or getter/setter specifier", (StaticSpellingKind))
ERROR(pattern_type_access,none,
      "%select{%select{variable|constant}0|property}1 "
      "%select{must be declared %select{"
      "%select{private|fileprivate|internal|%error|%error}3|private or fileprivate}4"
      "|cannot be declared "
      "%select{in this context|fileprivate|internal|public|open}3}2 "
      "because its type uses "
      "%select{a private|a fileprivate|an internal|%error|%error}5 type",
      (bool, bool, bool, Accessibility, bool, Accessibility))
WARNING(pattern_type_access_warn,none,
        "%select{%select{variable|constant}0|property}1 "
        "%select{should be declared %select{private|fileprivate|internal|%error|%error}5"
        "|should not be declared %select{in this context|fileprivate|internal|public|open}3}2 "
        "because its type uses "
        "%select{a private|a fileprivate|an internal|%error|%error}5 type",
        (bool, bool, bool, Accessibility, bool, Accessibility))
ERROR(pattern_type_access_inferred,none,
      "%select{%select{variable|constant}0|property}1 "
      "%select{must be declared %select{"
      "%select{private|fileprivate|internal|%error|%error}3|private or fileprivate}4"
      "|cannot be declared "
      "%select{in this context|fileprivate|internal|public|open}3}2 "
      "because its type %6 uses "
      "%select{a private|a fileprivate|an internal|%error|%error}5 type",
      (bool, bool, bool, Accessibility, bool, Accessibility, Type))
WARNING(pattern_type_access_inferred_warn,none,
        "%select{%select{variable|constant}0|property}1 "
        "%select{should be declared %select{private|fileprivate|internal|%error|%error}5"
        "|should not be declared %select{in this context|fileprivate|internal|public|open}3}2 "
        "because its type %6 uses "
        "%select{a private|a fileprivate|an internal|%error|%error}5 type",
        (bool, bool, bool, Accessibility, bool, Accessibility, Type))
ERROR(pattern_binds_no_variables,none,
      "%select{property|global variable}0 declaration does not bind any "
      "variables",
      (unsigned))

ERROR(nscoding_unstable_mangled_name,none,
      "%select{private|fileprivate|nested|local}0 class %1 has an "
      "unstable name when archiving via 'NSCoding'",
      (unsigned, Type))
WARNING(nscoding_unstable_mangled_name_warn,none,
        "%select{private|fileprivate|nested|local}0 class %1 has an "
        "unstable name when archiving via 'NSCoding'",
        (unsigned, Type))
NOTE(unstable_mangled_name_add_objc_new,none,
     "for new classes, use '@objc' to specify a unique, prefixed Objective-C "
     "runtime name", ())
NOTE(unstable_mangled_name_add_objc,none,
     "for compatibility with existing archives, use '@objc' "
     "to record the Swift 3 runtime name", ())

// Generic types
ERROR(unsupported_type_nested_in_generic_function,none,
      "type %0 cannot be nested in generic function %1",
      (Identifier, Identifier))
ERROR(unsupported_type_nested_in_generic_closure,none,
      "type %0 cannot be nested in closure in generic context",
      (Identifier))
ERROR(unsupported_type_nested_in_protocol,none,
      "type %0 cannot be nested in protocol %1",
      (Identifier, Identifier))
ERROR(unsupported_type_nested_in_protocol_extension,none,
      "type %0 cannot be nested in protocol extension of %1",
      (Identifier, Identifier))
ERROR(unsupported_nested_protocol,none,
      "protocol %0 cannot be nested inside another declaration",
      (Identifier))

// Type aliases
ERROR(type_alias_underlying_type_access,none,
      "type alias %select{must be declared %select{"
      "%select{private|fileprivate|internal|%error|%error}2|private or fileprivate}3"
      "|cannot be declared "
      "%select{in this context|fileprivate|internal|public|open}1}0 "
      "because its underlying type uses "
      "%select{a private|a fileprivate|an internal|%error|%error}2 type",
      (bool, Accessibility, Accessibility, bool))
WARNING(type_alias_underlying_type_access_warn,none,
        "type alias %select{should be declared "
        "%select{private|fileprivate|internal|%error|%error}2"
        "|should not be declared "
        "%select{in this context|fileprivate|internal|public|open}1}0 "
        "because its underlying type uses "
        "%select{a private|a fileprivate|an internal|%error|%error}2 type",
        (bool, Accessibility, Accessibility, bool))

// Subscripts
ERROR(subscript_type_access,none,
      "subscript %select{must be declared "
      "%select{private|fileprivate|internal|%error|%error}1"
      "|cannot be declared "
      "%select{in this context|fileprivate|internal|public|open}1}0 "
      "because its %select{index|element type}3 uses "
      "%select{a private|a fileprivate|an internal|%error|%error}2 type",
      (bool, Accessibility, Accessibility, bool))
WARNING(subscript_type_access_warn,none,
        "subscript %select{should be declared "
        "%select{private|fileprivate|internal|%error|%error}2"
        "|should not be declared %select{in this context|fileprivate|internal|public|open}1}0 "
        "because its %select{index|element type}3 uses "
        "%select{a private|a fileprivate|an internal|%error|%error}2 type",
        (bool, Accessibility, Accessibility, bool))

// Functions
ERROR(function_type_access,none,
      "%select{function|method|initializer}4 "
      "%select{must be declared %select{"
      "%select{private|fileprivate|internal|%error|%error}1|private or fileprivate}2"
      "|cannot be declared "
      "%select{in this context|fileprivate|internal|public|open}1}0 "
      "because its %select{parameter|result}5 uses "
      "%select{a private|a fileprivate|an internal|%error|%error}3 type",
      (bool, Accessibility, bool, Accessibility, unsigned, bool))
WARNING(function_type_access_warn,none,
        "%select{function|method|initializer}4 "
        "%select{should be declared %select{private|fileprivate|internal|%error|%error}3"
        "|should not be declared %select{in this context|fileprivate|internal|public|open}1}0 "
        "because its %select{parameter|result}5 uses "
        "%select{a private|a fileprivate|an internal|%error|%error}3 type",
        (bool, Accessibility, bool, Accessibility, unsigned, bool))
ERROR(noreturn_not_supported,none,
      "'@noreturn' has been removed; functions that never return should have a "
      "return type of 'Never' instead", ())

// Extensions
ERROR(non_nominal_extension,none,
      "non-nominal type %0 cannot be extended", (Type))
ERROR(extension_access_with_conformances,none,
      "%0 modifier cannot be used with extensions that declare "
      "protocol conformances", (DeclAttribute))
ERROR(extension_metatype,none,
      "cannot extend a metatype %0", (Type))
ERROR(extension_specialization,none,
      "constrained extension must be declared on the unspecialized generic "
      "type %0 with constraints specified by a 'where' clause", (Identifier))
ERROR(extension_stored_property,none,
      "extensions may not contain stored properties", ())
ERROR(extension_nongeneric_trailing_where,none,
      "trailing 'where' clause for extension of non-generic type %0", (Type))
ERROR(extension_constrained_inheritance,none,
      "extension of type %0 with constraints cannot have an "
      "inheritance clause", (Type))
ERROR(extension_protocol_inheritance,none,
      "extension of protocol %0 cannot have an inheritance clause", (Type))
ERROR(objc_generic_extension_using_type_parameter,none,
      "extension of a generic Objective-C class cannot access the class's "
      "generic parameters at runtime", ())
NOTE(objc_generic_extension_using_type_parameter_here,none,
     "generic parameter used here", ())

// Protocols
ERROR(type_does_not_conform,none,
      "type %0 does not conform to protocol %1", (Type, Type))
ERROR(cannot_use_nil_with_this_type,none,
      "nil cannot be used in context expecting type %0", (Type))

ERROR(use_of_equal_instead_of_equality,none,
      "use of '=' in a boolean context, did you mean '=='?", ())


ERROR(protocol_does_not_conform_objc,none,
      "using %0 as a concrete type conforming to protocol %1 is not supported",
      (Type, Type))
ERROR(protocol_does_not_conform_static,none,
      "%0 cannot be used as a type conforming to protocol %1 because %1 "
      "has static requirements",
      (Type, Type))
ERROR(protocol_derivation_is_broken,none,
      "protocol %0 is broken; cannot derive conformance for type %1", (Type, Type))
ERROR(type_does_not_inherit,none,
      "%0 requires that %1 inherit from %2", (Type, Type, Type))
NOTE(type_does_not_inherit_requirement,none,
     "requirement specified as %0 : %1%2", (Type, Type, StringRef))
ERROR(types_not_equal,none,
      "%0 requires the types %1 and %2 be equivalent",
      (Type, Type, Type))
NOTE(candidate_types_equal_requirement,none,
     "candidate requires that the types %0 and %1 be equivalent "
     "(requirement specified as %2 == %3%4)",
     (Type, Type, Type, Type, StringRef))
NOTE(candidate_types_inheritance_requirement,none,
     "candidate requires that %1 inherit from %2 "
     "(requirement specified as %2 : %3%4)",
     (Type, Type, Type, Type, StringRef))
NOTE(types_not_equal_requirement,none,
     "requirement specified as %0 == %1%2", (Type, Type, StringRef))
ERROR(non_class_cannot_conform_to_class_protocol,none,
      "non-class type %0 cannot conform to class protocol %1",
      (Type, Type))
ERROR(cf_class_cannot_conform_to_objc_protocol,none,
      "Core Foundation class %0 cannot conform to @objc protocol %1 because "
      "Core Foundation types are not classes in Objective-C",
      (Type, Type))
ERROR(objc_runtime_visible_cannot_conform_to_objc_protocol,none,
      "class %0 cannot conform to @objc protocol %1 because "
      "the class is only visible via the Objective-C runtime",
      (Type, Type))
ERROR(protocol_has_missing_requirements,none,
      "type %0 cannot conform to protocol %1 because it has requirements that "
      "cannot be satisfied", (Type, Type))
ERROR(protocol_has_missing_requirements_versioned,none,
      "type %0 cannot conform to protocol %1 (compiled with Swift %2) because "
      "it has requirements that could not be loaded in Swift %3",
      (Type, Type, clang::VersionTuple, clang::VersionTuple))
ERROR(requirement_restricts_self,none,
      "%0 requirement %1 cannot add constraint '%2%select{:|:| ==|:}3 %4' on "
      "'Self'",
      (DescriptiveDeclKind, DeclName, StringRef, unsigned, StringRef))
WARNING(requirement_restricts_self_swift3,none,
        "adding constraint '%2%select{:|:| ==|:}3 %4' on 'Self' via %0 "
        "requirement %1 is deprecated in Swift 3",
        (DescriptiveDeclKind, DeclName, StringRef, unsigned, StringRef))
ERROR(witness_argument_name_mismatch,none,
      "%select{method|initializer}0 %1 has different argument names from those "
      "required by protocol %2 (%3)", (bool, DeclName, Type, DeclName))
ERROR(witness_initializer_not_required,none,
      "initializer requirement %0 can only be satisfied by a `required` "
      "initializer in%select{| the definition of}1 non-final class %2",
      (DeclName, bool, Type))
ERROR(witness_initializer_failability,none,
      "non-failable initializer requirement %0"
      "%select{| in Objective-C protocol}1 cannot be satisfied by a "
      "failable initializer ('init%select{?|!}1')",
      (DeclName, bool))
ERROR(witness_self_non_subtype,none,
      "protocol %0 requirement %1 cannot be satisfied by a non-final class "
      "(%2) because it uses 'Self' in a non-parameter, non-result type "
      "position",
      (Type, DeclName, Type))
ERROR(witness_self_same_type,none,
      "%0 %1 in non-final class %2 cannot be used to satisfy requirement %3 %4"
      " (in protocol %5) due to same-type requirement involving 'Self'",
      (DescriptiveDeclKind, DeclName, Type, DescriptiveDeclKind,
       DeclName, Type))
NOTE(witness_self_weaken_same_type,none,
      "consider weakening the same-type requirement %0 == %1 to a superclass "
      "requirement", (Type, Type))
ERROR(witness_requires_dynamic_self,none,
      "method %0 in non-final class %1 must return `Self` to conform to "
      "protocol %2",
      (DeclName, Type, Type))
ERROR(witness_not_accessible_proto,none,
      "%select{initializer %1|method %1|%select{|setter for }2property %1"
      "|subscript%select{| setter}2}0 must be declared "
      "%select{%error|fileprivate|internal|public|%error}3 because it matches a "
      "requirement in %select{private|fileprivate|internal|public|%error}4 protocol "
      "%5",
      (RequirementKind, DeclName, bool, Accessibility, Accessibility, DeclName))
ERROR(witness_not_accessible_type,none,
      "%select{initializer %1|method %1|%select{|setter for }2property %1"
      "|subscript%select{| setter}2}0 must be as accessible as its enclosing "
      "type because it matches a requirement in protocol %5",
      (RequirementKind, DeclName, bool, Accessibility, Accessibility, DeclName))
ERROR(type_witness_not_accessible_proto,none,
      "%0 %1 must be declared %select{%error|fileprivate|internal|public|%error}2 "
      "because it matches a requirement in "
      "%select{%error|fileprivate|internal|public|%error}2 protocol %3",
      (DescriptiveDeclKind, DeclName, Accessibility, DeclName))
ERROR(type_witness_not_accessible_type,none,
      "%0 %1 must be as accessible as its enclosing type because it "
      "matches a requirement in protocol %3",
      (DescriptiveDeclKind, DeclName, Accessibility, DeclName))

ERROR(protocol_refine_access,none,
      "%select{protocol must be declared %select{"
      "%select{private|fileprivate|internal|%error|%error}2"
      "|private or fileprivate}3 because it refines"
      "|%select{in this context|fileprivate|internal|public|%error}1 "
      "protocol cannot refine}0 "
      "%select{a private|a fileprivate|an internal|%error|%error}2 protocol",
      (bool, Accessibility, Accessibility, bool))
WARNING(protocol_refine_access_warn,none,
        "%select{protocol should be declared "
        "%select{private|fileprivate|internal|%error|%error}2 because it refines"
        "|%select{in this context|fileprivate|internal|public|%error}1 protocol should not "
        "refine}0 %select{a private|a fileprivate|an internal|%error|%error}2 protocol",
        (bool, Accessibility, Accessibility, bool))
ERROR(protocol_property_must_be_computed_var,none,
      "immutable property requirement must be declared as 'var' with a "
      "'{ get }' specifier", ())
ERROR(protocol_property_must_be_computed,none,
      "property in protocol must have explicit { get } or { get set } specifier",
      ())
NOTE(inherited_protocol_does_not_conform,none,
     "type %0 does not conform to inherited protocol %1", (Type, Type))
NOTE(no_witnesses,none,
     "protocol requires "
     "%select{initializer %1|function %1|property %1|subscript}0 with type %2"
     "%select{|; do you want to add a stub?}3",
     (RequirementKind, DeclName, Type, bool))
NOTE(missing_witnesses_general,none, "do you want to add protocol stubs?",
     ())
NOTE(ambiguous_witnesses,none,
     "multiple matching "
     "%select{initializers named %1|functions named %1|properties named %1|"
     "subscript operators}0 with type %2", (RequirementKind, DeclName, Type))
NOTE(ambiguous_witnesses_wrong_name,none,
     "multiple matching "
     "%select{initializers named %1|functions named %1|properties named %1|"
     "subscript operators}0 with type %2", (RequirementKind, DeclName, Type))
NOTE(no_witnesses_type,none,
     "protocol requires nested type %0; do you want to add it?", (Identifier))
NOTE(default_associated_type_req_fail,none,
     "default type %0 for associated type %1 (from protocol %2) "
     "does not %select{inherit from|conform to}4 %3",
     (Type, DeclName, Type, Type, bool))
ERROR(associated_type_access,none,
      "associated type in "
      "%select{a private|a fileprivate|an internal|a public|%error}0 protocol "
      "uses "
      "%select{a private|a fileprivate|an internal|%error|%error}1 type in its "
      "%select{default definition|requirement}2 ",
      (Accessibility, Accessibility, unsigned))
WARNING(associated_type_access_warn,none,
        "associated type in "
        "%select{a private|a fileprivate|an internal|a public|%error}0 protocol uses "
        "%select{a private|a fileprivate|an internal|%error|%error}1 type in its "
        "%select{default definition|requirement}2 ",
        (Accessibility, Accessibility, unsigned))

NOTE(bad_associated_type_deduction,none,
     "unable to infer associated type %0 for protocol %1",
     (DeclName, DeclName))
NOTE(associated_type_deduction_witness_failed,none,
     "inferred type %1 (by matching requirement %0) is invalid: "
     "does not %select{inherit from|conform to}3 %2",
     (DeclName, Type, DeclName, bool))
NOTE(ambiguous_associated_type_deduction,none,
     "ambiguous inference of associated type %0: %1 vs. %2",
     (DeclName, Type, Type))
NOTE(associated_type_deduction_witness,none,
     "matching requirement %0 to this declaration inferred associated type to "
     "%1",
     (DeclName, Type))
NOTE(associated_type_deduction_default,none,
     "using associated type default %0", (Type))
NOTE(ambiguous_witnesses_type,none,
     "multiple matching types named %0", (Identifier))
NOTE(protocol_witness_exact_match,none,
     "candidate exactly matches%0", (StringRef))
NOTE(protocol_witness_renamed,none,
     "rename to %0 to satisfy this requirement%1", (DeclName, StringRef))
NOTE(protocol_witness_kind_conflict,none,
     "candidate is not %select{an initializer|a function|a variable|"
     "a subscript}0", (RequirementKind))
NOTE(protocol_witness_type_conflict,none,
     "candidate has non-matching type %0%1", (Type, StringRef))

NOTE(protocol_witness_optionality_conflict,none,
     "candidate %select{type has|result type has|parameter type has|"
     "parameter types have|result and parameter types have}0 incorrect "
     "optionality%1",
     (unsigned, StringRef))
ERROR(err_protocol_witness_optionality,none,
      "%select{type|result|parameter|parameters|"
      "result and parameters}0 of %1 %select{has|has|has|have|have|}0"
      " different optionality than required by protocol %2",
      (unsigned, DeclName, DeclName))
WARNING(warn_protocol_witness_optionality,none,
      "%select{type|result|parameter|parameters|"
      "result and parameters}0 of %1 %select{has|has|has|have|have|}0"
      " different optionality than expected by protocol %2",
      (unsigned, DeclName, DeclName))

NOTE(protocol_witness_static_conflict,none,
     "candidate operates on %select{a type|an instance}0, not "
     "%select{an instance|a type}0 as required", (bool))
NOTE(protocol_witness_prefix_postfix_conflict,none,
     "candidate is %select{|prefix, |postfix, }1not "
     "%select{prefix|postfix}0 as required", (bool, unsigned))
NOTE(protocol_witness_mutating_conflict,none,
     "candidate is marked 'mutating' but protocol does not allow it", ())
NOTE(protocol_witness_settable_conflict,none,
     "candidate is not settable, but protocol requires it", ())
NOTE(protocol_witness_rethrows_conflict,none,
     "candidate is not 'rethrows', but protocol requires it", ())
NOTE(protocol_witness_throws_conflict,none,
     "candidate throws, but protocol does not allow it", ())
NOTE(protocol_witness_not_objc,none,
     "candidate is explicitly '@nonobjc'", ())

NOTE(protocol_witness_type,none,
     "possibly intended match", ())
NOTE(protocol_witness_nonconform_type,none,
     "possibly intended match %0 does not "
     "%select{inherit from|conform to}2 %1", (Type, Type, bool))

NOTE(protocol_requirement_here,none,
     "requirement %0 declared here", (DeclName))
NOTE(protocol_conformance_here,none,
     "%select{|class }0%1 declares conformance to protocol %2 here",
     (bool, DeclName, DeclName))
NOTE(declared_protocol_conformance_here,none,
     "%select{%0 inherits conformance to protocol %2 from superclass|"
     "%0 declares conformance to protocol %2|"
     "%0 implicitly conforms to protocol %2 (via conformance to %3)|"
     "%0 implicitly conforms to protocol %2}1 here",
     (Type, unsigned, DeclName, DeclName))

WARNING(witness_unavailable_warn,none,
        "unavailable %0 %1 was used to satisfy a requirement of protocol %2",
        (DescriptiveDeclKind, DeclName, DeclName))
ERROR(witness_unavailable,none,
        "unavailable %0 %1 was used to satisfy a requirement of protocol %2",
        (DescriptiveDeclKind, DeclName, DeclName))

ERROR(redundant_conformance,none,
      "redundant conformance of %0 to protocol %1", (Type, DeclName))
WARNING(redundant_conformance_adhoc,none,
        "conformance of %0 to protocol %1 was already stated in "
        "%select{the protocol's|the type's}2 module %3",
        (Type, DeclName, bool, Identifier))
NOTE(redundant_conformance_witness_ignored,none,
     "%0 %1 will not be used to satisfy the conformance to %2",
     (DescriptiveDeclKind, DeclName, DeclName))

// "Near matches"
WARNING(optional_req_near_match,none,
        "%0 %1 nearly matches optional requirement %2 of protocol %3",
        (DescriptiveDeclKind, DeclName, DeclName, DeclName))
NOTE(optional_req_nonobjc_near_match_add_objc,none,
     "add '@objc' to provide an Objective-C entrypoint", ())
NOTE(optional_req_near_match_move,none,
     "move %0 to %select{an|another}1 extension to silence this warning",
     (DeclName, unsigned))
NOTE(optional_req_near_match_nonobjc,none,
     "add '@nonobjc' to silence this %select{warning|error}0", (bool))
NOTE(optional_req_near_match_accessibility,none,
     "make %0 %select{ERROR|private|private|non-public|non-public}1 to silence this "
     "warning", (DeclName, Accessibility))

// Protocols and existentials
ERROR(assoc_type_outside_of_protocol,none,
      "associated type %0 can only be used with a concrete type or "
      "generic parameter base", (Identifier))
ERROR(typealias_outside_of_protocol,none,
      "type alias %0 can only be used with a concrete type or "
      "generic parameter base", (Identifier))

ERROR(circular_protocol_def,none,
      "circular protocol inheritance %0", (StringRef))
NOTE(protocol_here,none,
     "protocol %0 declared here", (Identifier))
ERROR(objc_protocol_inherits_non_objc_protocol,none,
      "@objc protocol %0 cannot refine non-@objc protocol %1", (Type, Type))
WARNING(protocol_composition_with_postfix,none,
        "protocol-constrained type with postfix '%0' is ambiguous "
        "and will be rejected in future version of Swift", (StringRef))

ERROR(invalid_protocol_composition_member,none,
      "non-protocol, non-class type %0 cannot be used within a "
      "protocol-constrained type", (Type))
ERROR(protocol_composition_one_class,none,
      "protocol-constrained type cannot contain class %0 because it already "
      "contains class %1", (Type, Type))

ERROR(requires_conformance_nonprotocol,none,
      "type %0 constrained to non-protocol type %1", (TypeLoc, TypeLoc))
ERROR(requires_not_suitable_archetype,none,
      "%select{|first |second }0type %1 in %select{conformance|same-type}2 "
      "requirement does not refer to a generic parameter or associated type",
      (int, TypeLoc, int))
ERROR(requires_no_same_type_archetype,none,
      "neither type in same-type refers to a generic parameter or "
      "associated type",
      ())
ERROR(requires_generic_params_made_equal,none,
      "same-type requirement makes generic parameters %0 and %1 equivalent",
      (Type, Type))
ERROR(requires_generic_param_made_equal_to_concrete,none,
      "same-type requirement makes generic parameter %0 non-generic",
      (Type))
ERROR(recursive_type_reference,none,
      "%0 %1 references itself", (DescriptiveDeclKind, Identifier))
ERROR(recursive_requirement_reference,none,
      "type may not reference itself as a requirement",())
ERROR(recursive_same_type_constraint,none,
      "same-type constraint %0 == %1 is recursive", (Type, Type))
ERROR(recursive_superclass_constraint,none,
      "superclass constraint %0 : %1 is recursive", (Type, Type))
ERROR(requires_same_type_conflict,none,
      "%select{associated type|generic parameter}0 %1 cannot be equal to "
      "both %2 and %3", (bool, Type, Type, Type))
ERROR(requires_generic_param_same_type_does_not_conform,none,
      "same-type constraint type %0 does not conform to required protocol %1",
      (Type, Identifier))
ERROR(requires_same_concrete_type,none,
      "generic signature requires types %0 and %1 to be the same", (Type, Type))
WARNING(redundant_conformance_constraint,none,
        "redundant conformance constraint %0: %1", (Type, ProtocolDecl *))
NOTE(redundant_conformance_here,none,
     "conformance constraint %1: %2 %select{written here|implied here|"
     "inferred from type here}0",
     (unsigned, Type, ProtocolDecl *))

ERROR(same_type_conflict,none,
      "%select{generic parameter |protocol |}0%1 cannot be equal to both "
      "%2 and %3", (unsigned, Type, Type, Type))
WARNING(redundant_same_type_to_concrete,none,
        "redundant same-type constraint %0 == %1", (Type, Type))
NOTE(same_type_redundancy_here,none,
     "same-type constraint %1 == %2 %select{written here|implied here|"
     "inferred from type here}0",
     (unsigned, Type, Type))
ERROR(requires_superclass_conflict,none,
      "%select{generic parameter |protocol |}0%1 cannot be a subclass of both "
      "%2 and %3", (unsigned, Type, Type, Type))
WARNING(redundant_superclass_constraint,none,
        "redundant superclass constraint %0 : %1", (Type, Type))
NOTE(superclass_redundancy_here,none,
     "superclass constraint %1 : %2 %select{written here|implied here|"
     "inferred from type here}0",
     (unsigned, Type, Type))

ERROR(conflicting_layout_constraints,none,
      "%select{generic parameter |protocol |}0%1 has conflicting layout "
      "constraints %2 and %3",
      (unsigned, Type, LayoutConstraint, LayoutConstraint))
WARNING(redundant_layout_constraint,none,
        "redundant layout constraint %0 : %1", (Type, LayoutConstraint))
NOTE(previous_layout_constraint, none,
     "layout constraint constraint %1 : %2 %select{written here|implied here|"
     "inferred from type here}0",
     (unsigned, Type, LayoutConstraint))

WARNING(redundant_same_type_constraint,none,
        "redundant same-type constraint %0 == %1", (Type, Type))
NOTE(previous_same_type_constraint, none,
     "previous same-type constraint %1 == %2 "
     "%select{written here|implied here|inferred from type here}0",
     (unsigned, Type, Type))

WARNING(inherited_associated_type_redecl,none,
        "redeclaration of associated type %0 from protocol %1 is better "
        "expressed as a 'where' clause on the protocol", (DeclName, Type))
WARNING(typealias_override_associated_type,none,
        "typealias overriding associated type %0 from protocol %1 is better "
        "expressed as same-type constraint on the protocol", (DeclName, Type))
WARNING(associated_type_override_typealias,none,
        "associated type %0 is redundant with type %0 declared in inherited "
        "%1 %2", (DeclName, DescriptiveDeclKind, Type))

ERROR(generic_param_access,none,
      "%0 %select{must be declared %select{"
      "%select{private|fileprivate|internal|%error|%error}3|private or fileprivate}4"
      "|cannot be declared "
      "%select{in this context|fileprivate|internal|public|open}2}1 "
      "because its generic %select{parameter|requirement}5 uses "
      "%select{a private|a fileprivate|an internal|%error|%error}3 type",
      (DescriptiveDeclKind, bool, Accessibility, Accessibility, bool, bool))
WARNING(generic_param_access_warn,none,
        "%0 %select{should be declared "
        "%select{private|fileprivate|internal|%error|%error}3"
        "|should not be declared %select{in this context|fileprivate|internal|public|open}2}1 "
        "because its generic %select{parameter|requirement}5 uses "
        "%select{a private|a fileprivate|an internal|%error|%error}3 type",
        (DescriptiveDeclKind, bool, Accessibility, Accessibility, bool, bool))

ERROR(override_multiple_decls_base,none,
      "declaration %0 cannot override more than one superclass declaration",
      (DeclName))
ERROR(override_multiple_decls_arg_mismatch,none,
      "declaration %0 has different argument names from any potential "
      "overrides", (DeclName))
NOTE(overridden_near_match_here,none,
     "potential overridden %0 %1 here",
      (DescriptiveDeclKind, DeclName))
ERROR(override_decl_extension,none,
      "declarations %select{in extensions|from extensions}0 cannot "
      "%select{override|be overridden}0 yet", (bool))
NOTE(overridden_here,none,
     "overridden declaration is here", ())
ERROR(override_objc_type_mismatch_method,none,
      "overriding method with selector %0 has incompatible type %1",
      (ObjCSelector, Type))
ERROR(override_objc_type_mismatch_subscript,none,
      "overriding %select{|indexed |keyed }0subscript with incompatible type "
      "%1",
      (unsigned, Type))
NOTE(overridden_here_with_type,none,
     "overridden declaration here has type %0", (Type))
ERROR(missing_override,none,
      "overriding declaration requires an 'override' keyword", ())

ERROR(multiple_override,none,
      "%0 has already been overridden", (DeclName))
NOTE(multiple_override_prev,none,
     "%0 previously overridden here", (DeclName))

ERROR(override_unavailable,none,
      "cannot override %0 which has been marked unavailable", (Identifier))
ERROR(override_unavailable_msg, none,
      "cannot override %0 which has been marked unavailable: %1",
      (Identifier, StringRef))

ERROR(override_less_available,none,
      "overriding %0 must be as available as declaration it overrides",
      (Identifier))

ERROR(override_accessor_less_available,none,
      "overriding %0 for %1 must be as available as declaration it overrides",
      (DescriptiveDeclKind, Identifier))

ERROR(override_let_property,none,
      "cannot override immutable 'let' property %0 with the getter of a 'var'",
      (Identifier))


ERROR(override_not_accessible,none,
      "%select{|setter of }0overriding %1 must be as accessible as "
      "%select{its enclosing type|the declaration it overrides}2",
      (bool, DescriptiveDeclKind, bool))

ERROR(override_of_non_open,none,
      "overriding non-open %0 outside of its defining module",
      (DescriptiveDeclKind))

ERROR(method_does_not_override,none,
      "method does not override any method from its superclass", ())
ERROR(property_does_not_override,none,
      "property does not override any property from its superclass", ())
ERROR(subscript_does_not_override,none,
      "subscript does not override any subscript from its superclass", ())
ERROR(initializer_does_not_override,none,
      "initializer does not override a designated initializer from its "
      "superclass", ())
ERROR(failable_initializer_override,none,
      "failable initializer %0 cannot override a non-failable initializer",
      (DeclName))
NOTE(nonfailable_initializer_override_here,none,
     "non-failable initializer %0 overridden here", (DeclName))

NOTE(property_override_here,none,
     "attempt to override property here", ())
NOTE(subscript_override_here,none,
     "attempt to override subscript here", ())
NOTE(convenience_init_override_here,none,
     "attempt to override convenience initializer here", ())
NOTE(override_type_mismatch_with_fixits,none,
     "type does not match superclass %0 with type %1",
     (DescriptiveDeclKind, Type))
NOTE(override_type_mismatch_with_fixits_init,none,
     "type does not match superclass initializer with %select{no arguments|argument %1|arguments %1}0",
     (unsigned, Type))
ERROR(override_nonclass_decl,none,
      "'override' can only be specified on class members", ())
ERROR(override_property_type_mismatch,none,
      "property %0 with type %1 cannot override a property with type %2",
      (Identifier, Type, Type))
ERROR(override_with_stored_property,none,
      "cannot override with a stored property %0", (Identifier))
ERROR(observing_readonly_property,none,
      "cannot observe read-only property %0; it can't change", (Identifier))
ERROR(override_mutable_with_readonly_property,none,
      "cannot override mutable property with read-only property %0",
      (Identifier))
ERROR(override_argument_name_mismatch,none,
      "argument names for %select{method|initializer}0 %1 do not match those "
      "of overridden %select{method|initializer}0 %2",
      (bool, DeclName, DeclName))
ERROR(override_ownership_mismatch,none,
      "cannot override %select{strong|weak|unowned|unowned(unsafe)}0 property "
      "with %select{strong|weak|unowned|unowned(unsafe)}1 property",
      (/*Ownership*/unsigned, /*Ownership*/unsigned))
ERROR(override_class_declaration_in_extension,none,
      "cannot override a non-dynamic class declaration from an extension",
      ())
WARNING(override_class_declaration_in_extension_warning,none,
      "cannot override a non-dynamic class declaration from an extension",
      ())
ERROR(override_throws,none,
      "cannot override non-throwing %select{method|initializer}0 with "
      "throwing %select{method|initializer}0", (bool))
ERROR(override_throws_objc,none,
      "overriding a throwing @objc %select{method|initializer}0 with "
      "a non-throwing %select{method|initializer}0 is not supported", (bool))

ERROR(override_optional_mismatch,none,
      "cannot override %0 %select{parameter|index}1 of type %2 with "
      "non-optional type %3",
      (DescriptiveDeclKind, bool, Type, Type))
ERROR(override_optional_result_mismatch,none,
      "cannot override %0 %select{result|element}1 type %2 with "
      "optional type %3",
      (DescriptiveDeclKind, bool, Type, Type))
WARNING(override_unnecessary_IUO,none,
      "overriding %0 parameter of type %1 with implicitly unwrapped optional "
      "type %2",
      (DescriptiveDeclKind, Type, Type))
WARNING(override_unnecessary_result_IUO,none,
      "overriding %0 optional result type %1 with implicitly unwrapped "
      "optional type %2",
      (DescriptiveDeclKind, Type, Type))
NOTE(override_unnecessary_IUO_remove,none,
     "remove '!' to make the parameter required", ())
NOTE(override_unnecessary_IUO_use_strict,none,
     "use '?' to make the result optional", ())
NOTE(override_unnecessary_IUO_silence,none,
     "add parentheses to silence this warning", ())

ERROR(iuo_in_illegal_position,none,
      "implicitly unwrapped optionals are only allowed at top level and as "
      "function results", ())

ERROR(override_mutable_covariant_property,none,
      "cannot override mutable property %0 of type %1 with covariant type %2",
      (Identifier, Type, Type))
ERROR(override_mutable_covariant_subscript,none,
      "cannot override mutable subscript of type %0 with covariant type %1",
      (Type, Type))
ERROR(decl_already_final,none,
      "static declarations are already final", ())
ERROR(open_decl_cannot_be_final,none,
      "%0 cannot be declared both 'final' and 'open'", (DescriptiveDeclKind))

WARNING(override_swift3_objc_inference,none,
        "override of %0 %1 from extension of %2 depends on deprecated "
        "inference of '@objc'",
        (DescriptiveDeclKind, DeclName, Identifier))

// Inheritance
ERROR(duplicate_inheritance,none,
  "duplicate inheritance from %0", (Type))
ERROR(multiple_inheritance,none,
  "multiple inheritance from classes %0 and %1", (Type, Type))
ERROR(non_class_inheritance,none,
  "non-class type %0 cannot inherit from class %1", (Type, Type))
ERROR(extension_class_inheritance,none,
  "extension of type %0 cannot inherit from class %1", (Type, Type))
ERROR(inheritance_from_non_protocol_or_class,none,
  "inheritance from non-protocol, non-class type %0", (Type))
ERROR(inheritance_from_non_protocol,none,
  "inheritance from non-protocol type %0", (Type))
ERROR(superclass_not_first,none,
  "superclass %0 must appear first in the inheritance clause", (Type))
ERROR(superclass_not_open,none,
  "cannot inherit from non-open class %0 outside of its defining module",
  (Type))
NOTE(superclass_here,none,"superclass is declared here", ())
ERROR(superclass_of_open_not_open,none,
  "superclass %0 of open class must be open", (Type))
ERROR(circular_class_inheritance,none,
      "circular class inheritance %0", (StringRef))
NOTE(class_here,none,
     "class %0 declared here", (Identifier))
ERROR(inheritance_from_final_class,none,
      "inheritance from a final class %0", (Identifier))
ERROR(inheritance_from_unspecialized_objc_generic_class,none,
      "inheritance from a generic Objective-C class %0 must bind "
      "type parameters of %0 to specific concrete types", (Identifier))
ERROR(inheritance_from_class_with_missing_vtable_entries,none,
      "cannot inherit from class %0 because it has overridable members that "
      "could not be loaded",
      (Identifier))
ERROR(inheritance_from_class_with_missing_vtable_entries_versioned,none,
      "cannot inherit from class %0 (compiled with Swift %1) because it has "
      "overridable members that could not be loaded in Swift %2",
      (Identifier, clang::VersionTuple, clang::VersionTuple))
ERROR(inheritance_from_cf_class,none,
      "cannot inherit from Core Foundation type %0", (Identifier))
ERROR(inheritance_from_objc_runtime_visible_class,none,
      "cannot inherit from class %0 because it is only visible via the "
      "Objective-C runtime", (Identifier))
WARNING(class_inherits_anyobject,none,
        "conformance of class %0 to 'AnyObject' is redundant", (Type))

// Enums
ERROR(enum_case_access,none,
      "enum case in %select{a private|a fileprivate|an internal|a public|%error}0 enum "
      "uses %select{a private|a fileprivate|an internal|%error|%error}1 type",
      (Accessibility, Accessibility))
WARNING(enum_case_access_warn,none,
        "enum case in %select{a private|a fileprivate|an internal|a public|%error}0 enum "
        "uses %select{a private|a fileprivate|an internal|%error|%error}1 type",
        (Accessibility, Accessibility))
ERROR(enum_stored_property,none,
      "enums may not contain stored properties", ())

// Enum raw types
ERROR(multiple_enum_raw_types,none,
  "multiple enum raw types %0 and %1", (Type, Type))
ERROR(circular_enum_inheritance,none,
      "circular enum raw types %0", (StringRef))
ERROR(raw_type_not_first,none,
  "raw type %0 must appear first in the enum inheritance clause", (Type))
ERROR(raw_type_not_literal_convertible,none,
      "raw type %0 is not expressible by any literal",
      (Type))
ERROR(enum_raw_type_not_equatable,none,
      "RawRepresentable conformance cannot be synthesized because raw type %0 is not "
      "Equatable", (Type))
ERROR(enum_raw_type_nonconforming_and_nonsynthable,none,
      "%0 declares raw type %1, but does not conform to RawRepresentable "
      "and conformance could not be synthesized", (Type, Type))
NOTE(enum_declares_rawrep_with_raw_type,none,
      "%0 declares raw type %1, which implies RawRepresentable", (Type, Type))
ERROR(enum_raw_type_access,none,
      "enum %select{must be declared %select{"
      "%select{private|fileprivate|internal|%error|%error}2|private or fileprivate}3"
      "|cannot be declared "
      "%select{in this context|fileprivate|internal|public|open}1}0 "
      "because its raw type uses "
      "%select{a private|a fileprivate|an internal|%error|%error}2 type",
      (bool, Accessibility, Accessibility, bool))
WARNING(enum_raw_type_access_warn,none,
        "enum %select{should be declared "
        "%select{private|fileprivate|internal|%error|%error}2"
        "|should not be declared %select{in this context|fileprivate|internal|public|open}1}0 "
        "because its raw type uses "
        "%select{a private|a fileprivate|an internal|%error|%error}2 type",
        (bool, Accessibility, Accessibility, bool))

NOTE(enum_here,none,
     "enum %0 declared here", (Identifier))
ERROR(empty_enum_raw_type,none,
      "an enum with no cases cannot declare a raw type", ())
ERROR(enum_raw_value_without_raw_type,none,
      "enum case cannot have a raw value if the enum does not have a raw type", ())
ERROR(enum_with_raw_type_case_with_argument,none,
      "enum with raw type cannot have cases with arguments", ())
NOTE(enum_raw_type_here,none,
     "declared raw type %0 here", (Type))
ERROR(objc_enum_no_raw_type,none,
      "'@objc' enum must declare an integer raw type", ())
ERROR(objc_enum_raw_type_not_integer,none,
      "'@objc' enum raw type %0 is not an integer type", (Type))
ERROR(enum_non_integer_raw_value_auto_increment,none,
      "enum case must declare a raw value when the preceding raw value is not an integer", ())
ERROR(enum_non_integer_convertible_raw_type_no_value,none,
      "enum cases require explicit raw values when the raw type is not "
      "expressible by integer or string literal", ())
ERROR(enum_raw_value_not_unique,none,
      "raw value for enum case is not unique", ())
NOTE(enum_raw_value_used_here,none,
     "raw value previously used here", ())
NOTE(enum_raw_value_incrementing_from_here,none,
     "raw value auto-incremented from here",())
NOTE(enum_raw_value_incrementing_from_zero,none,
     "raw value implicitly auto-incremented from zero",())
NOTE(construct_raw_representable_from_unwrapped_value,none,
     "construct %0 from unwrapped %1 value", (Type, Type))

// Derived conformances

ERROR(cannot_synthesize_in_extension,none,
      "implementation of %0 cannot be automatically synthesized in an extension yet", (Type))

ERROR(broken_raw_representable_requirement,none,
      "RawRepresentable protocol is broken: unexpected requirement", ())
ERROR(broken_equatable_requirement,none,
      "Equatable protocol is broken: unexpected requirement", ())
ERROR(broken_hashable_requirement,none,
      "Hashable protocol is broken: unexpected requirement", ())
ERROR(broken_errortype_requirement,none,
      "Error protocol is broken: unexpected requirement", ())
ERROR(broken_int_hashable_conformance,none,
      "Int type is broken: does not conform to Hashable", ())
ERROR(broken_int_integer_literal_convertible_conformance,none,
      "Int type is broken: does not conform to ExpressibleByIntegerLiteral", ())
ERROR(no_equal_overload_for_int,none,
      "no overload of '==' for Int", ())
ERROR(broken_coding_key_requirement,none,
      "CodingKey protocol is broken: unexpected requirement", ())
ERROR(broken_encodable_requirement,none,
      "Encodable protocol is broken: unexpected requirement", ())
ERROR(broken_decodable_requirement,none,
      "Decodable protocol is broken: unexpected requirement", ())

NOTE(codable_extraneous_codingkey_case_here,none,
     "CodingKey case %0 does not match any stored properties", (Identifier))
NOTE(codable_non_conforming_property_here,none,
     "cannot automatically synthesize %0 because %1 does not conform to %0", (Type, Type))
NOTE(codable_non_decoded_property_here,none,
     "cannot automatically synthesize %0 because %1 does not have a matching CodingKey and does not have a default value", (Type, Identifier))
NOTE(codable_codingkeys_type_is_not_an_enum_here,none,
     "cannot automatically synthesize %0 because 'CodingKeys' is not an enum", (Type))
NOTE(codable_codingkeys_type_does_not_conform_here,none,
     "cannot automatically synthesize %0 because 'CodingKeys' does not conform to CodingKey", (Type))
NOTE(decodable_no_super_init_here,none,
     "cannot automatically synthesize %0 because superclass does not have a callable %1", (DeclName, DeclName))
NOTE(decodable_super_init_not_designated_here,none,
     "cannot automatically synthesize %0 because implementation would need to call %1, which is not designated", (DeclName, DeclName))
NOTE(decodable_inaccessible_super_init_here,none,
     "cannot automatically synthesize %0 because implementation would need to call %1, which is inaccessible due to "
     "'%select{private|fileprivate|internal|%error|%error}2' protection level",
     (DeclName, DeclName, Accessibility))
NOTE(decodable_super_init_is_failable_here,none,
     "cannot automatically synthesize %0 because implementation would need to call %1, which is failable", (DeclName, DeclName))
NOTE(decodable_suggest_overriding_init_here,none,
     "did you mean to override 'init(from:)'?", ())
NOTE(codable_suggest_overriding_init_here,none,
     "did you mean to override 'init(from:)' and 'encode(to:)'?", ())

// Dynamic Self
ERROR(dynamic_self_non_method,none,
      "%select{global|local}0 function cannot return 'Self'", (bool))

ERROR(self_in_nominal,none,
      "'Self' is only available in a protocol or as the result of a "
      "method in a class; did you mean '%0'?", (StringRef))

// Duplicate declarations
ERROR(duplicate_enum_element,none,
      "duplicate definition of enum element",())

// Property behaviors
ERROR(property_behavior_not_protocol,none,
      "property behavior name must refer to a protocol", ())
ERROR(property_behavior_protocol_reqt_ambiguous,none,
      "property behavior protocol has ambiguous %0 member", (Identifier))
NOTE(property_behavior_protocol_reqt_here,none,
     "%0 declared here", (Identifier))
ERROR(property_behavior_protocol_no_value,none,
      "property behavior protocol does not have a 'value' property", ())
ERROR(property_behavior_protocol_no_initStorage,none,
      "property behavior protocol has a 'storage' requirement but does not "
      "have a static 'initStorage' method with the expected type %0 or %1",
      (Type, Type))
ERROR(property_behavior_unknown_requirement,none,
      "property behavior protocol %0 has non-behavior requirement %1",
      (Identifier, Identifier))
NOTE(property_behavior_unknown_requirement_here,none,
     "declared here", ())
NOTE(self_conformance_required_by_property_behavior,none,
     "conformance to %0 required to contain an instance property with "
     "behavior %1",
     (Identifier, Identifier))
NOTE(value_conformance_required_by_property_behavior,none,
     "behavior %1 requires property type to conform to protocol %0",
     (Identifier, Identifier))
ERROR(property_behavior_with_self_requirement_not_in_type,none,
      "property behavior %0 can only be used on instance properties "
      "because it has 'Self' requirements",
      (Identifier))
ERROR(property_behavior_with_feature_not_supported,none,
      "property behavior %0 with %1 is not supported outside of "
      "type contexts",
      (Identifier, StringRef))
ERROR(property_behavior_value_type_doesnt_match,none,
      "property behavior %0 provides 'value' property implementation with "
      "type %1 that doesn't match type %2 of declared property %3",
      (Identifier, Type, Identifier, Type))
NOTE(property_behavior_value_decl_here,none,
     "'value' property declared here", ())
ERROR(property_behavior_invalid_parameter_reqt,none,
      "property behavior %0 has a 'parameter' requirement that is "
      "static or generic", (Identifier))
ERROR(property_behavior_requires_parameter,none,
      "property behavior %0 requires a parameter in the declaration of %1",
      (Identifier, Identifier))
ERROR(property_behavior_invalid_initializer,none,
      "initializer expression provided, but property behavior %0 does not "
      "use it",
      (Identifier))
ERROR(property_behavior_unsupported_initializer,none,
      "property behaviors do not support destructuring initialization of "
      "multiple properties", ())
ERROR(property_behavior_invalid_parameter,none,
      "parameter expression provided, but property behavior %0 does not "
      "use it",
      (Identifier))
ERROR(property_behavior_conformance_broken,none,
      "property behavior for %0 in type %1 is broken", (DeclName, Type))

//------------------------------------------------------------------------------
// Type Check Attributes
//------------------------------------------------------------------------------

ERROR(attr_only_one_decl_kind,none,
      "%0 may only be used on '%1' declarations", (DeclAttribute,StringRef))
ERROR(attr_only_on_parameters,none,
      "%0 may only be used on parameters", (StringRef))
ERROR(attr_not_on_variadic_parameters,none,
      "%0 may not be used on variadic parameters", (StringRef))
ERROR(attr_not_on_subscript_parameters,none,
      "%0 may not be used on subscript parameters", (StringRef))

ERROR(override_final,none,
      "%0 overrides a 'final' %1", (DescriptiveDeclKind, DescriptiveDeclKind))

ERROR(override_static,none,
      "cannot override %0", (DescriptiveDeclKind))

ERROR(member_cannot_be_final,none,
      "only classes and class members may be marked with 'final'",
      ())
WARNING(protocol_extension_cannot_be_final,none,
      "functions in a protocol extension do not need to be marked with 'final'",
      ())

ERROR(final_not_allowed_here,none,
      "'final' may only be applied to classes, properties, methods, and "
      "subscripts", ())

ERROR(final_not_on_accessors,none,
      "'final' cannot be applied to accessors, it must be put on the "
      "%select{var|let|subscript}0", (unsigned))

ERROR(override_rethrows_with_non_rethrows,none,
      "override of 'rethrows' %select{method|initializer}0 should also "
      "be 'rethrows'", (bool))
ERROR(rethrows_without_throwing_parameter,none,
      "'rethrows' function must take a throwing function argument", ())

ERROR(autoclosure_function_type,none,
      "@autoclosure may only be applied to values of function type",
      ())
ERROR(autoclosure_function_input_nonunit,none,
      "autoclosure argument type must be '()'", ())

// FIXME: drop these when we drop @noescape
ERROR(noescape_function_type,none,
      "@noescape may only be applied to parameters of function type",
      ())
ERROR(noescape_implied_by_autoclosure,none,
      "@noescape is implied by @autoclosure and should not be "
      "redundantly specified", ())
ERROR(noescape_conflicts_escaping_autoclosure,none,
      "@noescape conflicts with @autoclosure(escaping)", ())

ERROR(escaping_non_function_parameter,none,
      "@escaping attribute may only be used in function parameter position", ())

NOTE(escaping_optional_type_argument, none,
     "closure is already escaping in optional type argument", ())

// NSManaged attribute
ERROR(attr_NSManaged_not_instance_member,none,
      "@NSManaged only allowed on an instance property or method", ())
ERROR(attr_NSManaged_not_stored,none,
      "@NSManaged not allowed on %select{computed|observing|addressed}0 "
      "properties", (unsigned))
ERROR(attr_NSManaged_let_property,none,
      "@NSManaged not allowed on a 'let' property", ())
ERROR(attr_NSManaged_initial_value,none,
      "@NSManaged property cannot have an initial value", ())
ERROR(attr_NSManaged_NSCopying,none,
      "@NSManaged property cannot also be marked @NSCopying", ())
ERROR(attr_NSManaged_method_body,none,
      "@NSManaged method cannot have a body; it must be provided at runtime",())


// NSCopying attribute
ERROR(nscopying_only_on_class_properties,none,
      "@NSCopying may only be used on properties in classes",
      ())
ERROR(nscopying_only_mutable,none,
      "@NSCopying requires property to be mutable", ())
ERROR(nscopying_only_stored_property,none,
      "@NSCopying is only valid on stored properties", ())
ERROR(nscopying_doesnt_conform,none,
      "@NSCopying is only valid with types that conform to"
      " the NSCopying protocol", ())

// UIApplicationMain/NSApplicationMain attribute
#define SELECT_APPLICATION_MAIN "select{'UIApplicationMain'|'NSApplicationMain'}"
#define SELECT_APPLICATION_DELEGATE "select{'UIApplicationDelegate'|'NSApplicationDelegate'}"

ERROR(attr_ApplicationMain_not_ApplicationDelegate,none,
      "%" SELECT_APPLICATION_MAIN "0 class must conform to the %" SELECT_APPLICATION_DELEGATE "0 protocol",
      (unsigned))
ERROR(attr_generic_ApplicationMain_not_supported,none,
      "generic %" SELECT_APPLICATION_MAIN "0 classes are not supported",
      (unsigned))
ERROR(attr_ApplicationMain_multiple,none,
      "%" SELECT_APPLICATION_MAIN "0 attribute can only apply to one class in a module",
      (unsigned))
ERROR(attr_ApplicationMain_with_script,none,
      "%" SELECT_APPLICATION_MAIN "0 attribute cannot be used in a module that contains "
      "top-level code",
      (unsigned))
NOTE(attr_ApplicationMain_script_here,none,
     "top-level code defined in this source file",
     ())

#undef SELECT_APPLICATION_MAIN
#undef SELECT_APPLICATION_DELEGATE

// lazy
ERROR(lazy_not_on_let,none,
      "'lazy' cannot be used on a let", ())
ERROR(lazy_not_on_computed,none,
      "'lazy' may not be used on a computed property", ())

ERROR(lazy_on_already_lazy_global,none,
      "'lazy' may not be used on an already-lazy global", ())
ERROR(lazy_not_in_protocol,none,
      "'lazy' isn't allowed on a protocol requirement", ())
ERROR(lazy_requires_initializer,none,
      "lazy properties must have an initializer", ())

ERROR(lazy_requires_single_var,none,
      "'lazy' cannot destructure an initializer", ())

ERROR(lazy_must_be_property,none,
      "lazy is only valid for members of a struct or class", ())
ERROR(lazy_not_observable,none,
      "lazy properties may not have observers", ())

// Debugger function attribute.
ERROR(attr_for_debugger_support_only,none,
      "@LLDBDebuggerSupport may only be used when debugger support is on", ())

// @_implements
ERROR(implements_attr_protocol_lacks_member,none,
      "protocol %0 has no member %1", (DeclName, DeclName))

ERROR(implements_attr_non_protocol_type,none,
      "non-protocol type in @_implements attribute", ())

ERROR(implements_attr_protocol_not_conformed_to,none,
      "containing type %0 does not conform to protocol %1",
      (DeclName, DeclName))

//------------------------------------------------------------------------------
// Type Check Expressions
//------------------------------------------------------------------------------

NOTE(found_candidate,none,
     "found this candidate", ())
NOTE(found_candidate_type,none,
     "found candidate with type %0", (Type))

ERROR(no_MaxBuiltinIntegerType_found,none,
   "standard library error: _MaxBuiltinIntegerType is not properly defined", ())
ERROR(no_MaxBuiltinFloatType_found,none,
   "standard library error: _MaxBuiltinFloatType is not properly defined", ())

ERROR(no_member_of_module,none,
      "module %0 has no member named %1", (Identifier, DeclName))

ERROR(super_with_no_base_class,none,
      "'super' members cannot be referenced in a root class", ())

ERROR(bad_init_ref_base, none,
      "'init' can only refer to the initializers of "
      "'self'%select{| or 'super'}0", (bool))
ERROR(init_delegation_outside_initializer,none,
      "initializer delegation can only occur within an initializer", ())
ERROR(init_delegates_and_chains,none,
      "initializer cannot both delegate ('self.init') and chain to a "
      "superclass initializer ('super.init')", ())
NOTE(init_delegation_or_chain,none,
      "previous %select{delegation|chaining}0 call is here", (bool))
ERROR(delegating_convenience_super_init,none,
      "convenience initializer for %0 must delegate (with 'self.init') rather "
      "than chaining to a superclass initializer (with 'super.init')",
      (Type))
ERROR(delegating_designated_init,none,
      "designated initializer for %0 cannot delegate (with 'self.init'); "
      "did you mean this to be a convenience initializer?",
      (Type))
NOTE(delegation_here,none, "delegation occurs here", ())
ERROR(chain_convenience_init,none,
      "must call a designated initializer of the superclass %0",
      (Type))
ERROR(delegate_chain_nonoptional_to_optional,none,
      "a non-failable initializer cannot %select{delegate|chain}0 to "
      "failable initializer %1 written with 'init?'", (bool, DeclName))
NOTE(init_force_unwrap,none,
     "force potentially-failing result with '!'", ())
NOTE(init_propagate_failure,none,
     "propagate the failure with 'init?'", ())
ERROR(delegate_chain_nonoptional_to_optional_try,none,
      "a non-failable initializer cannot use 'try?' to "
      "%select{delegate|chain}0 to another initializer", (bool))
NOTE(init_delegate_force_try,none,
     "force potentially-failing result with 'try!'", ())
ERROR(init_delegation_nested,none,
      "%select{initializer delegation ('self.init')|"
      "initializer chaining ('super.init')}0 cannot be nested in another "
      "%select{expression|statement}1", (bool, bool))

NOTE(convenience_init_here,none,
     "convenience initializer is declared here", ())
ERROR(designated_init_in_extension,none,
      "designated initializer cannot be declared in an extension of %0; "
      "did you mean this to be a convenience initializer?",
      (Type))
ERROR(enumstruct_convenience_init,none,
      "delegating initializers in %0 are not marked with 'convenience'",
      (StringRef))
ERROR(nonclass_convenience_init,none,
      "convenience initializer not allowed in non-class type %0",
      (Type))
ERROR(cfclass_convenience_init,none,
      "convenience initializers are not supported in extensions of CF types",
      ())

ERROR(dynamic_construct_class,none,
      "constructing an object of class type %0 with a metatype value must use "
      "a 'required' initializer", (Type))
NOTE(note_nonrequired_initializer,none,
      "selected %select{non-required|implicit}0 initializer %1",
     (bool, DeclName))
ERROR(construct_protocol_value,none,
      "value of type %0 is a protocol; it cannot be instantiated",
      (Type))
ERROR(construct_protocol_by_name,none,
      "protocol type %0 cannot be instantiated",
      (Type))

// Operators
ERROR(unknown_binop,none,
       "operator is not a known binary operator", ())
ERROR(non_associative_adjacent_operators,none,
      "adjacent operators are in non-associative precedence group %0",
      (Identifier))
ERROR(unordered_adjacent_operators,none,
      "adjacent operators are in unordered precedence groups %0 and %1",
      (Identifier, Identifier))
ERROR(missing_builtin_precedence_group,none,
      "broken standard library: missing builtin precedence group %0",
      (Identifier))

// If you change this, also change enum TryKindForDiagnostics.
#define TRY_KIND_SELECT(SUB) "%select{try|try!|try?}" #SUB

ERROR(try_rhs,none,
      "'" TRY_KIND_SELECT(0) "' cannot appear to the right of a "
      "non-assignment operator", (unsigned))
ERROR(try_if_rhs_noncovering,none,
      "'" TRY_KIND_SELECT(0) "' following conditional operator does not cover "
      "everything to its right", (unsigned))
ERROR(try_assign_rhs_noncovering,none,
      "'" TRY_KIND_SELECT(0) "' following assignment operator does not cover "
      "everything to its right", (unsigned))

ERROR(broken_bool,none, "type 'Bool' is broken", ())

WARNING(inject_forced_downcast,none,
        "treating a forced downcast to %0 as optional will never produce 'nil'",
        (Type))
NOTE(forced_to_conditional_downcast,none,
     "use 'as?' to perform a conditional downcast to %0", (Type))
NOTE(silence_inject_forced_downcast,none,
     "add parentheses around the cast to silence this warning", ())

ERROR(conditional_downcast_foreign,none,
      "conditional downcast to CoreFoundation type %0 will always succeed",
      (Type))

ERROR(optional_used_as_boolean,none,
     "optional type %0 cannot be used as a boolean; "
     "test for '!= nil' instead", (Type))

ERROR(interpolation_missing_proto,none,
      "string interpolation requires the protocol '_ExpressibleByStringInterpolation' to be defined",
      ())
ERROR(interpolation_broken_proto,none,
      "protocol '_ExpressibleByStringInterpolation' is broken",
      ())

ERROR(object_literal_broken_proto,none,
      "object literal protocol is broken", ())

ERROR(discard_expr_outside_of_assignment,none,
      "'_' can only appear in a pattern or on the left side of an assignment",
      ())
ERROR(inout_expr_outside_of_call,none,
      "'&' can only appear immediately in a call argument list", ())
ERROR(collection_literal_heterogeneous,none,
      "heterogeneous collection literal could only be inferred to %0; add"
      " explicit type annotation if this is intentional", (Type))
ERROR(collection_literal_empty,none,
      "empty collection literal requires an explicit type", ())

ERROR(unresolved_member_no_inference,none,
      "reference to member %0 cannot be resolved without a contextual type",
      (DeclName))
ERROR(unresolved_collection_literal,none,
      "cannot infer type for empty collection literal without a "
      "contextual type", ())
ERROR(unresolved_nil_literal,none,
      "'nil' requires a contextual type", ())

ERROR(type_of_expression_is_ambiguous,none,
      "type of expression is ambiguous without more context", ())

ERROR(specific_type_of_expression_is_ambiguous,none,
      "expression type %0 is ambiguous without more context", (Type))


ERROR(missing_protocol,none,
      "missing protocol %0", (Identifier))
ERROR(nil_literal_broken_proto,none,
      "protocol 'ExpressibleByNilLiteral' is broken", ())

ERROR(builtin_integer_literal_broken_proto,none,
      "protocol '_ExpressibleByBuiltinIntegerLiteral' is broken", ())
ERROR(integer_literal_broken_proto,none,
      "protocol 'ExpressibleByIntegerLiteral' is broken", ())

ERROR(builtin_float_literal_broken_proto,none,
      "protocol '_ExpressibleByBuiltinFloatLiteral' is broken", ())
ERROR(float_literal_broken_proto,none,
      "protocol 'ExpressibleByFloatLiteral' is broken", ())

ERROR(builtin_boolean_literal_broken_proto,none,
      "protocol '_ExpressibleByBuiltinBooleanLiteral' is broken", ())
ERROR(boolean_literal_broken_proto,none,
      "protocol 'ExpressibleByBooleanLiteral' is broken", ())

ERROR(builtin_unicode_scalar_literal_broken_proto,none,
      "protocol '_ExpressibleByBuiltinUnicodeScalarLiteral' is broken", ())
ERROR(unicode_scalar_literal_broken_proto,none,
      "protocol 'ExpressibleByUnicodeScalarLiteral' is broken", ())

ERROR(builtin_utf16_extended_grapheme_cluster_literal_broken_proto,none,
      "protocol '_ExpressibleByBuiltinUTF16ExtendedGraphemeClusterLiteral' is broken", ())
ERROR(builtin_extended_grapheme_cluster_literal_broken_proto,none,
      "protocol '_ExpressibleByBuiltinExtendedGraphemeClusterLiteral' is broken", ())
ERROR(extended_grapheme_cluster_literal_broken_proto,none,
      "protocol 'ExpressibleByExtendedGraphemeClusterLiteral' is broken", ())

ERROR(builtin_string_literal_broken_proto,none,
      "protocol '_ExpressibleByBuiltinStringLiteral' is broken", ())
ERROR(string_literal_broken_proto,none,
      "protocol 'ExpressibleByStringLiteral' is broken", ())

// Array literals
ERROR(array_protocol_broken,none,
      "ExpressibleByArrayLiteral protocol definition is broken", ())
ERROR(type_is_not_array,none,
      "contextual type %0 cannot be used with array literal", (Type))
NOTE(meant_dictionary_lit,none,
     "did you mean to use a dictionary literal instead?", ())
ERROR(should_use_empty_dictionary_literal,none,
      "use [:] to get an empty dictionary literal", ())

// Dictionary literals
ERROR(dictionary_protocol_broken,none,
      "ExpressibleByDictionaryLiteral protocol definition is broken", ())
ERROR(type_is_not_dictionary,none,
      "contextual type %0 cannot be used with dictionary literal", (Type))


// Generic specializations
ERROR(cannot_explicitly_specialize_generic_function,none,
      "cannot explicitly specialize a generic function", ())
ERROR(not_a_generic_definition,none,
      "cannot specialize a non-generic definition", ())
ERROR(not_a_generic_type,none,
      "cannot specialize non-generic type %0", (Type))
ERROR(type_parameter_count_mismatch,none,
      "generic type %0 specialized with %select{too many|too few}3 type "
      "parameters (got %2, but expected %1)",
      (Identifier, unsigned, unsigned, bool))
ERROR(generic_type_requires_arguments,none,
      "reference to generic type %0 requires arguments in <...>", (Type))
NOTE(generic_type_declared_here,none,
     "generic type %0 declared here", (Identifier))

WARNING(use_of_void_pointer,none,
"Unsafe%0Pointer<Void> has been replaced by Unsafe%0RawPointer", (StringRef))

// Ambiguities
ERROR(ambiguous_decl_ref,none,
      "ambiguous use of %0", (DeclName))
ERROR(ambiguous_operator_ref,none,
      "ambiguous use of operator %0", (DeclName))
NOTE(ambiguous_because_of_trailing_closure,none,
     "%select{use an explicit argument label instead of a trailing closure|"
     "avoid using a trailing closure}0 to call %1",
     (bool, DeclName))

// Cannot capture inout-ness of a parameter
// Partial application of foreign functions not supported
ERROR(partial_application_of_function_invalid,none,
      "partial application of %select{"
        "function with 'inout' parameters|"
        "'mutating' method|"
        "'super.init' initializer chain|"
        "'self.init' initializer delegation"
      "}0 is not allowed",
      (unsigned))

ERROR(self_assignment_var,none,
      "assigning a variable to itself", ())
ERROR(self_assignment_prop,none,
      "assigning a property to itself", ())
ERROR(property_use_in_closure_without_explicit_self,none,
      "reference to property %0 in closure requires explicit 'self.' to make"
      " capture semantics explicit", (Identifier))
ERROR(method_call_in_closure_without_explicit_self,none,
      "call to method %0 in closure requires explicit 'self.' to make"
      " capture semantics explicit", (Identifier))
ERROR(implicit_use_of_self_in_closure,none,
      "implicit use of 'self' in closure; use 'self.' to make"
      " capture semantics explicit", ())
ERROR(capture_before_declaration,none,
      "cannot capture %0 before it is declared", (Identifier))
ERROR(transitive_capture_before_declaration,none,
      "cannot capture %0, which would use %1 before it is declared",
      (Identifier, Identifier))
NOTE(transitive_capture_through_here,none,
     "%0, declared here, captures %1",
     (Identifier, Identifier))

ERROR(closure_implicit_capture_without_noescape,none,
      "escaping closures can only capture inout parameters explicitly by value",
      ())
ERROR(closure_implicit_capture_mutating_self,none,
      "closure cannot implicitly capture a mutating self parameter",
      ())
ERROR(nested_function_with_implicit_capture_argument,none,
      "nested function with %select{an |}0implicitly captured inout "
      "parameter%select{|s}0 can only be used as a non-escaping argument", (bool))
ERROR(nested_function_escaping_inout_capture,none,
      "nested function cannot capture inout parameter and escape", ())

WARNING(recursive_accessor_reference,none,
        "attempting to %select{access|modify}1 %0 within its own "
        "%select{getter|setter}1", (Identifier, bool))
NOTE(recursive_accessor_reference_silence,none,
     "access 'self' explicitly to silence this warning", ())
WARNING(store_in_willset,none,
        "attempting to store to property %0 within its own willSet, which is "
        "about to be overwritten by the new value", (Identifier))

ERROR(tuple_splat_use,none,
      "passing %0 arguments to a callee as a single tuple value has been removed in Swift 3",
        (unsigned))


ERROR(value_of_module_type,none,
      "expected module member name after module name", ())

ERROR(value_of_metatype_type,none,
      "expected member name or constructor call after type name", ())
WARNING(warn_value_of_metatype_missing_self,none,
      "missing '.self' for reference to metatype of type %0", (Type))

NOTE(add_parens_to_type,none,
     "add arguments after the type to construct a value of the type", ())
NOTE(add_self_to_type,none,
     "use '.self' to reference the type object", ())

WARNING(warn_unqualified_access,none,
        "use of %0 treated as a reference to %1 in %2 %3",
        (Identifier, DescriptiveDeclKind, DescriptiveDeclKind, DeclName))
NOTE(fix_unqualified_access_member,none,
     "use 'self.' to silence this warning", ())
NOTE(fix_unqualified_access_top_level,none,
     "use '%0' to reference the %1",
     (StringRef, DescriptiveDeclKind, Identifier))
NOTE(fix_unqualified_access_top_level_multi,none,
     "use '%0' to reference the %1 in module %2",
     (StringRef, DescriptiveDeclKind, Identifier))

ERROR(unsupported_special_decl_ref, none,
      "referencing %0 as a function value is not implemented", (Identifier))

WARNING(bitcasting_away_noescape, none,
        "'unsafeBitCast' from non-escaping function type %0 to escaping "
        "function type %1 is undefined; use "
        "'withoutActuallyEscaping' to temporarily escape a function",
        (Type, Type))
WARNING(bitcasting_to_change_function_rep, none,
        "'unsafeBitCast' from function type %0 to %1 changes @convention and "
        "is undefined; use an implicit conversion to change conventions",
        (Type, Type))
WARNING(bitcasting_to_downcast, none,
        "'unsafeBitCast' from %0 to %1 can be replaced with 'unsafeDowncast'",
        (Type, Type))
WARNING(bitcasting_is_no_op, none,
        "'unsafeBitCast' from %0 to %1 is unnecessary and can be removed",
        (Type, Type))
WARNING(bitcasting_to_change_pointer_kind, none,
        "'unsafeBitCast' from %0 to %1 can be replaced with %2 initializer",
        (Type, Type, Identifier))
WARNING(bitcasting_to_change_pointee_type, none,
        "'unsafeBitCast' from %0 to %1 changes pointee type and may lead to "
        "undefined behavior; use the 'withMemoryRebound' method on %0 to "
        "rebind the type of memory",
        (Type, Type))
WARNING(bitcasting_to_give_type_to_raw_pointer, none,
        "'unsafeBitCast' from %0 to %1 gives a type to a raw pointer and may "
        "lead to undefined behavior",
        (Type, Type))
NOTE(bitcast_assume_memory_rebound, none,
     "use the 'assumingMemoryBound' method if the pointer is known to point to "
     "an existing value or array of type %0 in memory",
     (Type))
NOTE(bitcast_bind_memory, none,
     "use the 'bindMemory' method to assign type %0 to uninitialized raw "
     "memory",
     (Type))
WARNING(bitcasting_for_number_bit_pattern_init, none,
        "'unsafeBitCast' from %0 to %1 can be replaced with 'bitPattern:' "
        "initializer on %1",
        (Type, Type))
WARNING(bitcasting_for_number_bit_pattern_property, none,
        "'unsafeBitCast' from %0 to %1 can be replaced with 'bitPattern' "
        "property on %0",
        (Type, Type))
WARNING(bitcasting_to_change_from_unsized_to_sized_int, none,
        "'unsafeBitCast' from %0 to %1 can be replaced with %1 "
        "initializer",
        (Type, Type))

WARNING(use_of_qq_on_non_optional_value,none,
        "left side of nil coalescing operator '?""?' has non-optional type %0, "
        "so the right side is never used", (Type))
WARNING(nonoptional_compare_to_nil,none,
        "comparing non-optional value of type %0 to nil always returns"
        " %select{false|true}1", (Type, bool))
WARNING(optional_check_nonoptional,none,
        "non-optional expression of type %0 used in a check for optionals",
        (Type))
WARNING(optional_check_promotion,none,
        "explicitly specified type %0 adds an additional level of optional to"
        " the initializer, making the optional check always succeed",
        (Type))
WARNING(optional_pattern_match_promotion,none,
        "pattern match introduces an implicit promotion from %0 to %1",
        (Type, Type))
WARNING(optional_to_any_coercion,none,
        "expression implicitly coerced from %0 to Any", (Type))
NOTE(default_optional_to_any,none,
     "provide a default value to avoid this warning", ())
NOTE(force_optional_to_any,none,
     "force-unwrap the value to avoid this warning", ())
NOTE(silence_optional_to_any,none,
     "explicitly cast to Any with 'as Any' to silence this warning", ())
WARNING(optional_in_string_interpolation_segment,none,
        "string interpolation produces a debug description for an optional "
        "value; did you mean to make this explicit?",
        ())
NOTE(silence_optional_in_interpolation_segment_call,none,
     "use 'String(describing:)' to silence this warning", ())

ERROR(invalid_noescape_use,none,
      "non-escaping %select{value|parameter}1 %0 may only be called",
      (Identifier, bool))
NOTE(noescape_autoclosure,none,
    "parameter %0 is implicitly non-escaping because it was declared @autoclosure",
     (Identifier))
NOTE(noescape_parameter,none,
    "parameter %0 is implicitly non-escaping",
     (Identifier))

ERROR(closure_noescape_use,none,
      "closure use of non-escaping parameter %0 may allow it to escape",
      (Identifier))
ERROR(decl_closure_noescape_use,none,
      "declaration closing over non-escaping parameter %0 may allow it to escape",
      (Identifier))
ERROR(passing_noescape_to_escaping,none,
      "passing non-escaping parameter %0 to function expecting an @escaping closure",
      (Identifier))
ERROR(assigning_noescape_to_escaping,none,
      "assigning non-escaping parameter %0 to an @escaping closure",
      (Identifier))
ERROR(general_noescape_to_escaping,none,
      "using non-escaping parameter %0 in a context expecting an @escaping closure",
      (Identifier))

ERROR(capture_across_type_decl,none,
      "%0 declaration cannot close over value %1 defined in outer scope",
      (DescriptiveDeclKind, Identifier))

//------------------------------------------------------------------------------
// Type Check Statements
//------------------------------------------------------------------------------

ERROR(jump_out_of_defer,none,
      "'%0' cannot transfer control out of a defer statement",
      (StringRef))

ERROR(return_invalid_outside_func,none,
      "return invalid outside of a func", ())

ERROR(return_expr_missing,none,
      "non-void function should return a value", ())
ERROR(return_non_failable_init,none,
      "only a failable initializer can return 'nil'", ())
NOTE(make_init_failable,none,
      "use 'init?' to make the initializer %0 failable", (DeclName))
ERROR(return_init_non_nil,none,
      "'nil' is the only return value permitted in an initializer",
      ())

WARNING(if_always_true,none,
        "'if' condition is always true", ())
WARNING(while_always_true,none,
        "'while' condition is always true", ())

WARNING(guard_always_succeeds,none,
        "'guard' condition is always true, body is unreachable", ())


ERROR(expression_unused_closure,none,
      "closure expression is unused", ())
ERROR(expression_unused_function,none,
      "expression resolves to an unused function", ())
ERROR(expression_unused_lvalue,none,
      "expression resolves to an unused l-value", ())
WARNING(expression_unused_result_call,none,
        "result of call to %0 is unused", (DeclName))
WARNING(expression_unused_result_operator,none,
        "result of operator %0 is unused", (DeclName))
WARNING(expression_unused_result_unknown, none,
        "result of call is unused, but produces %0", (Type))
WARNING(expression_unused_result, none,
        "expression of type %0 is unused", (Type))
WARNING(expression_unused_init_result,none,
        "result of %0 initializer is unused", (Type))
WARNING(expression_unused_optional_try,none,
        "result of 'try?' is unused", ())
WARNING(expression_unused_selector_result, none,
        "result of '#selector' is unused", ())
WARNING(expression_unused_literal,none,
        "%0 literal is unused", (StringRef))

ERROR(assignment_lhs_not_lvalue,none,
      "cannot assign to immutable expression of type %0", (Type))
ERROR(assignment_lhs_is_immutable_variable,none,
      "cannot assign to value: %0", (StringRef))
ERROR(assignment_lhs_is_immutable_property,none,
      "cannot assign to property: %0", (StringRef))
ERROR(assignment_subscript_has_immutable_base,none,
      "cannot assign through subscript: %0", (StringRef))
ERROR(assignment_bang_has_immutable_subcomponent,none,
      "cannot assign through '!': %0", (StringRef))

NOTE(change_to_mutating,none,
     "mark %select{method|accessor}0 'mutating' to make 'self' mutable",
     (bool))

// For Stmt
ERROR(deprecated_c_style_for_stmt,none,
      "C-style for statement has been removed in Swift 3", ())

// ForEach Stmt
ERROR(sequence_protocol_broken,none,
      "SequenceType protocol definition is broken", ())
ERROR(iterator_protocol_broken,none,
      "IteratorProtocol protocol definition is broken", ())

ERROR(label_shadowed, none,
      "label %0 cannot be reused on an inner statement", (Identifier))
ERROR(break_outside_loop,none,
      "'break' is only allowed inside a loop, if, do, or switch", ())
ERROR(unlabeled_break_outside_loop,none,
      "unlabeled 'break' is only allowed inside a loop or switch, a"
      " labeled break is required to exit an if or do", ())

ERROR(continue_outside_loop,none,
      "'continue' is only allowed inside a loop", ())
ERROR(continue_not_in_this_stmt,none,
      "'continue' cannot be used with %0 statements", (StringRef))

// Switch Stmt
ERROR(no_match_operator,none,
      "no binary '~=' operator available for 'switch' statement", ())
ERROR(fallthrough_outside_switch,none,
      "'fallthrough' is only allowed inside a switch", ())
ERROR(fallthrough_from_last_case,none,
      "'fallthrough' without a following 'case' or 'default' block", ())
ERROR(fallthrough_into_case_with_var_binding,none,
      "'fallthrough' cannot transfer control to a case label that declares variables",
      ())

ERROR(unnecessary_cast_over_optionset,none,
      "unnecessary cast over raw value of %0", (Type))

ERROR(type_mismatch_multiple_pattern_list,none,
      "pattern variable bound to type %0, expected type %1", (Type, Type))

WARNING(where_on_one_item, none,
        "'where' only applies to the second pattern match in this case", ())

NOTE(add_where_newline, none,
     "disambiguate by adding a line break between them if this is desired", ())

NOTE(duplicate_where, none,
     "duplicate the 'where' on both patterns to check both patterns",())

ERROR(trailing_closure_requires_parens,none,
      "trailing closure requires parentheses for disambiguation in this"
      " context", ())

//------------------------------------------------------------------------------
// Type Check Patterns
//------------------------------------------------------------------------------

ERROR(cannot_infer_type_for_pattern,none,
      "type annotation missing in pattern", ())
ERROR(refutable_pattern_requires_initializer,none,
      "pattern matching requires an initializer value to match against", ())
WARNING(var_pattern_didnt_bind_variables,none,
        "'%0' pattern has no effect; sub-pattern didn't bind any variables",
        (StringRef))
ERROR(iflet_pattern_matching,none,
      "pattern matching in a condition requires the 'case' keyword", ())
ERROR(iflet_implicitly_unwraps,none,
      "pattern matching in a condition implicitly unwraps optionals", ())
ERROR(type_pattern_missing_is,none,
      "'is' keyword required to pattern match against type name", ())


ERROR(pattern_type_mismatch_context,none,
      "type annotation does not match contextual type %0", (Type))

ERROR(tuple_pattern_in_non_tuple_context,none,
      "tuple pattern cannot match values of the non-tuple type %0", (Type))
ERROR(closure_argument_list_tuple,none,
      "contextual closure type %0 expects %1 argument%s1, "
      "but %2 %select{were|was}3 used in closure body", (Type, unsigned, unsigned, bool))
ERROR(closure_argument_list_missing,none,
      "contextual type for closure argument list expects %0 argument%s0, "
      "which cannot be implicitly ignored", (unsigned))
ERROR(closure_tuple_parameter_destructuring,none,
      "closure tuple parameter %0 does not support destructuring", (Type))
ERROR(closure_tuple_parameter_destructuring_implicit,none,
      "closure tuple parameter %0 does not support destructuring "
      "with implicit parameters", (Type))
ERROR(nested_tuple_parameter_destructuring,none,
      "nested tuple parameter %0 of function %1 "
      "does not support destructuring", (Type, Type))
ERROR(single_tuple_parameter_mismatch,none,
      "%0 %select{|%1 }3expects a single parameter of type %2",
      (DescriptiveDeclKind, Identifier, Type, bool))
ERROR(unknown_single_tuple_parameter_mismatch,none,
      "single parameter of type %0 is expected in call", (Type))

ERROR(enum_element_pattern_assoc_values_mismatch,none,
      "pattern with associated values does not match enum case %0",
      (Identifier))
NOTE(enum_element_pattern_assoc_values_remove,none,
     "remove associated values to make the pattern match", ())
ERROR(tuple_pattern_length_mismatch,none,
      "tuple pattern has the wrong length for tuple type %0", (Type))
ERROR(tuple_pattern_label_mismatch,none,
      "tuple pattern element label %0 must be %1", (Identifier, Identifier))
ERROR(enum_element_pattern_member_not_found,none,
      "enum case '%0' not found in type %1", (StringRef, Type))
ERROR(optional_element_pattern_not_valid_type,none,
      "'?' pattern cannot match values of type %0", (Type))
ERROR(condition_optional_element_pattern_not_valid_type,none,
      "initializer for conditional binding must have Optional type, not %0",
      (Type))
ERROR(enum_element_pattern_not_member_of_enum,none,
      "enum case '%0' is not a member of type %1", (StringRef, Type))
ERROR(ambiguous_enum_pattern_type,none,
      "generic enum type %0 is ambiguous without explicit generic parameters "
      "when matching value of type %1", (Type, Type))
WARNING(type_inferred_to_undesirable_type,none,
        "%select{variable|constant}2 %0 inferred to have type %1, "
        "which may be unexpected", (Identifier, Type, bool))
NOTE(add_explicit_type_annotation_to_silence,none,
     "add an explicit type annotation to silence this warning", ())
ERROR(isa_pattern_value,none,
      "downcast pattern value of type %0 cannot be used", (Type))

WARNING(swift3_ignore_specialized_enum_element_call,none,
        "cannot specialize enum case; ignoring generic argument, "
        "which will be rejected in future version of Swift", ())

//------------------------------------------------------------------------------
// Error-handling diagnostics
//------------------------------------------------------------------------------



ERROR(try_unhandled,none,
      "errors thrown from here are not handled", ())
ERROR(throwing_call_unhandled,none,
      "call can throw, but the error is not handled", ())
ERROR(tryless_throwing_call_unhandled,none,
      "call can throw, but it is not marked with 'try' and "
      "the error is not handled", ())
ERROR(throw_in_nonthrowing_function,none,
      "error is not handled because the enclosing function "
      "is not declared 'throws'", ())

ERROR(throwing_call_in_rethrows_function,none,
      "call can throw, but the error is not handled; a function declared "
      "'rethrows' may only throw if its parameter does", ())
ERROR(tryless_throwing_call_in_rethrows_function,none,
      "call can throw, but it is not marked with 'try' and "
      "the error is not handled; a function declared "
      "'rethrows' may only throw if its parameter does", ())
ERROR(throw_in_rethrows_function,none,
      "a function declared 'rethrows' may only throw if its parameter does", ())
NOTE(because_rethrows_argument_throws,none,
     "call is to 'rethrows' function, but argument function can throw", ())
NOTE(because_rethrows_default_argument_throws,none,
     "call is to 'rethrows' function, but a defaulted argument function"
     " can throw", ())

ERROR(throwing_call_in_nonthrowing_autoclosure,none,
      "call can throw, but it is executed in a non-throwing "
      "autoclosure",())
ERROR(tryless_throwing_call_in_nonthrowing_autoclosure,none,
      "call can throw, but it is not marked with 'try' and "
      "it is executed in a non-throwing autoclosure",())
ERROR(throw_in_nonthrowing_autoclosure,none,
      "error is not handled because it is thrown in a non-throwing "
      "autoclosure", ())

ERROR(try_unhandled_in_nonexhaustive_catch,none,
      "errors thrown from here are not handled because the "
      "enclosing catch is not exhaustive", ())
ERROR(throwing_call_in_nonexhaustive_catch,none,
      "call can throw, but the enclosing catch is not exhaustive", ())
ERROR(tryless_throwing_call_in_nonexhaustive_catch,none,
      "call can throw, but it is not marked with 'try' and "
      "the enclosing catch is not exhaustive", ())
ERROR(throw_in_nonexhaustive_catch,none,
      "error is not handled because the enclosing catch is not exhaustive", ())

ERROR(throwing_call_in_illegal_context,none,
      "call can throw, but errors cannot be thrown out of %0",
      (StringRef))
ERROR(throw_in_illegal_context,none,
      "errors cannot be thrown out of %0", (StringRef))

ERROR(throwing_operator_without_try,none,
      "operator can throw but expression is not marked with 'try'", ())
ERROR(throwing_call_without_try,none,
      "call can throw but is not marked with 'try'", ())
WARNING(no_throw_in_try,none,
        "no calls to throwing functions occur within 'try' expression", ())

WARNING(no_throw_in_do_with_catch,none,
        "'catch' block is unreachable because no errors are thrown in 'do' block", ())

//------------------------------------------------------------------------------
// Type Check Types
//------------------------------------------------------------------------------

ERROR(unsupported_recursive_struct,none,
      "value type %0 cannot have a stored property that recursively "
      "contains it",
      (Type))

ERROR(recursive_enum_not_indirect,none,
      "recursive enum %0 is not marked 'indirect'", (Type))
ERROR(unsupported_infinitely_sized_type,none,
      "value type %0 has infinite size", (Type))
NOTE(note_type_cycle_starts_here,none,
     "cycle beginning here: %0", (StringRef))
NOTE(note_recursive_enum_case_here,none,
     "recursive case here", ())

ERROR(sugar_type_not_found,none,
      "broken standard library: cannot find "
      "%select{Array|Optional|ImplicitlyUnwrappedOptional|Dictionary|"
      "Error}0 type", (unsigned))
ERROR(optional_intrinsics_not_found,none,
      "broken standard library: cannot find intrinsic operations on "
      "Optional<T>", ())
ERROR(pointer_argument_intrinsics_not_found,none,
      "broken standard library: cannot find intrinsic operations on "
      "UnsafeMutablePointer<T>", ())
ERROR(array_literal_intrinsics_not_found,none,
      "broken standard library: cannot find intrinsic operations on "
      "Array<T>", ())
ERROR(bool_intrinsics_not_found,none,
      "broken standard library: cannot find intrinsic operations on Bool", ())
ERROR(class_super_access,none,
      "class %select{must be declared %select{"
      "%select{private|fileprivate|internal|%error|%error}2|private or fileprivate}3"
      "|cannot be declared "
      "%select{in this context|fileprivate|internal|public|open}1}0 "
      "because its superclass is "
      "%select{private|fileprivate|internal|%error|%error}2",
      (bool, Accessibility, Accessibility, bool))
WARNING(class_super_access_warn,none,
        "class %select{should be declared "
        "%select{private|fileprivate|internal|%error|%error}2"
        "|should not be declared %select{in this context|fileprivate|internal|public|open}1}0 "
        "because its superclass is "
        "%select{private|fileprivate|internal|%error|%error}2",
        (bool, Accessibility, Accessibility, bool))
ERROR(dot_protocol_on_non_existential,none,
      "cannot use 'Protocol' with non-protocol type %0", (Type))
ERROR(tuple_single_element,none,
      "cannot create a single-element tuple with an element label", ())
ERROR(tuple_ellipsis,none,
      "cannot create a variadic tuple", ())

// Ownership
ERROR(invalid_ownership_type,none,
      "'%select{strong|weak|unowned|unowned}0' may only be applied to "
      "class and class-bound protocol types, not %1",
      (/*Ownership*/unsigned, Type))
ERROR(invalid_ownership_protocol_type,none,
      "'%select{strong|weak|unowned|unowned}0' may not be applied to "
      "non-class-bound %1; consider adding a protocol conformance that has a class bound",
      (/*Ownership*/unsigned, Type))
ERROR(invalid_weak_ownership_not_optional,none,
      "'weak' variable should have optional type %0", (Type))
ERROR(invalid_weak_let,none,
      "'weak' must be a mutable variable, because it may change at runtime", ())

// required
ERROR(required_initializer_nonclass,none,
      "'required' initializer in non-class type %0", (Type))
ERROR(required_initializer_in_extension,none,
      "'required' initializer must be declared directly in class %0"
      " (not in an extension)", (Type))
ERROR(required_initializer_missing,none,
      "'required' initializer %0 must be provided by subclass of %1",
      (DeclName, Type))
NOTE(required_initializer_here,none,
      "'required' initializer is declared in superclass here", ())

ERROR(required_initializer_not_accessible,none,
      "'required' initializer must be as accessible as its enclosing type", ())
ERROR(required_initializer_missing_keyword,none,
      "'required' modifier must be present on all overrides of a required "
      "initializer", ())
ERROR(required_initializer_override_wrong_keyword,none,
      "use the 'required' modifier to override a required initializer", ())
WARNING(required_initializer_override_keyword,none,
      "'override' is implied when overriding a required initializer", ())
NOTE(overridden_required_initializer_here,none,
     "overridden required initializer is here", ())

// Functions
ERROR(attribute_requires_function_type,none,
      "@%0 attribute only applies to function types", (StringRef))
ERROR(attribute_not_supported,none,
      "this attribute is not supported", ())
ERROR(unsupported_convention,none,
      "convention '%0' not supported", (StringRef))
ERROR(unreferenced_generic_parameter,none,
      "generic parameter '%0' is not used in function signature", (StringRef))

// SIL
ERROR(opened_non_protocol,none,
      "@opened cannot be applied to non-protocol type %0", (Type))
ERROR(sil_function_ellipsis,PointsToFirstBadToken,
      "SIL function types cannot be variadic", ())
ERROR(sil_function_input_label,PointsToFirstBadToken,
      "SIL function types cannot have labeled inputs", ())
ERROR(sil_function_output_label,PointsToFirstBadToken,
      "SIL function types cannot have labeled results", ())
ERROR(sil_function_repeat_convention,PointsToFirstBadToken,
      "repeated %select{parameter|result|callee}0 convention attribute",
      (unsigned))
ERROR(sil_function_multiple_error_results,PointsToFirstBadToken,
      "SIL function types cannot have multiple @error results", ())
ERROR(unsupported_sil_convention,none,
      "convention '%0' not supported in SIL", (StringRef))
ERROR(illegal_sil_type,none,
      "type %0 is not a legal SIL value type", (Type))
ERROR(sil_box_arg_mismatch,none,
      "SIL box type has wrong number of generic arguments for layout", ())
// SIL Metatypes
ERROR(sil_metatype_without_repr,none,
      "metatypes in SIL must have @thin, @thick, or @objc_metatype attribute",
      ())
ERROR(sil_metatype_multiple_reprs,none,
      "metatypes in SIL can only be one of @thin, @thick, or @objc_metatype",
      ())

//------------------------------------------------------------------------------
// @objc and @nonobjc
//------------------------------------------------------------------------------

ERROR(attr_used_without_required_module, none,
      "%0 attribute used without importing module %1",
      (DeclAttribute, Identifier))

ERROR(invalid_objc_decl_context,none,
      "@objc can only be used with members of classes, @objc protocols, and "
      "concrete extensions of classes", ())
ERROR(invalid_objc_decl,none,
      "only classes (and their extensions), protocols, methods, initializers, "
      "properties, and subscript declarations can be declared @objc", ())
ERROR(invalid_objc_swift_rooted_class,none,
      "only classes that inherit from NSObject can be declared @objc", ())
ERROR(invalid_nonobjc_decl,none,
      "only class members and extensions of classes can be declared @nonobjc", ())
ERROR(invalid_nonobjc_extension,none,
      "only extensions of classes can be declared @nonobjc", ())

ERROR(objc_in_extension_context,none,
      "members of constrained extensions cannot be declared @objc", ())
ERROR(objc_in_generic_extension,none,
      "@objc is not supported within extensions of generic classes or classes that inherit from generic classes", ())
ERROR(objc_operator, none,
      "operator methods cannot be declared @objc", ())
ERROR(objc_operator_proto, none,
      "@objc protocols may not have operator requirements", ())
WARNING(objc_inference_swift3_dynamic,none,
        "inference of '@objc' for 'dynamic' members is deprecated", ())
WARNING(objc_inference_swift3_objc_derived,none,
        "inference of '@objc' for members of Objective-C-derived classes is "
        "deprecated", ())

NOTE(objc_inference_swift3_addobjc,none,
     "add `@objc` to continue exposing an Objective-C entry point (Swift 3 "
     "behavior)", ())
NOTE(objc_inference_swift3_addnonobjc,none,
     "add `@nonobjc` to suppress the Objective-C entry point (Swift 4 "
     "behavior)", ())

ERROR(objc_for_generic_class,none,
      "generic subclasses of '@objc' classes cannot have an explicit '@objc' "
      "because they are not directly visible from Objective-C", ())
ERROR(objc_getter_for_nonobjc_property,none,
      "'@objc' getter for non-'@objc' property", ())
ERROR(objc_getter_for_nonobjc_subscript,none,
      "'@objc' getter for non-'@objc' subscript", ())
ERROR(objc_setter_for_nonobjc_property,none,
      "'@objc' setter for non-'@objc' property", ())
ERROR(objc_setter_for_nonobjc_subscript,none,
      "'@objc' setter for non-'@objc' subscript", ())
WARNING(accessor_swift3_objc_inference,none,
        "%select{%0 %1|%1}2 with '@objc' %select{getter|setter}3 depends on "
        "deprecated inference of '@objc'",
        (DescriptiveDeclKind, DeclName, bool, bool))

ERROR(objc_enum_generic,none,
      "'@objc' enum cannot be generic", ())
ERROR(objc_name_req_nullary,none,
      "'@objc' %0 must have a simple name", (DescriptiveDeclKind))
ERROR(objc_name_subscript,none,
      "'@objc' subscript cannot have a name; did you mean to put "
      "the name on the getter or setter?", ())
ERROR(objc_name_deinit,none,
      "'@objc' deinitializer cannot have a name", ())
ERROR(objc_name_func_mismatch,none,
      "'@objc' %select{initializer|method}0 name provides "
      "%select{one argument name|names for %1 arguments}2, but "
      "%select{initializer|method}0 has %select{one parameter|%3 parameters}4"
      "%select{| (%select{|including }4the error parameter)}5",
      (bool, unsigned, bool, unsigned, bool, bool))
ERROR(objc_enum_case_req_name,none,
      "attribute has no effect; cases within an '@objc' enum are already "
      "exposed to Objective-C", ())
ERROR(objc_enum_case_req_objc_enum,none,
      "'@objc' enum case is not allowed outside of an '@objc' enum", ())
ERROR(objc_enum_case_multi,none,
      "'@objc' enum case declaration defines multiple enum cases with the same Objective-C name", ())

ERROR(objc_extension_not_class,none,
      "'@objc' can only be applied to an extension of a class", ())

// If you change this, also change enum ObjCReason
#define OBJC_ATTR_SELECT "select{marked @_cdecl|marked dynamic|marked @objc|marked @IBOutlet|marked @IBAction|marked @NSManaged|a member of an @objc protocol|implicitly @objc|an @objc override|an implementation of an @objc requirement|marked @IBInspectable|marked @GKInspectable|in an @objc extension of a class (without @nonobjc)}"

WARNING(attribute_meaningless_when_nonobjc,none,
        "'@%0' attribute is meaningless on a property that cannot be "
        "represented in Objective-C", (StringRef))

ERROR(objc_invalid_on_var,none,
      "property cannot be %" OBJC_ATTR_SELECT "0 "
      "because its type cannot be represented in Objective-C", (unsigned))
ERROR(objc_invalid_subscript_key_type,none,
      "subscript cannot be %" OBJC_ATTR_SELECT "0 because its key "
      "type %1 is neither an integer nor an object", (unsigned, Type))
ERROR(objc_invalid_on_subscript,none,
      "subscript cannot be %" OBJC_ATTR_SELECT "0 because its type "
      "cannot be represented in Objective-C", (unsigned))
ERROR(objc_invalid_with_generic_params,none,
      "method cannot be %" OBJC_ATTR_SELECT "0 because it has generic "
      "parameters", (unsigned))
ERROR(objc_convention_invalid,none,
      "%0 is not representable in Objective-C, so it cannot be used"
      " with '@convention(%1)'", (Type, StringRef))
ERROR(function_type_no_parens,none,
      "single argument function types require parentheses", ())
WARNING(paren_void_probably_void,none,
      "when calling this function in Swift 4 or later, you must pass a '()' tuple; did you mean for the input type to be '()'?", ())
NOTE(not_objc_empty_protocol_composition,none,
     "'Any' is not considered '@objc'; use 'AnyObject' instead", ())
NOTE(not_objc_protocol,none,
     "protocol-constrained type containing protocol %0 cannot be represented "
     "in Objective-C", (Type))
NOTE(not_objc_class_constraint,none,
     "protocol-constrained type containing class %0 cannot be represented "
     "in Objective-C", (Type))
NOTE(not_objc_error_protocol_composition,none,
     "protocol-constrained type containing 'Error' cannot be represented "
     "in Objective-C", ())
NOTE(not_objc_empty_tuple,none,
      "empty tuple type cannot be represented in Objective-C", ())
NOTE(not_objc_tuple,none,
      "tuples cannot be represented in Objective-C", ())
NOTE(not_objc_swift_class,none,
     "classes not annotated with @objc cannot be represented "
     "in Objective-C", ())
NOTE(not_objc_swift_struct,none,
      "Swift structs cannot be represented in Objective-C", ())
NOTE(not_objc_swift_enum,none,
      "non-'@objc' enums cannot be represented in Objective-C", ())
NOTE(not_objc_generic_type_param,none,
     "generic type parameters cannot be represented in Objective-C", ())
NOTE(not_objc_function_type_param,none,
     "function types cannot be represented in Objective-C unless their "
     "parameters and returns can be", ())
NOTE(not_objc_function_type_throwing,none,
      "throwing function types cannot be represented in Objective-C", ())
NOTE(objc_inferring_on_objc_protocol_member,none,
     "inferring '@objc' because the declaration is a member of "
     "an '@objc' protocol", ())
NOTE(objc_overriding_objc_decl,none,
     "overriding '@objc' %select{property|subscript|initializer|method}0 %1 "
     "here", (unsigned, DeclName))
NOTE(objc_witness_objc_requirement,none,
     "satisfying requirement for %0 %1 in protocol %2",
     (DescriptiveDeclKind, DeclName, DeclName))
WARNING(witness_swift3_objc_inference,none,
        "use of %0 %1 to satisfy a requirement of protocol %2 depends on "
        "'@objc' inference deprecated in Swift 4",
        (DescriptiveDeclKind, DeclName, Type))


ERROR(objc_invalid_on_func_curried,none,
      "method cannot be %" OBJC_ATTR_SELECT "0 because curried functions "
      "cannot be represented in Objective-C", (unsigned))
ERROR(objc_observing_accessor, none,
      "observing accessors are not allowed to be marked @objc", ())
ERROR(objc_addressor, none,
      "addressors are not allowed to be marked @objc", ())
ERROR(objc_invalid_on_func_variadic,none,
      "method cannot be %" OBJC_ATTR_SELECT "0 because it has a variadic "
      "parameter", (unsigned))
ERROR(objc_invalid_on_func_param_type,none,
      "method cannot be %" OBJC_ATTR_SELECT "1 because the type of the "
      "parameter %0 cannot be represented in Objective-C", (unsigned, unsigned))
ERROR(objc_invalid_on_func_single_param_type,none,
      "method cannot be %" OBJC_ATTR_SELECT "0 because the type of the "
      "parameter cannot be represented in Objective-C", (unsigned))
ERROR(objc_invalid_on_func_result_type,none,
      "method cannot be %" OBJC_ATTR_SELECT "0 because its result type "
      "cannot be represented in Objective-C", (unsigned))
ERROR(objc_invalid_on_foreign_class,none,
      "method cannot be %" OBJC_ATTR_SELECT "0 because Core Foundation "
      "types are not classes in Objective-C", (unsigned))
ERROR(objc_invalid_on_throwing_optional_result,none,
      "throwing method cannot be %" OBJC_ATTR_SELECT "0 because "
      "it returns a value of optional type %1; 'nil' indicates failure to "
      "Objective-C",
      (unsigned, Type))
ERROR(objc_invalid_on_throwing_result,none,
      "throwing method cannot be %" OBJC_ATTR_SELECT "0 because "
      "it returns a value of type %1; return 'Void' or a type that bridges "
      "to an Objective-C class",
      (unsigned, Type))
ERROR(objc_invalid_on_failing_init,none,
      "a failable and throwing initializer cannot be "
      "%" OBJC_ATTR_SELECT "0 because 'nil' indicates failure to Objective-C",
      (unsigned))

ERROR(objc_in_objc_runtime_visible,none,
      "%0 cannot be %" OBJC_ATTR_SELECT "1 because class %2 is only visible "
      "via the Objective-C runtime",
      (DescriptiveDeclKind, unsigned, Identifier))

ERROR(objc_override_method_selector_mismatch,none,
      "Objective-C method has a different selector from the "
      "method it overrides (%0 vs. %1)", (ObjCSelector, ObjCSelector))

ERROR(objc_override_property_name_mismatch,none,
      "Objective-C property has a different name from the "
      "property it overrides (%0 vs. %1)", (Identifier, Identifier))

ERROR(objc_ambiguous_inference,none,
      "ambiguous inference of Objective-C name for %0 %1 (%2 vs %3)",
      (DescriptiveDeclKind, DeclName, ObjCSelector, ObjCSelector))
NOTE(objc_ambiguous_inference_candidate,none,
     "%0 (in protocol %1) provides Objective-C name %2",
     (DeclName, DeclName, ObjCSelector))

ERROR(nonlocal_bridged_to_objc,none,
      "conformance of %0 to %1 can only be written in module %2",
      (Identifier, Identifier, Identifier))

ERROR(broken_bridged_to_objc_protocol,none,
      "_BridgedToObjectiveC protocol is broken", ())

ERROR(missing_bridging_function,Fatal,
      "missing '%select{_forceBridgeFromObjectiveC|"
      "_conditionallyBridgeFromObjectiveC}0'", (bool))
ERROR(missing_nserror_bridging_function,none,
      "missing _bridgeNSError", ())

#define OBJC_DIAG_SELECT "%select{initializer %1|implicit initializer %1|deinitializer|implicit deinitializer|method %1|getter for %1|subscript getter|setter for %1|subscript setter}0"

#define OBJC_DIAG_SELECT_2 "%select{initializer %3|implicit initializer %3|deinitializer|implicit deinitializer|method %3|getter for %3|subscript getter|setter for %3|subscript setter}2"

ERROR(objc_redecl,none,
      OBJC_DIAG_SELECT " with Objective-C selector %4 conflicts with "
      OBJC_DIAG_SELECT_2 " with the same Objective-C selector",
      (unsigned, DeclName, unsigned, DeclName, ObjCSelector))
NOTE(objc_declared_here,none,
     OBJC_DIAG_SELECT " declared here",
     (unsigned, DeclName))

ERROR(objc_redecl_same,none,
      OBJC_DIAG_SELECT " with Objective-C selector %2 conflicts with "
      "previous declaration with the same Objective-C selector",
      (unsigned, DeclName, ObjCSelector))

ERROR(objc_override_other,none,
      OBJC_DIAG_SELECT " with Objective-C selector %4 conflicts with "
      OBJC_DIAG_SELECT_2 " from superclass %5 with the same Objective-C "
      "selector",
      (unsigned, DeclName, unsigned, DeclName, ObjCSelector, Type))

ERROR(objc_class_method_not_permitted,none,
      OBJC_DIAG_SELECT " defines Objective-C class method %2, which is "
      "not permitted by Swift", (unsigned, DeclName, ObjCSelector))

WARNING(objc_class_method_not_permitted_swift3_compat_warning,none,
      OBJC_DIAG_SELECT " defines Objective-C class method %2, which is "
      "not guaranteed to be invoked by Swift and will be disallowed in future "
      "versions", (unsigned, DeclName, ObjCSelector))

ERROR(objc_witness_selector_mismatch,none,
      "Objective-C method %2 provided by " OBJC_DIAG_SELECT
      " does not match the requirement's selector (%3)",
      (unsigned, DeclName, ObjCSelector, ObjCSelector))

ERROR(objc_optional_requirement_conflict,none,
      "Objective-C method %4 provided by " OBJC_DIAG_SELECT
      " conflicts with optional requirement " OBJC_DIAG_SELECT_2
      " in protocol %5",
      (unsigned, DeclName, unsigned, DeclName, ObjCSelector, DeclName))

NOTE(objc_optional_requirement_swift_rename,none,
     "rename %select{method|initializer|property|subscript}0 to match "
     "requirement %1", (bool, DeclName))

ERROR(witness_non_objc,none,
      "non-'@objc' " OBJC_DIAG_SELECT " does not satisfy requirement "
      "of '@objc' protocol %2",
      (unsigned, DeclName, DeclName))

WARNING(witness_non_objc_optional,none,
        "non-'@objc' " OBJC_DIAG_SELECT " does not satisfy optional "
        "requirement of '@objc' protocol %2",
        (unsigned, DeclName, DeclName))

ERROR(witness_non_objc_storage,none,
      "non-'@objc' %select{property %1|subscript}0 does not satisfy "
      "requirement of '@objc' protocol %2",
      (bool, DeclName, DeclName))

WARNING(witness_non_objc_storage_optional,none,
      "non-'@objc' %select{property %1|subscript}0 does not satisfy "
      "optional requirement of '@objc' protocol %2",
      (bool, DeclName, DeclName))

ERROR(nonobjc_not_allowed,none,
      "declaration is %" OBJC_ATTR_SELECT "0, and cannot be marked @nonobjc",
      (unsigned))

#undef OBJC_DIAG_SELECT_2
#undef OBJC_DIAG_SELECT
#undef OBJC_ATTR_SELECT

//------------------------------------------------------------------------------
// dynamic
//------------------------------------------------------------------------------

ERROR(dynamic_not_in_class,none,
      "only members of classes may be dynamic", ())
ERROR(dynamic_with_final,none,
      "a declaration cannot be both 'final' and 'dynamic'",
      ())
ERROR(dynamic_with_nonobjc,none,
      "a declaration cannot be both '@nonobjc' and 'dynamic'",
      ())
ERROR(dynamic_requires_objc,none,
      "'dynamic' %0 %1 must also be '@objc'",
      (DescriptiveDeclKind, DeclName))

//------------------------------------------------------------------------------
// @available
//------------------------------------------------------------------------------

ERROR(availability_decl_unavailable, none,
  "%0 is unavailable", (DeclName))

#define REPLACEMENT_DECL_KIND_SELECT "select{| instance method| property}"
ERROR(availability_decl_unavailable_rename, none,
      "%0 has been %select{renamed to|replaced by}1"
      "%" REPLACEMENT_DECL_KIND_SELECT "2 '%3'",
      (DeclName, bool, unsigned, StringRef))

ERROR(availability_decl_unavailable_rename_msg, none,
      "%0 has been %select{renamed to|replaced by}1"
      "%" REPLACEMENT_DECL_KIND_SELECT "2 '%3': %4",
      (DeclName, bool, unsigned, StringRef, StringRef))

ERROR(availability_decl_unavailable_msg, none,
  "%0 is unavailable: %1", (DeclName, StringRef))

ERROR(availability_decl_unavailable_in_swift, none,
  "%0 is unavailable in Swift", (DeclName))

ERROR(availability_decl_unavailable_in_swift_msg, none,
  "%0 is unavailable in Swift: %1", (DeclName, StringRef))

NOTE(availability_marked_unavailable, none,
  "%0 has been explicitly marked unavailable here", (DeclName))

NOTE(availability_introduced_in_swift, none,
     "%0 was introduced in Swift %1",
    (DeclName, clang::VersionTuple))

NOTE(availability_obsoleted, none,
     "%0 was obsoleted in %1 %2",
    (DeclName, StringRef, clang::VersionTuple))

WARNING(availability_deprecated, none,
        "%0 %select{is|%select{is|was}3}1 deprecated"
        "%select{| %select{on|in}3 %2%select{| %4}3}1",
        (DeclName, bool, StringRef, bool, clang::VersionTuple))

WARNING(availability_deprecated_msg, none,
        "%0 %select{is|%select{is|was}3}1 deprecated"
        "%select{| %select{on|in}3 %2%select{| %4}3}1: %5",
        (DeclName, bool, StringRef, bool, clang::VersionTuple, StringRef))

WARNING(availability_deprecated_rename, none,
        "%0 %select{is|%select{is|was}3}1 deprecated"
        "%select{| %select{on|in}3 %2%select{| %4}3}1: "
        "%select{renamed to|replaced by}5%" REPLACEMENT_DECL_KIND_SELECT "6 "
        "'%7'",
        (DeclName, bool, StringRef, bool, clang::VersionTuple, bool, unsigned,
         StringRef))
#undef REPLACEMENT_DECL_KIND_SELECT

NOTE(note_deprecated_rename, none,
     "use '%0' instead", (StringRef))

ERROR(availability_decl_more_than_enclosing, none,
      "declaration cannot be more available than enclosing scope", ())

NOTE(availability_decl_more_than_enclosing_enclosing_here, none,
     "enclosing scope here", ())

ERROR(availability_decl_only_version_newer, none,
      "%0 is only available on %1 %2 or newer",
      (DeclName, StringRef, clang::VersionTuple))

NOTE(availability_guard_with_version_check, none,
     "add 'if #available' version check", ())

NOTE(availability_add_attribute, none,
     "add @available attribute to enclosing %0", (DescriptiveDeclKind))

ERROR(availability_accessor_only_version_newer, none,
      "%select{getter|setter}0 for %1 is only available on %2 %3"
      " or newer",
      (/*AccessorKind*/unsigned, DeclName, StringRef, clang::VersionTuple))

ERROR(availability_inout_accessor_only_version_newer, none,
      "cannot pass as inout because %select{getter|setter}0 for %1 is only "
      "available on %2 %3 or newer",
      (/*AccessorKind*/unsigned, DeclName, StringRef, clang::VersionTuple))

ERROR(availability_query_required_for_platform, none,
      "condition required for target platform '%0'", (StringRef))

WARNING(availability_query_useless_enclosing_scope, none,
        "unnecessary check for '%0'; enclosing scope ensures guard "
        "will always be true", (StringRef))

NOTE(availability_query_useless_enclosing_scope_here, none,
     "enclosing scope here", ())

ERROR(availability_global_script_no_potential,
      none, "global variable cannot be marked potentially "
      "unavailable with '@available' in script mode", ())

ERROR(availability_stored_property_no_potential,
      none, "stored properties cannot be marked potentially unavailable with "
      "'@available'", ())

ERROR(availability_protocol_requires_version,
      none, "protocol %0 requires %1 to be available on %2 %3 and newer",
      (DeclName, DeclName, StringRef, clang::VersionTuple))

NOTE(availability_protocol_requirement_here, none,
     "protocol requirement here", ())

NOTE(availability_conformance_introduced_here, none,
     "conformance introduced here", ())

// This doesn't display as an availability diagnostic, but it's
// implemented there and fires when these subscripts are marked
// unavailable, so it seems appropriate to put it here.
ERROR(availabilty_string_subscript_migration, none,
      "subscripts returning String were obsoleted in Swift 4; explicitly construct a String from subscripted result", ())

//------------------------------------------------------------------------------
// @discardableResult
//------------------------------------------------------------------------------

WARNING(discardable_result_on_void_never_function, none,
        "@discardableResult declared on a function returning %select{Never|Void}0 is unnecessary",
        (bool))

//------------------------------------------------------------------------------
// Resilience diagnostics
//------------------------------------------------------------------------------

ERROR(fixed_layout_attr_on_internal_type,
      none, "'@_fixed_layout' attribute can only be applied to '@_versioned' "
      "or public declarations, but %0 is "
      "%select{private|fileprivate|internal|%error|%error}1",
      (Identifier, Accessibility))

ERROR(versioned_attr_with_explicit_accessibility,
      none, "'@_versioned' attribute can only be applied to internal "
      "declarations, but %0 is %select{private|fileprivate|%error|public|open}1",
      (Identifier, Accessibility))

ERROR(versioned_attr_in_protocol,none,
      "'@_versioned' attribute cannot be used in protocols", ())

#define FRAGILE_FUNC_KIND \
  "%select{a '@_transparent' function|" \
  "an '@inline(__always)' function|" \
  "an '@_inlineable' function|" \
  "a default argument value}"

ERROR(local_type_in_inlineable_function,
      none, "type %0 cannot be nested inside " FRAGILE_FUNC_KIND "1",
      (DeclName, unsigned))

ERROR(resilience_decl_unavailable,
      none, "%0 %1 is %select{private|fileprivate|internal|%error|%error}2 and "
      "cannot be referenced from " FRAGILE_FUNC_KIND "3",
      (DescriptiveDeclKind, DeclName, Accessibility, unsigned))

#undef FRAGILE_FUNC_KIND

NOTE(resilience_decl_declared_here,
     none, "%0 %1 is not public", (DescriptiveDeclKind, DeclName))

NOTE(resilience_decl_declared_here_versioned,
     none, "%0 %1 is not '@_versioned' or public", (DescriptiveDeclKind, DeclName))

ERROR(designated_init_in_extension_resilient,none,
      "initializer declared in an extension of "
      "non-'@_fixed_layout' type %0 must delegate to another initializer", (Type))

ERROR(designated_init_inlineable_resilient,none,
      "initializer for non-'@_fixed_layout' type %0 is "
      "'%select{@_transparent|@inline(__always)|@_inlineable|%error}1' and must "
      "delegate to another initializer", (Type, unsigned))

ERROR(class_designated_init_inlineable_resilient,none,
      "initializer for class %0 is "
      "'%select{@_transparent|@inline(__always)|@_inlineable|%error}1' and must "
      "delegate to another initializer", (Type, unsigned))

ERROR(inlineable_stored_property,
      none, "'@_inlineable' attribute cannot be applied to stored properties", ())

ERROR(inlineable_decl_not_public,
      none, "'@_inlineable' attribute can only be applied to public declarations, "
      "but %0 is %select{private|fileprivate|internal|%error|%error}1",
      (Identifier, Accessibility))

//------------------------------------------------------------------------------
// @_specialize diagnostics
//------------------------------------------------------------------------------

ERROR(specialize_attr_nongeneric_trailing_where,none,
      "trailing 'where' clause in '_specialize' attribute of non-generic function %0", (Identifier))
ERROR(specialize_missing_where_clause,none,
      "missing 'where' clause in '_specialize' attribute", ())
ERROR(specialize_empty_where_clause,none,
      "empty 'where' clause in '_specialize' attribute", ())
ERROR(specialize_attr_non_concrete_same_type_req,none,
      "Only concrete type same-type requirements are supported by '_specialize' attribute", ())
ERROR(specialize_attr_only_generic_param_req,none,
      "Only requirements on generic parameters are supported by '_specialize' attribute", ())
ERROR(specialize_attr_only_one_concrete_same_type_req,none,
      "Only one concrete type should be used in the same-type requirement in '_specialize' attribute", ())
ERROR(specialize_attr_non_nominal_type_constraint_req,none,
      "Only conformances to nominal types are supported by '_specialize' attribute", ())
ERROR(specialize_attr_non_protocol_type_constraint_req,none,
      "Only conformances to protocol types are supported by '_specialize' attribute", ())
ERROR(specialize_attr_type_parameter_count_mismatch,none,
      "%select{too many|too few}2 type parameters are specified "
      "in '_specialize' attribute (got %1, but expected %0)",
      (unsigned, unsigned, bool))
ERROR(specialize_attr_missing_constraint,none,
      "Missing constraint for %0 in '_specialize' attribute", (DeclName))
ERROR(specialize_attr_unsupported_kind_of_req,none,
      "Only same-type and layout requirements are supported by '_specialize' attribute", ())

//------------------------------------------------------------------------------
// Variable usage diagnostics
//------------------------------------------------------------------------------

WARNING(pbd_never_used_stmtcond, none,
        "value %0 was defined but never used; consider replacing "
        "with boolean test",
        (Identifier))

WARNING(pbd_never_used, none,
        "initialization of %select{variable|immutable value}1 %0 was never used"
        "; consider replacing with assignment to '_' or removing it",
        (Identifier, unsigned))


WARNING(capture_never_used, none,
        "capture %0 was never used",
        (Identifier))

WARNING(variable_never_used, none,
        "%select{variable|immutable value}1 %0 was never used; "
        "consider replacing with '_' or removing it",
        (Identifier, unsigned))
WARNING(immutable_value_never_used_but_assigned, none,
        "immutable value %0 was never used; "
        "consider removing it",
        (Identifier))
WARNING(variable_never_mutated, none,
        "%select{variable|parameter}1 %0 was never mutated; "
        "consider changing to 'let' constant",
        (Identifier, unsigned))
WARNING(variable_never_read, none,
        "%select{variable|parameter}1 %0 was written to, but never read",
        (Identifier, unsigned))

//------------------------------------------------------------------------------
// Circular reference diagnostics
//------------------------------------------------------------------------------
ERROR(circular_reference, none,
      "circular reference", ())

ERROR(redundant_type_alias_define, none,
      "redundant type alias declaration", ())

NOTE(circular_reference_through, none,
     "through reference here", ())

//------------------------------------------------------------------------------
// Debug diagnostics
//------------------------------------------------------------------------------

WARNING(debug_long_function_body, none,
        "%0 %1 took %2ms to type-check (limit: %3ms)",
        (DescriptiveDeclKind, DeclName, unsigned, unsigned))
WARNING(debug_long_closure_body, none,
        "closure took %0ms to type-check (limit: %1ms)",
        (unsigned, unsigned))
WARNING(debug_long_expression, none,
        "expression took %0ms to type-check (limit: %1ms)",
        (unsigned, unsigned))

//------------------------------------------------------------------------------
// Pattern match diagnostics
//------------------------------------------------------------------------------


ERROR(empty_switch_stmt,none,
      "'switch' statement body must have at least one 'case' or 'default' "
      "block; do you want to add a default case?",())
ERROR(non_exhaustive_switch,none, "switch must be exhaustive", ())
NOTE(missing_several_cases,none,
     "do you want to add "
     "%select{missing cases|a default clause}0"
     "?", (bool))

NOTE(missing_particular_case,none,
     "add missing case: '%0'", (StringRef))
WARNING(redundant_particular_case,none,
        "case is already handled by previous patterns; consider removing it",())

// HACK: Downgrades the above to warnings if any of the cases is marked
// @_downgrade_exhaustivity_check.
WARNING(non_exhaustive_switch_warn_swift3,none, "switch must be exhaustive", ())

#ifndef DIAG_NO_UNDEF
# if defined(DIAG)
#  undef DIAG
# endif
# undef NOTE
# undef WARNING
# undef ERROR
#endif
