//===--- ConstraintLocatorPathElts.def - Constraint Locator Path Elements -===//
//
// This source file is part of the Swift.org open source project
//
// Copyright (c) 2019 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 enumerates the elements that can make up the path of a
/// ConstraintLocator.
///
//===----------------------------------------------------------------------===//

/// Describes any kind of path element.
#ifndef LOCATOR_PATH_ELT
#define LOCATOR_PATH_ELT(Name)
#endif

/// Defines a path element which is characterized only by its kind, and as such
/// doesn't store additional values.
#ifndef SIMPLE_LOCATOR_PATH_ELT
#define SIMPLE_LOCATOR_PATH_ELT(Name) LOCATOR_PATH_ELT(Name)
#endif

/// Defines a path element that requires a class definition to be provided in
/// order to expose things like accessors for path element info.
#ifndef CUSTOM_LOCATOR_PATH_ELT
#define CUSTOM_LOCATOR_PATH_ELT(Name) LOCATOR_PATH_ELT(Name)
#endif

/// Defines an abstract path element superclass which doesn't itself have a path
/// element kind.
#ifndef ABSTRACT_LOCATOR_PATH_ELT
#define ABSTRACT_LOCATOR_PATH_ELT(Name) CUSTOM_LOCATOR_PATH_ELT(Name)
#endif

/// Matching an argument to a parameter.
CUSTOM_LOCATOR_PATH_ELT(ApplyArgToParam)

/// The argument of function application.
SIMPLE_LOCATOR_PATH_ELT(ApplyArgument)

/// The function being applied.
SIMPLE_LOCATOR_PATH_ELT(ApplyFunction)

/// An argument passed in an autoclosure parameter
/// position, which must match the autoclosure return type.
SIMPLE_LOCATOR_PATH_ELT(AutoclosureResult)

/// The result of a closure.
SIMPLE_LOCATOR_PATH_ELT(ClosureResult)

/// FIXME: Misleading name: this locator is used only for single-expression
/// closure returns.
///
/// The type of a closure body.
CUSTOM_LOCATOR_PATH_ELT(ClosureBody)

/// The lookup for a constructor member.
SIMPLE_LOCATOR_PATH_ELT(ConstructorMember)

/// The constructor member type in the lookup of a constructor.
CUSTOM_LOCATOR_PATH_ELT(ConstructorMemberType)

/// The desired contextual type passed in to the constraint system.
CUSTOM_LOCATOR_PATH_ELT(ContextualType)

/// A result of an expression involving dynamic lookup.
SIMPLE_LOCATOR_PATH_ELT(DynamicLookupResult)

/// The superclass of a protocol composition type.
SIMPLE_LOCATOR_PATH_ELT(ProtocolCompositionSuperclassType)

/// The constraint of an existential type.
SIMPLE_LOCATOR_PATH_ELT(ExistentialConstraintType)

/// The argument type of a function.
SIMPLE_LOCATOR_PATH_ELT(FunctionArgument)

/// The result type of a function.
SIMPLE_LOCATOR_PATH_ELT(FunctionResult)

/// The result type of a result builder body.
SIMPLE_LOCATOR_PATH_ELT(ResultBuilderBodyResult)

/// A generic argument.
/// FIXME: Add support for named generic arguments?
CUSTOM_LOCATOR_PATH_ELT(GenericArgument)

/// An implicit reference to a 'callAsFunction' method of a nominal type.
SIMPLE_LOCATOR_PATH_ELT(ImplicitCallAsFunction)

/// Locator for a binding from an IUO disjunction choice.
SIMPLE_LOCATOR_PATH_ELT(ImplicitlyUnwrappedDisjunctionChoice)

/// The instance of a metatype type.
SIMPLE_LOCATOR_PATH_ELT(InstanceType)

/// A generic parameter being opened.
///
/// Also contains the generic parameter type itself.
CUSTOM_LOCATOR_PATH_ELT(GenericParameter)

/// The wrappedValue type for a property wrapper.
///
/// Must equal the property declaration's property wrapper type.
CUSTOM_LOCATOR_PATH_ELT(WrappedValue)

/// A component of a key path.
CUSTOM_LOCATOR_PATH_ELT(KeyPathComponent)

/// The result type of a key path component. Not used for subscripts.
SIMPLE_LOCATOR_PATH_ELT(KeyPathComponentResult)

/// The member looked up via keypath based dynamic lookup.
CUSTOM_LOCATOR_PATH_ELT(KeyPathDynamicMember)

/// The root of a key path.
SIMPLE_LOCATOR_PATH_ELT(KeyPathRoot)

/// The type of the key path expression.
CUSTOM_LOCATOR_PATH_ELT(KeyPathType)

/// The value of a key path.
SIMPLE_LOCATOR_PATH_ELT(KeyPathValue)

/// An implicit @lvalue-to-inout conversion; only valid for operator
/// arguments.
SIMPLE_LOCATOR_PATH_ELT(LValueConversion)

/// A member.
/// FIXME: Do we need the actual member name here?
SIMPLE_LOCATOR_PATH_ELT(Member)

/// The base of a member expression.
SIMPLE_LOCATOR_PATH_ELT(MemberRefBase)

/// This is referring to a type produced by opening a generic type at the
/// base of the locator.
CUSTOM_LOCATOR_PATH_ELT(OpenedGeneric)

/// This is referring to a type produced by opening an opaque type archetype
/// type at the base of the locator.
CUSTOM_LOCATOR_PATH_ELT(OpenedOpaqueArchetype)

