//===- DiagnosticsSema.def - Diagnostics Text -------------------*- C++ -*-===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2015 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See http://swift.org/LICENSE.txt for license information
// See http://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,Category,Options,Text,Signature)   \
  DIAG(ERROR,ID,Category,Options,Text,Signature)
#endif

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

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


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

NOTE(while_converting_default_tuple_value,sema,none,
     "while converting default tuple value to element type %0", (Type))
NOTE(while_converting_subscript_index,sema,none,
     "while converting subscript index to expected type %0", (Type))

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

ERROR(cannot_find_appropriate_overload,sema,none,
      "could not find an overload for '%0' that accepts the supplied "
      "arguments", (StringRef))

ERROR(cannot_find_appropriate_overload_with_type,sema,none,
      "cannot invoke '%0' with an argument of type %1", (StringRef, Type))

ERROR(cannot_find_appropriate_overload_with_type_list,sema,none,
      "cannot invoke '%0' with an argument list of type %1", (StringRef, Type))

ERROR(could_not_find_member,sema,none,
      "could not find member %0", (Identifier))

ERROR(could_not_convert_argument,sema,none,
      "cannot invoke function with an argument list of type %0", (Type))

ERROR(single_expression_conformance_failure,sema,none,
      "expression does not conform to type %0", (Type))

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

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

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

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

ERROR(cannot_apply_lvalue_unop_to_rvalue,sema,none,
      "cannot pass immutable value of type '%1' to mutating unary operator '%0'",
      (StringRef, StringRef))

ERROR(cannot_apply_lvalue_unop_to_rvalue_vardecl,sema_tcs,none,
      "cannot pass %select{'let' value|get-only property|immutable value}2 %1"
      " to mutating unary operator '%0'",
      (StringRef, Identifier, unsigned))

ERROR(cannot_apply_lvalue_binop_to_rvalue,sema,none,
      "cannot pass immutable value of type '%1' to mutating binary operator '%0'",
      (StringRef, StringRef))

ERROR(cannot_apply_lvalue_binop_to_rvalue_vardecl,sema_tcs,none,
      "cannot pass %select{'let' value|get-only property|immutable value}2 %1"
      " to mutating binary operator '%0'",
      (StringRef, Identifier, unsigned))

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

ERROR(cannot_assign_values,sema,none,
      "cannot assign a value of type '%0' to a value of type '%1'",
      (StringRef, StringRef))

ERROR(cannot_assign_to_immutable_expr,sema,none,
      "cannot assign to immutable value of type '%0'", (StringRef))

ERROR(cannot_assign_to_rvalue_vardecl,sema_tcs,none,
      "cannot assign to %select{'let' value|get-only property|immutable value}1"
      " %0", (Identifier, unsigned))

ERROR(cannot_pass_rvalue_inout,sema_tcs,none,
      "cannot pass immutable value of type '%0' as inout argument",
      (StringRef))

ERROR(cannot_pass_rvalue_vardecl_inout,sema_tcs,none,
      "cannot pass %select{'let' value|get-only property|immutable value}1 %0"
      " as inout argument",
      (Identifier, unsigned))

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

ERROR(cannot_apply_function_to_args,sema,none,
      "cannot invoke '%0' with an argument list of type "
      "'%1'", (StringRef,StringRef))

ERROR(cannot_apply_initializer_to_args,sema,none,
      "cannot invoke initializer for type '%0' with an argument list of type "
      "'%1'", (StringRef,StringRef))

NOTE(expected_certain_args,sema_nb,none,
      "expected an argument list of type '%0'", (StringRef))

ERROR(cannot_find_appropriate_overload_with_list,sema,none,
      "cannot find an overload for '%0' that accepts an argument list of"
      " type '%1'", (StringRef, StringRef))

ERROR(cannot_find_appropriate_initializer_with_list,sema,none,
      "cannot find an initializer for type '%0' that accepts an argument list"
      " of type '%1'", (StringRef, StringRef))

ERROR(cannot_find_overload_with_no_params,sema,none,
      "cannot invoke '%0' with no arguments", (StringRef))

ERROR(cannot_find_initializer_with_no_params,sema,none,
      "cannot invoke initializer for type '%0' with no arguments", (StringRef))

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

ERROR(cannot_infer_closure_type,sema,none,
      "unable to infer closure type in the current context", ())
NOTE(mult_stmt_closures_require_explicit_result,sema,none,
      "multi-statement closures require an explicit return type", ())

ERROR(invalid_trailing_closure_target,sema,none,
      "unexpected trailing closure", ())

NOTE(suggest_partial_overloads,sema,none,
      "overloads for '%0' exist with these partially matching parameter "
      "lists: %1", (StringRef, StringRef))

ERROR(cannot_convert_to_return_type,sema,none,
      "cannot convert return expression of type %0 to expected return type %1",
      (Type,Type))

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

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

ERROR(sema_no_import,sema_nb,Fatal,
      "no such module '%0'", (StringRef))
ERROR(sema_no_import_repl,sema_nb,none,
      "no such module '%0'", (StringRef))
NOTE(sema_no_import_no_sdk,sema_nb,none,
     "did you forget to set an SDK using -sdk or SDKROOT?", ())
NOTE(sema_no_import_no_sdk_xcrun,sema_nb,none,
     "use \"xcrun -sdk macosx swift\" to select the default OS X SDK installed "
     "with Xcode", ())
ERROR(sema_opening_import,sema_nb,Fatal,
      "opening import file for module %0: %1", (Identifier, StringRef))

ERROR(serialization_malformed_module,sema,Fatal,
      "malformed module file: %0", (StringRef))
ERROR(serialization_module_too_new,sema,Fatal,
      "module file was created by a newer version of the compiler: %0",
      (StringRef))
ERROR(serialization_module_too_old,sema,Fatal,
      "module file was created by an older version of the compiler: %0",
      (StringRef))
ERROR(serialization_missing_single_dependency,sema,Fatal,
      "missing required module '%0'", (StringRef))
ERROR(serialization_missing_dependencies,sema,Fatal,
      "missing required modules: %0", (StringRef))
ERROR(serialization_missing_shadowed_module,sema,Fatal,
      "cannot load underlying module for %0", (Identifier))
ERROR(serialization_name_mismatch,sema,Fatal,
      "cannot load module '%0' as %1", (StringRef, Identifier))
ERROR(serialization_name_mismatch_repl,sema,none,
      "cannot load module '%0' as %1", (StringRef, Identifier))
ERROR(serialization_target_incompatible,sema,Fatal,
      "module file was created for incompatible target %0: %1",
      (StringRef, StringRef))
ERROR(serialization_target_incompatible_repl,sema,none,
      "module file was created for incompatible target %0: %1",
      (StringRef, StringRef))
ERROR(serialization_target_too_new,sema,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,sema,none,
      "module file's minimum deployment target is %0 v%1.%2%select{|.%3}3: %4",
      (StringRef, unsigned, unsigned, unsigned, StringRef))

ERROR(unknown_name_in_type,sema_nb,none,
      "use of unknown scope %0 in type reference", (Identifier))

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

ERROR(ambiguous_type_base,sema_nb,none,
      "%0 is ambiguous for type lookup in this context", (Identifier))
ERROR(invalid_member_type,sema_nb,none,
      "%0 is not a member type of %1", (Identifier, Type))
ERROR(invalid_member_type_suggest,sema_nb,none,
      "%0 does not have a member type named %1; did you mean %2?",
      (Type, Identifier, Identifier))
ERROR(ambiguous_member_type,sema_nb,none,
      "ambiguous type name %0 in %1", (Identifier, Type))
ERROR(no_module_type,sema_nb,none,
      "no type named %0 in module %1", (Identifier, Identifier))
ERROR(ambiguous_module_type,sema_nb,none,
      "ambiguous type name %0 in module %1", (Identifier, Identifier))
ERROR(use_nonmatching_operator,sema_nb,none,
      "%0 is not a %select{binary|prefix unary|postfix unary}1 operator",
      (Identifier, unsigned))
ERROR(use_unresolved_identifier,sema_nb,none,
      "use of unresolved identifier %0", (Identifier))
ERROR(use_undeclared_type,sema_nb,none,
      "use of undeclared type %0", (Identifier))
ERROR(use_undeclared_type_did_you_mean,sema_nb,none,
"use of undeclared type %0; did you mean to use '%1'?", (Identifier, StringRef))
NOTE(note_remapped_type,sema_nb,none,
  "did you mean to use '%0'?", (StringRef))
ERROR(identifier_init_failure,sema_nb,none,
  "could not infer type for %0", (Identifier))
NOTE(note_module_as_type,sema_nb,none,
     "cannot use module %0 as a type", (Identifier))

ERROR(use_unknown_object_literal,sema_nb,none,
     "use of unknown object literal name %0", (Identifier))

ERROR(use_non_type_value,sema_nb,none,
      "%0 is not a type", (Identifier))
NOTE(use_non_type_value_prev,sema_nb,none,
     "%0 declared here", (Identifier))
ERROR(use_local_before_declaration,sema_nb,none,
      "use of local variable %0 before its declaration", (Identifier))
ERROR(unsupported_existential_type,sema_nb,none,
      "protocol %0 can only be used as a generic constraint because it has "
      "Self or associated type requirements", (Identifier))

ERROR(no_decl_in_module,sema_nb,none,
      "no such decl in module", ())
ERROR(imported_decl_is_wrong_kind,sema_nb,none,
      "%0 was imported as '%1', but is a "
      "%select{**MODULE**|type|struct|class|enum|protocol|variable|function}2",
      (Identifier, StringRef, /*ImportKind*/ unsigned))
