Skip to content
Permalink
main
Switch branches/tags
Go to file
…references

Check actor isolation of calls to functions with global-actor-qualified
type. This closes a pre-existing loophole where a value of
global-actor-qualified function type could be called from any context.
Paired with this, references to global-actor-qualified function
declarations will get global-actor-qualified function type whenever
they are referenced within an experience, i.e., whenever we form a
value of that type. Such references can occur anywhere (one does not
need to be on the actor), and carrying the global actor along with the
function type ensures that they can only be called from the right
actor. For example:

    @mainactor func onlyOnMainActor() { ... }

    func callIt(_ fn: @mainactor () -> Void) {
      fn() // error: not on the main actor, so cannot synchronously call
           // this wasn't previously diagnosed
    }

    func passIt() {
      callIt(onlyOnMainActor)  // okay to pass the function
                               // used to be an error
    }

While here, fix up some broken substitution logic for
global-actor-qualified function types and "override" actor isolation.
149 contributors

Users who have contributed to this file

@DougGregor @lattner @jrose-apple @slavapestov @jckarter @xedin @swift-ci @hborla @rjmccall @theblixguy @rudkx @jopamer
5879 lines (5325 sloc) 271 KB
//===--- DiagnosticsSema.def - Diagnostics Text -----------------*- C++ -*-===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2014 - 2018 Apple Inc. and the Swift project authors
// Licensed under Apache License v2.0 with Runtime Library Exception
//
// See https://swift.org/LICENSE.txt for license information
// See https://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
//
//===----------------------------------------------------------------------===//
//
// This file defines diagnostics emitted during semantic analysis and type
// checking.
// Each diagnostic is described using one of three kinds (error, warning, or
// note) along with a unique identifier, category, options, and text, and is
// followed by a signature describing the diagnostic argument kinds.
//
//===----------------------------------------------------------------------===//
#define DEFINE_DIAGNOSTIC_MACROS
#include "DefineDiagnosticMacros.h"
#ifndef REMARK
# define REMARK(ID,Options,Text,Signature) \
DIAG(REMARK,ID,Options,Text,Signature)
#endif
NOTE(decl_declared_here,none,
"%0 declared here", (DeclName))
NOTE(kind_declared_here,none,
"%0 declared here", (DescriptiveDeclKind))
NOTE(implicit_member_declared_here,none,
"%1 '%0' is implicitly declared", (StringRef, StringRef))
NOTE(extended_type_declared_here,none,
"extended type declared here", ())
NOTE(opaque_return_type_declared_here,none,
"opaque return type declared here", ())
//------------------------------------------------------------------------------
// MARK: Constraint solver diagnostics
//------------------------------------------------------------------------------
ERROR(ambiguous_member_overload_set,none,
"ambiguous reference to member %0", (DeclNameRef))
ERROR(ambiguous_reference_to_decl,none,
"ambiguous reference to %0 %1", (DescriptiveDeclKind, DeclName))
ERROR(no_overloads_match_exactly_in_call,none,
"no exact matches in %select{reference|call}0 to %1 %select{%3|}2",
(bool, DescriptiveDeclKind, bool, DeclBaseName))
NOTE(candidate_partial_match,none,
"candidate has partially matching parameter list %0",
(StringRef))
ERROR(could_not_find_value_subscript,none,
"value of type %0 has no subscripts",
(Type))
ERROR(could_not_find_tuple_member,none,
"value of tuple type %0 has no member %1", (Type, DeclNameRef))
ERROR(could_not_find_value_member,none,
"value of type %0 has no member %1", (Type, DeclNameRef))
ERROR(could_not_find_value_member_corrected,none,
"value of type %0 has no member %1; did you mean %2?",
(Type, DeclNameRef, DeclName))
ERROR(could_not_find_value_dynamic_member_corrected,none,
"value of type %0 has no dynamic member %2 using key path from root type %1; did you mean %3?",
(Type, Type, DeclNameRef, DeclName))
ERROR(could_not_find_value_dynamic_member,none,
"value of type %0 has no dynamic member %2 using key path from root type %1",
(Type, Type, DeclNameRef))
ERROR(cannot_infer_contextual_keypath_type_specify_root,none,
"cannot infer key path type from context; consider explicitly specifying a root type", ())
ERROR(cannot_infer_keypath_root_anykeypath_context,none,
"'AnyKeyPath' does not provide enough context for root type to be inferred; "
"consider explicitly specifying a root type", ())
ERROR(could_not_find_type_member,none,
"type %0 has no member %1", (Type, DeclNameRef))
ERROR(could_not_find_type_member_corrected,none,
"type %0 has no member %1; did you mean %2?",
(Type, DeclNameRef, DeclName))
ERROR(could_not_find_subscript_member_did_you_mean,none,
"value of type %0 has no property or method named 'subscript'; "
"did you mean to use the subscript operator?",
(Type))
ERROR(could_not_find_subscript_member_tuple, none,
"cannot access element using subscript for tuple type %0; "
"use '.' notation instead", (Type))
ERROR(could_not_find_subscript_member_tuple_did_you_mean_use_dot, none,
"cannot access element using subscript for tuple type %0; "
"did you mean to use '.%1'?", (Type, StringRef))
ERROR(could_not_find_enum_case,none,
"enum type %0 has no case %1; did you mean %2?",
(Type, DeclNameRef, DeclName))
NOTE(did_you_mean_raw_type,none,
"did you mean to specify a raw type on the enum declaration?", ())
NOTE(did_you_mean_generic_param_as_conformance,none,
"did you mean to declare %0 as a protocol conformance for %1?", (DeclName, Type))
NOTE(any_as_anyobject_fixit, none,
"cast 'Any' to 'AnyObject' or use 'as!' to force downcast to a more specific type to access members", ())
ERROR(expected_argument_in_contextual_member,none,
"member %0 expects argument of type %1", (DeclName, Type))
ERROR(expected_parens_in_contextual_member,none,
"member %0 is a function; did you mean to call it?", (DeclName))
ERROR(expected_parens_in_contextual_member_type,none,
"member %0 is a function that produces expected type %1; did you mean to "
"call it?", (DeclName, Type))
ERROR(expected_result_in_contextual_member,none,
"member %0 in %2 produces result of type %1, but context expects %2",
(DeclName, Type, Type))
ERROR(unexpected_arguments_in_enum_case,none,
"enum case %0 has no associated values", (DeclName))
ERROR(could_not_use_type_member_on_instance,none,
"static member %1 cannot be used on instance of type %0",
(Type, DeclNameRef))
ERROR(could_not_use_enum_element_on_instance,none,
"enum case %0 cannot be used as an instance member",
(DeclNameRef))
ERROR(could_not_use_type_member_on_protocol_metatype,none,
"static member %1 cannot be used on protocol metatype %0",
(Type, DeclNameRef))
ERROR(could_not_use_instance_member_on_type,none,
"instance member %1"
"%select{| of type %2}3 cannot be used on"
"%select{| instance of nested}3 type %0",
(Type, DeclNameRef, Type, bool))
ERROR(could_not_use_member_on_existential,none,
"member %1 cannot be used on value of protocol type %0; use a generic"
" constraint instead",
(Type, DeclNameRef))
FIXIT(replace_with_type,"%0",(Type))
FIXIT(insert_type_qualification,"%0.",(Type))
ERROR(candidate_inaccessible,none,
"%0 is inaccessible due to "
"'%select{private|fileprivate|internal|@_spi|@_spi}1' protection level",
(DeclBaseName, AccessLevel))
NOTE(note_candidate_inaccessible,none,
"%0 is inaccessible due to "
"'%select{private|fileprivate|internal|@_spi|@_spi}1' protection level",
(DeclName, AccessLevel))
ERROR(init_candidate_inaccessible,none,
"%0 initializer is inaccessible due to "
"'%select{private|fileprivate|internal|@_spi|@_spi}1' protection level",
(Type, AccessLevel))
ERROR(cannot_pass_rvalue_mutating_subelement,none,
"cannot use mutating member on immutable value: %0",
(StringRef))
ERROR(cannot_pass_rvalue_mutating,none,
"cannot use mutating member on immutable value of type %0",
(Type))
ERROR(cannot_pass_rvalue_mutating_getter_subelement,none,
"cannot use mutating getter on immutable value: %0",
(StringRef))
ERROR(cannot_pass_rvalue_mutating_getter,none,
"cannot use mutating getter on immutable value of type %0",
(Type))
ERROR(expression_too_complex,none,
"the compiler is unable to type-check this expression in reasonable time; "
"try breaking up the expression into distinct sub-expressions", ())
ERROR(value_type_comparison_with_nil_illegal_did_you_mean,none,
"value of type %0 cannot be compared by reference; "
"did you mean to compare by value?",
(Type))
ERROR(value_type_comparison_with_nil_illegal,none,
"type %0 is not optional, value can never be nil",
(Type))
ERROR(cannot_match_expr_pattern_with_value,none,
"expression pattern of type %0 cannot match values of type %1",
(Type, Type))
ERROR(cannot_match_expr_tuple_pattern_with_nontuple_value,none,
"tuple pattern cannot match values of non-tuple type %0",
(Type))
ERROR(cannot_match_unresolved_expr_pattern_with_value,none,
"pattern cannot match values of type %0",
(Type))
ERROR(cannot_reference_compare_types,none,
"cannot check reference equality of functions; operands here have types "
"%1 and %2",
(StringRef, Type, Type))
ERROR(cannot_apply_binop_to_args,none,
"binary operator '%0' cannot be applied to operands of type "
"%1 and %2",
(StringRef, Type, Type))
ERROR(cannot_apply_binop_to_same_args,none,
"binary operator '%0' cannot be applied to two %1 operands",
(StringRef, Type))
ERROR(cannot_apply_unop_to_arg,none,
"unary operator '%0' cannot be applied to an operand of type %1",
(StringRef, Type))
ERROR(cannot_apply_lvalue_unop_to_subelement,none,
"cannot pass immutable value to mutating operator: %0",
(StringRef))
ERROR(cannot_apply_lvalue_unop_to_rvalue,none,
"cannot pass immutable value of type %0 to mutating operator",
(Type))
ERROR(cannot_apply_lvalue_binop_to_subelement,none,
"left side of mutating operator isn't mutable: %0", (StringRef))
ERROR(cannot_apply_lvalue_binop_to_rvalue,none,
"left side of mutating operator has immutable type %0", (Type))
ERROR(cannot_subscript_base,none,
"cannot subscript a value of type %0",
(Type))
ERROR(cannot_subscript_ambiguous_base,none,
"cannot subscript a value of incorrect or ambiguous type", ())
ERROR(cannot_subscript_nil_literal,none,
"cannot subscript a nil literal value", ())
ERROR(conditional_cast_from_nil,none,
"nil literal cannot be the source of a conditional cast", ())
ERROR(cannot_pass_rvalue_inout_subelement,none,
"cannot pass immutable value as inout argument: %0",
(StringRef))
ERROR(cannot_pass_rvalue_inout_converted,none,
"inout argument could be set to a value with a type other than %0; "
"use a value declared as type %1 instead", (Type, Type))
NOTE(inout_change_var_type_if_possible,none,
"change variable type to %1 if it doesn't need to be declared as %0",
(Type, Type))
ERROR(cannot_pass_rvalue_inout,none,
"cannot pass immutable value of type %0 as inout argument",
(Type))
ERROR(cannot_provide_default_value_inout,none,
"cannot provide default value to inout parameter %0", (Identifier))
ERROR(cannot_call_with_params, none,
"cannot invoke %select{|initializer for type }2'%0' with an argument list"
" of type '%1'", (StringRef, StringRef, bool))
ERROR(cannot_call_non_function_value,none,
"cannot call value of non-function type %0", (Type))
ERROR(no_candidates_match_result_type,none,
"no '%0' candidates produce the expected contextual result type %1",
(StringRef, Type))
ERROR(no_candidates_match_argument_type,none,
"no '%0' candidates produce the expected type %1 for parameter #%2",
(StringRef, Type, unsigned))
ERROR(cannot_infer_closure_parameter_type,none,
"unable to infer type of a closure parameter %0 in the current context",
(StringRef))
ERROR(cannot_infer_closure_type,none,
"unable to infer closure type in the current context", ())
ERROR(cannot_infer_closure_result_type,none,
"unable to infer%select{ complex|}0 closure return type; "
"add explicit type to disambiguate", (bool))
FIXIT(insert_closure_return_type_placeholder,
"%select{| () }0-> <#Result#> %select{|in }0",
(bool))
ERROR(incorrect_explicit_closure_result,none,
"declared closure result %0 is incompatible with contextual type %1",
(Type, Type))
ERROR(unsupported_closure_attr,none,
"%select{attribute |}0 '%1' is not supported on a closure",
(bool, StringRef))
NOTE(suggest_expected_match,none,
"%select{expected an argument list|produces result}0 of type '%1'",
(bool, StringRef))
NOTE(suggest_partial_overloads,none,
"overloads for '%1' exist with these %select{"
"partially matching parameter lists|result types}0: %2",
(bool, StringRef, StringRef))
NOTE(no_binary_op_overload_for_enum_with_payload,none,
"binary operator '%0' cannot be synthesized for enums "
"with associated values",
(StringRef))
ERROR(cannot_convert_initializer_value,none,
"cannot convert value of type %0 to specified type %1", (Type,Type))
ERROR(cannot_convert_initializer_value_protocol,none,
"value of type %0 does not conform to specified type %1", (Type,Type))
ERROR(cannot_convert_initializer_value_anyobject,none,
"value of type %0 expected to be instance of class or "
"class-constrained type",
(Type, Type))
ERROR(cannot_convert_initializer_value_nil,none,
"'nil' cannot initialize specified type %0", (Type))
ERROR(cannot_convert_to_return_type,none,
"cannot convert return expression of type %0 to return type %1",
(Type,Type))
ERROR(cannot_convert_to_return_type_protocol,none,
"return expression of type %0 does not conform to %1", (Type,Type))
ERROR(cannot_convert_return_type_to_anyobject,none,
"return expression of type %0 expected to be an instance of "
"a class or class-constrained type",
(Type, Type))
ERROR(cannot_convert_to_return_type_nil,none,
"'nil' is incompatible with return type %0", (Type))
ERROR(cannot_convert_thrown_type,none,
"thrown expression type %0 does not conform to 'Error'", (Type))
ERROR(cannot_throw_error_code,none,
"thrown error code type %0 does not conform to 'Error'; construct an %1 "
"instance", (Type, Type))
FIXIT(insert_type_coercion,
" %select{as!|as}0 %1",(bool, Type))
ERROR(bad_yield_count,none,
"expected %0 yield value(s)", (unsigned))
ERROR(cannot_throw_nil,none,
"cannot infer concrete Error for thrown 'nil' value", ())
ERROR(cannot_convert_raw_initializer_value,none,
"cannot convert value of type %0 to raw type %1", (Type,Type))
ERROR(cannot_convert_raw_initializer_value_nil,none,
"cannot convert 'nil' to raw type %0", (Type))
ERROR(cannot_convert_default_arg_value,none,
"default argument value of type %0 cannot be converted to type %1",
(Type,Type))
ERROR(cannot_convert_default_arg_value_protocol,none,
"default argument value of type %0 does not conform to %1", (Type,Type))
ERROR(cannot_convert_default_arg_value_nil,none,
"nil default argument value cannot be converted to type %0", (Type))
ERROR(cannot_convert_argument_value,none,
"cannot convert value of type %0 to expected argument type %1",
(Type,Type))
NOTE(candidate_has_invalid_argument_at_position,none,
"candidate expects %select{|in-out }2value of type %0 for parameter #%1",
(Type, unsigned, bool))
ERROR(cannot_convert_array_to_variadic,none,
"cannot pass array of type %0 as variadic arguments of type %1",
(Type,Type))
NOTE(candidate_would_match_array_to_variadic,none,
"candidate would match if array elements were passed as"
" variadic arguments of type %0", (Type))
NOTE(suggest_pass_elements_directly,none,
"remove brackets to pass array elements directly", ())
ERROR(cannot_convert_argument_value_generic,none,
"cannot convert value of type %0 (%1) to expected argument type %2 (%3)",
(Type, StringRef, Type, StringRef))
ERROR(conflicting_arguments_for_generic_parameter,none,
"conflicting arguments to generic parameter %0 (%1)",
(Type, StringRef))
// @_nonEphemeral conversion diagnostics
ERROR(cannot_pass_type_to_non_ephemeral,none,
"cannot pass %0 to parameter; argument %1 must be a pointer that "
"outlives the call%select{| to %3}2", (Type, StringRef, bool, DeclName))
WARNING(cannot_pass_type_to_non_ephemeral_warning,none,
"passing %0 to parameter, but argument %1 should be a pointer that "
"outlives the call%select{| to %3}2", (Type, StringRef, bool, DeclName))
ERROR(cannot_use_inout_non_ephemeral,none,
"cannot use inout expression here; argument %0 must be a pointer that "
"outlives the call%select{| to %2}1", (StringRef, bool, DeclName))
WARNING(cannot_use_inout_non_ephemeral_warning,none,
"inout expression creates a temporary pointer, but argument %0 should "
"be a pointer that outlives the call%select{| to %2}1",
(StringRef, bool, DeclName))
ERROR(cannot_construct_dangling_pointer,none,
"initialization of %0 results in a dangling %select{|buffer }1pointer",
(Type, unsigned))
WARNING(cannot_construct_dangling_pointer_warning,none,
"initialization of %0 results in a dangling %select{|buffer }1pointer",
(Type, unsigned))
NOTE(ephemeral_pointer_argument_conversion_note,none,
"implicit argument conversion from %0 to %1 produces a pointer valid only "
"for the duration of the call%select{| to %3}2",
(Type, Type, bool, DeclName))
NOTE(ephemeral_use_with_unsafe_pointer,none,
"use 'withUnsafe%select{Bytes|MutableBytes|Pointer|MutablePointer}0' in "
"order to explicitly convert argument to %select{buffer |buffer ||}0"
"pointer valid for a defined scope", (unsigned))
NOTE(ephemeral_use_string_with_c_string,none,
"use the 'withCString' method on String in order to explicitly "
"convert argument to pointer valid for a defined scope", ())
NOTE(ephemeral_use_array_with_unsafe_buffer,none,
"use the 'withUnsafe%select{Bytes|MutableBytes|BufferPointer|"
"MutableBufferPointer}0' method on Array in order to explicitly convert "
"argument to buffer pointer valid for a defined scope", (unsigned))
NOTE(candidate_performs_illegal_ephemeral_conv,none,
"candidate expects pointer that outlives the call for parameter #%0",
(unsigned))
ERROR(cannot_convert_argument_value_protocol,none,
"argument type %0 does not conform to expected type %1", (Type, Type))
ERROR(cannot_convert_argument_value_anyobject,none,
"argument type %0 expected to be an instance of "
"a class or class-constrained type",
(Type, Type))
ERROR(cannot_convert_argument_value_nil,none,
"'nil' is not compatible with expected argument type %0", (Type))
ERROR(cannot_convert_condition_value,none,
"cannot convert value of type %0 to expected condition type %1",
(Type, Type))
ERROR(cannot_convert_condition_value_nil,none,
"'nil' is not compatible with expected condition type %0", (Type))
ERROR(cannot_yield_rvalue_by_reference_same_type,none,
"cannot yield immutable value of type %0 as an inout yield", (Type))
ERROR(cannot_yield_rvalue_by_reference,none,
"cannot yield immutable value of type %0 as an inout yield of type %1",
(Type,Type))
ERROR(cannot_yield_wrong_type_by_reference,none,
"cannot yield reference to storage of type %0 as an inout yield of type %1",
(Type,Type))
ERROR(cannot_convert_yield_value,none,
"cannot convert value of type %0 to expected yield type %1",
(Type,Type))
ERROR(cannot_convert_yield_value_protocol,none,
"yielded type %0 does not conform to expected type %1",
(Type,Type))
ERROR(cannot_convert_yield_value_nil,none,
"nil is not compatible with expected yield type %0", (Type))
ERROR(cannot_convert_closure_result,none,
"cannot convert value of type %0 to closure result type %1",
(Type,Type))
ERROR(cannot_convert_closure_result_protocol,none,
"result value of type %0 does not conform to closure result type %1",
(Type, Type))
ERROR(cannot_convert_closure_result_nil,none,
"'nil' is not compatible with closure result type %0", (Type))
ERROR(cannot_convert_parent_type,none,
"cannot convert parent type %0 to expected type %1",
(Type, Type))
ERROR(cannot_convert_chain_result_type,none,
"member chain produces result of type %0 but contextual base was "
"inferred as %1",
(Type, Type))
NOTE(generic_argument_mismatch,none,
"arguments to generic parameter %0 (%1 and %2) are expected to be equal",
(Identifier, Type, Type))
ERROR(destructor_not_accessible,none,
"deinitializers cannot be accessed", ())
// Array Element
ERROR(cannot_convert_array_element,none,
"cannot convert value of type %0 to expected element type %1",
(Type,Type))
ERROR(cannot_convert_array_element_protocol,none,
"value of type %0 does not conform to expected element type %1",
(Type, Type))
ERROR(cannot_convert_array_element_nil,none,
"'nil' is not compatible with expected element type %0", (Type))
// Dictionary Key
ERROR(cannot_convert_dict_key,none,
"cannot convert value of type %0 to expected dictionary key type %1",
(Type,Type))
ERROR(cannot_convert_dict_key_protocol,none,
"value of type %0 does not conform to expected dictionary key type %1",
(Type, Type))
ERROR(cannot_convert_dict_key_nil,none,
"'nil' is not compatible with expected dictionary key type %0", (Type))
// Dictionary Value
ERROR(cannot_convert_dict_value,none,
"cannot convert value of type %0 to expected dictionary value type %1",
(Type,Type))
ERROR(cannot_convert_dict_value_protocol,none,
"value of type %0 does not conform to expected dictionary value type %1",
(Type, Type))
ERROR(cannot_convert_dict_value_nil,none,
"'nil' is not compatible with expected dictionary value type %0", (Type))
// Coerce Expr
ERROR(cannot_convert_coerce,none,
"cannot convert value of type %0 to type %1 in coercion",
(Type,Type))
ERROR(cannot_convert_coerce_protocol,none,
"value of type %0 does not conform to %1 in coercion",
(Type, Type))
ERROR(cannot_convert_coerce_nil,none,
"'nil' is not compatible with type %0 in coercion", (Type))
// Assign Expr
ERROR(cannot_convert_assign,none,
"cannot assign value of type %0 to type %1",
(Type,Type))
NOTE(assign_protocol_conformance_fix_it,none,
"add missing conformance to %0 to %1 %2",
(Type, DescriptiveDeclKind, Type))
ERROR(cannot_convert_assign_protocol,none,
"value of type %0 does not conform to %1 in assignment",
(Type, Type))
ERROR(cannot_convert_assign_anyobject,none,
"value of type %0 expected to be an instance of "
"a class or class-constrained type in assignment",
(Type, Type))
ERROR(cannot_convert_assign_nil,none,
"'nil' cannot be assigned to type %0", (Type))
// Subscript Assign Expr
ERROR(cannot_convert_subscript_assign,none,
"cannot assign value of type %0 to subscript of type %1",
(Type,Type))
ERROR(cannot_convert_subscript_assign_protocol,none,
"value of type %0 does not conform to %1 in subscript assignment",
(Type, Type))
ERROR(cannot_convert_subscript_assign_nil,none,
"'nil' cannot be assigned to subscript of type %0", (Type))
NOTE(cannot_convert_candidate_result_to_contextual_type,none,
"%0 produces %1, not the expected contextual result type %2",
(DeclName, Type, Type))
// for ... in expression
ERROR(cannot_convert_sequence_element_value,none,
"cannot convert sequence element type %0 to expected type %1",
(Type, Type))
ERROR(cannot_convert_sequence_element_protocol,none,
"sequence element type %0 does not conform to expected protocol %1",
(Type, Type))
ERROR(throws_functiontype_mismatch,none,
"invalid conversion from throwing function of type %0 to "
"non-throwing function type %1", (Type, Type))
ERROR(async_functiontype_mismatch,none,
"invalid conversion from 'async' function of type %0 to "
"synchronous function type %1", (Type, Type))
// Key-path expressions.
ERROR(expr_keypath_no_objc_runtime,none,
"'#keyPath' can only be used with the Objective-C runtime", ())
ERROR(expression_unused_keypath_result,none,
"result of key path is unused", ())
ERROR(expr_keypath_non_objc_property,none,
"argument of '#keyPath' refers to non-'@objc' property %0",
(Identifier))
WARNING(expr_keypath_swift3_objc_inference,none,
"argument of '#keyPath' refers to property %0 in %1 that depends on "
"'@objc' inference deprecated in Swift 4",
(Identifier, Identifier))
ERROR(expr_keypath_type_of_property,none,
"cannot refer to type member %0 within instance of type %1",
(DeclNameRef, Type))
ERROR(expr_keypath_generic_type,none,
"key path cannot refer to generic type %0", (Identifier))
ERROR(expr_keypath_not_property,none,
"%select{key path|dynamic key path member lookup}2 cannot refer to %0 %1",
(DescriptiveDeclKind, DeclName, bool))
ERROR(expr_keypath_mutating_getter,none,
"%select{key path|dynamic key path member lookup}1 cannot refer to %0, "
"which has a mutating getter",
(DeclName, bool))
ERROR(expr_keypath_static_member,none,
"%select{key path|dynamic key path member lookup}1 cannot refer to static member %0",
(DeclName, bool))
ERROR(expr_keypath_enum_case,none,
"%select{key path|dynamic key path member lookup}1 cannot refer to enum case %0",
(DeclName, bool))
ERROR(expr_keypath_empty,none,
"empty key path does not refer to a property", ())
ERROR(expr_unsupported_objc_key_path_component,none,
"an Objective-C key path cannot contain "
"%select{BAD|subscript|BAD|BAD|optional-forcing|optional-chaining|BAD} "
"components",
(unsigned))
ERROR(expr_unsupported_objc_key_path_compound_name,none,
"an Objective-C key path cannot reference a declaration with a "
"compound name", ())
ERROR(expr_keypath_no_keypath_type,none,
"broken standard library: no 'KeyPath' type found", ())
ERROR(expr_swift_keypath_invalid_component,none,
"invalid component of Swift key path", ())
ERROR(expr_swift_keypath_not_starting_with_type,none,
"a Swift key path must begin with a type", ())
ERROR(expr_swift_keypath_not_starting_with_dot,none,
"a Swift key path with contextual root must begin with a leading dot",
())
ERROR(expr_smart_keypath_value_covert_to_contextual_type,none,
"key path value type %0 cannot be converted to contextual type %1",
(Type, Type))
ERROR(expr_swift_keypath_empty, none,
"key path must have at least one component", ())
ERROR(expr_string_interpolation_outside_string,none,
"string interpolation can only appear inside a string literal", ())
ERROR(expr_keypath_subscript_index_not_hashable, none,
"subscript index of type %0 in a key path must be Hashable", (Type))
ERROR(expr_smart_keypath_application_type_mismatch,none,
"key path of type %0 cannot be applied to a base of type %1",
(Type, Type))
ERROR(expr_keypath_root_type_mismatch, none,
"key path with root type %0 cannot be applied to a base of type %1",
(Type, Type))
ERROR(expr_swift_keypath_anyobject_root,none,
"the root type of a Swift key path cannot be 'AnyObject'", ())
ERROR(expr_keypath_multiparam_func_conversion, none,
"cannot convert key path into a multi-argument function type %0", (Type))
WARNING(expr_deprecated_writable_keypath,none,
"forming a writable keypath to property %0 that is read-only in this context "
"is deprecated and will be removed in a future release",(DeclName))
// Selector expressions.
ERROR(expr_selector_no_objc_runtime,none,
"'#selector' can only be used with the Objective-C runtime", ())
ERROR(expr_selector_module_missing,none,
"import the 'ObjectiveC' module to use '#selector'", ())
ERROR(expr_selector_no_declaration,none,
"argument of '#selector' does not refer to an '@objc' method, property, "
"or initializer", ())
ERROR(expr_selector_not_method,none,
"argument of '#selector' cannot refer to %select{local|global}0 "
"function %1", (bool, DeclName))
ERROR(expr_selector_expected_property,none,
"cannot reference %1 %2 as a property; remove '%select{getter|setter}0:'",
(bool, DescriptiveDeclKind, DeclName))
ERROR(expr_selector_not_property,none,
"argument of '#selector' cannot refer to %select{variable|parameter}0 %1",
(bool, DeclName))
ERROR(expr_selector_expected_method,none,
"use 'getter:'%select{| or 'setter:'}0 to refer to the Objective-C getter"
"%select{| or setter}0 of property %1%select{|, respectively}0",
(bool, DeclName))
NOTE(expr_selector_add_modifier,none,
"add '%select{getter|setter}0:' to reference the Objective-C "
"%select{getter|setter}0 for %1", (bool, DeclName))
ERROR(expr_selector_property_not_settable,none,
"argument of '#selector(setter:)' refers to non-settable %0 %1",
(DescriptiveDeclKind, DeclName))
ERROR(expr_selector_property_setter_inaccessible,none,
"setter of %0 %1 is inaccessible", (DescriptiveDeclKind, DeclName))
ERROR(expr_selector_cannot_be_used,none,
"cannot use %0 as a selector because protocol %1 is not exposed to Objective-C",
(DeclBaseName, Identifier))
ERROR(expr_selector_not_objc,none,
"argument of '#selector' refers to %0 %1 that is not exposed to "
"Objective-C",
(DescriptiveDeclKind, DeclName))
NOTE(make_decl_objc,none,
"add '@objc' to expose this %0 to Objective-C",
(DescriptiveDeclKind))
WARNING(expr_selector_swift3_objc_inference,none,
"argument of '#selector' refers to %0 %1 in %2 that depends on "
"'@objc' inference deprecated in Swift 4",
(DescriptiveDeclKind, DeclName, Identifier))
// Selectors-as-string-literals.
WARNING(selector_literal_invalid,none,
"string literal is not a valid Objective-C selector", ())
WARNING(selector_literal_undeclared,none,
"no method declared with Objective-C selector %0", (ObjCSelector))
WARNING(selector_literal_deprecated,none,
"use of string literal for Objective-C selectors is deprecated; "
"use '#selector' or explicitly construct a 'Selector'", ())
WARNING(selector_literal_deprecated_suggest,none,
"use of string literal for Objective-C selectors is deprecated; "
"use '#selector' instead", ())
WARNING(selector_construction_suggest,none,
"use '#selector' instead of explicitly constructing a 'Selector'", ())
NOTE(selector_construction_suppress_warning,none,
"wrap the selector name in parentheses to suppress this warning", ())
ERROR(cannot_return_value_from_void_func,none,
"unexpected non-void return value in void function", ())
NOTE(add_return_type_note,none,
"did you mean to add a return type?", ())
//------------------------------------------------------------------------------
// MARK: Import Resolution
//------------------------------------------------------------------------------
ERROR(sema_no_import,Fatal,
"no such module '%0'", (StringRef))
ERROR(sema_no_import_target,Fatal,
"could not find module '%0' for target '%1'; "
"found: %2, at: %3", (StringRef, StringRef, StringRef, StringRef))
ERROR(sema_no_import_repl,none,
"no such module '%0'", (StringRef))
NOTE(sema_no_import_no_sdk,none,
"did you forget to set an SDK using -sdk or SDKROOT?", ())
NOTE(sema_no_import_no_sdk_xcrun,none,
"use \"xcrun swiftc\" to select the default macOS SDK "
"installed with Xcode", ())
WARNING(sema_import_current_module,none,
"this file is part of module %0; ignoring import", (Identifier))
WARNING(sema_import_current_module_with_file,none,
"file '%0' is part of module %1; ignoring import",
(StringRef, Identifier))
ERROR(sema_opening_import,Fatal,
"opening import file for module %0: %1", (Identifier, StringRef))
ERROR(serialization_load_failed,Fatal,
"failed to load module '%0'", (StringRef))
ERROR(module_interface_build_failed,Fatal,
"failed to %select{build module '%1' for importation|"
"verify module interface of '%1'}0 due to the errors above; "
"the textual interface may be broken by project issues"
"%select{, differences between compilers (the producer '%3' and this compiler '%4')|}2 or a compiler bug",
(bool, StringRef, bool, StringRef, StringRef))
ERROR(module_interface_build_failed_mismatching_compiler,Fatal,
"failed to build module '%0'; this SDK is not supported by the compiler "
"(the SDK is built with '%1', while this compiler is '%2'). Please select a toolchain which matches the SDK.",
(StringRef, StringRef, StringRef))
ERROR(serialization_malformed_module,Fatal,
"malformed compiled module: %0", (StringRef))
ERROR(serialization_module_too_new,Fatal,
"compiled module was created by a newer version of the compiler: %0",
(StringRef))
ERROR(serialization_module_language_version_mismatch,Fatal,
"module compiled with Swift %0 cannot be imported by the Swift %1 "
"compiler: %2",
(StringRef, StringRef, StringRef))
ERROR(serialization_module_too_old,Fatal,
"compiled module was created by an older version of the compiler; "
"rebuild %0 and try again: %1",
(Identifier, StringRef))
ERROR(serialization_missing_single_dependency,Fatal,
"missing required module '%0'", (StringRef))
ERROR(serialization_missing_dependencies,Fatal,
"missing required modules: %0", (StringRef))
ERROR(serialization_circular_dependency,Fatal,
"circular dependency between modules '%0' and %1",
(StringRef, Identifier))
ERROR(serialization_missing_underlying_module,Fatal,
"cannot load underlying module for %0", (Identifier))
ERROR(serialization_name_mismatch,Fatal,
"cannot load module '%0' as '%1'", (StringRef, StringRef))
ERROR(serialization_name_mismatch_repl,none,
"cannot load module '%0' as '%1'", (StringRef, StringRef))
ERROR(serialization_target_incompatible,Fatal,
"module %0 was created for incompatible target %1: %2",
(Identifier, StringRef, StringRef))
ERROR(serialization_target_incompatible_repl,none,
"module %0 was created for incompatible target %1: %2",
(Identifier, StringRef, StringRef))
ERROR(serialization_target_too_new,Fatal,
"compiling for %0 %1, but module %2 has a minimum "
"deployment target of %0 %3: %4",
(StringRef, llvm::VersionTuple, Identifier, llvm::VersionTuple,
StringRef))
ERROR(serialization_target_too_new_repl,none,
"compiling for %0 %1, but module %2 has a minimum "
"deployment target of %0 %3: %4",
(StringRef, llvm::VersionTuple, Identifier, llvm::VersionTuple,
StringRef))
ERROR(serialization_fatal,Fatal,
"fatal error encountered while reading from module '%0'; "
SWIFT_BUG_REPORT_MESSAGE,
(StringRef))
NOTE(serialization_misc_version,none,
"module '%0' full misc version is '%1'",
(StringRef, StringRef))
NOTE(serialization_compatibility_version_mismatch,none,
"compiling as Swift %0, with '%1' built as Swift %2 "
"(this is supported but may expose additional compiler issues)",
(StringRef, StringRef, StringRef))
ERROR(serialization_invalid_decl,Fatal,
"deserialized invalid declaration %0 (%1) in module '%2'",
(DeclName, DescriptiveDeclKind, StringRef))
ERROR(serialization_allowing_invalid_decl,none,
"allowing deserialization of invalid declaration %0 (%1) in module '%2'",
(DeclName, DescriptiveDeclKind, StringRef))
ERROR(serialization_error_type,Fatal,
"deserialized error type '%0' in module '%1'",
(StringRef, StringRef))
ERROR(serialization_allowing_error_type,none,
"allowing deserialization of error type '%0' in module '%1'",
(StringRef, StringRef))
ERROR(reserved_member_name,none,
"type member must not be named %0, since it would conflict with the"
" 'foo.%1' expression", (DeclName, StringRef))
NOTE(invalid_redecl_by_optionality_note,none,
"%select{implicitly unwrapped |}0optional parameter is of "
"same type as %select{implicitly unwrapped |}1optional parameter",
(bool, bool))
ERROR(invalid_redecl,none,"invalid redeclaration of %0", (DeclName))
ERROR(invalid_redecl_init,none,
"invalid redeclaration of synthesized %select{|memberwise }1%0",
(DeclName, bool))
ERROR(invalid_redecl_implicit,none,
"invalid redeclaration of synthesized "
"%select{%0|implementation for protocol requirement}1 %2",
(DescriptiveDeclKind, bool, DeclName))
WARNING(invalid_redecl_swift5_warning,none,
"redeclaration of %0 is deprecated and will be an error in Swift 5",
(DeclName))
NOTE(invalid_redecl_prev,none,
"%0 previously declared here", (DeclName))
NOTE(invalid_redecl_implicit_wrapper,none,
"%0 synthesized for property wrapper "
"%select{projected value|backing storage}1",
(DeclName, bool))
ERROR(ambiguous_type_base,none,
"%0 is ambiguous for type lookup in this context", (DeclNameRef))
ERROR(invalid_member_type,none,
"%0 is not a member type of %1 %2",
(DeclNameRef, DescriptiveDeclKind, FullyQualified<Type>))
ERROR(invalid_member_type_suggest,none,
"%0 does not have a member type named %1; did you mean %2?",
(Type, DeclNameRef, DeclName))
ERROR(invalid_member_reference,none,
"%0 %1 is not a member type of %2",
(DescriptiveDeclKind, DeclName, Type))
ERROR(ambiguous_member_type,none,
"ambiguous type name %0 in %1", (DeclNameRef, Type))
ERROR(no_module_type,none,
"no type named %0 in module %1", (DeclNameRef, Identifier))
ERROR(ambiguous_module_type,none,
"ambiguous type name %0 in module %1", (DeclNameRef, Identifier))
ERROR(use_nonmatching_operator,none,
"%0 is not a %select{binary|prefix unary|postfix unary}1 operator",
(DeclNameRef, unsigned))
ERROR(unsupported_recursion_in_associated_type_reference,none,
"unsupported recursion for reference to %select{associated type|type alias}0 %1 of type %2",
(bool, Identifier, Type))
ERROR(broken_associated_type_witness,none,
"reference to invalid %select{associated type|type alias}0 %1 of type %2",
(bool, Identifier, Type))
ERROR(unspaced_binary_operator_fixit,none,
"missing whitespace between %0 and %1 operators",
(Identifier, Identifier, bool))
ERROR(unspaced_binary_operator,none,
"ambiguous missing whitespace between unary and binary operators", ())
NOTE(unspaced_binary_operators_candidate,none,
"could be %select{binary|postfix}2 %0 and %select{prefix|binary}2 %1",
(Identifier, Identifier, bool))
ERROR(unspaced_unary_operator,none,
"unary operators must not be juxtaposed; parenthesize inner expression",
())
ERROR(nonexistent_power_operator,none,
"no operator '**' is defined; did you mean 'pow(_:_:)'?",
())
ERROR(cannot_find_in_scope,none,
"cannot %select{find|find operator}1 %0 in scope", (DeclNameRef, bool))
ERROR(cannot_find_in_scope_corrected,none,
"cannot %select{find|find operator}1 %0 in scope; did you mean '%2'?",
(DeclNameRef, bool, StringRef))
NOTE(confusable_character,none,
"%select{identifier|operator}0 '%1' contains possibly confused characters; "
"did you mean to use '%2'?",
(bool, StringRef, StringRef))
NOTE(single_confusable_character,none,
"%select{identifier|operator}0 '%1' (%2) looks similar to '%3' (%4); did you mean '%3' (%4)?",
(bool, StringRef, StringRef, StringRef, StringRef))
ERROR(cannot_find_type_in_scope,none,
"cannot find type %0 in scope", (DeclNameRef))
ERROR(cannot_find_type_in_scope_did_you_mean,none,
"cannot find type %0 in scope; did you mean to use '%1'?", (DeclNameRef, StringRef))
NOTE(note_typo_candidate_implicit_member,none,
"did you mean the implicitly-synthesized %1 '%0'?", (StringRef, StringRef))
NOTE(note_remapped_type,none,
"did you mean to use '%0'?", (StringRef))
NOTE(note_module_as_type,none,
"cannot use module %0 as a type", (Identifier))
ERROR(use_unknown_object_literal_protocol,none,
"cannot deduce protocol for %0 literal", (StringRef))
ERROR(object_literal_default_type_missing,none,
"could not infer type of %0 literal", (StringRef))
NOTE(object_literal_resolve_import,none,
"import %0 to use '%1' as the default %2 literal type",
(StringRef, StringRef, StringRef))
ERROR(use_local_before_declaration,none,
"use of local variable %0 before its declaration", (DeclNameRef))
ERROR(unsupported_existential_type,none,
"protocol %0 can only be used as a generic constraint because it has "
"Self or associated type requirements", (Identifier))
ERROR(decl_does_not_exist_in_module,none,
"%select{%error|type|struct|class|enum|protocol|variable|function}0 "
"%1 does not exist in module %2",
(/*ImportKind*/ unsigned, Identifier, Identifier))
ERROR(imported_decl_is_wrong_kind,none,
"%0 was imported as '%1', but is "
"%select{%error|a type|a struct|a class|an enum|a protocol|a variable|"
"a function}2",
(Identifier, StringRef, /*ImportKind*/ unsigned))
ERROR(imported_decl_is_wrong_kind_typealias,none,
"%0 %1 cannot be imported as '%2'",
(DescriptiveDeclKind, Type, StringRef))
ERROR(ambiguous_decl_in_module,none,
"ambiguous name %0 in module %1", (Identifier, Identifier))
ERROR(module_not_testable,Fatal,
"module %0 was not compiled for testing", (Identifier))
ERROR(module_not_compiled_for_private_import,none,
"module %0 was not compiled for private import", (Identifier))
ERROR(import_implementation_cannot_be_exported,none,
"module %0 cannot be both exported and implementation-only", (Identifier))
WARNING(module_not_compiled_with_library_evolution,none,
"module %0 was not compiled with library evolution support; "
"using it means binary compatibility for %1 can't be guaranteed",
(Identifier, Identifier))
REMARK(cross_import_added,none,
"import of %0 and %1 triggered a cross-import of %2",
(Identifier, Identifier, Identifier))
REMARK(module_loaded,none,
"loaded module at %0",
(StringRef))
// Operator decls
ERROR(ambiguous_operator_decls,none,
"ambiguous operator declarations found for operator", ())
NOTE(found_this_operator_decl,none,
"found this matching operator declaration", ())
ERROR(operator_redeclared,none,
"operator redeclared", ())
NOTE(previous_operator_decl,none,
"previous operator declaration here", ())
ERROR(declared_operator_without_operator_decl,none,
"operator implementation without matching operator declaration", ())
ERROR(declared_unary_op_without_attribute,none,
"unary operator implementation must have a 'prefix' or 'postfix' modifier", ())
ERROR(unary_op_missing_prepos_attribute,none,
"%select{prefix|postfix}0 unary operator missing "
"'%select{prefix|postfix}0' modifier", (bool))
NOTE(unary_operator_declaration_here,none,
"%select{prefix|postfix}0 operator found here", (bool))
ERROR(invalid_arg_count_for_operator,none,
"operators must have one or two arguments", ())
ERROR(operator_in_local_scope,none,
"operator functions can only be declared at global or in type scope", ())
ERROR(nonstatic_operator_in_nominal,none,
"operator %0 declared in type %1 must be 'static'",
(Identifier, DeclName))
ERROR(nonstatic_operator_in_extension,none,
"operator %0 declared in extension%select{| of %2}1 must be 'static'",
(Identifier, bool, TypeRepr*))
ERROR(nonfinal_operator_in_class,none,
"operator %0 declared in non-final class %1 must be 'final'",
(Identifier, Type))
ERROR(operator_in_unrelated_type,none,
"member operator %2%select{| of protocol %0}1 must have at least one "
"argument of type %select{%0|'Self'}1", (Type, bool, DeclName))
// Precedence groups
ERROR(ambiguous_precedence_groups,none,
"multiple precedence groups found", ())
NOTE(found_this_precedence_group,none,
"found this matching precedence group", ())
ERROR(unknown_precedence_group,none,
"unknown precedence group %0", (Identifier))
ERROR(precedence_group_cycle,none,
"cycle in '%select{lowerThan|higherThan}0' relation", (bool))
ERROR(higher_than_precedence_group_cycle,none,
"cycle in higherThan relation: %0", (StringRef))
ERROR(precedence_group_lower_within_module,none,
"precedence group cannot be given lower precedence than group in same"
" module; make the other precedence group higher than this one instead",
())
ERROR(precedence_group_redeclared,none,
"precedence group redeclared", ())
NOTE(previous_precedence_group_decl,none,
"previous precedence group declaration here", ())
NOTE(circular_reference_through_precedence_group, none,
"through reference to precedence group %0 here", (Identifier))
//------------------------------------------------------------------------------
// MARK: Expression Type Checking Errors
//------------------------------------------------------------------------------
ERROR(tuple_types_not_convertible_nelts,none,
"%0 is not convertible to %1, "
"tuples have a different number of elements", (Type, Type))
ERROR(tuple_types_not_convertible,none,
"tuple type %0 is not convertible to tuple type %1", (Type, Type))
ERROR(invalid_force_unwrap,none,
"cannot force unwrap value of non-optional type %0", (Type))
ERROR(invalid_optional_chain,none,
"cannot use optional chaining on non-optional value of type %0",
(Type))
ERROR(if_expr_cases_mismatch,none,
"result values in '? :' expression have mismatching types %0 and %1",
(Type, Type))
ERROR(did_not_call_function_value,none,
"function value was used as a property; add () to call it",
())
ERROR(did_not_call_function,none,
"function %0 was used as a property; add () to call it",
(Identifier))
ERROR(did_not_call_method,none,
"method %0 was used as a property; add () to call it",
(Identifier))
ERROR(init_not_instance_member_use_assignment,none,
"'init' is a member of the type; use assignment "
"to initialize the value instead", ())
ERROR(init_not_instance_member,none,
"'init' is a member of the type; use 'type(of: ...)' to initialize "
"a new object of the same dynamic type", ())
ERROR(super_initializer_not_in_initializer,none,
"'super.init' cannot be called outside of an initializer", ())
WARNING(isa_is_always_true,none, "'%0' test is always true",
(StringRef))
WARNING(isa_is_foreign_check,none,
"'is' test is always true because %0 is a Core Foundation type",
(Type))
WARNING(checked_cast_not_supported,none,
"runtime conversion from %0 to %1 is not supported; "
"%select{'is' test|cast}2 always fails",
(Type, Type, unsigned))
NOTE(checked_cast_not_supported_coerce_instead,none,
"consider using 'as' coercion instead", ())
WARNING(conditional_downcast_coercion,none,
"conditional cast from %0 to %1 always succeeds",
(Type, Type))
WARNING(literal_conditional_downcast_to_coercion,none,
"conditional downcast from literal to %0 always fails; "
"consider using 'as' coercion",
(Type))
WARNING(forced_downcast_noop,none,
"forced cast of %0 to same type has no effect", (Type))
WARNING(forced_downcast_coercion,none,
"forced cast from %0 to %1 always succeeds; did you mean to use 'as'?",
(Type, Type))
// Note: the Boolean at the end indicates whether bridging is required after
// the cast.
WARNING(downcast_same_type,none,
"forced cast from %0 to %1 %select{only unwraps optionals|only unwraps "
"and bridges}3; did you mean to use '%2'%select{| with 'as'}3?",
(Type, Type, StringRef, bool))
// The unsigned value can be 0 (types are equal), 1 (types implicitly convert),
// or 2 (types bridge).
WARNING(conditional_downcast_same_type,none,
"conditional downcast from %0 to %1 %select{does nothing|"
"is equivalent to an implicit conversion to an optional %1|is a "
"bridging conversion; did you mean to use 'as'?}2",
(Type, Type, unsigned))
WARNING(is_expr_same_type,none,
"checking a value with optional type %0 against dynamic type %1 "
"succeeds whenever the value is non-nil; did you mean to use "
"'!= nil'?", (Type, Type))
WARNING(downcast_to_unrelated,none,
"cast from %0 to unrelated type %1 always fails", (Type, Type))
NOTE(downcast_to_unrelated_fixit,none,
"did you mean to call %0 with '()'?", (Identifier))
ERROR(optional_chain_noop,none,
"optional chain has no effect, expression already produces %0",
(Type))
ERROR(optional_chain_isnt_chaining,none,
"'?' must be followed by a call, member lookup, or subscript",
())
ERROR(pattern_in_expr,none,
"%0 cannot appear in an expression", (PatternKind))
NOTE(note_call_to_operator,none,
"in call to operator %0", (DeclName))
NOTE(note_call_to_func,none,
"in call to function %0", (DeclName))
NOTE(note_call_to_subscript,none,
"in call to %0", (DeclName))
NOTE(note_call_to_initializer,none,
"in call to initializer", ())
NOTE(note_init_parameter,none,
"in initialization of parameter %0", (Identifier))
ERROR(missing_nullary_call,none,
"function produces expected type %0; did you mean to call it with '()'?",
(Type))
ERROR(optional_not_unwrapped,none,
"value of optional type %0 must be unwrapped to a value of type %1",
(Type, Type))
NOTE(unwrap_with_default_value,none,
"coalesce using '?" "?' to provide a default when the optional value "
"contains 'nil'", ())
NOTE(unwrap_with_force_value,none,
"force-unwrap using '!' to abort execution if the optional value contains "
"'nil'", ())
NOTE(unwrap_iuo_initializer,none,
"value inferred to be type %0 when initialized with an implicitly "
"unwrapped value", (Type))
NOTE(unwrap_with_guard,none,
"short-circuit using 'guard' to exit this function early "
"if the optional value contains 'nil'", ())
ERROR(optional_base_not_unwrapped,none,
"value of optional type %0 must be unwrapped to refer to member %1 of "
"wrapped base type %2", (Type, DeclNameRef, Type))
ERROR(invalid_optional_infered_keypath_root, none,
"key path root inferred as optional type %0 must be unwrapped to refer to member %1 "
"of unwrapped type %2", (Type, DeclNameRef, Type))
NOTE(optional_base_chain,none,
"chain the optional using '?' to access member %0 only for non-'nil' "
"base values", (DeclNameRef))
NOTE(optional_base_remove_optional_for_keypath_root, none,
"use unwrapped type %0 as key path root", (Type))
NOTE(optional_keypath_application_base, none,
"use '?' to access key path subscript only for non-'nil' base values", ())
NOTE(optional_key_path_root_base_chain, none,
"chain the optional using '?.' to access unwrapped type member %0",
(DeclNameRef))
NOTE(optional_key_path_root_base_unwrap, none,
"unwrap the optional using '!.' to access unwrapped type member %0",
(DeclNameRef))
ERROR(missing_unwrap_optional_try,none,
"value of optional type %0 not unwrapped; did you mean to use 'try!' "
"or chain with '?'?",
(Type))
ERROR(cannot_coerce_to_type, none,
"%0 is not convertible to %1", (Type, Type))
NOTE(missing_forced_downcast, none,
"did you mean to use 'as!' to force downcast?", ())
NOTE(missing_optional_downcast, none,
"did you mean to use 'as?' to conditionally downcast?", ())
WARNING(coercion_may_fail_warning,none,
"coercion from %0 to %1 may fail; use 'as?' or 'as!' instead",
(Type, Type))
ERROR(missing_explicit_conversion,none,
"%0 is not implicitly convertible to %1; "
"did you mean to use 'as' to explicitly convert?", (Type, Type))
ERROR(missing_address_of,none,
"passing value of type %0 to an inout parameter requires explicit '&'",
(Type))
ERROR(missing_address_of_yield,none,
"yielding mutable value of type %0 requires explicit '&'",
(Type))
ERROR(extraneous_address_of,none,
"use of extraneous '&'",
())
ERROR(extra_address_of,none,
"'&' used with non-inout argument of type %0",
(Type))
ERROR(extra_address_of_unsafepointer,none,
"'&' is not allowed passing array value as %0 argument",
(Type))
ERROR(cannot_pass_inout_arg_to_subscript,none,
"cannot pass an inout argument to a subscript; use "
"'withUnsafeMutablePointer' to explicitly convert argument "
"to a pointer", ())
ERROR(incorrect_property_wrapper_reference,none,
"cannot convert value %0 of type %1 to expected type %2, "
"use %select{wrapper|wrapped value}3 instead",
(Identifier, Type, Type, bool))
ERROR(incorrect_property_wrapper_reference_member,none,
"referencing %0 %1 requires %select{wrapper|wrapped value of type}2 %3",
(DescriptiveDeclKind, DeclName, bool, Type))
ERROR(missing_init_on_metatype_initialization,none,
"initializing from a metatype value must reference 'init' explicitly",
())
ERROR(extra_argument_labels,none,
"extraneous argument label%select{|s}0 '%1' in %select{call|subscript}2",
(bool, StringRef, bool))
ERROR(missing_argument_labels,none,
"missing argument label%select{|s}0 '%1' in %select{call|subscript}2",
(bool, StringRef, bool))
ERROR(wrong_argument_labels,none,
"incorrect argument label%select{|s}0 in %select{call|subscript}3 "
"(have '%1', expected '%2')",
(bool, StringRef, StringRef, bool))
ERROR(argument_out_of_order_named_named,none,
"argument %0 must precede argument %1", (Identifier, Identifier))
ERROR(argument_out_of_order_named_unnamed,none,
"argument %0 must precede unnamed argument #%1", (Identifier, unsigned))
ERROR(argument_out_of_order_unnamed_named,none,
"unnamed argument #%0 must precede argument %1", (unsigned, Identifier))
ERROR(argument_out_of_order_unnamed_unnamed,none,
"unnamed argument #%0 must precede unnamed argument #%1",
(unsigned, unsigned))
ERROR(argument_out_of_order_binary_op,none,
"operator argument #%0 must precede operator argument #%1",
(unsigned, unsigned))
NOTE(candidate_expected_different_labels,none,
"incorrect labels for candidate (have: '%0', expected: '%1')",
(StringRef, StringRef))
ERROR(member_shadows_function,none,
"use of %0 refers to %1 rather than %2 %3",
(DeclNameRef, DescriptiveDeclKind, DescriptiveDeclKind, DeclName))
ERROR(member_shadows_global_function,none,
"use of %0 refers to %1 rather than %2 %3 in module %4",
(DeclNameRef, DescriptiveDeclKind, DescriptiveDeclKind, DeclName, DeclName))
ERROR(instance_member_use_on_type,none,
"instance member %1 cannot be used on type %0; "
"did you mean to use a value of this type instead?", (Type, DeclNameRef))
ERROR(instance_member_in_initializer,none,
"cannot use instance member %0 within property initializer; "
"property initializers run before 'self' is available", (DeclNameRef))
ERROR(instance_member_in_default_parameter,none,
"cannot use instance member %0 as a default parameter", (DeclNameRef))
ERROR(missing_argument_named,none,
"missing argument for parameter %0 in call", (Identifier))
ERROR(missing_argument_positional,none,
"missing argument for parameter #%0 in call", (unsigned))
ERROR(missing_arguments_in_call,none,
"missing arguments for parameters %0 in call", (StringRef))
ERROR(extra_argument_named,none,
"extra argument %0 in call", (Identifier))
ERROR(extra_argument_positional,none,
"extra argument in call", ())
ERROR(extra_arguments_in_call,none,
"extra arguments at positions %0 in call", (StringRef))
ERROR(extra_argument_to_nullary_call,none,
"argument passed to call that takes no arguments", ())
ERROR(extra_trailing_closure_in_call,none,
"extra trailing closure passed in call", ())
ERROR(trailing_closure_bad_param,none,
"trailing closure passed to parameter of type %0 that does not "
"accept a closure", (Type))
WARNING(unlabeled_trailing_closure_deprecated,none,
"backward matching of the unlabeled trailing closure is deprecated; label the argument with %0 to suppress this warning",
(Identifier))
NOTE(decl_multiple_defaulted_closure_parameters,none,
"%0 contains defaulted closure parameters %1 and %2",
(DeclName, Identifier, Identifier))
NOTE(candidate_with_extraneous_args,none,
"candidate %0 requires %1 argument%s1, "
"but %2 %select{were|was}3 %select{provided|used in closure body}4",
(Type, unsigned, unsigned, bool, bool))
ERROR(no_accessible_initializers,none,
"%0 cannot be constructed because it has no accessible initializers",
(Type))
ERROR(non_nominal_no_initializers,none,
"non-nominal type %0 does not support explicit initialization",
(Type))
ERROR(unbound_generic_parameter,none,
"generic parameter %0 could not be inferred", (Type))
ERROR(unbound_generic_parameter_cast,none,
"generic parameter %0 could not be inferred in cast to %1", (Type, Type))
NOTE(archetype_declared_in_type,none,
"%0 declared as parameter to type %1", (Type, Type))
NOTE(unbound_generic_parameter_explicit_fix,none,
"explicitly specify the generic arguments to fix this issue", ())
ERROR(invalid_dynamic_callable_type,none,
"@dynamicCallable attribute requires %0 to have either a valid "
"'dynamicallyCall(withArguments:)' method or "
"'dynamicallyCall(withKeywordArguments:)' method", (Type))
ERROR(missing_dynamic_callable_kwargs_method,none,
"@dynamicCallable type %0 cannot be applied with keyword arguments; "
"missing 'dynamicCall(withKeywordArguments:)' method", (Type))
ERROR(invalid_dynamic_member_lookup_type,none,
"@dynamicMemberLookup attribute requires %0 to have a "
"'subscript(dynamicMember:)' method that accepts either "
"'ExpressibleByStringLiteral' or a key path", (Type))
NOTE(invalid_dynamic_member_subscript, none,
"add an explicit argument label to this subscript to satisfy "
"the @dynamicMemberLookup requirement", ())
ERROR(string_index_not_integer,none,
"String must not be indexed with %0, it has variable size elements",
(Type))
NOTE(string_index_not_integer_note,none,
"consider using an existing high level algorithm, "
"str.startIndex.advanced(by: n), or a projection like str.utf8", ())
ERROR(invalid_c_function_pointer_conversion_expr,none,
"a C function pointer can only be formed from a reference to a 'func' or "
"a literal closure", ())
ERROR(c_function_pointer_from_method,none,
"a C function pointer cannot be formed from a method", ())
ERROR(c_function_pointer_from_generic_function,none,
"a C function pointer cannot be formed from a reference to a generic "
"function", ())
ERROR(invalid_autoclosure_forwarding,none,
"add () to forward @autoclosure parameter", ())
ERROR(invalid_differentiable_function_conversion_expr,none,
"a '@differentiable' function can only be formed from "
"a reference to a 'func' or 'init' or a literal closure", ())
NOTE(invalid_differentiable_function_conversion_parameter,none,
"did you mean to take a '%0' closure?", (StringRef))
ERROR(invalid_autoclosure_pointer_conversion,none,
"cannot perform pointer conversion of value of type %0 to autoclosure "
"result type %1",
(Type, Type))
//------------------------------------------------------------------------------
// MARK: Type Check Declarations
//------------------------------------------------------------------------------
ERROR(missing_initializer_def,PointsToFirstBadToken,
"initializer requires a body", ())
WARNING(pound_warning, none, "%0", (StringRef))
ERROR(pound_error, none, "%0", (StringRef))
// Attributes
ERROR(operator_not_func,none,
"operators must be declared with 'func'", ())
ERROR(redefining_builtin_operator,none,
"cannot declare a custom %0 '%1' operator", (StringRef, StringRef))
ERROR(attribute_requires_operator_identifier,none,
"'%0' requires a function with an operator identifier", (StringRef))
ERROR(attribute_requires_single_argument,none,
"'%0' requires a function with one argument", (StringRef))
ERROR(nominal_type_not_attribute,none,
"%0 %1 cannot be used as an attribute", (DescriptiveDeclKind, Identifier))
ERROR(mutating_invalid_global_scope,none, "%0 is only valid on methods",
(SelfAccessKind))
ERROR(mutating_invalid_classes,none, "%0 is not valid on %1s in "
"%select{classes|class-bound protocols}2",
(SelfAccessKind, DescriptiveDeclKind, bool))
ERROR(functions_mutating_and_not,none,
"method must not be declared both %0 and %1",
(SelfAccessKind, SelfAccessKind))
ERROR(static_functions_not_mutating,none,
"static functions must not be declared mutating", ())
ERROR(modify_mutatingness_differs_from_setter,none,
"'modify' accessor cannot be %0 when the setter is %1",
(SelfAccessKind, SelfAccessKind))
ERROR(transparent_in_protocols_not_supported,none,
"'@_transparent' attribute is not supported on declarations within protocols", ())
ERROR(transparent_in_classes_not_supported,none,
"'@_transparent' attribute is not supported on declarations within classes", ())
ERROR(invalid_iboutlet,none,
"only instance properties can be declared @IBOutlet", ())
ERROR(iboutlet_nonobjc_class,none,
"@IBOutlet property cannot %select{have|be an array of}0 "
"non-'@objc' class type %1", (bool, Type))
ERROR(iboutlet_nonobjc_protocol,none,
"@IBOutlet property cannot %select{have|be an array of}0 "
"non-'@objc' protocol type %1", (bool, Type))
ERROR(iboutlet_nonobject_type,none,
"@IBOutlet property cannot %select{have|be an array of}0 "
"non-object type %1", (bool, Type))
ERROR(iboutlet_only_mutable,none,
"@IBOutlet attribute requires property to be mutable", ())
ERROR(iboutlet_non_optional,none,
"@IBOutlet property has non-optional type %0", (Type))
NOTE(note_make_optional,none,
"add '?' to form the optional type %0", (Type))
NOTE(note_make_implicitly_unwrapped_optional,none,
"add '!' to form an implicitly unwrapped optional", ())
ERROR(invalid_ibdesignable_extension,none,
"@IBDesignable can only be applied to classes and extensions "
"of classes", ())
ERROR(invalid_ibinspectable,none,
"only instance properties can be declared @%0", (StringRef))
ERROR(invalid_ibaction_decl,none,
"only instance methods can be declared @%0", (StringRef))
ERROR(invalid_ibaction_result,none,
"methods declared @%0 must %select{|not }1return a value", (StringRef, bool))
ERROR(invalid_ibaction_argument_count,none,
"@%0 methods must have %1 to %2 arguments",
(StringRef, int, int))
ERROR(invalid_ibaction_argument_count_exact,none,
"@%0 methods must have %2 argument%s2",
(StringRef, int, int))
ERROR(invalid_ibaction_argument_count_max,none,
"@%0 methods must have at most %2 argument%s2",
(StringRef, int, int))
ERROR(ibsegueaction_objc_method_family,none,
"@%0 method cannot have selector %1 because it has special memory "
"management behavior", (StringRef, ObjCSelector))
NOTE(fixit_rename_in_swift,none,
"change Swift name to %0", (DeclName))
NOTE(fixit_rename_in_objc,none,
"change Objective-C selector to %0", (ObjCSelector))
ERROR(no_objc_tagged_pointer_not_class_protocol,none,
"@unsafe_no_objc_tagged_pointer can only be applied to class protocols",
())
ERROR(swift_native_objc_runtime_base_not_on_root_class,none,
"@_swift_native_objc_runtime_base_not_on_root_class can only be applied "
"to root classes", ())
ERROR(cdecl_not_at_top_level,none,
"@_cdecl can only be applied to global functions", ())
ERROR(cdecl_empty_name,none,
"@_cdecl symbol name cannot be empty", ())
ERROR(cdecl_throws,none,
"raising errors from @_cdecl functions is not supported", ())
ERROR(cdecl_async,none,
"@_cdecl functions cannot be asynchronous", ())
ERROR(attr_methods_only,none,
"only methods can be declared %0", (DeclAttribute))
ERROR(access_control_in_protocol,none,
"%0 modifier cannot be used in protocols", (DeclAttribute))
NOTE(access_control_in_protocol_detail,none,
"protocol requirements implicitly have the same access as the "
"protocol itself", ())
ERROR(access_control_setter,none,
"'%select{private|fileprivate|internal|public|open}0(set)' modifier can only "
"be applied to variables and subscripts",
(AccessLevel))
ERROR(access_control_setter_read_only,none,
"'%select{private|fileprivate|internal|public|%error}0(set)' modifier cannot be "
"applied to %select{constants|read-only variables|read-only properties"
"|read-only subscripts}1",
(AccessLevel, unsigned))
ERROR(access_control_setter_more,none,
"%select{private|fileprivate|internal|public|%error}0 "
"%select{variable|property|subscript}1 cannot have "
"%select{%error|a fileprivate|an internal|a public|an open}2 setter",
(AccessLevel, unsigned, AccessLevel))
WARNING(access_control_setter_redundant,none,
"'%select{private|fileprivate|internal|public|open}0(set)' modifier is "
"redundant for %select{a private|a fileprivate|an internal|a public|an open}2 "
"%1",
(AccessLevel, DescriptiveDeclKind, AccessLevel))
WARNING(access_control_ext_member_more,none,
"'%select{%error|fileprivate|internal|public|open}0' modifier conflicts "
"with extension's default access of "
"'%select{private|fileprivate|internal|public|%error}1'",
(AccessLevel, AccessLevel))
WARNING(access_control_ext_member_redundant,none,
"'%select{%error|fileprivate|internal|public|%error}0' modifier is redundant "
"for %1 declared in %select{a private (equivalent to fileprivate)|a fileprivate"
"|an internal|a public|%error}2 extension",
(AccessLevel, DescriptiveDeclKind, AccessLevel))
ERROR(access_control_ext_requirement_member_more,none,
"cannot declare %select{%error|a fileprivate|an internal|a public|an open}0 %1 "
"in an extension with %select{private|fileprivate|internal|public|%error}2 "
"requirements",
(AccessLevel, DescriptiveDeclKind, AccessLevel))
ERROR(access_control_extension_more,none,
"extension of %select{private|fileprivate|internal|%error|%error}0 %1 cannot "
"be declared %select{%error|fileprivate|internal|public|%error}2",
(AccessLevel, DescriptiveDeclKind, AccessLevel))
ERROR(access_control_extension_open,none,
"extensions cannot use 'open' as their default access; use 'public'",
())
ERROR(access_control_open_bad_decl,none,
"only classes and overridable class members can be declared 'open';"
" use 'public'", ())
ERROR(invalid_decl_attribute,none,
"'%0' attribute cannot be applied to this declaration", (DeclAttribute))
ERROR(invalid_decl_modifier,none,
"%0 modifier cannot be applied to this declaration", (DeclAttribute))
ERROR(attribute_does_not_apply_to_type,none,
"attribute does not apply to type", ())
ERROR(optional_attribute_non_protocol,none,
"'optional' can only be applied to protocol members", ())
ERROR(optional_attribute_non_objc_protocol,none,
"'optional' can only be applied to members of an @objc protocol", ())
ERROR(optional_attribute_missing_explicit_objc,none,
"'optional' requirements are an Objective-C compatibility feature; add '@objc'",
())
ERROR(objcmembers_attribute_nonclass,none,
"'@objcMembers' attribute can only be applied to a class", ())
ERROR(optional_attribute_initializer,none,
"'optional' cannot be applied to an initializer", ())
ERROR(unavailable_method_non_objc_protocol,none,
"protocol members can only be marked unavailable in an @objc protocol",
())
ERROR(missing_in_class_init_1,none,
"stored property %0 requires an initial value%select{| or should be "
"@NSManaged}1", (Identifier, bool))
ERROR(missing_in_class_init_2,none,
"stored properties %0 and %1 require initial values%select{| or should "
"be @NSManaged}2",
(Identifier, Identifier, bool))
ERROR(missing_in_class_init_3plus,none,
"stored properties %0, %1, %select{and %2|%2, and others}3 "
"require initial values%select{| or should be @NSManaged}4",
(Identifier, Identifier, Identifier, bool, bool))
NOTE(requires_stored_property_inits_here,none,
"%select{superclass|class}1 %0 requires all stored properties to have "
"initial values%select{| or use @NSManaged}2", (Type, bool, bool))
ERROR(class_without_init,none,
"class %0 has no initializers", (Type))
NOTE(note_no_in_class_init_1,none,
"stored property %0 without initial value prevents synthesized "
"initializers",
(Identifier))
NOTE(note_no_in_class_init_2,none,
"stored properties %0 and %1 without initial values prevent synthesized "
"initializers",
(Identifier, Identifier))
NOTE(note_no_in_class_init_3plus,none,
"stored properties %0, %1, %select{and %2|%2, and others}3 "
"without initial values prevent synthesized initializers",
(Identifier, Identifier, Identifier, bool))
ERROR(missing_unimplemented_init_runtime,none,
"standard library error: missing _unimplementedInitializer", ())
ERROR(missing_undefined_runtime,none,
"standard library error: missing _undefined", ())
WARNING(expr_dynamic_lookup_swift3_objc_inference,none,
"reference to %0 %1 of %2 depends on '@objc' inference "
"deprecated in Swift 4",
(DescriptiveDeclKind, DeclName, Identifier))
ERROR(inherited_default_value_not_in_designated_constructor,none,
"default value inheritance via 'super' is only valid on the parameters of "
"designated initializers", ())
ERROR(inherited_default_value_used_in_non_overriding_constructor,none,
"default value inheritance via 'super' can only be used when "
"overriding a designated initializer", ())
ERROR(corresponding_param_not_defaulted,none,
"default value inheritance via 'super' requires that the corresponding "
"parameter of the overridden designated initializer has a default value",
())
NOTE(inherited_default_param_here,none,
"corresponding parameter declared here", ())
WARNING(option_set_zero_constant,none,
"static property %0 produces an empty option set",
(Identifier))
NOTE(option_set_empty_set_init,none,
"use [] to silence this warning", ())
ERROR(originally_defined_in_dupe_platform,none,
"duplicate version number for platform %0", (StringRef))
ERROR(originally_definedin_topleve_decl,none,
"@%0 is only applicable to top-level decl", (StringRef))
ERROR(originally_definedin_need_available,none,
"need @available attribute for @%0", (StringRef))
ERROR(originally_definedin_must_after_available_version,none,
"moved version from @%0 must after introduced OS version", (StringRef))
// Alignment attribute
ERROR(alignment_not_power_of_two,none,
"alignment value must be a power of two", ())
// Enum annotations
ERROR(indirect_case_without_payload,none,
"enum case %0 without associated value cannot be 'indirect'", (Identifier))
ERROR(indirect_case_in_indirect_enum,none,
"enum case in 'indirect' enum cannot also be 'indirect'", ())
WARNING(enum_frozen_nonpublic,none,
"%0 has no effect on non-public enums", (DeclAttribute))
// Variables (var and let).
ERROR(getset_init,none,
"variable with getter/setter cannot have an initial value", ())
ERROR(effectful_not_representable_objc,none,
"%0 with 'throws' or 'async' is not representable in Objective-C",
(DescriptiveDeclKind))
ERROR(unimplemented_static_var,none,
"%select{ERROR|static|class}1 stored properties not supported"
"%select{ in this context| in generic types| in classes| in protocol extensions}0"
"%select{|; did you mean 'static'?}2",
(unsigned, StaticSpellingKind, unsigned))
ERROR(observingprop_requires_initializer,none,
"non-member observing properties require an initializer", ())
ERROR(global_requires_initializer,none,
"global '%select{var|let}0' declaration requires an initializer expression"
"%select{ or an explicitly stated getter|}0", (bool))
ERROR(static_requires_initializer,none,
"'%select{ERROR|static|class|}0 %select{var|let}1' declaration requires "
"an initializer expression or an explicitly stated getter",
(StaticSpellingKind, bool))
NOTE(static_requires_initializer_add_init,none,
"add an initializer to silence this error", ())
ERROR(pattern_type_access,none,
"%select{%select{variable|constant}0|property}1 "
"%select{must be declared %select{"
"%select{private|fileprivate|internal|%error|%error}3|private or fileprivate}4"
"|cannot be declared "
"%select{in this context|fileprivate|internal|public|open}3}2 "
"because its type uses "
"%select{a private|a fileprivate|an internal|%error|%error}5 type",
(bool, bool, bool, AccessLevel, bool, AccessLevel))
WARNING(pattern_type_access_warn,none,
"%select{%select{variable|constant}0|property}1 "
"%select{should be declared %select{private|fileprivate|internal|%error|%error}5"
"|should not be declared %select{in this context|fileprivate|internal|public|open}3}2 "
"because its type uses "
"%select{a private|a fileprivate|an internal|%error|%error}5 type",
(bool, bool, bool, AccessLevel, bool, AccessLevel))
ERROR(pattern_type_access_inferred,none,
"%select{%select{variable|constant}0|property}1 "
"%select{must be declared %select{"
"%select{private|fileprivate|internal|%error|%error}3|private or fileprivate}4"
"|cannot be declared "
"%select{in this context|fileprivate|internal|public|open}3}2 "
"because its type %6 uses "
"%select{a private|a fileprivate|an internal|%error|%error}5 type",
(bool, bool, bool, AccessLevel, bool, AccessLevel, Type))
WARNING(pattern_type_access_inferred_warn,none,
"%select{%select{variable|constant}0|property}1 "
"%select{should be declared %select{private|fileprivate|internal|%error|%error}5"
"|should not be declared %select{in this context|fileprivate|internal|public|open}3}2 "
"because its type %6 uses "
"%select{a private|a fileprivate|an internal|%error|%error}5 type",
(bool, bool, bool, AccessLevel, bool, AccessLevel, Type))
ERROR(pattern_type_not_usable_from_inline,none,
"type referenced from a '@usableFromInline' "
"%select{%select{variable|constant}0|property}1 "
"must be '@usableFromInline' or public",
(bool, bool))
WARNING(pattern_type_not_usable_from_inline_warn,none,
"type referenced from a '@usableFromInline' "
"%select{%select{variable|constant}0|property}1 "
"should be '@usableFromInline' or public",
(bool, bool))
ERROR(pattern_type_not_usable_from_inline_frozen,none,
"type referenced from a stored property in a '@frozen' struct must "
"be '@usableFromInline' or public",
(/*ignored*/bool, /*ignored*/bool))
ERROR(pattern_type_not_usable_from_inline_inferred,none,
"type referenced from a '@usableFromInline' "
"%select{%select{variable|constant}0|property}1 "
"with inferred type %2 "
"must be '@usableFromInline' or public",
(bool, bool, Type))
WARNING(pattern_type_not_usable_from_inline_inferred_warn,none,
"type referenced from a '@usableFromInline' "
"%select{%select{variable|constant}0|property}1 "
"with inferred type %2 "
"should be '@usableFromInline' or public",
(bool, bool, Type))
ERROR(pattern_type_not_usable_from_inline_inferred_frozen,none,
"type referenced from a stored property with inferred type %2 in a "
"'@frozen' struct must be '@usableFromInline' or public",
(/*ignored*/bool, /*ignored*/bool, Type))
ERROR(pattern_binds_no_variables,none,
"%select{property|global variable}0 declaration does not bind any "
"variables",
(unsigned))
ERROR(variable_bound_by_no_pattern,none,
"variable %0 is not bound by any pattern",
(DeclName))
WARNING(optional_ambiguous_case_ref,none,
"assuming you mean '%0.%2'; did you mean '%1.%2' instead?",
(StringRef, StringRef, StringRef))
NOTE(optional_fixit_ambiguous_case_ref,none,
"explicitly specify 'Optional' to silence this warning", ())
NOTE(optional_fixit_ambiguous_case_ref_switch,none,
"use 'nil' to silence this warning", ())
NOTE(type_fixit_optional_ambiguous_case_ref,none,
"use '%0.%1' instead", (StringRef, StringRef))
NOTE(type_fixit_optional_ambiguous_case_ref_switch,none,
"use '%0' instead", (StringRef))
ERROR(nscoding_unstable_mangled_name,none,
"%select{private|fileprivate|nested|local}0 class %1 has an "
"unstable name when archiving via 'NSCoding'",
(unsigned, Type))
NOTE(unstable_mangled_name_add_objc_new,none,
"for new classes, use '@objc' to specify a unique, prefixed Objective-C "
"runtime name", ())
NOTE(unstable_mangled_name_add_objc,none,
"for compatibility with existing archives, use '@objc' "
"to record the Swift 3 runtime name", ())
// Generic declarations
ERROR(unsupported_type_nested_in_generic_function,none,
"type %0 cannot be nested in generic function %1",
(Identifier, DeclName))
ERROR(unsupported_type_nested_in_generic_closure,none,
"type %0 cannot be nested in closure in generic context",
(Identifier))
ERROR(unsupported_type_nested_in_protocol,none,
"type %0 cannot be nested in protocol %1",
(Identifier, Identifier))
ERROR(unsupported_type_nested_in_protocol_extension,none,
"type %0 cannot be nested in protocol extension of %1",
(Identifier, Identifier))
ERROR(unsupported_nested_protocol,none,
"protocol %0 cannot be nested inside another declaration",
(Identifier))
ERROR(where_nongeneric_ctx,none,
"'where' clause on non-generic member declaration requires a "
"generic context", ())
ERROR(where_nongeneric_toplevel,none,
"'where' clause cannot be applied to a non-generic top-level "
"declaration", ())
ERROR(unable_to_convert_generic_swift_types,none,
"could not generate C++ types from the generic Swift types provided. "
"The following Swift type(s) provided to '%0' could not be "
"converted: %1.",
(StringRef, StringRef))
// Type aliases
ERROR(type_alias_underlying_type_access,none,
"type alias %select{must be declared %select{"
"%select{private|fileprivate|internal|%error|%error}1|private or fileprivate}3"
"|cannot be declared "
"%select{in this context|fileprivate|internal|public|open}1}0 "
"because its underlying type uses "
"%select{a private|a fileprivate|an internal|%error|%error}2 type",
(bool, AccessLevel, AccessLevel, bool))
WARNING(type_alias_underlying_type_access_warn,none,
"type alias %select{should be declared "
"%select{private|fileprivate|internal|%error|%error}1"
"|should not be declared "
"%select{in this context|fileprivate|internal|public|open}1}0 "
"because its underlying type uses "
"%select{a private|a fileprivate|an internal|%error|%error}2 type",
(bool, AccessLevel, AccessLevel, bool))
ERROR(type_alias_underlying_type_not_usable_from_inline,none,
"type referenced from the underlying type of a "
"'@usableFromInline' type alias "
"must be '@usableFromInline' or public",
())
WARNING(type_alias_underlying_type_not_usable_from_inline_warn,none,
"type referenced from the underlying type of a "
"'@usableFromInline' type alias "
"should be '@usableFromInline' or public",
())
// Subscripts
ERROR(subscript_type_access,none,
"subscript %select{must be declared "
"%select{private|fileprivate|internal|%error|%error}1"
"|cannot be declared "
"%select{in this context|fileprivate|internal|public|open}1}0 "
"because its %select{index|element type}3 uses "
"%select{a private|a fileprivate|an internal|%error|%error}2 type",
(bool, AccessLevel, AccessLevel, bool))
WARNING(subscript_type_access_warn,none,
"subscript %select{should be declared "
"%select{private|fileprivate|internal|%error|%error}1"
"|should not be declared %select{in this context|fileprivate|internal|public|open}1}0 "
"because its %select{index|element type}3 uses "
"%select{a private|a fileprivate|an internal|%error|%error}2 type",
(bool, AccessLevel, AccessLevel, bool))
ERROR(subscript_type_usable_from_inline,none,
"%select{index type|element type}0 of a '@usableFromInline' subscript "
"must be '@usableFromInline' or public",
(bool))
WARNING(subscript_type_usable_from_inline_warn,none,
"%select{index type|element type}0 of a '@usableFromInline' subscript "
"should be '@usableFromInline' or public",
(bool))
// Functions
ERROR(function_type_access,none,
"%select{function|method|initializer}4 "
"%select{must be declared %select{"
"%select{private|fileprivate|internal|%error|%error}1|private or fileprivate}2"
"|cannot be declared "
"%select{in this context|fileprivate|internal|public|open}1}0 "
"because its %select{parameter|result}5 uses "
"%select{a private|a fileprivate|an internal|an '@_spi'|an '@_spi'}3"
"%select{| API wrapper}6 type",
(bool, AccessLevel, bool, AccessLevel, unsigned, bool, bool))
ERROR(function_type_spi,none,
"%select{function|method|initializer}0 "
"cannot be declared '@_spi' "
"because its %select{parameter|result}1 uses "
"%select{a private|a fileprivate|an internal|a public|an open}2 type"
"%select{| that is not '@_spi'}3",
(unsigned, bool, AccessLevel, bool))
WARNING(function_type_access_warn,none,
"%select{function|method|initializer}4 "
"%select{should be declared %select{private|fileprivate|internal|%error|%error}1"
"|should not be declared %select{in this context|fileprivate|internal|public|open}1}0 "
"because its %select{parameter|result}5 uses "
"%select{a private|a fileprivate|an internal|%error|%error}3 "
"%select{|API wrapper}6 type",
(bool, AccessLevel, bool, AccessLevel, unsigned, bool, bool))
ERROR(function_type_usable_from_inline,none,
"the %select{parameter|result}1%select{| API wrapper}2 of a "
"'@usableFromInline' %select{function|method|initializer}0 "
"must be '@usableFromInline' or public",
(unsigned, bool, bool))
WARNING(function_type_usable_from_inline_warn,none,
"the %select{parameter|result}1%select{| API wrapper}2 of a "
"'@usableFromInline' %select{function|method|initializer}0 "
"should be '@usableFromInline' or public",
(unsigned, bool, bool))
ERROR(spi_attribute_on_non_public,none,
"%select{private|fileprivate|internal|%error|%error}0 %1 "
"cannot be declared '@_spi' because only public and open "
"declarations can be '@_spi'",
(AccessLevel, DescriptiveDeclKind))
ERROR(spi_attribute_on_protocol_requirement,none,
"protocol requirement %0 cannot be declared '@_spi' without "
"a default implementation in a protocol extension",
(DeclName))
ERROR(spi_attribute_on_frozen_stored_properties,none,
"stored property %0 cannot be declared '@_spi' in a '@frozen' struct",
(DeclName))
WARNING(spi_attribute_on_import_of_public_module,none,
"'@_spi' import of %0 will not include any SPI symbols; "
"%0 was built from the public interface at %1",
(DeclName, StringRef))
// Opaque return types
ERROR(opaque_type_invalid_constraint,none,
"an 'opaque' type must specify only 'Any', 'AnyObject', protocols, "
"and/or a base class", ())
ERROR(inferred_opaque_type,none,
"property definition has inferred type %0, involving the 'some' "
"return type of another declaration", (Type))
// Extensions
ERROR(non_nominal_extension,none,
"non-nominal type %0 cannot be extended", (Type))
WARNING(composition_in_extended_type,none,
"extending a protocol composition is not supported; extending %0 "
"instead", (Type))
NOTE(composition_in_extended_type_alternative,none,
"did you mean to extend the most specific type %0 instead?", (Type))
ERROR(extension_access_with_conformances,none,
"%0 modifier cannot be used with extensions that declare "
"protocol conformances", (DeclAttribute))
ERROR(extension_metatype,none,
"cannot extend a metatype %0", (Type))
ERROR(extension_specialization,none,
"constrained extension must be declared on the unspecialized generic "
"type %0 with constraints specified by a 'where' clause", (Identifier))
ERROR(extension_stored_property,none,
"extensions must not contain stored properties", ())
NOTE(extension_stored_property_fixit,none,
"Remove '=' to make %0 a computed property", (Identifier))
ERROR(extension_nongeneric_trailing_where,none,
"trailing 'where' clause for extension of non-generic type %0",
(Identifier))
ERROR(extension_protocol_inheritance,none,
"extension of protocol %0 cannot have an inheritance clause",
(Identifier))
ERROR(objc_generic_extension_using_type_parameter,none,
"extension of a generic Objective-C class cannot access the class's "
"generic parameters at runtime", ())
NOTE(objc_generic_extension_using_type_parameter_here,none,
"generic parameter used here", ())
NOTE(objc_generic_extension_using_type_parameter_try_objc,none,
"add '@objc' to allow uses of 'self' within the function body", ())
ERROR(invalid_nominal_extension,none,
"extension of type %0 must be declared as an extension of %1",
(Type, Type))
NOTE(invalid_nominal_extension_rewrite,none,
"did you mean to extend %0 instead?", (Type))
// Protocols
ERROR(type_does_not_conform,none,
"type %0 does not conform to protocol %1", (Type, Type))
ERROR(cannot_use_nil_with_this_type,none,
"'nil' cannot be used in context expecting type %0", (Type))
ERROR(type_cannot_conform_to_nsobject,none,
"cannot declare conformance to 'NSObjectProtocol' in Swift; %0 should "
"inherit 'NSObject' instead", (Type))
ERROR(use_of_equal_instead_of_equality,none,
"use of '=' in a boolean context, did you mean '=='?", ())
ERROR(type_cannot_conform, none,
"%select{type %1|protocol %1 as a type}0 cannot conform to "
"%select{%3|the protocol itself}2",
(bool, Type, bool, Type))
NOTE(only_concrete_types_conform_to_protocols,none,
"only concrete types such as structs, enums and classes can conform to protocols",
())
NOTE(required_by_opaque_return,none,
"required by opaque return type of %0 %1", (DescriptiveDeclKind, DeclName))
NOTE(required_by_decl,none,
"required by %0 %1 where %2 = %3",
(DescriptiveDeclKind, DeclName, Type, Type))
NOTE(required_by_decl_ref,none,
"required by referencing %0 %1 on %2 where %3 = %4",
(DescriptiveDeclKind, DeclName, Type, Type, Type))
ERROR(protocol_does_not_conform_static,none,
"%0 cannot be used as a type conforming to protocol %1 because %1 "
"has static requirements",
(Type, Type))
ERROR(protocol_derivation_is_broken,none,
"protocol %0 is broken; cannot derive conformance for type %1", (Type, Type))
ERROR(type_does_not_inherit,none,
"%0 requires that %1 inherit from %2", (Type, Type, Type))
NOTE(type_does_not_inherit_or_conform_requirement,none,
"requirement specified as %0 : %1%2", (Type, Type, StringRef))
ERROR(types_not_equal,none,
"%0 requires the types %1 and %2 be equivalent",
(Type, Type, Type))
ERROR(type_does_not_conform_owner,none,
"%0 requires that %1 conform to %2", (Type, Type, Type))
ERROR(type_does_not_conform_in_decl_ref,none,
"referencing %0 %1 on %2 requires that %3 conform to %4",
(DescriptiveDeclKind, DeclName, Type, Type, Type))
ERROR(contextual_member_ref_on_protocol_requires_self_requirement,none,
"contextual member reference to %0 %1 requires "
"'Self' constraint in the protocol extension",
(DescriptiveDeclKind, DeclName))
NOTE(missing_sametype_requirement_on_self,none,
"missing same-type requirement on 'Self'", ())
ERROR(type_does_not_conform_anyobject_in_decl_ref,none,
"referencing %0 %1 on %2 requires that %3 be a class type",
(DescriptiveDeclKind, DeclName, Type, Type, Type))
ERROR(type_does_not_conform_decl_owner,none,
"%0 %1 requires that %2 conform to %3",
(DescriptiveDeclKind, DeclName, Type, Type))
ERROR(type_does_not_conform_anyobject_decl_owner,none,
"%0 %1 requires that %2 be a class type",
(DescriptiveDeclKind, DeclName, Type, Type))
ERROR(type_does_not_conform_in_opaque_return,none,
"return type of %0 %1 requires that %2 %select{conform to %3|be a class type}4",
(DescriptiveDeclKind, DeclName, Type, Type, bool))
ERROR(types_not_equal_decl,none,
"%0 %1 requires the types %2 and %3 be equivalent",
(DescriptiveDeclKind, DeclName, Type, Type))
ERROR(types_not_equal_in_decl_ref,none,
"referencing %0 %1 on %2 requires the types %3 and %4 be equivalent",
(DescriptiveDeclKind, DeclName, Type, Type, Type))
ERROR(types_not_inherited_decl,none,
"%0 %1 requires that %2 inherit from %3",
(DescriptiveDeclKind, DeclName, Type, Type))
ERROR(types_not_inherited_in_decl_ref,none,
"referencing %0 %1 on %2 requires that %3 inherit from %4",
(DescriptiveDeclKind, DeclName, Type, Type, Type))
NOTE(where_requirement_failure_one_subst,none,
"where %0 = %1", (Type, Type))
NOTE(where_requirement_failure_both_subst,none,
"where %0 = %1, %2 = %3", (Type, Type, Type, Type))
NOTE(requirement_implied_by_conditional_conformance,none,
"requirement from conditional conformance of %0 to %1", (Type, Type))
NOTE(wrapped_type_satisfies_requirement,none,
"wrapped type %0 satisfies this requirement; did you mean to unwrap?", (Type))
NOTE(candidate_types_conformance_requirement,none,
"candidate requires that %0 conform to %1 "
"(requirement specified as %2 == %3%4)",
(Type, Type, Type, Type, StringRef))
NOTE(candidate_types_equal_requirement,none,
"candidate requires that the types %0 and %1 be equivalent "
"(requirement specified as %2 == %3%4)",
(Type, Type, Type, Type, StringRef))
NOTE(candidate_types_inheritance_requirement,none,
"candidate requires that %1 inherit from %2 "
"(requirement specified as %2 : %3%4)",
(Type, Type, Type, Type, StringRef))
NOTE(types_not_equal_requirement,none,
"requirement specified as %0 == %1%2", (Type, Type, StringRef))
ERROR(type_is_not_a_class,none,
"%0 requires that %1 be a class type", (Type, Type, Type))
NOTE(anyobject_requirement,none,
"requirement specified as %0 : 'AnyObject'%2", (Type, Type, StringRef))
ERROR(non_class_cannot_conform_to_class_protocol,none,
"non-class type %0 cannot conform to class protocol %1",
(Type, Type))
ERROR(cf_class_cannot_conform_to_objc_protocol,none,
"Core Foundation class %0 cannot conform to @objc protocol %1 because "
"Core Foundation types are not classes in Objective-C",
(Type, Type))
ERROR(objc_runtime_visible_cannot_conform_to_objc_protocol,none,
"class %0 cannot conform to @objc protocol %1 because "
"the class is only visible via the Objective-C runtime",
(Type, Type))
ERROR(objc_generics_cannot_conditionally_conform,none,
"type %0 cannot conditionally conform to protocol %1 because "
"the type uses the Objective-C generics model",
(Type, Type))
ERROR(objc_protocol_cannot_have_conditional_conformance,none,
"type %0 cannot conditionally conform to @objc protocol %1 because "
"Objective-C does not support conditional conformances",
(Type, Type))
ERROR(objc_protocol_in_generic_extension,none,
"conformance of "
"%select{class from generic context|generic class}0 "
"%1 to @objc protocol %2 cannot be in an extension",
(bool, Type, Type))
ERROR(conditional_conformances_cannot_imply_conformances,none,
"conditional conformance of type %0 to protocol %1 does not imply conformance to "
"inherited protocol %2",
(Type, Type, Type))
NOTE(note_explicitly_state_conditional_conformance_different,none,
"did you mean to explicitly state the conformance with different bounds?", ())
NOTE(note_explicitly_state_conditional_conformance_relaxed,none,
"did you mean to explicitly state the conformance with relaxed bounds?", ())
NOTE(note_explicitly_state_conditional_conformance_same,none,
"did you mean to explicitly state the conformance with the same bounds?", ())
NOTE(note_explicitly_state_conditional_conformance_noneditor,none,
"did you mean to explicitly state the conformance like '%0where ...'?",
(StringRef))
ERROR(protocol_has_missing_requirements,none,
"type %0 cannot conform to protocol %1 because it has requirements that "
"cannot be satisfied", (Type, Type))
ERROR(protocol_has_missing_requirements_versioned,none,
"type %0 cannot conform to protocol %1 (compiled with Swift %2) because "
"it has requirements that could not be loaded in Swift %3",
(Type, Type, llvm::VersionTuple, llvm::VersionTuple))
ERROR(requirement_restricts_self,none,
"%0 requirement %1 cannot add constraint '%2%select{:|:| ==|:}3 %4' on "
"'Self'",
(DescriptiveDeclKind, DeclName, StringRef, unsigned, StringRef))
ERROR(witness_argument_name_mismatch,none,
"%0 %1 has different argument labels "
"from those required by protocol %2 (%3)",
(DescriptiveDeclKind, DeclName, Type, DeclName))
ERROR(witness_initializer_not_required,none,
"initializer requirement %0 can only be satisfied by a 'required' "
"initializer in%select{| the definition of}1 non-final class %2",
(DeclName, bool, Type))
ERROR(witness_initializer_failability,none,
"non-failable initializer requirement %0"
"%select{| in Objective-C protocol}1 cannot be satisfied by a "
"failable initializer ('init%select{?|!}1')",
(DeclName, bool))
ERROR(witness_self_non_subtype,none,
"protocol %0 requirement %1 cannot be satisfied by a non-final class "
"(%2) because it uses 'Self' in a non-parameter, non-result type "
"position",
(Type, DeclName, Type))
ERROR(witness_self_same_type,none,
"%0 %1 in non-final class %2 cannot be used to satisfy requirement %3 %4"
" (in protocol %5) due to same-type requirement involving 'Self'",
(DescriptiveDeclKind, DeclName, Type, DescriptiveDeclKind,
DeclName, Type))
NOTE(witness_self_weaken_same_type,none,
"consider weakening the same-type requirement %0 == %1 to a superclass "
"requirement", (Type, Type))
ERROR(witness_requires_dynamic_self,none,
"%select{%error|method|property|subscript}0 %1 in non-final class %2 "
"must %select{%error|return|specify type|return}0 'Self' "
"to conform to protocol %3",
(RequirementKind, DeclName, Type, Type))
ERROR(witness_requires_class_implementation,none,
"%select{%error|method|%error|subscript}0 %1 in non-final class %2 "
"cannot be implemented in a protocol extension because it returns 'Self' "
"and has associated type requirements",
(RequirementKind, DeclName, Type))
ERROR(witness_not_accessible_proto,none,
"%select{initializer %1|method %1|%select{|setter for }2property %1"
"|subscript%select{| setter}2}0 must be declared "
"%select{%error|fileprivate|internal|public|%error}3 because it matches a "
"requirement in %select{private|fileprivate|internal|public|%error}4 protocol "
"%5",
(RequirementKind, DeclName, bool, AccessLevel, AccessLevel, Identifier))
ERROR(witness_not_accessible_type,none,
"%select{initializer %1|method %1|%select{|setter for }2property %1"
"|subscript%select{| setter}2}0 must be as accessible as its enclosing "
"type because it matches a requirement in protocol %5",
(RequirementKind, DeclName, bool, AccessLevel, AccessLevel, Identifier))
ERROR(type_witness_not_accessible_proto,none,
"%0 %1 must be declared %select{%error|fileprivate|internal|public|%error}2 "
"because it matches a requirement in "
"%select{%error|fileprivate|internal|public|%error}2 protocol %3",
(DescriptiveDeclKind, Identifier, AccessLevel, Identifier))
ERROR(type_witness_not_accessible_type,none,
"%0 %1 must be as accessible as its enclosing type because it "
"matches a requirement in protocol %3",
(DescriptiveDeclKind, Identifier, AccessLevel, Identifier))
ERROR(witness_not_usable_from_inline,none,
"%0 %1 must be declared '@usableFromInline' "
"because it matches a requirement in protocol %2",
(DescriptiveDeclKind, DeclName, Identifier))
WARNING(witness_not_usable_from_inline_warn,none,
"%0 %1 should be declared '@usableFromInline' "
"because it matches a requirement in protocol %2",
(DescriptiveDeclKind, DeclName, Identifier))
ERROR(type_witness_objc_generic_parameter,none,
"type %0 involving Objective-C type parameter%select{| %1}2 cannot be "
"used for associated type %3 of protocol %4",
(Type, Type, bool, Identifier, Identifier))
NOTE(witness_fix_access,none,
"mark the %0 as '%select{%error|fileprivate|internal|public|%error}1' to "
"satisfy the requirement", (DescriptiveDeclKind, AccessLevel))
NOTE(witness_move_to_another_extension,none,
"move the %0 to another extension where it can be declared "
"'%select{%error|%error|internal|public|%error}1' to "
"satisfy the requirement", (DescriptiveDeclKind, AccessLevel))
WARNING(assoc_type_default_conformance_failed,none,
"default type %0 for associated type %1 does not satisfy constraint "
"%2: %3", (Type, Identifier, Type, Type))
NOTE(assoc_type_default_here,none,
"associated type %0 has default type %1 written here", (Identifier, Type))
ERROR(protocol_access,none,
"%select{protocol must be declared %select{"
"%select{private|fileprivate|internal|%error|%error}1"
"|private or fileprivate}4 because %select{it refines|its 'where' clause uses}2"
"|%select{in this context|fileprivate|internal|public|%error}1 "
"%select{protocol cannot refine|protocol's 'where' clause cannot use}2}0 "
"%select{a private|a fileprivate|an internal|%error|%error}3 %5",
(bool, AccessLevel, bool, AccessLevel, bool, DescriptiveDeclKind))
WARNING(protocol_access_warn,none,
"%select{protocol should be declared "
"%select{private|fileprivate|internal|%error|%error}1 because "
"%select{it refines|its 'where' clause uses}2"
"|%select{in this context|fileprivate|internal|public|%error}1 "
"%select{protocol should not refine|protocol's 'where' clause should not use}2}0 "
"%select{a private|a fileprivate|an internal|%error|%error}3 %5",
(bool, AccessLevel, bool, AccessLevel, bool, DescriptiveDeclKind))
ERROR(protocol_usable_from_inline,none,
"protocol %select{refined|used}0 by '@usableFromInline' protocol "
"must be '@usableForInline' or public", (bool))
WARNING(protocol_usable_from_inline_warn,none,
"protocol %select{refined|used}0 by '@usableFromInline' protocol "
"should be '@usableForInline' or public", (bool))
ERROR(protocol_property_must_be_computed_var,none,
"protocols cannot require properties to be immutable; declare read-only "
"properties by using 'var' with a '{ get }' specifier", ())
ERROR(protocol_property_must_be_computed,none,
"property in protocol must have explicit { get } or { get set } specifier",
())
NOTE(inherited_protocol_does_not_conform,none,
"type %0 does not conform to inherited protocol %1", (Type, Type))
NOTE(no_witnesses,none,
"protocol requires "
"%select{initializer %1|function %1|property %1|subscript}0 with type %2"
"%select{|; do you want to add a stub?}3",
(RequirementKind, DeclName, Type, bool))
NOTE(missing_witnesses_general,none, "do you want to add protocol stubs?",
())
NOTE(ambiguous_witnesses,none,
"multiple matching "
"%select{initializers named %1|functions named %1|properties named %1|"
"subscript operators}0 with type %2", (RequirementKind, DeclName, Type))
NOTE(ambiguous_witnesses_wrong_name,none,
"multiple matching "
"%select{initializers named %1|functions named %1|properties named %1|"
"subscript operators}0 with type %2", (RequirementKind, DeclName, Type))
NOTE(no_witnesses_type,none,
"protocol requires nested type %0; do you want to add it?", (Identifier))
NOTE(default_associated_type_req_fail,none,
"default type %0 for associated type %1 (from protocol %2) "
"does not %select{inherit from|conform to}4 %3",
(Type, Identifier, Type, Type, bool))
ERROR(associated_type_access,none,
"associated type in "
"%select{a private|a fileprivate|an internal|a public|%error}0 protocol "
"uses "
"%select{a private|a fileprivate|an internal|%error|%error}1 type in its "
"%select{default definition|requirement}2 ",
(AccessLevel, AccessLevel, unsigned))
WARNING(associated_type_access_warn,none,
"associated type in "
"%select{a private|a fileprivate|an internal|a public|%error}0 protocol uses "
"%select{a private|a fileprivate|an internal|%error|%error}1 type in its "
"%select{default definition|requirement}2 ",
(AccessLevel, AccessLevel, unsigned))
ERROR(associated_type_not_usable_from_inline,none,
"type referenced from a "
"%select{default definition|requirement}0 of an associated type in a "
"'@usableFromInline' protocol must be '@usableFromInline' or public",
(unsigned))
WARNING(associated_type_not_usable_from_inline_warn,none,
"type referenced from a "
"%select{default definition|requirement}0 of an associated type in a "
"'@usableFromInline' protocol should be '@usableFromInline' or public",
(unsigned))
NOTE(bad_associated_type_deduction,none,
"unable to infer associated type %0 for protocol %1",
(Identifier, Identifier))
NOTE(associated_type_deduction_witness_failed,none,
"candidate would match and infer %0 = %1 if %1 "
"%select{inherited from|conformed to}3 %2",
(Identifier, Type, Type, bool))
NOTE(associated_type_witness_conform_impossible,none,
"candidate can not infer %0 = %1 because %1 "
"is not a nominal type and so can't conform to %2",
(Identifier, Type, Type))
NOTE(associated_type_witness_inherit_impossible,none,
"candidate can not infer %0 = %1 because %1 "
"is not a class type and so can't inherit from %2",
(Identifier, Type, Type))
NOTE(ambiguous_associated_type_deduction,none,
"ambiguous inference of associated type %0: %1 vs. %2",
(Identifier, Type, Type))
NOTE(associated_type_deduction_witness,none,
"matching requirement %0 to this declaration inferred associated type to "
"%1",
(DeclName, Type))
NOTE(associated_type_deduction_default,none,
"using associated type default %0", (Type))
NOTE(ambiguous_witnesses_type,none,
"multiple matching types named %0", (Identifier))
NOTE(protocol_witness_exact_match,none,
"candidate exactly matches%0", (StringRef))
NOTE(protocol_witness_renamed,none,
"rename to %0 to satisfy this requirement%1", (DeclName, StringRef))
NOTE(protocol_witness_kind_conflict,none,
"candidate is not %select{an initializer|a function|a variable|"
"a subscript}0", (RequirementKind))
NOTE(protocol_witness_type_conflict,none,
"candidate has non-matching type %0%1", (Type, StringRef))
NOTE(protocol_witness_missing_requirement,none,
"candidate would match if %0 %select{conformed to|subclassed|"
"was the same type as}2 %1", (Type, Type, unsigned))
NOTE(protocol_witness_optionality_conflict,none,
"candidate %select{type has|result type has|parameter type has|"
"parameter types have|result and parameter types have}0 incorrect "
"optionality%1",
(unsigned, StringRef))
ERROR(err_protocol_witness_optionality,none,
"%select{type|result|parameter|parameters|"
"result and parameters}0 of %1 %select{has|has|has|have|have|}0"
" different optionality than required by protocol %2",
(unsigned, DeclName, Identifier))
WARNING(warn_protocol_witness_optionality,none,
"%select{type|result|parameter|parameters|"
"result and parameters}0 of %1 %select{has|has|has|have|have|}0"
" different optionality than expected by protocol %2",
(unsigned, DeclName, Identifier))
NOTE(protocol_witness_static_conflict,none,
"candidate operates on %select{a type|an instance}0, not "
"%select{an instance|a type}0 as required", (bool))
NOTE(protocol_witness_prefix_postfix_conflict,none,
"candidate is %select{|prefix, |postfix, }1not "
"%select{prefix|postfix}0 as required", (bool, unsigned))
NOTE(protocol_witness_mutation_modifier_conflict,none,
"candidate is marked %0 but protocol does not allow it",
(SelfAccessKind))
NOTE(protocol_witness_settable_conflict,none,
"candidate is not settable, but protocol requires it", ())
NOTE(protocol_witness_rethrows_conflict,none,
"candidate is not 'rethrows', but protocol requires it", ())
NOTE(protocol_witness_rethrows_by_conformance_conflict,none,
"candidate is 'rethrows' via a conformance, "
"but the protocol requirement is not from a '@rethrows' protocol", ())
NOTE(protocol_witness_throws_conflict,none,
"candidate throws, but protocol does not allow it", ())
NOTE(protocol_witness_not_objc,none,
"candidate is explicitly '@nonobjc'", ())
NOTE(protocol_witness_enum_case_payload, none,
"candidate is an enum case with associated values, "
"but protocol does not allow it", ())
NOTE(protocol_witness_type,none,
"possibly intended match", ())
NOTE(protocol_witness_nonconform_type,none,
"possibly intended match %0 does not "
"%select{inherit from|conform to}2 %1", (Type, Type, bool))
NOTE(protocol_witness_circularity,none,
"candidate references itself", ())
NOTE(protocol_conformance_here,none,
"%select{|class }0%1 declares conformance to protocol %2 here",
(bool, Identifier, Identifier))
NOTE(declared_protocol_conformance_here,none,
"%select{%0 inherits conformance to protocol %2 from superclass|"
"%0 declares conformance to protocol %2|"
"%0 implicitly conforms to protocol %2 (via conformance to %3)|"
"%0 implicitly conforms to protocol %2}1 here",
(Type, unsigned, Identifier, Identifier))
ERROR(witness_unavailable,none,
"unavailable %0 %1 was used to satisfy a requirement of protocol %2",
(DescriptiveDeclKind, DeclName, Identifier))
ERROR(redundant_conformance,none,
"redundant conformance of %0 to protocol %1", (Type, Identifier))
ERROR(redundant_conformance_conditional,none,
"conflicting conformance of %0 to protocol %1; there cannot be more "
"than one conformance, even with different conditional bounds",
(Type, Identifier))
WARNING(redundant_conformance_adhoc,none,
"conformance of %0 to protocol %1 was already stated in "
"%select{the protocol's|the type's}2 module %3",
(Type, Identifier, bool, Identifier))
WARNING(redundant_conformance_adhoc_conditional,none,
"conformance of %0 to protocol %1 conflicts with that stated in "
"%select{the protocol's|the type's}2 module %3 and will be ignored; "
"there cannot be more than one conformance, even with different conditional bounds",
(Type, Identifier, bool, Identifier))
NOTE(redundant_conformance_witness_ignored,none,
"%0 %1 will not be used to satisfy the conformance to %2",
(DescriptiveDeclKind, DeclName, Identifier))
// "Near matches"
WARNING(req_near_match,none,
"%0 %1 nearly matches %select{defaulted|optional}2 requirement %3 "
"of protocol %4",
(DescriptiveDeclKind, DeclName, bool, DeclName, Identifier))
NOTE(optional_req_nonobjc_near_match_add_objc,none,
"add '@objc' to provide an Objective-C entrypoint", ())
NOTE(req_near_match_move,none,
"move %0 to %select{an|another}1 extension to silence this warning",
(DeclName, unsigned))
NOTE(req_near_match_nonobjc,none,
"add '@nonobjc' to silence this %select{warning|error}0", (bool))
NOTE(req_near_match_access,none,
"make %0 %select{ERROR|private|private|non-public|non-public}1 to silence this "
"warning", (DeclName, AccessLevel))
// appendInterpolation methods
ERROR(missing_append_interpolation,none,
"type conforming to 'StringInterpolationProtocol' does not implement "
"a valid 'appendInterpolation' method", ())
WARNING(append_interpolation_static,none,
"'appendInterpolation' method will never be used because it is static",
())
WARNING(append_interpolation_void_or_discardable,none,
"'appendInterpolation' method does not return 'Void' or have a "
"discardable result", ())
WARNING(append_interpolation_access_control,none,
"'appendInterpolation' method is %select{private|fileprivate|internal|"
"public|open}0, but %1 is %select{private|fileprivate|internal|public|"
"open}2",
(AccessLevel, DeclName, AccessLevel))
// Protocols and existentials
ERROR(assoc_type_outside_of_protocol,none,
"associated type %0 can only be used with a concrete type or "
"generic parameter base", (DeclNameRef))
ERROR(typealias_outside_of_protocol,none,
"type alias %0 can only be used with a concrete type or "
"generic parameter base", (DeclNameRef))
ERROR(objc_protocol_inherits_non_objc_protocol,none,
"@objc protocol %0 cannot refine non-@objc protocol %1", (Type, Type))
ERROR(protocol_where_clause_self_requirement,none,
"constraint with subject type of 'Self' is not supported; "
"consider adding requirement to protocol inheritance clause instead", ())
ERROR(invalid_protocol_composition_member,none,
"non-protocol, non-class type %0 cannot be used within a "
"protocol-constrained type", (Type))
ERROR(protocol_composition_one_class,none,
"protocol-constrained type cannot contain class %0 because it already "
"contains class %1", (Type, Type))
ERROR(requires_conformance_nonprotocol,none,
"type %0 constrained to non-protocol, non-class type %1",
(Type, Type))
NOTE(requires_conformance_nonprotocol_fixit,none,
"use '%0 == %1' to require '%0' to be '%1'",
(StringRef, StringRef))
ERROR(requires_not_suitable_archetype,none,
"type %0 in conformance requirement does not refer to a "
"generic parameter or associated type",
(Type))
WARNING(requires_no_same_type_archetype,none,
"neither type in same-type constraint (%0 or %1) refers to a "
"generic parameter or associated type",
(Type, Type))
ERROR(requires_generic_params_made_equal,none,
"same-type requirement makes generic parameters %0 and %1 equivalent",
(Type, Type))
ERROR(requires_generic_param_made_equal_to_concrete,none,
"same-type requirement makes generic parameter %0 non-generic",
(Type))
ERROR(recursive_decl_reference,none,
"%0 %1 references itself", (DescriptiveDeclKind, DeclBaseName))
ERROR(recursive_same_type_constraint,none,
"same-type constraint %0 == %1 is recursive", (Type, Type))
ERROR(recursive_superclass_constraint,none,
"superclass constraint %0 : %1 is recursive", (Type, Type))
ERROR(requires_generic_param_same_type_does_not_conform,none,
"same-type constraint type %0 does not conform to required protocol %1",
(Type, Identifier))
ERROR(requires_same_concrete_type,none,
"generic signature requires types %0 and %1 to be the same", (Type, Type))
WARNING(redundant_conformance_constraint,none,
"redundant conformance constraint %0 : %1", (Type, ProtocolDecl *))
NOTE(redundant_conformance_here,none,
"conformance constraint %0 : %1 implied here",
(Type, ProtocolDecl *))
ERROR(unsupported_recursive_requirements, none,
"requirement involves recursion that is not currently supported", ())
ERROR(same_type_conflict,none,
"%select{generic parameter |protocol |}0%1 cannot be equal to both "
"%2 and %3", (unsigned, Type, Type, Type))
WARNING(redundant_same_type_to_concrete,none,
"redundant same-type constraint %0 == %1", (Type, Type))
NOTE(same_type_redundancy_here,none,
"same-type constraint %1 == %2 %select{written here|implied here|"
"inferred from type here}0",
(unsigned, Type, Type))
ERROR(conflicting_superclass_constraints,none,
"type %0 cannot be a subclass of both %1 and %2",
(Type, Type, Type))
NOTE(conflicting_superclass_constraint,none,
"constraint conflicts with %0 : %1",
(Type, Type))
WARNING(redundant_superclass_constraint,none,
"redundant superclass constraint %0 : %1", (Type, Type))
NOTE(superclass_redundancy_here,none,
"superclass constraint %0 : %1 implied here",
(Type, Type))
ERROR(conflicting_layout_constraints,none,
"type %0 has conflicting constraints %1 and %2",
(Type, LayoutConstraint, LayoutConstraint))
NOTE(conflicting_layout_constraint, none,
"constraint conflicts with %0 : %1",
(Type, LayoutConstraint))
WARNING(redundant_layout_constraint,none,
"redundant constraint %0 : %1",
(Type, LayoutConstraint))
NOTE(previous_layout_constraint, none,
"constraint %0 : %1 implied here",
(Type, LayoutConstraint))
WARNING(redundant_same_type_constraint,none,
"redundant same-type constraint %0 == %1", (Type, Type))
NOTE(previous_same_type_constraint, none,
"previous same-type constraint %1 == %2 "
"%select{written here|implied here|inferred from type here}0",
(unsigned, Type, Type))
WARNING(inherited_associated_type_redecl,none,
"redeclaration of associated type %0 from protocol %1 is better "
"expressed as a 'where' clause on the protocol",
(Identifier, Type))
WARNING(typealias_override_associated_type,none,
"typealias overriding associated type %0 from protocol %1 is better "
"expressed as same-type constraint on the protocol",
(Identifier, Type))
WARNING(associated_type_override_typealias,none,
"associated type %0 is redundant with type %0 declared in inherited "
"%1 %2", (Identifier, DescriptiveDeclKind, Type))
ERROR(associated_type_objc,none,
"associated type %0 cannot be declared inside '@objc' protocol %1",
(Identifier, Identifier))
ERROR(generic_param_access,none,
"%0 %select{must be declared %select{"
"%select{private|fileprivate|internal|%error|%error}3|private or fileprivate}4"
"|cannot be declared "
"%select{in this context|fileprivate|internal|public|open}2}1 "
"because its generic %select{parameter|requirement}5 uses "
"%select{a private|a fileprivate|an internal|an '@_spi'|an '@_spi'}3 type",
(DescriptiveDeclKind, bool, AccessLevel, AccessLevel, bool, bool))
WARNING(generic_param_access_warn,none,
"%0 %select{should be declared "
"%select{private|fileprivate|internal|%error|%error}3"
"|should not be declared %select{in this context|fileprivate|internal|public|open}2}1 "
"because its generic %select{parameter|requirement}5 uses "
"%select{a private|a fileprivate|an internal|an '@_spi'|an '@_spi'}3 type",
(DescriptiveDeclKind, bool, AccessLevel, AccessLevel, bool, bool))
ERROR(generic_param_usable_from_inline,none,
"type referenced from a "
"generic %select{parameter|requirement}1 of a '@usableFromInline' %0 "
"must be '@usableFromInline' or public",
(DescriptiveDeclKind, bool))
WARNING(generic_param_usable_from_inline_warn,none,
"type referenced from a "
"generic %select{parameter|requirement}1 of a '@usableFromInline' %0 "
"should be '@usableFromInline' or public",
(DescriptiveDeclKind, bool))
ERROR(override_multiple_decls_base,none,
"declaration %0 cannot override more than one superclass declaration",
(DeclName))
ERROR(override_multiple_decls_arg_mismatch,none,
"declaration %0 has different argument labels from any potential "
"overrides", (DeclName))
NOTE(overridden_near_match_here,none,
"potential overridden %0 %1 here",
(DescriptiveDeclKind, DeclName))
ERROR(override_decl_extension,none,
"%select{|non-@objc}0 %2 %3 %select{"
"is declared in extension of %4 and cannot be overridden|"
"declared in %4 cannot be overridden from extension}1",
(bool, bool, DescriptiveDeclKind, DeclName, DeclName))
NOTE(overridden_here,none,
"overridden declaration is here", ())
NOTE(overridden_here_can_be_objc,none,
"add '@objc' to make this declaration overridable", ())
ERROR(missing_override,none,
"overriding declaration requires an 'override' keyword", ())
WARNING(missing_override_warn,none,
"implicit override should be marked with 'override' or suppressed "
"with '@_nonoverride'", ())
ERROR(multiple_override,none,
"%0 has already been overridden", (DeclName))
NOTE(multiple_override_prev,none,
"%0 previously overridden here", (DeclName))
ERROR(override_unavailable, none,
"cannot override %0 which has been marked unavailable%select{|: %1}1",
(DeclBaseName, StringRef))
NOTE(suggest_removing_override, none,
"remove 'override' modifier to declare a new %0",
(DeclBaseName))
ERROR(override_less_available,none,
"overriding %0 must be as available as declaration it overrides",
(DeclBaseName))
ERROR(override_accessor_less_available,none,
"overriding %0 for %1 must be as available as declaration it overrides",
(DescriptiveDeclKind, DeclBaseName))
ERROR(override_let_property,none,
"cannot override immutable 'let' property %0 with the getter of a 'var'",
(Identifier))
ERROR(override_not_accessible,none,
"%select{|setter of }0overriding %1 must be as accessible as "
"%select{its enclosing type|the declaration it overrides}2",
(bool, DescriptiveDeclKind, bool))
ERROR(override_of_non_open,none,
"overriding non-open %0 outside of its defining module",
(DescriptiveDeclKind))
ERROR(method_does_not_override,none,
"method does not override any method from its %select{parent protocol|superclass}0", (bool))
ERROR(property_does_not_override,none,
"property does not override any property from its %select{parent protocol|superclass}0", (bool))
ERROR(subscript_does_not_override,none,
"subscript does not override any subscript from its %select{parent protocol|superclass}0", (bool))
ERROR(initializer_does_not_override,none,
"initializer does not override a designated initializer from its "
"%select{parent protocol|superclass}0", (bool))
ERROR(failable_initializer_override,none,
"failable initializer %0 cannot override a non-failable initializer",
(DeclName))
NOTE(nonfailable_initializer_override_here,none,
"non-failable initializer %0 overridden here", (DeclName))
NOTE(property_override_here,none,
"attempt to override property here", ())
NOTE(subscript_override_here,none,
"attempt to override subscript here", ())
NOTE(convenience_init_override_here,none,
"attempt to override convenience initializer here", ())
NOTE(override_type_mismatch_with_fixits,none,
"type does not match superclass %0 with type %1",
(DescriptiveDeclKind, Type))
NOTE(override_type_mismatch_with_fixits_init,none,
"type does not match superclass initializer with %select{no arguments|argument %1|arguments %1}0",
(unsigned, Type))
ERROR(override_nonclass_decl,none,
"'override' can only be specified on class members", ())
ERROR(nonoverride_wrong_decl_context,none,
"'@_nonoverride' can only be specified on class or protocol members", ())
ERROR(nonoverride_and_override_attr,none,
"'override' cannot be combined with '@_nonoverride'", ())
ERROR(override_property_type_mismatch,none,
"property %0 with type %1 cannot override a property with type %2",
(Identifier, Type, Type))
ERROR(override_with_stored_property,none,
"cannot override with a stored property %0", (Identifier))
WARNING(override_with_stored_property_warn,none,
"cannot override with a stored property %0", (Identifier))
ERROR(observing_readonly_property,none,
"cannot observe read-only property %0; it can't change", (Identifier))
ERROR(override_mutable_with_readonly_property,none,
"cannot override mutable property with read-only property %0",
(Identifier))
ERROR(override_argument_name_mismatch,none,
"argument labels for %select{method|initializer}0 %1 do not match those "
"of overridden %select{method|initializer}0 %2",
(bool, DeclName, DeclName))
ERROR(override_ownership_mismatch,none,
"cannot override %0 property with %1 property",
(ReferenceOwnership, ReferenceOwnership))
ERROR(override_dynamic_self_mismatch,none,
"cannot override a Self return type with a non-Self return type",
())
ERROR(override_class_declaration_in_extension,none,
"cannot override a non-dynamic class declaration from an extension",
())
ERROR(override_with_more_effects,none,
"cannot override non-%1 %0 with %1 %0",
(DescriptiveDeclKind, StringRef))
ERROR(override_throws_objc,none,
"overriding a throwing @objc %select{method|initializer}0 with "
"a non-throwing %select{method|initializer}0 is not supported", (bool))
ERROR(satisfy_throws_objc,none,
"satisfying a throwing @objc %select{method|initializer}0 with "
"a non-throwing %select{method|initializer}0 is not supported", (bool))
ERROR(override_optional_mismatch,none,
"cannot override %0 %select{parameter|index}1 of type %2 with "
"non-optional type %3",
(DescriptiveDeclKind, bool, Type, Type))
ERROR(override_optional_result_mismatch,none,
"cannot override %0 %select{result|element}1 type %2 with "
"optional type %3",
(DescriptiveDeclKind, bool, Type, Type))
WARNING(override_unnecessary_IUO,none,
"overriding %0 parameter of type %1 with implicitly unwrapped optional "
"type %2",
(DescriptiveDeclKind, Type, Type))
WARNING(override_unnecessary_result_IUO,none,
"overriding %0 optional result type %1 with implicitly unwrapped "
"optional type %2",
(DescriptiveDeclKind, Type, Type))
NOTE(override_unnecessary_IUO_remove,none,
"remove '!' to make the parameter required", ())
NOTE(override_unnecessary_IUO_use_strict,none,
"use '?' to make the result optional", ())
NOTE(override_unnecessary_IUO_silence,none,
"add parentheses to silence this warning", ())
ERROR(override_mutable_covariant_property,none,
"cannot override mutable property %0 of type %1 with covariant type %2",
(Identifier, Type, Type))
ERROR(override_mutable_covariant_subscript,none,
"cannot override mutable subscript of type %0 with covariant type %1",
(Type, Type))
ERROR(static_decl_already_final,none,
"static declarations are already final", ())
ERROR(open_decl_cannot_be_final,none,
"%0 cannot be declared both 'final' and 'open'", (DescriptiveDeclKind))
ERROR(implicitly_final_cannot_be_open,none,
"%select{'let' properties|members of 'final' classes|"
"static declarations}0 are implicitly 'final'; use 'public' instead of "
"'open'", (unsigned))
WARNING(implicitly_final_cannot_be_open_swift4,none,
"%select{'let' properties|members of 'final' classes|"
"static declarations}0 are implicitly 'final'; use 'public' instead of "
"'open'", (unsigned))
WARNING(override_swift3_objc_inference,none,
"override of %0 %1 from extension of %2 depends on deprecated "
"inference of '@objc'",
(DescriptiveDeclKind, DeclName, Identifier))
ERROR(override_method_different_generic_sig,none,
"overridden method %0 has generic signature %1 which is incompatible with "
"base method's generic signature %2; expected generic signature to be %3",
(DeclBaseName, StringRef, StringRef, StringRef))
// Inheritance
ERROR(duplicate_inheritance,none,
"duplicate inheritance from %0", (Type))
WARNING(duplicate_anyobject_class_inheritance,none,
"redundant inheritance from 'AnyObject' and Swift 3 'class' keyword", ())
ERROR(inheritance_from_protocol_with_superclass,none,
"inheritance from class-constrained protocol composition type %0", (Type))
WARNING(anyobject_class_inheritance_deprecated,none,
"using 'class' keyword to define a class-constrained protocol is deprecated; "
"use 'AnyObject' instead", ())
ERROR(multiple_inheritance,none,
"multiple inheritance from classes %0 and %1", (Type, Type))
ERROR(inheritance_from_non_protocol_or_class,none,
"inheritance from non-protocol, non-class type %0", (Type))
ERROR(inheritance_from_non_protocol,none,
"inheritance from non-protocol type %0", (Type))
ERROR(superclass_not_first,none,
"superclass %0 must appear first in the inheritance clause", (Type))
ERROR(superclass_not_open,none,
"cannot inherit from non-open class %0 outside of its defining module",
(Type))
NOTE(superclass_here,none,"superclass is declared here", ())
ERROR(superclass_of_open_not_open,none,
"superclass %0 of open class must be open", (Type))
ERROR(inheritance_from_final_class,none,
"inheritance from a final class %0", (Type))
ERROR(inheritance_from_unspecialized_objc_generic_class,none,
"inheritance from a generic Objective-C class %0 must bind "
"type parameters of %0 to specific concrete types", (Identifier))
ERROR(inheritance_from_class_with_missing_vtable_entries,none,
"cannot inherit from class %0 because it has overridable members that "
"could not be loaded",
(Identifier))
ERROR(inheritance_from_class_with_missing_vtable_entries_versioned,none,
"cannot inherit from class %0 (compiled with Swift %1) because it has "
"overridable members that could not be loaded in Swift %2",
(Identifier, llvm::VersionTuple, llvm::VersionTuple))
ERROR(inheritance_from_cf_class,none,
"cannot inherit from Core Foundation type %0", (Identifier))
ERROR(inheritance_from_objc_runtime_visible_class,none,
"cannot inherit from class %0 because it is only visible via the "
"Objective-C runtime", (Identifier))
// Enums
ERROR(enum_case_access,none,
"enum case in %select{a private|a fileprivate|an internal|a public|%error}0 enum "
"uses %select{a private|a fileprivate|an internal|%error|%error}1 type",
(AccessLevel, AccessLevel))
WARNING(enum_case_access_warn,none,
"enum case in %select{a private|a fileprivate|an internal|a public|%error}0 enum "
"uses %select{a private|a fileprivate|an internal|%error|%error}1 type",
(AccessLevel, AccessLevel))
ERROR(enum_case_usable_from_inline,none,
"type of enum case in '@usableFromInline' enum "
"must be '@usableFromInline' or public", ())
WARNING(enum_case_usable_from_inline_warn,none,
"type of enum case in '@usableFromInline' enum "
"should be '@usableFromInline' or public", ())
ERROR(enum_stored_property,none,
"enums must not contain stored properties", ())
// Enum raw types
ERROR(multiple_enum_raw_types,none,
"multiple enum raw types %0 and %1", (Type, Type))
ERROR(raw_type_not_first,none,
"raw type %0 must appear first in the enum inheritance clause", (Type))
ERROR(raw_type_not_literal_convertible,none,
"raw type %0 is not expressible by a string, integer, or floating-point literal",
(Type))
ERROR(enum_raw_type_not_equatable,none,
"RawRepresentable conformance cannot be synthesized because raw type %0 is not "
"Equatable", (Type))
ERROR(enum_raw_type_nonconforming_and_nonsynthable,none,
"%0 declares raw type %1, but does not conform to RawRepresentable "
"and conformance could not be synthesized", (Type, Type))
NOTE(enum_declares_rawrep_with_raw_type,none,
"%0 declares raw type %1, which implies RawRepresentable", (Type, Type))
ERROR(enum_raw_type_access,none,
"enum %select{must be declared %select{"
"%select{private|fileprivate|internal|%error|%error}1|private or fileprivate}3"
"|cannot be declared "
"%select{in this context|fileprivate|internal|public|open}1}0 "
"because its raw type uses "
"%select{a private|a fileprivate|an internal|%error|%error}2 type",
(bool, AccessLevel, AccessLevel, bool))
WARNING(enum_raw_type_access_warn,none,
"enum %select{should be declared "
"%select{private|fileprivate|internal|%error|%error}1"
"|should not be declared %select{in this context|fileprivate|internal|public|open}1}0 "
"because its raw type uses "
"%select{a private|a fileprivate|an internal|%error|%error}2 type",
(bool, AccessLevel, AccessLevel, bool))
ERROR(enum_raw_type_not_usable_from_inline,none,
"type referenced from the raw type of a "
"'@usableFromInline' enum "
"must be '@usableFromInline' or public",
())
WARNING(enum_raw_type_not_usable_from_inline_warn,none,
"type referenced from the raw type of a "
"'@usableFromInline' enum "
"should be '@usableFromInline' or public",
())
ERROR(empty_enum_raw_type,none,
"an enum with no cases cannot declare a raw type", ())
ERROR(enum_raw_value_without_raw_type,none,
"enum case cannot have a raw value if the enum does not have a raw type", ())
ERROR(enum_with_raw_type_case_with_argument,none,
"enum with raw type cannot have cases with arguments", ())
NOTE(enum_raw_type_here,none,
"declared raw type %0 here", (Type))
ERROR(objc_enum_no_raw_type,none,
"'@objc' enum must declare an integer raw type", ())
ERROR(objc_enum_raw_type_not_integer,none,
"'@objc' enum raw type %0 is not an integer type", (Type))
ERROR(enum_non_integer_raw_value_auto_increment,none,
"enum case must declare a raw value when the preceding raw value is not an integer", ())
ERROR(enum_non_integer_convertible_raw_type_no_value,none,
"enum cases require explicit raw values when the raw type is not "
"expressible by integer or string literal", ())
ERROR(enum_raw_value_not_unique,none,
"raw value for enum case is not unique", ())
ERROR(enum_raw_value_magic_literal,none,
"use of '%0' literal as raw value for enum case is not supported",
(StringRef))
NOTE(enum_raw_value_used_here,none,
"raw value previously used here", ())
NOTE(enum_raw_value_incrementing_from_here,none,
"raw value auto-incremented from here",())
NOTE(enum_raw_value_incrementing_from_zero,none,
"raw value implicitly auto-incremented from zero",())
NOTE(construct_raw_representable_from_unwrapped_value,none,
"construct %0 from unwrapped %1 value", (Type, Type))
ERROR(decl_from_hidden_module,none,
"cannot use %0 %1 %select{here|as property wrapper here|"
"as result builder here|"
"in an extension with public or '@usableFromInline' members|"
"in an extension with conditional conformances}2; "
"%select{%3 has been imported as implementation-only|"
"it is an SPI imported from %3|"
"it is SPI}4",
(DescriptiveDeclKind, DeclName, unsigned, Identifier, unsigned))
WARNING(decl_from_hidden_module_warn,none,
"cannot use %0 %1 %select{in SPI|as property wrapper in SPI|"
"as result builder in SPI|"
"in an extension with public or '@usableFromInline' members|"
"in an extension with conditional conformances}2; "
"%select{%3 has been imported as implementation-only}4",
(DescriptiveDeclKind, DeclName, unsigned, Identifier, unsigned))
ERROR(conformance_from_implementation_only_module,none,
"cannot use conformance of %0 to %1 %select{here|as property wrapper here|"
"as result builder here|"
"in an extension with public or '@usableFromInline' members|"
"in an extension with conditional conformances}2; "
"%select{%3 has been imported as implementation-only|"
"the conformance is declared as SPI in %3|"
"the conformance is declared as SPI}4",
(Type, Identifier, unsigned, Identifier, unsigned))
NOTE(assoc_conformance_from_implementation_only_module,none,
"in associated type %0 (inferred as %1)", (Type, Type))
ERROR(unexportable_clang_function_type,none,
"cannot export the underlying C type of the function type %0; "
"it may use anonymous types or types defined outside of a module",
(Type))
ERROR(cxx_class_instantiation_failed,none,
"couldn't instantiate a C++ class template",
())
WARNING(warn_implementation_only_conflict,none,
"%0 inconsistently imported as implementation-only",
(Identifier))
NOTE(implementation_only_conflict_here,none,
"imported as implementation-only here", ())
WARNING(warn_public_import_of_private_module,none,
"private module %0 is imported publicly from the public module %1",
(Identifier, Identifier))
ERROR(implementation_only_decl_non_override,none,
"'@_implementationOnly' can only be used on overrides", ())
ERROR(implementation_only_override_changed_type,none,
"'@_implementationOnly' override must have the same type as the "
"declaration it overrides (%0)", (Type))
ERROR(implementation_only_override_without_attr,none,
"override of '@_implementationOnly' %0 should also be declared "
"'@_implementationOnly'", (DescriptiveDeclKind))
ERROR(implementation_only_override_import_without_attr,none,
"override of %0 imported as implementation-only must be declared "
"'@_implementationOnly'", (DescriptiveDeclKind))
// Derived conformances
ERROR(cannot_synthesize_init_in_extension_of_nonfinal,none,
"implementation of %0 for non-final class cannot be automatically "
"synthesized in extension because initializer requirement %1 can only "
"be satisfied by a 'required' initializer in the class definition",
(Type, DeclName))
ERROR(cannot_synthesize_in_crossfile_extension,none,
"extension outside of file declaring %0 %1 prevents automatic synthesis "
"of %2 for protocol %3",
(DescriptiveDeclKind, DeclName, DeclName, Type))
ERROR(broken_additive_arithmetic_requirement,none,
"AdditiveArithmetic protocol is broken: unexpected requirement", ())
ERROR(broken_case_iterable_requirement,none,
"CaseIterable protocol is broken: unexpected requirement", ())
ERROR(broken_raw_representable_requirement,none,
"RawRepresentable protocol is broken: unexpected requirement", ())
ERROR(broken_comparable_requirement,none,
"Comparable protocol is broken: unexpected requirement", ())
ERROR(broken_equatable_requirement,none,
"Equatable protocol is broken: unexpected requirement", ())
ERROR(broken_hashable_requirement,none,
"Hashable protocol is broken: unexpected requirement", ())
ERROR(broken_hashable_no_hasher,none,
"Hashable protocol is broken: Hasher type not found", ())
ERROR(broken_errortype_requirement,none,
"Error protocol is broken: unexpected requirement", ())
ERROR(broken_int_hashable_conformance,none,
"Int type is broken: does not conform to Hashable", ())
ERROR(broken_int_integer_literal_convertible_conformance,none,
"Int type is broken: does not conform to ExpressibleByIntegerLiteral", ())
ERROR(no_less_than_overload_for_int,none,
"no overload of '<' for Int", ())
ERROR(no_equal_overload_for_int,none,
"no overload of '==' for Int", ())
ERROR(broken_coding_key_requirement,none,
"CodingKey protocol is broken: unexpected requirement", ())
ERROR(broken_encodable_requirement,none,
"Encodable protocol is broken: unexpected requirement", ())
ERROR(broken_decodable_requirement,none,
"Decodable protocol is broken: unexpected requirement", ())
ERROR(broken_differentiable_requirement,none,
"Differentiable protocol is broken: unexpected requirement", ())
WARNING(differentiable_nondiff_type_implicit_noderivative_fixit,none,
"stored property %0 has no derivative because %1 does not conform to "
"'Differentiable'; add an explicit '@noDerivative' attribute"
"%select{|, or conform %2 to 'AdditiveArithmetic'}3",
(/*propName*/ Identifier, /*propType*/ Type, /*nominalName*/ Identifier,
/*nominalCanDeriveAdditiveArithmetic*/ bool))
WARNING(differentiable_immutable_wrapper_implicit_noderivative_fixit,none,
"synthesis of the 'Differentiable.move(by:)' requirement for %1 "
"requires 'wrappedValue' in property wrapper %0 to be mutable or have a "
"non-mutating 'move(by:)'; add an explicit '@noDerivative' attribute"
"%select{|, or conform %1 to 'AdditiveArithmetic'}2",
(/*wrapperType*/ Identifier, /*nominalName*/ Identifier,
/*nominalCanDeriveAdditiveArithmetic*/ bool))
WARNING(differentiable_let_property_implicit_noderivative_fixit,none,
"synthesis of the 'Differentiable.move(by:)' requirement for %0 "
"requires all stored properties not marked with `@noDerivative` to be "
"mutable or have a non-mutating 'move(by:)'; use 'var' instead, or "
"add an explicit '@noDerivative' attribute "
"%select{|, or conform %0 to 'AdditiveArithmetic'}1",
(/*nominalName*/ Identifier, /*nominalCanDeriveAdditiveArithmetic*/ bool))
NOTE(codable_extraneous_codingkey_case_here,none,
"CodingKey case %0 does not match any stored properties", (Identifier))
NOTE(codable_non_conforming_property_here,none,
"cannot automatically synthesize %0 because %1 does not conform to %0", (Type, TypeLoc))
NOTE(codable_non_decoded_property_here,none,
"cannot automatically synthesize %0 because %1 does not have a matching "
"CodingKey and does not have a default value", (Type, Identifier))
NOTE(codable_codingkeys_type_is_not_an_enum_here,none,
"cannot automatically synthesize %0 because 'CodingKeys' is not an enum", (Type))
NOTE(codable_codingkeys_type_does_not_conform_here,none,
"cannot automatically synthesize %0 because 'CodingKeys' does not conform to CodingKey", (Type))
NOTE(decodable_no_super_init_here,none,
"cannot automatically synthesize %0 because superclass does not have a callable %1", (DeclName, DeclName))
NOTE(decodable_super_init_not_designated_here,none,
"cannot automatically synthesize %0 because implementation would need to call %1, which is not designated", (DeclName, DeclName))
NOTE(decodable_inaccessible_super_init_here,none,
"cannot automatically synthesize %0 because implementation would need to call %1, which is inaccessible due to "
"'%select{private|fileprivate|internal|%error|%error}2' protection level",
(DeclName, DeclName, AccessLevel))
NOTE(decodable_super_init_is_failable_here,none,
"cannot automatically synthesize %0 because implementation would need to call %1, which is failable", (DeclName, DeclName))
NOTE(decodable_suggest_overriding_init_here,none,
"did you mean to override 'init(from:)'?", ())
NOTE(codable_suggest_overriding_init_here,none,
"did you mean to override 'init(from:)' and 'encode(to:)'?", ())
NOTE(codable_enum_duplicate_case_name_here,none,
"cannot automatically synthesize %0 because %1 has duplicate "
"case name %2", (Type, Type, Identifier))
NOTE(codable_enum_duplicate_parameter_name_here,none,
"cannot automatically synthesize %0 for %1 because "
"user defined parameter name %2 in %3 conflicts with "
"automatically generated parameter name", (Type, Type, Identifier, Identifier))
WARNING(decodable_property_will_not_be_decoded, none,
"immutable property will not be decoded because it is declared with "
"an initial value which cannot be overwritten", ())
NOTE(decodable_property_init_or_codingkeys_implicit, none,
"set the initial value via the initializer or explicitly define a "
"CodingKeys enum %select{including|without}0 a %1 case to silence "
"this warning", (unsigned, DeclName))
NOTE(decodable_property_init_or_codingkeys_explicit, none,
"set the initial value via the initializer or remove the %0 case from "
"the CodingKeys enum to silence this warning", (DeclName))
NOTE(decodable_make_property_mutable, none,
"make the property mutable instead", ())
NOTE(missing_member_type_conformance_prevents_synthesis, none,
"%select{associated value|stored property}0 type %1 does not conform to "
"protocol %2, preventing synthesized conformance "
"of %3 to %2",
(unsigned, Type, Type, Type))
NOTE(automatic_protocol_synthesis_unsupported,none,
"automatic synthesis of '%0' is not supported for %select{classes|structs}1",
(StringRef, unsigned))
NOTE(comparable_synthesis_raw_value_not_allowed, none,
"enum declares raw type %0, preventing synthesized conformance of %1 to %2",
(Type, Type, Type))
// Dynamic Self
ERROR(dynamic_self_non_method,none,
"%select{global|local}0 function cannot return 'Self'", (bool))
ERROR(dynamic_self_invalid,none,
"covariant 'Self' or 'Self?' can only appear as the type of a "
"property, subscript or method result; did you mean '%0'?", (StringRef))
ERROR(dynamic_self_in_mutable_property,none,
"mutable property cannot have covariant 'Self' type", ())
ERROR(dynamic_self_in_stored_property,none,
"stored property cannot have covariant 'Self' type", ())
ERROR(dynamic_self_in_mutable_subscript,none,
"mutable subscript cannot have covariant 'Self' type", ())
ERROR(dynamic_self_invalid_property,none,
"covariant 'Self' or 'Self?' can only appear at the top level of "
"property type", ())
ERROR(dynamic_self_invalid_subscript,none,
"covariant 'Self' or 'Self?' can only appear at the top level of "
"subscript element type", ())
ERROR(dynamic_self_invalid_method,none,
"covariant 'Self' or 'Self?' can only appear at the top level of "
"method result type", ())
ERROR(dynamic_self_stored_property_init,none,
"covariant 'Self' type cannot be referenced from a stored property initializer", ())
ERROR(dynamic_self_default_arg,none,
"covariant 'Self' type cannot be referenced from a default argument expression", ())
//------------------------------------------------------------------------------
// MARK: Type Check Attributes
//------------------------------------------------------------------------------
ERROR(attr_only_one_decl_kind,none,
"%0 may only be used on '%1' declarations", (DeclAttribute,StringRef))
ERROR(attr_not_on_variadic_parameters,none,
"'%0' must not be used on variadic parameters", (StringRef))
ERROR(attr_not_on_subscript_parameters,none,
"'%0' must not be used on subscript parameters", (StringRef))
ERROR(attr_ambiguous_reference_to_decl,none,
"ambiguous reference to %0 in '@%1' attribute", (DeclNameRef, StringRef))
ERROR(override_final,none,
"%0 overrides a 'final' %1", (DescriptiveDeclKind, DescriptiveDeclKind))
ERROR(override_static,none,
"cannot override %0", (DescriptiveDeclKind))
ERROR(member_cannot_be_final,none,
"only classes and class members may be marked with 'final'",
())
ERROR(final_not_allowed_here,none,
"'final' may only be applied to classes, properties, methods, and "
"subscripts", ())
ERROR(final_not_on_accessors,none,
"'final' cannot be applied to accessors, it must be put on the "
"%select{var|let|subscript}0", (unsigned))
ERROR(override_rethrows_with_non_rethrows,none,
"override of 'rethrows' %select{method|initializer}0 should also "
"be 'rethrows'", (bool))
ERROR(rethrows_without_throwing_parameter,none,
"'rethrows' function must take a throwing function argument", ())
ERROR(override_reasync_with_non_reasync,none,
"override of 'reasync' %select{method|initializer}0 should also "
"be 'reasync'", (bool))
ERROR(reasync_without_async_parameter,none,
"'reasync' function must take an 'async' function argument", ())
ERROR(autoclosure_function_type,none,
"@autoclosure attribute only applies to function types",
())
ERROR(invalid_autoclosure_and_convention_attributes,none,
"'@convention(%0)' attribute is not allowed on '@autoclosure' types",
(StringRef))
ERROR(autoclosure_function_input_nonunit,none,
"argument type of @autoclosure parameter must be '()'", ())
ERROR(escaping_non_function_parameter,none,
"@escaping attribute may only be used in function parameter position", ())
ERROR(escaping_optional_type_argument, none,
"closure is already escaping in optional type argument", ())
// @_nonEphemeral attribute
ERROR(non_ephemeral_non_pointer_type,none,
"@_nonEphemeral attribute only applies to pointer types", ())
// NSManaged attribute
ERROR(attr_NSManaged_not_instance_member,none,
"@NSManaged only allowed on an instance property or method", ())
ERROR(attr_NSManaged_not_stored,none,
"@NSManaged not allowed on %select{computed|observing|addressed}0 "
"properties", (unsigned))
ERROR(attr_NSManaged_let_property,none,
"@NSManaged not allowed on a 'let' property", ())
ERROR(attr_NSManaged_initial_value,none,
"@NSManaged property cannot have an initial value", ())
ERROR(attr_NSManaged_NSCopying,none,
"@NSManaged property cannot also be marked @NSCopying", ())
ERROR(attr_NSManaged_method_body,none,
"@NSManaged method cannot have a body; it must be provided at runtime",())
// NSCopying attribute
ERROR(nscopying_only_on_class_properties,none,
"@NSCopying may only be used on properties in classes",
())
ERROR(nscopying_only_mutable,none,
"@NSCopying requires property to be mutable", ())
ERROR(nscopying_only_stored_property,none,
"@NSCopying is only valid on stored properties", ())
ERROR(nscopying_doesnt_conform,none,
"@NSCopying is only valid with types that conform to"
" the NSCopying protocol", ())
// UIApplicationMain/NSApplicationMain attribute
#define SELECT_APPLICATION_MAIN "select{'UIApplicationMain'|'NSApplicationMain'|'main'}"
#define SELECT_APPLICATION_DELEGATE "select{'UIApplicationDelegate'|'NSApplicationDelegate'}"
#define SELECT_APPLICATION_TYPE "select{class|class|type}"
#define SELECT_APPLICATION_TYPES "select{classes|classes|types}"
ERROR(attr_ApplicationMain_not_ApplicationDelegate,none,
"%" SELECT_APPLICATION_MAIN "0 class must conform to the %" SELECT_APPLICATION_DELEGATE "0 protocol",
(unsigned))
ERROR(attr_generic_ApplicationMain_not_supported,none,
"generic %" SELECT_APPLICATION_MAIN "0 %" SELECT_APPLICATION_TYPES "0 are not supported",
(unsigned))
ERROR(attr_ApplicationMain_multiple,none,
"%" SELECT_APPLICATION_MAIN "0 attribute can only apply to one %" SELECT_APPLICATION_TYPE "0 in a module",
(unsigned))
ERROR(attr_ApplicationMain_with_script,none,
"%" SELECT_APPLICATION_MAIN "0 attribute cannot be used in a module that contains "
"top-level code",
(unsigned))
NOTE(attr_ApplicationMain_script_here,none,
"top-level code defined in this source file",
())
ERROR(attr_MainType_without_main,none,
"%0 is annotated with @main and must provide a main static function of type () -> Void or () throws -> Void.",
(DeclName))
#undef SELECT_APPLICATION_MAIN
#undef SELECT_APPLICATION_DELEGATE
// lazy
ERROR(lazy_not_on_let,none,
"'lazy' cannot be used on a let", ())
ERROR(lazy_not_on_computed,none,
"'lazy' cannot be used on a computed property", ())
ERROR(lazy_on_already_lazy_global,none,
"'lazy' cannot be used on an already-lazy global", ())
ERROR(lazy_not_in_protocol,none,
"'lazy' cannot be used on a protocol requirement", ())
ERROR(lazy_requires_initializer,none,
"lazy properties must have an initializer", ())
ERROR(lazy_requires_single_var,none,
"'lazy' cannot destructure an initializer", ())
ERROR(lazy_not_strong,none,
"lazy properties cannot be %0", (ReferenceOwnership))
ERROR(lazy_var_storage_access,none,
"access to the underlying storage of a lazy property is not allowed", ())
// Debugger function attribute.
ERROR(attr_for_debugger_support_only,none,
"@LLDBDebuggerSupport may only be used when debugger support is on", ())
// @_implements
ERROR(implements_attr_protocol_lacks_member,none,
"protocol %0 has no member %1", (Identifier, DeclName))
ERROR(implements_attr_non_protocol_type,none,
"non-protocol type in @_implements attribute", ())
ERROR(implements_attr_protocol_not_conformed_to,none,
"containing type %0 does not conform to protocol %1",
(Identifier, Identifier))
// @differentiable
ERROR(differentiable_attr_overload_not_found,none,
"%0 does not have expected type %1", (DeclNameRef, Type))
// TODO(TF-482): Change duplicate `@differentiable` attribute diagnostic to also
// mention "same generic requirements".
ERROR(differentiable_attr_duplicate,none,
"duplicate '@differentiable' attribute with same parameters", ())
NOTE(differentiable_attr_duplicate_note,none,
"other attribute declared here", ())
ERROR(differentiable_attr_function_not_same_type_context,none,
"%0 is not defined in the current type context", (DeclNameRef))
ERROR(differentiable_attr_derivative_not_function,none,
"registered derivative %0 must be a 'func' declaration", (DeclNameRef))
ERROR(differentiable_attr_class_derivative_not_final,none,
"class member derivative must be final", ())
ERROR(differentiable_attr_invalid_access,none,
"derivative function %0 is required to either be public or "
"'@usableFromInline' because the original function %1 is public or "
"'@usableFromInline'", (DeclNameRef, DeclName))
ERROR(differentiable_attr_protocol_req_where_clause,none,
"'@differentiable' attribute on protocol requirement cannot specify "
"'where' clause", ())
ERROR(differentiable_attr_class_member_dynamic_self_result_unsupported,none,
"'@differentiable' attribute cannot be declared on class members "
"returning 'Self'", ())
ERROR(differentiable_attr_nonfinal_class_init_unsupported,none,
"'@differentiable' attribute cannot be declared on 'init' in a non-final "
"class; consider making %0 final", (Type))
ERROR(differentiable_attr_empty_where_clause,none,
"empty 'where' clause in '@differentiable' attribute", ())
ERROR(differentiable_attr_where_clause_for_nongeneric_original,none,
"'where' clause is valid only when original function is generic %0",
(DeclName))
ERROR(differentiable_attr_layout_req_unsupported,none,
"'@differentiable' attribute does not yet support layout requirements",
())
ERROR(overriding_decl_missing_differentiable_attr,none,
"overriding declaration is missing attribute '%0'", (StringRef))
NOTE(protocol_witness_missing_differentiable_attr_invalid_context,none,
"candidate is missing explicit '%0' attribute to satisfy requirement %1 "
"(in protocol %3); explicit attribute is necessary because candidate is "
"declared in a different type context or file than the conformance of %2 "
"to %3", (StringRef, DeclName, Type, Type))
// @derivative
ERROR(derivative_attr_expected_result_tuple,none,
"'@derivative(of:)' attribute requires function to return a two-element "
"tuple; first element must have label 'value:' and second element must "
"have label 'pullback:' or 'differential:'", ())
ERROR(derivative_attr_invalid_result_tuple_value_label,none,
"'@derivative(of:)' attribute requires function to return a two-element "
"tuple; first element must have label 'value:'", ())
ERROR(derivative_attr_invalid_result_tuple_func_label,none,
"'@derivative(of:)' attribute requires function to return a two-element "
"tuple; second element must have label 'pullback:' or 'differential:'",
())
ERROR(derivative_attr_result_value_not_differentiable,none,
"'@derivative(of:)' attribute requires function to return a two-element "
"tuple; first element type %0 must conform to 'Differentiable'", (Type))
ERROR(derivative_attr_result_func_type_mismatch,none,
"function result's %0 type does not match %1", (Identifier, DeclName))
NOTE(derivative_attr_result_func_type_mismatch_note,none,
"%0 does not have expected type %1", (Identifier, Type))
NOTE(derivative_attr_result_func_original_note,none,
"%0 defined here", (DeclName))
ERROR(derivative_attr_not_in_same_file_as_original,none,
"derivative not in the same file as the original function", ())
ERROR(derivative_attr_original_stored_property_unsupported,none,
"cannot register derivative for stored property %0", (DeclNameRef))
ERROR(derivative_attr_class_member_dynamic_self_result_unsupported,none,
"cannot register derivative for class member %0 returning 'Self'",
(DeclNameRef))
ERROR(derivative_attr_nonfinal_class_init_unsupported,none,
"cannot register derivative for 'init' in a non-final class; consider "
"making %0 final", (Type))
ERROR(derivative_attr_unsupported_accessor_kind,none,
"cannot register derivative for %0", (/*accessorKind*/ DescriptiveDeclKind))
// TODO(SR-13096): Remove this temporary diagnostic.
ERROR(derivative_attr_class_setter_unsupported,none,
"cannot yet register derivative for class property or subscript setters",
())
// TODO(TF-982): Remove this temporary diagnostic.
NOTE(derivative_attr_protocol_requirement_unsupported,none,
"cannot yet register derivative default implementation for protocol "
"requirements", ())
ERROR(derivative_attr_original_already_has_derivative,none,
"a derivative already exists for %0", (DeclName))
NOTE(derivative_attr_duplicate_note,none,
"other attribute declared here", ())
ERROR(derivative_attr_access_level_mismatch,none,
"derivative function must have same access level as original function; "
"derivative function %2 is "
"%select{private|fileprivate|internal|public|open}3, "
"but original function %0 is "
"%select{private|fileprivate|internal|public|open}1",
(/*original*/ DeclName, /*original*/ AccessLevel,
/*derivative*/ DeclName, /*derivative*/ AccessLevel))
NOTE(derivative_attr_fix_access,none,
"mark the derivative function as "
"'%select{private|fileprivate|internal|@usableFromInline|@usableFromInline}0' "
"to match the original function", (AccessLevel))
ERROR(derivative_attr_static_method_mismatch_original,none,
"unexpected derivative function declaration; "
"%0 requires the derivative function %1 to be %select{an instance|a 'static'}2 method",
(/*original*/DeclName, /*derivative*/ DeclName,
/*originalIsStatic*/bool))
NOTE(derivative_attr_static_method_mismatch_original_note,none,
"original function %0 is %select{an instance|a 'static'}1 method",
(/*original*/ DeclName, /*originalIsStatic*/bool))
NOTE(derivative_attr_static_method_mismatch_fix,none,
"make derivative function %0 %select{an instance|a 'static'}1 method",
(/*derivative*/ DeclName, /*mustBeStatic*/bool))
// @transpose
ERROR(transpose_attr_invalid_linearity_parameter_or_result,none,
"cannot transpose with respect to original %select{result|parameter}1 "
"'%0' that does not conform to 'Differentiable' and satisfy "
"'%0 == %0.TangentVector'", (StringRef, /*isParameter*/ bool))
ERROR(transpose_attr_overload_not_found,none,
"could not find function %0 with expected type %1", (DeclName, Type))
ERROR(transpose_attr_cannot_use_named_wrt_params,none,
"cannot use named 'wrt' parameters in '@transpose(of:)' attribute, found "
"%0", (Identifier))
ERROR(transpose_attr_wrt_self_must_be_static,none,
"the transpose of an instance method must be a 'static' method in the "
"same type when 'self' is a linearity parameter", ())
NOTE(transpose_attr_wrt_self_self_type_mismatch_note,none,
"the transpose is declared in %0 but the original function is declared in "
"%1", (Type, Type))
ERROR(transpose_attr_static_method_mismatch_original,none,
"unexpected transpose function declaration; "
"%0 requires the transpose function %1 to be %select{an instance|a 'static'}2 method",
(/*original*/DeclName, /*transpose*/ DeclName,
/*originalIsStatic*/bool))
NOTE(transpose_attr_static_method_mismatch_original_note,none,
"original function %0 is %select{an instance|a 'static'}1 method",
(/*original*/ DeclName, /*originalIsStatic*/bool))
NOTE(transpose_attr_static_method_mismatch_fix,none,
"make transpose function %0 %select{an instance|a 'static'}1 method",
(/*transpose*/ DeclName, /*mustBeStatic*/bool))
// Automatic differentiation attributes
ERROR(autodiff_attr_original_decl_ambiguous,none,
"referenced declaration %0 is ambiguous", (DeclNameRef))
NOTE(autodiff_attr_original_decl_ambiguous_candidate,none,
"candidate %0 found here", (DescriptiveDeclKind))
ERROR(autodiff_attr_original_decl_none_valid,none,
"referenced declaration %0 could not be resolved", (DeclNameRef))
NOTE(autodiff_attr_original_decl_invalid_kind,none,
"candidate %0 is not a 'func', 'init', 'subscript', or 'var' computed "
"property declaration", (DescriptiveDeclKind))
NOTE(autodiff_attr_original_decl_missing_accessor,none,
"candidate %0 does not have a %1",
(DescriptiveDeclKind, /*accessorDeclKind*/ DescriptiveDeclKind))
NOTE(autodiff_attr_original_decl_type_mismatch,none,
"candidate %0 does not have "
"%select{expected type|type equal to or less constrained than}2 %1",
(DescriptiveDeclKind, Type, /*hasGenericSignature*/ bool))
NOTE(autodiff_attr_original_decl_not_same_type_context,none,
"candidate %0 is not defined in the current type context",
(DescriptiveDeclKind))
ERROR(autodiff_attr_original_void_result,none,
"cannot differentiate void function %0", (DeclName))
ERROR(autodiff_attr_original_multiple_semantic_results,none,
"cannot differentiate functions with both an 'inout' parameter and a "
"result", ())
ERROR(autodiff_attr_result_not_differentiable,none,
"can only differentiate functions with results that conform to "
"'Differentiable', but %0 does not conform to 'Differentiable'", (Type))
ERROR(autodiff_attr_opaque_result_type_unsupported,none,
"cannot differentiate functions returning opaque result types", ())
// differentiation `wrt` parameters clause
ERROR(diff_function_no_parameters,none,
"%0 has no parameters to differentiate with respect to", (DeclName))
ERROR(diff_params_clause_param_name_unknown,none,
"unknown parameter name %0", (Identifier))
ERROR(diff_params_clause_self_instance_method_only,none,
"'self' parameter is only applicable to instance methods", ())
ERROR(diff_params_clause_self_must_be_first,none,
"'self' parameter must come first in the parameter list", ())
ERROR(diff_params_clause_params_not_original_order,none,
"parameters must be specified in original order", ())
ERROR(diff_params_clause_param_index_out_of_range,none,
"parameter index is larger than total number of parameters", ())
ERROR(diff_params_clause_no_inferred_parameters,PointsToFirstBadToken,
"no differentiation parameters could be inferred; must differentiate "
"with respect to at least one parameter conforming to 'Differentiable'",
())
ERROR(diff_params_clause_cannot_diff_wrt_inout_parameter,none,
"cannot differentiate with respect to 'inout' parameter (%0)", (Type))
ERROR(diff_params_clause_param_not_differentiable,none,
"can only differentiate with respect to parameters that conform to "
"'Differentiable', but %0 does not conform to 'Differentiable'", (Type))
// completionHanderAsync attribute
ERROR(attr_completion_handler_async_handler_not_func,none,
"'%0' should be attached to a non-async completion-handler function",
(DeclAttribute))
NOTE(note_attr_function_declared_async,none,
"function declared async", ())
NOTE(note_attr_completion_function_must_return_void,none,
"completion handler must return 'Void'", ())
NOTE(note_attr_completion_handler_async_type_is_not_function,none,
"%0 is not a function type", (Type))
NOTE(note_attr_completion_handler_async_handler_attr_req,none,
"completion handler must%select{ not|}0 be '@%1'",