/// An optional payload.
SIMPLE_LOCATOR_PATH_ELT(OptionalPayload)

/// The parent of a nested type.
SIMPLE_LOCATOR_PATH_ELT(ParentType)

/// The requirement that we're matching during protocol conformance
/// checking.
CUSTOM_LOCATOR_PATH_ELT(ProtocolRequirement)

/// Type parameter requirements.
ABSTRACT_LOCATOR_PATH_ELT(AnyRequirement)
  /// The Nth conditional requirement in the parent locator's conformance.
  CUSTOM_LOCATOR_PATH_ELT(ConditionalRequirement)

  /// A single requirement placed on the type parameters.
  CUSTOM_LOCATOR_PATH_ELT(TypeParameterRequirement)

/// Access to `.dynamicType` element
SIMPLE_LOCATOR_PATH_ELT(DynamicType)

/// The element type of a sequence in a for ... in ... loop.
SIMPLE_LOCATOR_PATH_ELT(SequenceElementType)

/// The lookup for a subscript member.
SIMPLE_LOCATOR_PATH_ELT(SubscriptMember)

/// The missing argument synthesized by the solver.
CUSTOM_LOCATOR_PATH_ELT(SynthesizedArgument)

/// A tuple type, which provides context for subsequent tuple element
/// path components.
CUSTOM_LOCATOR_PATH_ELT(TupleType)

/// A generic type, which provides context for subsequent generic
/// argument path components.
CUSTOM_LOCATOR_PATH_ELT(GenericType)

/// Tuple elements.
ABSTRACT_LOCATOR_PATH_ELT(AnyTupleElement)
  /// A tuple element referenced by position.
  CUSTOM_LOCATOR_PATH_ELT(TupleElement)

  /// A tuple element referenced by name.
  CUSTOM_LOCATOR_PATH_ELT(NamedTupleElement)

/// Pack types <T, U, V, ...>
CUSTOM_LOCATOR_PATH_ELT(PackType)

/// An element of a pack type - the T in <T, U, V, ...>
CUSTOM_LOCATOR_PATH_ELT(PackElement)

/// The shape of a parameter pack.
SIMPLE_LOCATOR_PATH_ELT(PackShape)

/// The type of an "opened" pack expansion
CUSTOM_LOCATOR_PATH_ELT(PackExpansionType)

/// The pattern  of a pack expansion.
SIMPLE_LOCATOR_PATH_ELT(PackExpansionPattern)

/// An unresolved member.
SIMPLE_LOCATOR_PATH_ELT(UnresolvedMember)

/// The candidate witness during protocol conformance checking.
CUSTOM_LOCATOR_PATH_ELT(Witness)

/// The condition associated with 'if' expression or ternary operator.
SIMPLE_LOCATOR_PATH_ELT(Condition)

SIMPLE_LOCATOR_PATH_ELT(DynamicCallable)

/// The 'true' or 'false' branch of a ternary operator.
CUSTOM_LOCATOR_PATH_ELT(TernaryBranch)

/// Performing a pattern patch.
CUSTOM_LOCATOR_PATH_ELT(PatternMatch)

/// The constraint that models the allowed implicit casts for
/// an EnumElementPattern.
SIMPLE_LOCATOR_PATH_ELT(EnumPatternImplicitCastMatch)

/// Points to a particular attribute associated with one of
/// the arguments e.g. `inout` or its type e.g. `@escaping`.
///
/// This is very useful when dealing with argument-to-parameter
/// failures because it allows to express in the locator kind
/// of a problem.
CUSTOM_LOCATOR_PATH_ELT(ArgumentAttribute)

/// The result of a chain of member accesses off an UnresolvedMemberExpr
SIMPLE_LOCATOR_PATH_ELT(UnresolvedMemberChainResult)

/// The conformance requirement associated with a type.
CUSTOM_LOCATOR_PATH_ELT(ConformanceRequirement)

/// A source-specified placeholder.
CUSTOM_LOCATOR_PATH_ELT(PlaceholderType)

/// The implicit conversion applied at a given location.
CUSTOM_LOCATOR_PATH_ELT(ImplicitConversion)

/// An implicit call to a 'dynamicMember' subscript for a dynamic member lookup.
SIMPLE_LOCATOR_PATH_ELT(ImplicitDynamicMemberSubscript)

/// The element of the closure/function body e.g. statement, pattern,
/// declaration, or expression.
CUSTOM_LOCATOR_PATH_ELT(SyntacticElement)

/// The element of the pattern binding declaration.
CUSTOM_LOCATOR_PATH_ELT(PatternBindingElement)

/// A branch of a SingleValueStmtExpr.
CUSTOM_LOCATOR_PATH_ELT(SingleValueStmtBranch)

/// A declaration introduced by a pattern: name (i.e. `x`) or `_`
ABSTRACT_LOCATOR_PATH_ELT(PatternDecl)
  /// The variable declared by a named pattern.
  CUSTOM_LOCATOR_PATH_ELT(NamedPatternDecl)
  /// The anonymous variable declared by a `_` pattern.
  CUSTOM_LOCATOR_PATH_ELT(AnyPatternDecl)

/// A function type global actor.
SIMPLE_LOCATOR_PATH_ELT(GlobalActorType)

/// A type coercion operand.
SIMPLE_LOCATOR_PATH_ELT(CoercionOperand)

#undef LOCATOR_PATH_ELT
#undef CUSTOM_LOCATOR_PATH_ELT
#undef SIMPLE_LOCATOR_PATH_ELT
#undef ABSTRACT_LOCATOR_PATH_ELT