ERROR(ambiguous_decl_in_module,sema_nb,none,
      "ambiguous name %0 in module %1", (Identifier, Identifier))

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

// Operator decls
ERROR(ambiguous_operator_decls,sema_nb,none,
      "ambiguous operator declarations found for operator", ())
NOTE(found_this_operator_decl,sema_nb,none,
     "found this matching operator declaration", ())
ERROR(operator_redeclared,sema_nb,none,
      "operator redeclared", ())
NOTE(previous_operator_decl,sema_nb,none,
     "previous operator declaration here", ())
ERROR(declared_operator_without_operator_decl,sema_nb,none,
      "operator implementation without matching operator declaration", ())
ERROR(declared_unary_op_without_attribute,sema_nb,none,
      "unary operator implementation must have a 'prefix' or 'postfix' modifier", ())
ERROR(unary_op_missing_prepos_attribute,sema_nb,none,
      "%select{prefix|postfix}0 unary operator missing "
      "'%select{prefix|postfix}0' modifier", (bool))
NOTE(unary_operator_declaration_here,sema_nb,none,
   "%select{prefix|postfix}0 operator found here", (bool))
ERROR(invalid_arg_count_for_operator,sema_nb,none,
      "operators must have one or two arguments", ())

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

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

//------------------------------------------------------------------------------
// Expression Type Checking Errors
//------------------------------------------------------------------------------
ERROR(invalid_relation,sema_tcc,none,
      "%1 is not %select{identical to|a subtype of|"
      "convertible to|constructible with|identical to}0 %2", (unsigned, Type, Type))
ERROR(invalid_tuple_size,sema_tcc,none,
      "tuple types %0 and %1 have a different number of elements (%2 vs. %3)",
      (Type, Type, unsigned, unsigned))
ERROR(invalid_tuple_element_unused,sema_tcc,none,
      "tuple element of type %0 unused when converting tuple to %1",
      (Type, Type))
ERROR(does_not_have_member,sema_tcc,none,
      "%0 does not have a member named %1",
      (Type, DeclName))
ERROR(does_not_have_non_mutating_member,sema_tcc,none,
      "immutable value of type %0 only has mutating members named %1",
      (Type, DeclName))
WARNING(isa_is_always_true,sema_tcc,none,
        "'is' test is always true",
        (Type, Type))
WARNING(conditional_downcast_coercion,sema_tcc,none,
      "conditional cast from %0 to %1 always succeeds",
      (Type, Type))
WARNING(forced_downcast_coercion,sema_tcc,none,
      "forced cast from %0 to %1 always succeeds; did you mean to use 'as'?",
      (Type, Type))
ERROR(downcast_same_type,sema_tcc,none,
      "downcast from %0 to %1 only unwraps optionals; did you mean to use "
      "'%2'?",
      (Type, Type, StringRef))
WARNING(downcast_to_unrelated,sema_tcc,none,
        "cast from %0 to unrelated type %1 always fails", (Type, Type))
ERROR(downcast_from_existential_to_unrelated,sema_tcc,none,
      "cannot cast from protocol type %0 to non-conforming type %1",
      (Type, Type))
ERROR(downcast_to_more_optional,sema_tcc,none,
      "cannot downcast from %0 to a more optional type %1",
      (Type, Type))
ERROR(optional_chain_noop,sema_tcc,none,
      "optional chain has no effect, expression already produces %0",
      (Type))
ERROR(optional_chain_isnt_chaining,sema_tcc,none,
      "'?' must be followed by a call, member lookup, or subscript",
      ())
ERROR(pattern_in_expr,sema_tcc,none,
      "%0 cannot appear in an expression", (PatternKind))
NOTE(note_call_to_operator,sema_tcc,none,
     "in call to operator %0", (Identifier))
NOTE(note_call_to_func,sema_tcc,none,
     "in call to function %0", (Identifier))
NOTE(note_call_to_initializer,sema_tcc,none,
     "in call to initializer", ())
NOTE(note_init_parameter,sema_tcc,none,
     "in initialization of parameter %0", (Identifier))
ERROR(missing_nullary_call,sema_tcc,none,
     "function produces expected type %0; did you mean to call it with '()'?",
     (Type))
ERROR(missing_unwrap_optional,sema_tcc,none,
      "value of optional type %0 not unwrapped; did you mean to use '!' "
      "or '?'?",
     (Type))
ERROR(missing_forced_downcast,sema_tcc,none,
      "%0 is not convertible to %1; "
      "did you mean to use 'as!' to force downcast?", (Type, Type))
ERROR(missing_explicit_conversion,sema_tcc,none,
      "%0 is not implicitly convertible to %1; "
      "did you mean to use 'as' to explicitly convert?", (Type, Type))
ERROR(missing_address_of,sema_tcc,none,
      "passing value of type %0 to an inout parameter requires explicit '&'",
      (Type))
ERROR(extra_call_nonfunction,sema_tcc,none,
      "invalid use of '()' to call a value of non-function type %0",
      (Type))
ERROR(extra_argument_labels,sema_tcc,none,
      "extraneous argument label%select{|s}0 '%1' in %select{call|subscript}2",
      (bool, StringRef, bool))
ERROR(missing_argument_labels,sema_tcc,none,
      "missing argument label%select{|s}0 '%1' in %select{call|subscript}2",
      (bool, StringRef, bool))
ERROR(wrong_argument_labels,sema_tcc,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,sema_tcc,none,
      "cannot treat single-element named tuple as a scalar; use '.%0' to "
      "access its element", (StringRef))
ERROR(argument_out_of_order,sema_tcc,none,
      "argument %0 must precede argument %1", (Identifier, Identifier))
ERROR(missing_argument_named,sema_tcc,none,
      "missing argument for parameter %0 in call", (Identifier))
ERROR(missing_argument_positional,sema_tcc,none,
      "missing argument for parameter #%0 in call", (unsigned))
ERROR(extra_argument_named,sema_tcc,none,
      "extra argument %0 in call", (Identifier))
ERROR(extra_argument_positional,sema_tcc,none,
      "extra argument in call", ())
ERROR(no_accessible_initializers,sema_tcc,none,
      "%0 cannot be constructed because it has no accessible initializers",
      (Type))
ERROR(unbound_generic_parameter,sema_tcc,none,
      "argument for generic parameter %0 could not be inferred", (Type))
ERROR(generic_parameter_binds_to_non_objc_existential,sema_tcc,none,
      "generic parameter %0 cannot be bound to non-@objc protocol type %1",
      (Type, Type))
ERROR(throws_functiontype_mismatch,sema_tcc,none,
      "invalid conversion from %select{non-|}0throwing function of type %1 to "
      "%select{non-|}2throwing function type %3",
      (bool, Type, bool, Type))
ERROR(noescape_functiontype_mismatch,sema_tcc,none,
      "invalid use of non-escaping function in escaping context %0",
      (Type))
ERROR(invalid_function_conversion,sema_tcc,none,
      "function signature %0 is not compatible with expected type %1",
      (Type, Type))
NOTE(invalid_function_conversion_closure,sema_tcc,none,
     "use a closure to safely wrap calls to the function", ())

ERROR(invalid_c_function_pointer_conversion_expr,sema_tcc,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,sema_tcc,none,
      "a C function pointer cannot be formed from a method", ())
ERROR(c_function_pointer_from_function_with_context,sema_tcc,none,
      "a C function pointer cannot be formed from a "
      "%select{local function|closure}0 that captures context", (bool))
NOTE(c_function_pointer_captures_here,sema_tcc,none,
     "%0 captured here", (Identifier))

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

ERROR(var_type_not_materializable,sema_tcd,none,
      "type %0 of variable is not materializable", (Type))
ERROR(enum_element_not_materializable,sema_tcd,none,
      "type of enum case is not materializable", ())

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

// Attributes
ERROR(operator_not_func,sema_tcd,none,
      "operators must be declared with 'func'", ())
ERROR(redefining_builtin_operator,sema_tcd,none,
      "cannot declare a custom %0 '%1' operator", (StringRef, StringRef))
ERROR(invalid_infix_on_func,sema_tcd,none,
      "'infix' modifier is not required or allowed on func declarations", ())
ERROR(attribute_requires_operator_identifier,sema_tcd,none,
      "'%0' requires a function with an operator identifier", (StringRef))
ERROR(attribute_requires_single_argument,sema_tcd,none,
      "'%0' requires a function with one argument", (StringRef))

ERROR(inout_cant_be_variadic,sema_tce,none,
      "inout arguments cannot be variadic", ())
ERROR(inout_only_parameter,sema_tce,none,
      "'inout' is only valid in parameter lists", ())

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

ERROR(transparent_stored_property,sema_tcd,none,
      "@transparent cannot be applied to stored properties", ())
ERROR(transparent_on_invalid_extension,sema_tcd,none,
      "@transparent is only supported on struct and enum extensions", ())
ERROR(transparent_in_protocols_not_supported,sema_tcd,none,
      "@transparent is not supported on declarations within protocols", ())
ERROR(transparent_in_classes_not_supported,sema_tcd,none,
      "@transparent is not supported on declarations within classes", ())

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

ERROR(invalid_ibdesignable_extension,sema_tcd,none,
      "@IBDesignable can only be applied to classes and extensions "
      "of classes", ())
ERROR(invalid_ibinspectable,sema_tcd,none,
      "only instance properties can be declared @IBInspectable", ())
ERROR(invalid_ibaction_decl,sema_tcd,none,
      "only instance methods can be declared @IBAction", ())
ERROR(invalid_ibaction_result,sema_tcd,none,
      "methods declared @IBAction must return 'Void' (not %0)", (Type))
ERROR(invalid_ibaction_argument_count,sema_tcd,none,
      "@IBAction methods %select{must have a single argument"
      "|can only have up to 2 arguments}0", (bool))
ERROR(ibaction_nonobjc_class_argument,sema_tcd,none,
      "argument to @IBAction method cannot have non-'@objc' class type %0",
      (Type))
ERROR(ibaction_nonobject_argument,sema_tcd,none,
      "argument to @IBAction method cannot have non-object type %0", (Type))
ERROR(no_objc_tagged_pointer_not_class_protocol,sema_tcd,none,
      "@unsafe_no_objc_tagged_pointer can only be applied to class protocols",
      ())
ERROR(swift_native_objc_runtime_base_not_on_root_class,sema_tcd,none,
      "@_swift_native_objc_runtime_base_not_on_root_class can only be applied "
      "to root classes", ())
ERROR(access_control_in_protocol,sema_tcd,none,
      "%0 modifier cannot be used in protocols", (DeclAttribute))
ERROR(access_control_setter,sema_tcd,none,
      "'%select{private|internal|public}0(set)' modifier can only be applied "
      "to variables and subscripts",
      (Accessibility))
ERROR(access_control_setter_read_only,sema_tcd,none,
      "'%select{private|internal|public}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,sema_tcd,none,
      "%select{private|internal|PUBLIC}0 "
      "%select{variable|property|subscript}1 cannot have "
      "%select{PRIVATE|an internal|a public}2 setter",
      (Accessibility, unsigned, Accessibility))
WARNING(access_control_member_more,sema_tcd,none,
    "declaring %select{PRIVATE|an internal|a public}0 %1 for "
    "%select{a private|an internal|PUBLIC}2 %3",
    (Accessibility, DescriptiveDeclKind, Accessibility, DescriptiveDeclKind))
WARNING(access_control_ext_member_more,sema_tcd,none,
    "declaring %select{PRIVATE|an internal|a public}0 %1 in "
    "%select{a private|an internal|PUBLIC}2 extension",
    (Accessibility, DescriptiveDeclKind, Accessibility))
ERROR(access_control_extension_more,sema_tcd,none,
      "extension of %select{private|internal|PUBLIC}0 %1 cannot be "
      "declared %select{PRIVATE|internal|public}2",
      (Accessibility, DescriptiveDeclKind, Accessibility))

ERROR(invalid_decl_attribute_simple,sema_tcd,none,
      "attribute cannot be applied to declaration", ())
ERROR(invalid_decl_attribute,sema_tcd,none,
      "%0 cannot be applied to this declaration", (DeclAttribute))
ERROR(invalid_decl_modifier,sema_tcd,none,
      "%0 modifier cannot be applied to this declaration", (DeclAttribute))
ERROR(attribute_does_not_apply_to_type,type_parsing,none,
      "attribute does not apply to type", ())
ERROR(optional_attribute_non_protocol,sema_tcd,none,
      "'optional' can only be applied to protocol members", ())
ERROR(optional_attribute_non_objc_protocol,sema_tcd,none,
      "'optional' can only be applied to members of an @objc protocol", 
      ())
ERROR(optional_attribute_initializer,sema_tcd,none,
      "'optional' cannot be applied to an initializer", ())
ERROR(unavailable_method_non_objc_protocol,sema_tcd,none,
      "protocol members can only be marked unavailable in an @objc protocol",
      ())
ERROR(missing_in_class_init_1,sema_tcd,none,
      "stored property %0 requires an initial value%select{| or should be "
      "@NSManaged}1", (Identifier, bool))
ERROR(missing_in_class_init_2,sema_tcd,none,
      "stored properties %0 and %1 require initial values%select{| or should "
      "be @NSManaged}2", 
      (Identifier, Identifier, bool))
ERROR(missing_in_class_init_3plus,sema_tcd,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,sema_tcd,none,
     "%select{superclass|class}1 %0 requires all stored properties to have "
     "initial values%select{| or use @NSManaged}2", (Type, bool, bool))
ERROR(implied_name_no_argument,sema_tcd,none,
      "no name specified for first argument, name it '_' to ignore it", ())
ERROR(class_without_init,sema_tcd,none,
      "class %0 has no initializers", (Type))
NOTE(note_no_in_class_init_1,sema_tcd,none,
     "stored property %0 without initial value prevents synthesized "
     "initializers",
     (Identifier))
NOTE(note_no_in_class_init_2,sema_tcd,none,
     "stored properties %0 and %1 without initial values prevent synthesized "
     "initializers",
     (Identifier, Identifier))
NOTE(note_no_in_class_init_3plus,sema_tcd,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,sema_tcd,none,
      "standard library error: missing _unimplemented_initializer", ())
WARNING(unsupported_synthesize_init_variadic,sema_tcd,none,
        "synthesizing a variadic inherited initializer for subclass %0 is "
        "unsupported",
        (Type))
NOTE(variadic_superclass_init_here,sema_tcd,none,
     "variadic superclass initializer defined here", ())

ERROR(alignment_not_power_of_two,sema_tcd,none,
      "alignment value must be a power of two", ())

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


// Generic types
ERROR(unsupported_generic_nested_in_type,sema_tcd,none,
      "generic type %0 nested in type %1 is not allowed",
      (Identifier, Type))
ERROR(unsupported_type_nested_in_generic_type,sema_tcd,none,
      "type %0 nested in generic type %1 is not allowed",
      (Identifier, Type))
ERROR(unsupported_type_nested_in_generic_function,sema_tcd,none,
      "type %0 nested in generic function %1 is not allowed",
      (Identifier, Identifier))

// Type aliases
ERROR(circular_type_alias,sema_tct,none,
      "type alias %0 circularly references itself", (Identifier))
ERROR(type_alias_underlying_type_access,sema_tcd,none,
      "type alias %select{must be declared %select{private|internal|PUBLIC}2"
      "|cannot be declared %select{PRIVATE|internal|public}1}0 because its "
      "underlying type uses %select{a private|an internal|PUBLIC}2 type",
      (bool, Accessibility, Accessibility))

// Subscripts
ERROR(subscript_type_access,sema_tcd,none,
      "subscript %select{must be declared %select{private|internal|PUBLIC}2"
      "|cannot be declared %select{PRIVATE|internal|public}1}0 because its "
      "%select{index|element type}3 uses "
      "%select{a private|an internal|PUBLIC}2 type",
      (bool, Accessibility, Accessibility, bool))

// Functions
ERROR(function_type_access,sema_tcd,none,
      "%select{function|method|initializer}3 "
      "%select{must be declared %select{private|internal|PUBLIC}2"
      "|cannot be declared %select{PRIVATE|internal|public}1}0 because its "
      "%select{parameter|result}4 uses "
      "%select{a private|an internal|PUBLIC}2 type",
      (bool, Accessibility, Accessibility, unsigned, bool))
WARNING(non_trailing_closure_before_default_args,sema_tcd,none,
        "closure parameter prior to parameters with default arguments will "
        "not be treated as a trailing closure", ())

// Extensions
ERROR(non_nominal_extension,sema_tcd,none,
      "non-nominal type %0 cannot be extended", (Type))
ERROR(extension_access_with_conformances,sema_tcd,none,
      "%0 modifier cannot be used with extensions that declare "
      "protocol conformances", (DeclAttribute))
ERROR(extension_metatype,sema_tcd,none,
      "cannot extend a metatype of a type", ())
ERROR(extension_stored_property,sema_tcd,none,
      "extensions may not contain stored properties", ())
ERROR(extension_generic_extra_requirements,sema_tcd,none,
      "extension of generic type %0 cannot add requirements", (Type))
ERROR(extension_generic_wrong_number_of_parameters,sema_tcd,none,
      "extension of generic type %0 has %select{too few|too many}1 generic "
      "parameters (have %2, expected %3)", (Type, bool, unsigned, unsigned))
ERROR(extension_generic_params_for_non_generic,sema_tcd,none,
      "%0 does not have any generic parameters", (Identifier))
ERROR(extension_generic_params_for_non_generic_type,sema_tcd,none,
      "%0 does not have any generic parameters", (Type))
NOTE(extended_type_here,sema_tcd,none,
      "extended type %0 declared here", (Type))
ERROR(extension_nonprotocol_trailing_where,sema_tcd,none,
      "trailing 'where' clause for extension of non-protocol type %0", (Type))
ERROR(extension_protocol_inheritance,sema_tcd,none,
      "extension of protocol %0 cannot have an inheritance clause", (Type))
ERROR(extension_protocol_type_definition,sema_tcd,none,
      "type %0 cannot be defined within a protocol extension", (DeclName))
ERROR(extension_protocol_member_nonfinal,sema_tcd,none,
      "%select{method %1|property %1|subscript|initializer %}0 in protocol "
      "extension must be marked 'final'", (unsigned, DeclName))
ERROR(extension_protocol_via_typealias,sema_tcd,none,
      "protocol %0 cannot be extended via typealias %1", (Type, Type))
ERROR(extension_anyobject,sema_tcd,none,
      "'AnyObject' protocol cannot be extended", ())

// Protocols
ERROR(type_does_not_conform,sema_tcd,none,
      "type %0 does not conform to protocol %1", (Type, Type))
ERROR(protocol_derivation_is_broken,sema_tcd,none,
      "protocol %0 is broken; cannot derive conformance for type %1", (Type, Type))
ERROR(type_does_not_inherit,sema_tcd,none,
      "type %0 does not inherit from %1", (Type, Type))
ERROR(non_class_cannot_conform_to_class_protocol,sema_tcd,none,
      "non-class type %0 cannot conform to class protocol %1",
      (Type, Type))
ERROR(foreign_class_cannot_conform_to_objc_protocol,sema_tcd,none,
      "Core Foundation class %0 cannot conform to @objc protocol %1 because "
      "Core Foundation types are not classes in Objective-C",
      (Type, Type))
ERROR(protocol_has_missing_requirements,sema_tcd,none,
      "type %0 cannot conform to protocol %1 because it has requirements that "
      "cannot be satisfied", (Type, Type))
ERROR(witness_argument_name_mismatch,sema_tcd,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,sema_tcd,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,sema_tcd,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,sema_tcd,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_requires_dynamic_self,sema_tcd,none,
      "method %0 in non-final class %1 must return `Self` to conform to "
      "protocol %2",
      (DeclName, Type, Type))

ERROR(witness_not_accessible_proto,sema_tcd,none,
      "%select{initializer %1|method %1|%select{|setter for }2property %1"
      "|subscript%select{| setter}2}0 must be declared "
      "%select{PRIVATE|internal|public}3 because it matches a requirement "
      "in %select{PRIVATE|internal|public}3 protocol %4",
      (RequirementKind, DeclName, bool, Accessibility, DeclName))
ERROR(witness_not_accessible_type,sema_tcd,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 %4",
      (RequirementKind, DeclName, bool, Accessibility, DeclName))

ERROR(protocol_refine_access,sema_tcd,none,
      "%select{protocol must be declared %select{private|internal|PUBLIC}2 "
      "because it refines"
      "|%select{PRIVATE|internal|public}1 protocol cannot refine}0 "
      "%select{a private|an internal|PUBLIC}2 protocol",
      (bool, Accessibility, Accessibility))
ERROR(protocol_property_must_be_computed_var,sema_tcd,none,
      "immutable property requirement must be declared as 'var' with a "
      "'{ get }' specifier", ())
ERROR(protocol_property_must_be_computed,sema_tcd,none,
      "property in protocol must have explicit { get } or { get set } specifier",
      ())
NOTE(inherited_protocol_does_not_conform,sema_tcd,none,
     "type %0 does not conform to inherited protocol %1", (Type, Type))
NOTE(no_witnesses,sema_tcd,none,
     "protocol requires %select{initializer %1|function %1|property %1|"
     "subscript}0 with type %2", (RequirementKind, DeclName, Type))
NOTE(ambiguous_witnesses,sema_tcd,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,sema_tcd,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,sema_tcd,none,
     "protocol requires nested type %0", (Identifier))
NOTE(default_assocated_type_req_fail,sema_tcd,none,
     "default type %0 for associated type %1 (from protocol %2) "
     "does not conform to %3",
     (Type, DeclName, Type, Type))
ERROR(associated_type_access,sema_tcd,none,
      "associated type in %select{PRIVATE|an internal|a public}0 protocol "
      "uses %select{a private|an internal|PUBLIC}1 type in its "
      "%select{default definition|requirement}2 ",
      (Accessibility, Accessibility, unsigned))

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

NOTE(protocol_witness_optionality_conflict,sema_tcd,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,sema_tcd,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,sema_tcd,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,sema_tcd,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,sema_tcd,none,
     "candidate is %select{|prefix, |postfix, }1not "
     "%select{prefix|postfix}0 as required", (bool, unsigned))
NOTE(protocol_witness_mutating_conflict,sema_tcd,none,
     "candidate is marked 'mutating' but protocol does not allow it", ())
NOTE(protocol_witness_settable_conflict,sema_tcd,none,
     "candidate is not settable, but protocol requires it", ())
NOTE(protocol_witness_noreturn_conflict,sema_tcd,none,
     "candidate is not @noreturn, but protocol requires it", ())
NOTE(protocol_witness_rethrows_conflict,sema_tcd,none,
     "candidate is not 'rethrows', but protocol requires it", ())
NOTE(protocol_witness_throws_conflict,sema_tcd,none,
     "candidate throws, but protocol does not allow it", ())
NOTE(protocol_witness_not_objc,sema_tcd,none,
     "candidate is not '@objc', but protocol requires it", ())

NOTE(protocol_witness_type,sema_tcd,none,
     "possibly intended match", ())
NOTE(protocol_witness_nonconform_type,sema_tcd,none,
     "possibly intended match %0 does not conform to %1", (Type, Type))

NOTE(protocol_requirement_here,sema_tcd,none,
     "requirement %0 declared here", (DeclName))
NOTE(protocol_conformance_here,sema_tcd,none,
     "%select{|class }0%1 declares conformance to protocol %2 here",
     (bool, DeclName, DeclName))
NOTE(declared_protocol_conformance_here,sema_tcd,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))

ERROR(redundant_conformance,sema_tcd,none,
      "redundant conformance of %0 to protocol %1", (Type, DeclName))
ERROR(ambiguous_conformance,sema_tcd,none,
      "ambiguous implied conformance of %0 to protocol %1 (via %2) requires "
      "explicit conformance",
      (Type, DeclName, DeclName))
NOTE(protocol_conformance_implied_here,sema_tcd,none,
     "implied protocol conformance %0 here can be made explicit", (Identifier))

// Protocols and existentials
ERROR(assoc_type_outside_of_protocol,sema_nb,none,
      "cannot use associated type %0 outside of its protocol", (Identifier))

ERROR(circular_protocol_def,sema_tcd,none,
      "circular protocol inheritance %0", (StringRef))
NOTE(protocol_here,sema_tcd,none,
     "protocol %0 declared here", (Identifier))
ERROR(protocol_composition_not_protocol,sema_tcd,none, 
      "non-protocol type %0 cannot be used within 'protocol<...>'", (Type))
ERROR(objc_protocol_inherits_non_objc_protocol,sema_tcd,none,
      "@objc protocol %0 cannot refine non-@objc protocol %1", (Type, Type))

ERROR(requires_conformance_nonprotocol,sema_tcd,none,
      "type %0 constrained to non-protocol type %1", (TypeLoc, TypeLoc))
ERROR(requires_not_suitable_archetype,sema_tcd,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,sema_tcd,none,
      "neither type in same-type refers to a generic parameter or "
      "associated type",
      ())
ERROR(requires_generic_params_made_equal,sema_tcd,none,
      "same-type requirement makes generic parameters %0 and %1 equivalent",
      (Identifier, Identifier))
ERROR(requires_generic_param_made_equal_to_concrete,sema_tcd,none,
      "same-type requirement makes generic parameter %0 non-generic",
      (Identifier))
ERROR(requires_superclass_conflict,sema_tcd,none,
      "generic parameter %0 cannot be a subclass of both %1 and %2",
      (Identifier, Type, Type))
ERROR(recursive_requirement_reference,sema_tcd,none,
      "type may not reference itself as a requirement",())
ERROR(requires_same_type_conflict,sema_tcd,none,
      "generic parameter %0 cannot be equal to both %1 and %2",
      (Identifier, Type, Type))
ERROR(requires_generic_param_same_type_does_not_conform,sema_tcd,none,
      "same-type constraint type %0 does not conform to required protocol %1",
      (Type, Identifier))
ERROR(generic_param_access,sema_tcd,none,
      "%0 %select{must be declared %select{private|internal|PUBLIC}3"
      "|cannot be declared %select{PRIVATE|internal|public}2}1 because its "
      "generic %select{parameter|requirement}4 uses "
      "%select{a private|an internal|PUBLIC}3 type",
      (DescriptiveDeclKind, bool, Accessibility, Accessibility, bool))

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

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

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


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

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

NOTE(property_override_here,sema_tcd,none,
     "attempt to override property here", ())
NOTE(subscript_override_here,sema_tcd,none,
     "attempt to override subscript here", ())
NOTE(convenience_init_override_here,sema_tcd,none,
     "attempt to override convenience initializer here", ())
ERROR(override_nonclass_decl,sema_tcd,none,
      "'override' can only be specified on class members", ())
ERROR(override_property_type_mismatch,sema_tcd,none,
      "property %0 with type %1 cannot override a property with type %2",
      (Identifier, Type, Type))
ERROR(override_with_stored_property,sema_tcd,none,
      "cannot override with a stored property %0", (Identifier))
ERROR(observing_readonly_property,sema_tcd,none,
      "cannot observe read-only property %0; it can't change", (Identifier))
ERROR(override_mutable_with_readonly_property,sema_tcd,none,
      "cannot override mutable property with read-only property %0",
      (Identifier))
ERROR(override_argument_name_mismatch,sema_tcd,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,sema_tcd,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_throws,sema_tcd,none,
      "cannot override non-throwing %select{method|initializer}0 with "
      "throwing %select{method|initializer}0", (bool))

WARNING(override_unnecessary_IUO,sema_tcd,none,
      "overriding %0 parameter of type %1 with implicitly unwrapped optional "
      "type %2",
      (DescriptiveDeclKind, Type, Type))
WARNING(override_unnecessary_result_IUO,sema_tcd,none,
      "overriding %0 optional result type %1 with implicitly unwrapped "
      "optional type %2",
      (DescriptiveDeclKind, Type, Type))
NOTE(override_unnecessary_IUO_remove,sema_tcd,none,
     "remove '!' to make the parameter required", ())
NOTE(override_unnecessary_IUO_use_strict,sema_tcd,none,
     "use '?' to make the result optional", ())
NOTE(override_unnecessary_IUO_silence,sema_tcd,none,
     "add parentheses to silence this warning", ())

ERROR(override_mutable_covariant_property,sema_tcd,none,
      "cannot override mutable property %0 of type %1 with covariant type %2",
      (Identifier, Type, Type))
ERROR(override_mutable_covariant_subscript,sema_tcd,none,
      "cannot override mutable subscript of type %0 with covariant type %1",
      (Type, Type))
ERROR(decl_already_final,sema_tcd,none,
      "static declarations are already final", ())
ERROR(decl_no_default_init,sema_tcd,none,
      "cannot default-initialize variable of type %0", (Type))
ERROR(decl_no_default_init_ivar_hole,sema_tcd,none,
      "cannot use initial value when one of the variables is '_'", ())
NOTE(decl_init_here,sema_tcd,none,
     "initial value is here", ())


// Inheritance
ERROR(duplicate_inheritance,sema_tcd,none,
  "duplicate inheritance from %0", (Type))
ERROR(multiple_inheritance,sema_tcd,none,
  "multiple inheritance from classes %0 and %1", (Type, Type))
ERROR(non_class_inheritance,sema_tcd,none,
  "non-class type %0 cannot inherit from class %1", (Type, Type))
ERROR(extension_class_inheritance,sema_tcd,none,
  "extension of type %0 cannot inherit from class %1", (Type, Type))
ERROR(inheritance_from_non_protocol_or_class,sema_tcd,none,
  "inheritance from non-protocol, non-class type %0", (Type))
ERROR(inheritance_from_non_protocol,sema_tcd,none,
  "inheritance from non-protocol type %0", (Type))
ERROR(superclass_not_first,sema_tcd,none,
  "superclass %0 must appear first in the inheritance clause", (Type))
ERROR(circular_class_inheritance,sema_tcd,none,
      "circular class inheritance %0", (StringRef))
NOTE(class_here,sema_tcd,none,
     "class %0 declared here", (Identifier))
ERROR(inheritance_from_final_class,sema_tcd,none,
"inheritance from a final class %0", (Identifier))


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

// Enum raw types
ERROR(multiple_enum_raw_types,sema_tcd,none,
  "multiple enum raw types %0 and %1", (Type, Type))
ERROR(circular_enum_inheritance,sema_tcd,none,
      "circular enum raw types %0", (StringRef))
ERROR(raw_type_not_first,sema_tcd,none,
  "raw type %0 must appear first in the enum inheritance clause", (Type))
ERROR(raw_type_not_literal_convertible,sema_tcd,none,
      "raw type %0 is not convertible from any literal",
      (Type))
ERROR(enum_raw_type_not_equatable,sema_tcd,none,
      "RawRepresentable 'init' cannot be synthesized because raw type %0 is not "
      "Equatable", (Type))
ERROR(enum_raw_type_access,sema_tcd,none,
      "enum %select{must be declared %select{private|internal|PUBLIC}2"
      "|cannot be declared %select{PRIVATE|internal|public}1}0 because its "
      "raw type uses %select{a private|an internal|PUBLIC}2 type",
      (bool, Accessibility, Accessibility))

NOTE(enum_here,sema_tcd,none,
     "enum %0 declared here", (Identifier))
ERROR(empty_enum_raw_type,sema_tcd,none,
      "an enum with no cases cannot declare a raw type", ())
ERROR(enum_raw_value_without_raw_type,sema_tcd,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,sema_tcd,none,
      "enum with raw type cannot have cases with arguments", ())
NOTE(enum_raw_type_here,sema_tcd,none,
     "declared raw type %0 here", (Type))
ERROR(objc_enum_no_raw_type,sema_tcd,none,
      "'@objc' enum must declare an integer raw type", ())
ERROR(objc_enum_raw_type_not_integer,sema_tcd,none,
      "'@objc' enum raw type %0 is not an integer type", (Type))
ERROR(enum_non_integer_raw_value_auto_increment,sema_tcd,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,sema_tcd,none,
      "enum cases require explicit raw values when the raw type is not integer literal convertible", ())
ERROR(enum_raw_value_not_unique,sema_tcd,none,
      "raw value for enum case is not unique", ())
NOTE(enum_raw_value_used_here,sema_tcd,none,
     "raw value previously used here", ())
NOTE(enum_raw_value_incrementing_from_here,sema_tcd,none,
     "raw value auto-incremented from here",())
NOTE(enum_raw_value_incrementing_from_zero,sema_tcd,none,
     "raw value implicitly auto-incremented from zero",())
ERROR(broken_raw_representable_requirement,sema_tcd,none,
      "RawRepresentable protocol is broken: unexpected requirement", ())
ERROR(broken_equatable_requirement,sema_tcd,none,
      "Equatable protocol is broken: unexpected requirement", ())
ERROR(broken_hashable_requirement,sema_tcd,none,
      "Hashable protocol is broken: unexpected requirement", ())
ERROR(broken_errortype_requirement,sema_tcd,none,
      "ErrorType protocol is broken: unexpected requirement", ())
ERROR(broken_int_hashable_conformance,sema_tcd,none,
      "Int type is broken: does not conform to Hashable", ())
ERROR(broken_int_integer_literal_convertible_conformance,sema_tcd,none,
      "Int type is broken: does not conform to IntegerLiteralConvertible", ())
ERROR(broken_equatable_eq_operator,sema_tcd,none,
      "Equatable protocol is broken: no infix operator declaration for '=='", ())
ERROR(no_equal_overload_for_int,sema_tcd,none,
      "no overload of '==' for Int", ())

// Dynamic Self
ERROR(dynamic_self_non_method,sema_tcd,none,
      "%select{global|local}0 function cannot return 'Self'", (bool))
ERROR(dynamic_self_struct_enum,sema_tcd,none,
      "%select{struct|enum}0 method cannot return 'Self'; "
      "did you mean to use the %select{struct|enum}0 type %1?",
      (int, Identifier))

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

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

ERROR(attr_only_only_one_decl_kind,sema_tcd,none,
      "%0 may only be used on '%1' declarations", (DeclAttribute,StringRef))


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

ERROR(member_cannot_be_final,sema_tcd,none,
      "only classes and class members may be marked with 'final'",
      ())

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

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

ERROR(override_noreturn_with_return,sema_tcd,none,
      "an override of a @noreturn method should also be @noreturn", ())

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

ERROR(inconsistent_attribute_override,sema_tcd,none,
      "@%0 must be consistent between a method and its override", (StringRef))
ERROR(autoclosure_function_type,attribute_parsing,none,
      "@autoclosure may only be applied to values of function type",
      ())
ERROR(autoclosure_function_input_nonunit,attribute_parsing,none,
      "autoclosure argument type must be '()'", ())
ERROR(noescape_function_type,attribute_parsing,none,
      "@noescape may only be applied to parameters of function type",
      ())
ERROR(noescape_implied_by_autoclosure,attribute_parsing,none,
      "@noescape is implied by @autoclosure and should not be "
      "redundantly specified", ())
ERROR(noescape_conflicts_escaping_autoclosure,attribute_parsing,none,
      "@noescape conflicts with @autoclosure(escaping)", ())


// NSManaged attribute
ERROR(attr_NSManaged_not_property,sema_tcd,none,
      "@NSManaged only allowed on a property in a class", ())
ERROR(attr_NSManaged_not_stored,sema_tcd,none,
      "@NSManaged not allowed on %select{computed|observing|adressed}0 "
      "properties", (unsigned))
ERROR(attr_NSManaged_let_property,sema_tcd,none,
      "@NSManaged not allowed on a 'let' property", ())
ERROR(attr_NSManaged_initial_value,sema_tcd,none,
      "@NSManaged property cannot have an initial value", ())
ERROR(attr_NSManaged_NSCopying,sema_tcd,none,
      "@NSManaged property cannot also be marked @NSCopying", ())


// NSCopying attribute
ERROR(nscopying_only_on_class_properties,sema_tcd,none,
      "@NSCopying may only be used on properties in classes",
      ())
ERROR(nscopying_only_mutable,sema_tcd,none,
      "@NSCopying requires property to be mutable", ())
ERROR(nscopying_only_stored_property,sema_tcd,none,
      "@NSCopying is only valid on stored properties", ())
ERROR(nscopying_doesnt_conform,sema_tcd,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_class,sema_tcd,none,
      "%" SELECT_APPLICATION_MAIN "0 attribute may only be used on classes",
      (unsigned))
ERROR(attr_ApplicationMain_not_ApplicationDelegate,sema_tcd,none,
      "%" SELECT_APPLICATION_MAIN "0 class must conform to the %" SELECT_APPLICATION_DELEGATE "0 protocol",
      (unsigned))
ERROR(attr_generic_ApplicationMain_not_supported,sema_tcd,none,
      "generic %" SELECT_APPLICATION_MAIN "0 classes are not supported",
      (unsigned))
ERROR(attr_ApplicationMain_multiple,sema_tcd,none,
      "%" SELECT_APPLICATION_MAIN "0 attribute can only apply to one class in a module",
      (unsigned))
ERROR(attr_ApplicationMain_with_script,sema_tcd,none,
      "%" SELECT_APPLICATION_MAIN "0 attribute cannot be used in a module that contains "
      "top-level code",
      (unsigned))
NOTE(attr_ApplicationMain_script_here,sema_tcd,none,
     "top-level code defined in this source file",
     ())

#undef SELECT_APPLICATION_MAIN
#undef SELECT_APPLICATION_DELEGATE

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

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

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

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

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

// warn_unused_result
ERROR(attr_warn_unused_result_mutable_variable,sema_tcd,none,
      "'mutable_variant' parameter of 'warn_unused_result' attribute does not "
      "make sense on a %select{non-function|non-method|non-instance method|"
      "method of a class|mutating method}0", (unsigned))

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

NOTE(found_candidate,sema_tce,none,
     "found this candidate", ())
NOTE(found_candidate_type,sema_tce,none,
     "found candidate with type %0", (Type))
NOTE(first_declaration,sema_tce,none,
     "first declaration", ())
NOTE(second_declaration,sema_tce,none,
     "second declaration", ())

ERROR(no_IntegerLiteralType_found,sema_tce,none,
      "standard library error: IntegerLiteralType not defined", ())
ERROR(no_FloatLiteralType_found,sema_tce,none,
      "standard library error: FloatLiteralType not defined", ())
ERROR(no_CharacterLiteralType_found,sema_tce,none,
      "standard library error: CharacterLiteralType not defined", ())
ERROR(no_StringLiteralType_found,sema_tce,none,
      "standard library error: StringLiteralType not defined", ())
ERROR(no_MaxBuiltinIntegerType_found,sema_tce,none,
   "standard library error: _MaxBuiltinIntegerType is not properly defined", ())
ERROR(no_MaxBuiltinFloatType_found,sema_tce,none,
   "standard library error: _MaxBuiltinFloatType is not properly defined", ())

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

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

ERROR(bad_init_ref_base,sema_tce, none,
      "'init' can only refer to the initializers of "
      "'self'%select{| or 'super'}0", (bool))
ERROR(init_delegation_outside_initializer,sema_tce,none,
      "initializer delegation can only occur within an initializer", ())
ERROR(init_delegates_and_chains,sema_tce,none,
      "initializer cannot both delegate ('self.init') and chain to a "
      "superclass initializer ('super.init')", ())
NOTE(init_delegation_or_chain,sema_tce,none,
      "previous %select{delegation|chaining}0 call is here", (bool))
ERROR(delegating_convenience_super_init,sema_tce,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,sema_tce,none,
      "designated initializer for %0 cannot delegate (with 'self.init'); "
      "did you mean this to be a convenience initializer?",
      (Type))
NOTE(delegation_here,sema_tce,none, "delegation occurs here", ())
ERROR(chain_convenience_init,sema_tce,none,
      "must call a designated initializer of the superclass %0",
      (Type))
ERROR(delegate_chain_nonoptional_to_optional,sema_tce,none,
      "a non-failable initializer cannot %select{delegate|chain}0 to "
      "failable initializer %1 written with 'init?'", (bool, DeclName))
NOTE(init_propagate_failure,sema_tce,none,
     "propagate the failure with 'init?'", ())

NOTE(convenience_init_here,sema_tce,none,
     "convenience initializer is declared here", ())
ERROR(designated_init_in_extension,sema_tcd,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,sema_tce,none,
      "delegating initializers in %0 are not marked with 'convenience'",
      (StringRef))
ERROR(nonclass_convenience_init,sema_tce,none,
      "convenience initializer not allowed in non-class type %0",
      (Type))

ERROR(dynamic_construct_class,sema_tce,none,
      "constructing an object of class type %0 with a metatype value must use "
      "a 'required' initializer", (Type))
NOTE(note_nonrequired_initializer,sema_tce,none,
      "selected %select{non-required|implicit}0 initializer %1", 
     (bool, DeclName))
ERROR(static_construct_existential,sema_tce,none,
      "constructing an object of protocol type %0 requires a metatype value",
      (Type))

// Operators
ERROR(unknown_binop,sema_tce,none,
       "operator is not a known binary operator", ())
ERROR(non_assoc_adjacent,sema_tce,none,
      "non-associative operator is adjacent to operator of same precedence", ())
ERROR(incompatible_assoc,sema_tce,none,
      "operator is adjacent to operator of same precedence"
      " but incompatible associativity", ())
ERROR(try_rhs,sema_tce,none,
      "%select{'try'|'try!'}0 cannot appear to the right of a non-assignment "
      "operator", (bool))
ERROR(try_if_rhs_noncovering,sema_tce,none,
      "%select{'try'|'try!'}0 following conditional operator does not cover "
      "everything to its right", (bool))
ERROR(try_assign_rhs_noncovering,sema_tce,none,
      "%select{'try'|'try!'}0 following assignment operator does not cover "
      "everything to its right", (bool))
ERROR(reference_non_inout,sema_tce,none,
      "reference to %0 not used to initialize a inout parameter", (Type))
NOTE(subscript_decl_here,sema_tca,none,
     "subscript operator declared here", ())
ERROR(condition_broken_proto,sema_tce,none,
      "protocol 'BooleanType' is broken", ())
ERROR(option_type_broken,sema_tce,none,
      "type 'Optional' is broken", ())

ERROR(broken_bool,sema_tce,none, "type 'Bool' is broken", ())
ERROR(binding_injected_optional,sema_tce,none,
      "operand of postfix '?' should have optional type; type is %0", (Type))
ERROR(binding_explicit_downcast,sema_tce,none,
      "operand of postfix '?' is a forced downcast to type %0; use 'as?' to "
      "perform a conditional downcast", (Type))

ERROR(forcing_injected_optional,sema_tce,none,
      "operand of postfix '!' should have optional type; type is %0", (Type))

ERROR(forcing_explicit_downcast,sema_tce,none,
      "extraneous postfix '!'; forced downcast already produces a non-optional "
      "value of type %0", (Type))

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

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

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

ERROR(migrate_from_raw_to_init,sema_tce,none,
      "static method 'fromRaw' has been replaced with a failable initializer "
      "'init(rawValue:)'", ())
ERROR(migrate_to_raw_to_raw_value,sema_tce,none,
      "method 'fromRaw' has been replaced with a property 'rawValue'", ())

ERROR(new_array_bound_zero,sema_tce,none,
      "array type cannot have zero length", ())
ERROR(non_constant_array,type_parsing,none,
      "array has non-constant size", ())

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

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

ERROR(discard_expr_outside_of_assignment,sema_tce,none,
      "'_' can only appear in a pattern or on the left side of an assignment",
      ())

ERROR(not_enough_context_for_generic_method_reference,sema_tce,none,
      "reference to generic method %0 is ambiguous without more context",
      (Identifier))

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

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

ERROR(builtin_integer_literal_broken_proto,sema_tce,none,
      "protocol '_BuiltinIntegerLiteralConvertible' is broken", ())
ERROR(integer_literal_broken_proto,sema_tce,none,
      "protocol 'IntegerLiteralConvertible' is broken", ())

ERROR(builtin_float_literal_broken_proto,sema_tce,none,
      "protocol '_BuiltinFloatLiteralConvertible' is broken", ())
ERROR(float_literal_broken_proto,sema_tce,none,
      "protocol 'FloatLiteralConvertible' is broken", ())

ERROR(builtin_boolean_literal_broken_proto,sema_tce,none,
      "protocol '_BuiltinBooleanLiteralConvertible' is broken", ())
ERROR(boolean_literal_broken_proto,sema_tce,none,
      "protocol 'BooleanLiteralConvertible' is broken", ())

ERROR(builtin_character_literal_broken_proto,sema_tce,none,
      "protocol '_BuiltinCharacterLiteralConvertible' is broken", ())
ERROR(character_literal_broken_proto,sema_tce,none,
      "protocol 'CharacterLiteralConvertible' is broken", ())

ERROR(builtin_unicode_scalar_literal_broken_proto,sema_tce,none,
      "protocol '_BuiltinUnicodeScalarLiteralConvertible' is broken", ())
ERROR(unicode_scalar_literal_broken_proto,sema_tce,none,
      "protocol 'UnicodeScalarLiteralConvertible' is broken", ())

ERROR(builtin_extended_grapheme_cluster_literal_broken_proto,sema_tce,none,
      "protocol '_BuiltinExtendedGraphemeClusterLiteralConvertible' is broken", ())
ERROR(extended_grapheme_cluster_literal_broken_proto,sema_tce,none,
      "protocol 'ExtendedGraphemeClusterLiteralConvertible' is broken", ())

ERROR(builtin_string_literal_broken_proto,sema_tce,none,
      "protocol '_BuiltinStringLiteralConvertible' is broken", ())
ERROR(string_literal_broken_proto,sema_tce,none,
      "protocol 'StringLiteralConvertible' is broken", ())

ERROR(bool_type_broken,sema_tce,none,
      "could not find a Bool type defined for 'is'", ())

// Array literals
ERROR(array_protocol_broken,sema_tce,none,
      "ArrayLiteralConvertible protocol definition is broken", ())

// Dictionary literals
ERROR(dictionary_protocol_broken,sema_tce,none,
      "DictionaryLiteralConvertible protocol definition is broken", ())

// Generic specializations
ERROR(cannot_explicitly_specialize_generic_function,tce_sema,none,
      "cannot explicitly specialize a generic function", ())
ERROR(not_a_generic_definition,tce_sema,none,
      "cannot specialize a non-generic definition", ())
ERROR(not_a_generic_type,tce_sema,none,
      "cannot specialize non-generic type %0", (Type))
ERROR(type_parameter_count_mismatch,tce_sema,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,tce_sema,none,
      "reference to generic type %0 requires arguments in <...>", (Type))
NOTE(generic_type_declared_here,tce_sema,none,
     "generic type %0 declared here", (Identifier))

// Ambiguities
ERROR(ambiguous_decl_ref,tce_sema,none,
      "ambiguous use of %0", (Identifier))
ERROR(ambiguous_operator_ref,tce_sema,none,
      "ambiguous use of operator %0", (Identifier))

ERROR(partial_application_of_method_invalid,tce_sema,none,
      "partial application of %select{struct method|enum method|enum "
      "constructor|generic method|protocol method|Objective-C}0 is not allowed",
      (unsigned))

ERROR(self_assignment_var,tce_sema,none,
      "assigning a variable to itself", ())
ERROR(self_assignment_prop,tce_sema,none,
      "assigning a property to itself", ())
ERROR(property_use_in_closure_without_explicit_self,tce_sema,none,
      "reference to property %0 in closure requires explicit 'self.' to make"
      " capture semantics explicit", (Identifier))
ERROR(method_call_in_closure_without_explicit_self,tce_sema,none,
      "call to method %0 in closure requires explicit 'self.' to make"
      " capture semantics explicit", (Identifier))
ERROR(implicit_use_of_self_in_closure,tce_sema,none,
      "implicit use of 'self' in closure; use 'self.' to make"
      " capture semantics explicit", ())
ERROR(capture_before_declaration,tce_sema,none,
      "cannot capture %0 before it is declared", (Identifier))
ERROR(unsupported_local_function_reference,tce_sema,none,
      "cannot reference a local function with captures from another local "
      "function", ())
ERROR(unsupported_recursive_local_function,tce_sema,none,
      "local functions cannot reference themselves", ())

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

WARNING(unindented_code_after_return,tce_sema,none,
        "expression following 'return' is treated as an argument of "
        "the 'return'", ())
NOTE(indent_expression_to_silence,tce_sema,none,
     "indent the expression to silence this warning", ())

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

ERROR(value_of_metatype_type,tce_sema,none,
      "expected member name or constructor call after type name", ())

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

ERROR(type_of_metatype,tce_sema,none,
      "'.dynamicType' is not allowed after a type name", ())
ERROR(invalid_noescape_use,tce_sema,none,
      "@noescape parameter %0 may only be called", (Identifier))
NOTE(noescape_autoclosure,tce_sema,none,
    "parameter %0 is implicitly @noescape because it was declared @autoclosure",
     (Identifier))

ERROR(closure_noescape_use,tce_sema,none,
      "closure use of @noescape parameter %0 may allow it to escape",
      (Identifier))
ERROR(decl_closure_noescape_use,tce_sema,none,
      "declaration closing over @noescape parameter %0 may allow it to escape",
      (Identifier))

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

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

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

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

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

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


ERROR(expression_unused_function,sema_tcs,none,
      "expression resolves to an unused function", ())
ERROR(expression_unused_lvalue,sema_tcs,none,
      "expression resolves to an unused l-value", ())
WARNING(expression_unused_result,sema_tcs,none,
        "result of call to %0 is unused", (DeclName))
WARNING(expression_unused_result_message,sema_tcs,none,
        "result of call to %0 is unused: %1", (DeclName, StringRef))
WARNING(expression_unused_result_nonmutating,sema_tcs,none,
        "result of call to non-mutating function %0 is unused; "
        "use %1 to mutate in-place", (DeclName, DeclName))
ERROR(assignment_lhs_not_lvalue,sema_tcs,none,
      "cannot assign to the result of this expression", ())
ERROR(assignment_lhs_is_let,sema_tcs,none,
      "cannot assign to 'let' value %0", (Identifier))
ERROR(assignment_get_only_property,sema_tcs,none,
      "cannot assign to a get-only property %0", (Identifier))
ERROR(assignment_to_self,sema_tcs,none,
      "cannot assign to %0 in a method", (Identifier))

ERROR(assignment_lhs_is_vardecl,sema_tcs,none,
      "cannot assign to %0", (Identifier))

ERROR(assignment_unresolved_expr,sema_tcs,none,
      "cannot assign to %0 in %1", (Identifier, Identifier))

// ForEach Stmt
ERROR(sequence_protocol_broken,sema_tcs,none,
      "SequenceType protocol definition is broken", ())
ERROR(generator_protocol_broken,sema_tcs,none,
      "GeneratorType protocol definition is broken", ())

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

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

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

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

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



ERROR(pattern_type_mismatch_context,sema_tcp,none,
      "type annotation does not match contextual type %0", (Type))
ERROR(label_single_entry_tuple,sema_tcp,none,
      "label is not allowed on single element tuple pattern", ())
NOTE(remove_parens_for_type_annotation,sema_tcp,none,
     "remove the parentheses to make this a type annotation", ())
NOTE(remove_label_for_tuple_pattern,sema_tcp,none,
     "remove the label to make this a tuple pattern", ())

ERROR(tuple_pattern_in_non_tuple_context,sema_tcp,none,
      "tuple pattern cannot match values of the non-tuple type %0", (Type))
ERROR(tuple_pattern_length_mismatch,sema_tcp,none,
      "tuple pattern has the wrong length for tuple type %0", (Type))
ERROR(tuple_pattern_label_mismatch,sema_tcp,none,
      "tuple pattern element label %0 must be %1", (Identifier, Identifier))
ERROR(enum_element_pattern_member_not_found,sema_tcp,none,
      "enum case '%0' not found in type %1", (StringRef, Type))
ERROR(enum_element_pattern_not_enum,sema_tcp,none,
      "enum case pattern cannot match values of the non-enum type %0", (Type))
ERROR(optional_element_pattern_not_valid_type,sema_tcp,none,
      "'?' pattern cannot match values of type %0", (Type))
ERROR(condition_optional_element_pattern_not_valid_type,sema_tcp,none,
      "initializer for conditional binding must have Optional type, not %0",
      (Type))
ERROR(enum_element_pattern_not_member_of_enum,sema_tcp,none,
      "enum case '%0' is not a member of type %1", (StringRef, Type))
ERROR(nominal_type_pattern_not_nominal_type,sema_tcp,none,
      "non-nominal type %0 cannot be used with property pattern syntax", (Type))
ERROR(nominal_type_pattern_type_mismatch,sema_tcp,none,
      "type %0 of pattern does not match deduced type %1", (Type, Type))
ERROR(nominal_type_pattern_property_not_found,sema_tcp,none,
      "property '%0' not found in type %1", (StringRef, Type))
ERROR(nominal_type_pattern_property_ambiguous,sema_tcp,none,
      "property name '%0' in type %1 is ambiguous", (StringRef, Type))
ERROR(nominal_type_pattern_not_property,sema_tcp,none,
      "member '%0' of type %1 is not a property", (StringRef, Type))
ERROR(nominal_type_pattern_static_property,sema_tcp,none,
      "cannot match type property '%0' of type %1 in a 'case' pattern",
      (StringRef, Type))
ERROR(nominal_type_subpattern_without_property_name,pattern_parsing,none,
      "subpattern of a struct or class pattern must have a keyword name", ())
ERROR(ambiguous_enum_pattern_type,sema_tcp,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,sema_tcp,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,sema_tcp,none,
     "add an explicit type annotation to silence this warning", ())
ERROR(isa_pattern_value,sema_tcp,none,
      "downcast pattern value of type %0 cannot be used", (Type))

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



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

ERROR(throwing_call_in_nonthrowing_autoclosure,sema,none,
      "call can throw, but it is executed in a non-throwing "
      "autoclosure",())
ERROR(tryless_throwing_call_in_nonthrowing_autoclosure,sema,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,sema,none,
      "error is not handled because it is thrown in a non-throwing "
      "autoclosure", ())

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

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

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

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

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

ERROR(sugar_type_not_found,sema_tct,none,
      "broken standard library: cannot find "
      "%select{Array|Optional|ImplicitlyUnwrappedOptional|Dictionary|"
      "ErrorType}0 type", (unsigned))
ERROR(optional_intrinsics_not_found,sema_tct,none,
      "broken standard library: cannot find intrinsic operations on "
      "Optional<T>", ())
ERROR(pointer_argument_intrinsics_not_found,sema_tct,none,
      "broken standard library: cannot find intrinsic operations on "
      "UnsafeMutablePointer<T>", ())
ERROR(array_literal_intrinsics_not_found,sema_tct,none,
      "broken standard library: cannot find intrinsic operations on "
      "Array<T>", ())
ERROR(bool_intrinsics_not_found,sema_tct,none,
      "broken standard library: cannot find intrinsic operations on Bool", ())
ERROR(self_in_nominal,sema_tct,none,
      "'Self' is only available in a protocol or as the result of a "
      "method in a class; did you mean %0?", (Identifier))
ERROR(non_generic_class_with_generic_superclass,sema_tct,none,
      "classes derived from generic classes must also be generic", ())
ERROR(class_super_access,sema_tcd,none,
      "class %select{must be declared %select{private|internal|PUBLIC}2"
      "|cannot be declared %select{PRIVATE|internal|public}1}0 because its "
      "superclass is %select{private|internal|PUBLIC}2",
      (bool, Accessibility, Accessibility))
ERROR(dot_protocol_on_non_existential,sema_tct,none,
      "'Protocol' type only applies to existential types", ())
ERROR(tuple_single_element,sema_tcd,none,
      "cannot create a single-element tuple with an element label", ())
ERROR(tuple_ellipsis,sema_tcd,none,
      "cannot create a variadic tuple", ())

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

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

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

// Functions
ERROR(attribute_requires_function_type,attribute_parsing,none,
      "attribute only applies to syntactic function types", ())
ERROR(first_class_generic_function,type_parsing,PointsToFirstBadToken,
      "generic types cannot be used as first-class types", ())
ERROR(objc_block_cannot_be_thin,attribute_parsing,none,
      "@objc_block function type cannot be @thin", ())
ERROR(attribute_not_supported,attribute_parsing,none,
      "this attribute is not supported", ())
ERROR(convention_with_deprecated_representation_attribute,attribute_parsing,none,
      "@convention attribute cannot be used with deprecated @%0 attribute",
      (StringRef))
ERROR(unsupported_convention,type_parsing,none,
      "convention '%0' not supported", (StringRef))
ERROR(unreferenced_generic_parameter,type_parsing,none,
      "generic parameter '%0' is not used in function signature", (StringRef))
WARNING(deprecated_convention_attribute,type_parsing,none,
        "'@%0' attribute is deprecated; '@convention(%1)' should be used "
        "instead", (StringRef, StringRef))

// SIL
ERROR(sil_local_storage_nested, decl_parsing,none,
      "local storage types cannot be in nested positions", ())
ERROR(opened_non_protocol, decl_parsing,none,
      "@opened cannot be applied to non-protocol type %0", (Type))
ERROR(sil_function_ellipsis,type_parsing,PointsToFirstBadToken,
      "SIL function types cannot be variadic", ())
ERROR(sil_function_label,type_parsing,PointsToFirstBadToken,
      "SIL function types cannot have labeled inputs", ())
ERROR(sil_function_repeat_convention,type_parsing,PointsToFirstBadToken,
      "repeated %select{parameter|result|callee}0 convention attribute",
      (unsigned))
ERROR(sil_function_multiple_results,type_parsing,PointsToFirstBadToken,
      "SIL function types cannot have multiple results", ())
ERROR(sil_function_multiple_error_results,type_parsing,PointsToFirstBadToken,
      "SIL function types cannot have multiple @error results", ())
ERROR(unsupported_cc_representation_combo,type_parsing,none,
      "cc unsupported with this sil representation", ())
ERROR(unsupported_sil_convention,type_parsing,none,
      "convention '%0' not supported in SIL", (StringRef))
ERROR(sil_deprecated_convention_attribute,type_parsing,none,
      "'@%0' attribute is deprecated; '@convention(%1)' must be used instead",
      (StringRef, StringRef))

// SIL Metatypes
ERROR(sil_metatype_without_repr,type_parsing,none,
      "metatypes in SIL must have @thin, @thick, or @objc_metatype attribute",
      ())
ERROR(sil_metatype_multiple_reprs,type_parsing,none,
      "metatypes in SIL can only be one of @thin, @thick, or @objc_metatype", 
      ())

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

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

ERROR(invalid_objc_decl,sema_tcd,none,
      "only classes, protocols, methods, properties, and subscript "
      "declarations can be declared @objc", ())
ERROR(invalid_nonobjc_decl,sema_tcd,none,
      "only methods can be declared @nonobjc", ())
ERROR(objc_in_generic_context,sema_objc,none,
      "%select{method|initializer|variable|subscript}0 in a "
      "%select{generic class|protocol extension}1 cannot be represented in "
      "Objective-C", (int, bool))
ERROR(objc_getter_for_nonobjc_property,sema_tcd,none,
      "'@objc' getter for non-'@objc' property", ())
ERROR(objc_getter_for_nonobjc_subscript,sema_tcd,none,
      "'@objc' getter for non-'@objc' subscript", ())
ERROR(objc_setter_for_nonobjc_property,sema_tcd,none,
      "'@objc' setter for non-'@objc' property", ())
ERROR(objc_setter_for_nonobjc_subscript,sema_tcd,none,
      "'@objc' setter for non-'@objc' subscript", ())
ERROR(objc_enum_generic,sema_tcd,none,
      "'@objc' enum cannot be generic", ())
ERROR(objc_name_req_nullary,sema_objc,none,
      "'@objc' %select{class|protocol|property}0 must have a simple name", (int))
ERROR(objc_name_enum,sema_objc,none,
      "'@objc' enum cannot have a name", ())
ERROR(objc_name_subscript,sema_objc,none,
      "'@objc' subscript cannot have a name; did you mean to put "
      "the name on the getter or setter?", ())
ERROR(objc_name_func_mismatch,sema_objc,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))

// If you change this, also change enum ObjCReason
#define OBJC_ATTR_SELECT "select{marked dynamic|marked @objc|marked @IBOutlet|marked @NSManaged|a member of an @objc protocol|implicitly @objc}"

ERROR(objc_invalid_on_var,sema_objc,none,
      "property cannot be %" OBJC_ATTR_SELECT "0 "
      "because its type cannot be represented in Objective-C", (unsigned))
ERROR(objc_invalid_subscript_key_type,sema_objc,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,sema_objc,none,
      "subscript cannot be %" OBJC_ATTR_SELECT "0 because its type "
      "cannot be represented in Objective-C", (unsigned))
ERROR(objc_convention_invalid,sema_objc,none,
      "@convention(%0) type is not representable in Objective-C", (StringRef))
NOTE(not_objc_empty_protocol_composition,sema_objc,none,
     "'protocol<>' is not considered '@objc'; use 'AnyObject' instead", ())
NOTE(not_objc_protocol,sema_objc,none,
     "protocol %0 is not '@objc'", (Type))
NOTE(not_objc_empty_tuple,sema_objc,none,
      "empty tuple type cannot be represented in Objective-C", ())
NOTE(not_objc_tuple,sema_objc,none,
      "tuples cannot be represented in Objective-C", ())
NOTE(not_objc_swift_class,sema_objc,none,
     "classes not annotated with @objc cannot be represented "
     "in Objective-C", ())
NOTE(not_objc_swift_struct,sema_objc,none,
      "Swift structs cannot be represented in Objective-C", ())
NOTE(not_objc_swift_enum,sema_objc,none,
      "non-'@objc' enums cannot be represented in Objective-C", ())
NOTE(not_objc_generic_type_param,sema_objc,none,
     "generic type parameters cannot be represented in Objective-C", ())
NOTE(not_objc_function_type_param,sema_objc,none,
     "function types cannot be represented in Objective-C unless their "
     "parameters and returns can be", ())
NOTE(not_objc_function_type_throwing,sema_objc,none,
      "throwing function types cannot be represented in Objective-C", ())
NOTE(objc_inferring_on_objc_protocol_member,sema_objc,none,
     "inferring '@objc' because the declaration is a member of "
     "an '@objc' protocol", ())

ERROR(objc_invalid_on_func_curried,sema_objc,none,
      "method cannot be %" OBJC_ATTR_SELECT "0 because curried functions "
      "cannot be represented in Objective-C", (unsigned))
ERROR(objc_observing_accessor,sema_objc, none,
      "observing accessors are not allowed to be marked @objc", ())
ERROR(objc_invalid_on_func_variadic,sema_objc,none,
      "method cannot be %" OBJC_ATTR_SELECT "0 because it has a variadic "
      "parameter", (unsigned))
ERROR(objc_invalid_on_func_param_type,sema_objc,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,sema_objc,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,sema_objc,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,sema_objc,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,sema_objc,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,sema_objc,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,sema_objc,none,
      "a failable and throwing initializer cannot be "
      "%" OBJC_ATTR_SELECT "0 because 'nil' indicates failure to Objective-C",
      (unsigned))

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

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

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

ERROR(type_not_bridged,sema_objc,none,
      "%0 is not bridged to Objective-C", (Type))
ERROR(missing_bridging_function,sema_objc,Fatal,
      "missing '%select{_forceBridgeFromObjectiveC|"
      "_conditionallyBridgeFromObjectiveC}0'", (bool))
ERROR(missing_nserror_bridging_function,sema_objc,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,sema_objc,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,sema_objc,none,
     OBJC_DIAG_SELECT " declared here",
     (unsigned, DeclName))

ERROR(objc_redecl_same,sema_objc,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,sema_objc,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_load,sema_objc,none,
      OBJC_DIAG_SELECT " defines Objective-C class method 'load', which is "
      "not permitted by Swift", (unsigned, DeclName))

NOTE(objc_witness_selector_mismatch,sema_objc,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,sema_objc,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))

ERROR(nonobjc_not_allowed,sema_objc,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,sema_dynamic,none,
      "only members of classes may be dynamic", ())
ERROR(dynamic_with_final,sema_dynamic,none,
      "a declaration cannot be both 'final' and 'dynamic'",
      ())

//------------------------------------------------------------------------------
// @availability
//------------------------------------------------------------------------------

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

ERROR(availability_decl_unavailable_rename, sema_avail, none,
      "%0 has been renamed to %1", (DeclName, StringRef))

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

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

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

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

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

WARNING(availability_deprecated, sema_avail, 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, sema_avail, 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, sema_avail, none,
        "%0 %select{is|%select{is|was}3}1 deprecated"
        "%select{| %select{on|in}3 %2%select{| %4}3}1: renamed to '%5'",
        (DeclName, bool, StringRef, bool, clang::VersionTuple, StringRef))

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

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

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

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

NOTE(availability_guard_with_version_check, sema_avail, none,
     "guard with version check", ())

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

ERROR(availability_accessor_only_version_newer, sema_avail, 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, sema_avail, 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_repeated_platform, sema_avail, none,
      "conditions for '%0' already specified for this query", (StringRef))

ERROR(availability_query_wildcard_required, sema_avail, none,
      "check must handle potential future platforms with '*'", ())

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

WARNING(availability_query_useless_min_deployment, sema_avail, none,
        "unnecessary check for '%0'; minimum deployment target ensures guard "
        "will always be true", (StringRef))

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

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

ERROR(availability_query_outside_if_stmt_guard, sema_avail, none,
      "check can only be used as condition or where clause of if statement", ())

ERROR(availability_global_script_no_potential, sema_avail,
      none, "global variable cannot be marked potentially "
      "unavailable with 'introduced=' in script mode", ())

ERROR(availability_stored_property_no_potential, sema_avail,
      none, "stored properties cannot be marked potentially unavailable with "
      "'introduced='", ())

ERROR(availability_declaration_less_available_than_protocol, sema_avail,
      none, "%0 is less available than protocol requires", (DeclName))

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

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