1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691
|
//===--- TypeCheckType.h - Type Resolution Code ----------*- 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 utilities for resolving types.
//
//===----------------------------------------------------------------------===//
#ifndef SWIFT_SEMA_TYPE_CHECK_TYPE_H
#define SWIFT_SEMA_TYPE_CHECK_TYPE_H
#include "swift/AST/Type.h"
#include "swift/AST/TypeResolutionStage.h"
#include "swift/AST/Types.h"
#include "swift/Basic/LangOptions.h"
namespace swift {
class ASTContext;
class QualifiedIdentTypeRepr;
class TypeRepr;
class PackElementTypeRepr;
class GenericEnvironment;
class GenericSignature;
class SILTypeResolutionContext;
/// Flags that describe the context of type checking a pattern or
/// type.
enum class TypeResolutionFlags : uint16_t {
/// Whether to allow unspecified types within a pattern.
AllowUnspecifiedTypes = 1 << 0,
/// Whether the given type can override the type of a typed pattern.
OverrideType = 1 << 1,
/// Whether we are validating the type for SIL.
// FIXME: Move this flag to TypeResolverContext.
SILType = 1 << 2,
/// Whether we are parsing a SIL file. Not the same as SILType,
/// because the latter is not set if we're parsing an AST type.
SILMode = 1 << 3,
/// Whether this is a resolution based on a non-inferred type pattern.
FromNonInferredPattern = 1 << 4,
/// Whether we are at the direct base of a type expression.
Direct = 1 << 5,
/// Whether we should not produce diagnostics if the type is invalid.
SilenceErrors = 1 << 6,
/// Whether to allow module declaration types.
AllowModule = 1 << 7,
/// Make internal @usableFromInline and @inlinable decls visible.
AllowUsableFromInline = 1 << 8,
/// Forbid \c some types from resolving as opaque types.
///
/// Needed to enforce that \c any P<some Q> does not resolve to a
/// parameterized existential with an opaque type constraint.
DisallowOpaqueTypes = 1 << 9,
/// We are in a `@preconcurrency` declaration.
Preconcurrency = 1 << 10,
/// Whether references to type parameter packs are allowed.
///
/// Pack references are only allowed inside pack expansions
/// and in generic requirements.
AllowPackReferences = 1 << 11,
/// Whether this is a resolution based on a pack reference.
FromPackReference = 1 << 12,
/// Whether to suppress warnings about conversions from and bindings of type
/// Never
SilenceNeverWarnings = 1 << 13,
/// Whether the immediate context has an @escaping attribute.
DirectEscaping = 1 << 14,
};
/// Type resolution contexts that require special handling.
enum class TypeResolverContext : uint8_t {
/// No special type handling is required.
None,
/// Whether we are checking generic arguments of a non-variadic bound generic
/// type. This includes parameterized protocol types. We don't allow pack
/// expansions here.
ScalarGenericArgument,
/// Whether we are checking generic arguments of a variadic generic type.
/// We allow pack expansions in all argument positions, and then use the
/// PackMatcher to ensure that scalar parameters line up with scalar
/// arguments, and pack expansion parameters line up with pack expansion
/// arguments.
VariadicGenericArgument,
/// Whether we are checking a tuple element type.
TupleElement,
/// Whether we are checking a pack element type.
PackElement,
/// Whether we are checking the parameter list of a function.
AbstractFunctionDecl,
/// Whether we are checking the parameter list of a subscript.
SubscriptDecl,
/// Whether we are checking the parameter list or result of a closure.
ClosureExpr,
/// Whether we are in the input type of a function, or under one level of
/// tuple type. This is not set for multi-level tuple arguments.
/// See also: TypeResolutionFlags::Direct
FunctionInput,
/// Whether this is a variadic function input.
VariadicFunctionInput,
/// Whether this is an 'inout' function input.
InoutFunctionInput,
/// Whether we are in the result type of a function.
FunctionResult,
/// Whether this is a pattern binding entry.
PatternBindingDecl,
/// Whether we are the variable type in a for/in statement.
ForEachStmt,
/// Whether we are binding an extension declaration, which limits
/// the lookup.
ExtensionBinding,
/// Whether this type is being used in an expression or local declaration.
///
/// This affects what sort of dependencies are recorded when resolving the
/// type.
InExpression,
/// Whether this type is being used in a cast or coercion expression.
ExplicitCastExpr,
/// Whether this type is the value carried in an enum case.
EnumElementDecl,
/// Whether this type is a part of a macro declaration.
MacroDecl,
/// Whether this is the payload subpattern of an enum pattern.
EnumPatternPayload,
/// Whether we are checking the underlying type of a non-generic typealias.
TypeAliasDecl,
/// Whether we are checking the underlying type of a generic typealias.
GenericTypeAliasDecl,
/// Whether we are in the constraint type of an existential type.
ExistentialConstraint,
/// Whether we are in the constraint type of a conformance requirement.
GenericRequirement,
/// Whether we are in a same-type requirement of a generic
/// declaration.
SameTypeRequirement,
/// Whether this is the base type of .Protocol
ProtocolMetatypeBase,
/// Whether this is the base type of .Type
MetatypeBase,
/// Whether we are in a type argument for an optional
ImmediateOptionalTypeArgument,
/// Whether this is the type of an editor placeholder.
EditorPlaceholderExpr,
/// Whether this is an inheritance clause of a concrete type.
Inherited,
/// Whether this is an inheritance clause of a generic parameter.
GenericParameterInherited,
/// Whether this is an inheritance clause of an associated type.
AssociatedTypeInherited,
/// Whether this is a custom attribute.
CustomAttr,
/// Whether this is the argument of an inverted constraint (~).
Inverted,
};
/// Options that determine how type resolution should work.
class TypeResolutionOptions {
using Context = TypeResolverContext;
// The "base" type resolution context. This never changes.
Context base = Context::None;
// The current type resolution context.
Context context = Context::None;
// TypeResolutionFlags
uint16_t flags = 0;
static_assert(sizeof(TypeResolutionOptions::flags) ==
sizeof(TypeResolutionFlags),
"Flags size error");
public:
~TypeResolutionOptions() = default;
TypeResolutionOptions(const TypeResolutionOptions &) = default;
TypeResolutionOptions(TypeResolutionOptions &&) = default;
TypeResolutionOptions &operator =(const TypeResolutionOptions &) = default;
TypeResolutionOptions &operator =(TypeResolutionOptions &&) = default;
// NOTE: Use either setContext() or explicit construction and assignment.
void operator =(const Context &) = delete;
void operator =(Context &&) = delete;
// NOTE: "None" might be more permissive than one wants, therefore no
// reasonable default context is possible.
TypeResolutionOptions() = delete;
TypeResolutionOptions(Context context) : base(context), context(context),
flags(unsigned(TypeResolutionFlags::Direct)) {}
// Helper forwarding constructors:
TypeResolutionOptions(std::nullopt_t)
: TypeResolutionOptions(Context::None) {}
/// Test the current type resolution base context.
bool hasBase(Context context) const { return base == context; }
/// Get the base type resolution context.
Context getBaseContext() const { return base; }
/// Test the current type resolution context.
bool is(Context context) const { return this->context == context; }
/// Get the current type resolution context.
Context getContext() const { return context; }
/// Set the current type resolution context.
void setContext(Context newContext) {
context = newContext;
flags &= ~(unsigned(TypeResolutionFlags::Direct) |
unsigned(TypeResolutionFlags::DirectEscaping));
}
void setContext(std::nullopt_t) { setContext(Context::None); }
/// Get the current flags.
TypeResolutionFlags getFlags() const { return TypeResolutionFlags(flags); }
/// Is this type resolution context an expression.
bool isAnyExpr() const {
switch (base) {
case Context::InExpression:
case Context::ExplicitCastExpr:
case Context::ForEachStmt:
case Context::PatternBindingDecl:
case Context::EditorPlaceholderExpr:
case Context::ClosureExpr:
return true;
case Context::None:
case Context::ScalarGenericArgument:
case Context::VariadicGenericArgument:
case Context::TupleElement:
case Context::PackElement:
case Context::FunctionInput:
case Context::VariadicFunctionInput:
case Context::InoutFunctionInput:
case Context::FunctionResult:
case Context::ExtensionBinding:
case Context::SubscriptDecl:
case Context::EnumElementDecl:
case Context::MacroDecl:
case Context::EnumPatternPayload:
case Context::TypeAliasDecl:
case Context::GenericTypeAliasDecl:
case Context::GenericRequirement:
case Context::ExistentialConstraint:
case Context::SameTypeRequirement:
case Context::ProtocolMetatypeBase:
case Context::MetatypeBase:
case Context::ImmediateOptionalTypeArgument:
case Context::AbstractFunctionDecl:
case Context::Inherited:
case Context::GenericParameterInherited:
case Context::AssociatedTypeInherited:
case Context::CustomAttr:
case Context::Inverted:
return false;
}
llvm_unreachable("unhandled kind");
}
/// Whether a generic constraint type is implicitly an
/// existential type in this context.
bool isConstraintImplicitExistential() const {
switch (context) {
case Context::Inherited:
case Context::GenericParameterInherited:
case Context::AssociatedTypeInherited:
case Context::ExtensionBinding:
case Context::TypeAliasDecl:
case Context::GenericTypeAliasDecl:
case Context::GenericRequirement:
case Context::ExistentialConstraint:
case Context::MetatypeBase:
case Context::Inverted:
return false;
case Context::None:
case Context::ScalarGenericArgument:
case Context::VariadicGenericArgument:
case Context::PackElement:
case Context::TupleElement:
case Context::InExpression:
case Context::ExplicitCastExpr:
case Context::ForEachStmt:
case Context::PatternBindingDecl:
case Context::EditorPlaceholderExpr:
case Context::ClosureExpr:
case Context::FunctionInput:
case Context::VariadicFunctionInput:
case Context::InoutFunctionInput:
case Context::FunctionResult:
case Context::SubscriptDecl:
case Context::EnumElementDecl:
case Context::MacroDecl:
case Context::EnumPatternPayload:
case Context::SameTypeRequirement:
case Context::ProtocolMetatypeBase:
case Context::ImmediateOptionalTypeArgument:
case Context::AbstractFunctionDecl:
case Context::CustomAttr:
return true;
}
}
/// Whether pack expansion types are supported in this context.
bool isPackExpansionSupported() const {
switch (context) {
case Context::FunctionInput:
case Context::VariadicFunctionInput:
case Context::PackElement:
case Context::TupleElement:
case Context::VariadicGenericArgument:
case Context::Inverted:
return true;
case Context::None:
case Context::PatternBindingDecl:
case Context::ScalarGenericArgument:
case Context::Inherited:
case Context::GenericParameterInherited:
case Context::AssociatedTypeInherited:
case Context::ExtensionBinding:
case Context::TypeAliasDecl:
case Context::GenericTypeAliasDecl:
case Context::GenericRequirement:
case Context::ExistentialConstraint:
case Context::MetatypeBase:
case Context::InExpression:
case Context::ExplicitCastExpr:
case Context::ForEachStmt:
case Context::EditorPlaceholderExpr:
case Context::ClosureExpr:
case Context::InoutFunctionInput:
case Context::FunctionResult:
case Context::SubscriptDecl:
case Context::EnumElementDecl:
case Context::MacroDecl:
case Context::EnumPatternPayload:
case Context::SameTypeRequirement:
case Context::ProtocolMetatypeBase:
case Context::ImmediateOptionalTypeArgument:
case Context::AbstractFunctionDecl:
case Context::CustomAttr:
return false;
}
}
/// Whether we are resolving a type in a `where` clause, generic parameter
/// declaration inheritance clause, or associated type inheritance clause.
bool isGenericRequirement() const {
switch (base) {
case Context::GenericRequirement:
case Context::SameTypeRequirement:
case Context::GenericParameterInherited:
case Context::AssociatedTypeInherited:
return true;
case Context::None:
case Context::Inherited:
case Context::FunctionInput:
case Context::PackElement:
case Context::TupleElement:
case Context::ScalarGenericArgument:
case Context::VariadicGenericArgument:
case Context::ExtensionBinding:
case Context::TypeAliasDecl:
case Context::GenericTypeAliasDecl:
case Context::ExistentialConstraint:
case Context::MetatypeBase:
case Context::InExpression:
case Context::ExplicitCastExpr:
case Context::ForEachStmt:
case Context::PatternBindingDecl:
case Context::EditorPlaceholderExpr:
case Context::ClosureExpr:
case Context::VariadicFunctionInput:
case Context::InoutFunctionInput:
case Context::FunctionResult:
case Context::SubscriptDecl:
case Context::EnumElementDecl:
case Context::MacroDecl:
case Context::EnumPatternPayload:
case Context::ProtocolMetatypeBase:
case Context::ImmediateOptionalTypeArgument:
case Context::AbstractFunctionDecl:
case Context::CustomAttr:
case Context::Inverted:
return false;
}
}
/// Determine whether all of the given options are set.
bool contains(TypeResolutionFlags set) const {
return !static_cast<bool>(unsigned(set) & ~unsigned(flags));
}
friend bool operator==(TypeResolutionOptions lhs, TypeResolutionOptions rhs) {
return lhs.base == rhs.base && lhs.context == rhs.context &&
lhs.flags == rhs.flags;
}
friend bool operator!=(TypeResolutionOptions lhs, TypeResolutionOptions rhs) {
return !(lhs == rhs);
}
/// Produce type resolution options with additional flags.
friend TypeResolutionOptions operator|(TypeResolutionOptions lhs,
TypeResolutionFlags rhs) {
return lhs |= rhs;
}
/// Merge additional flags into type resolution options.
friend TypeResolutionOptions &operator|=(TypeResolutionOptions &lhs,
TypeResolutionFlags rhs) {
lhs.flags |= unsigned(rhs);
return lhs;
}
/// Test whether any given flag is set in the type resolution options.
friend bool operator&(TypeResolutionOptions lhs, TypeResolutionFlags rhs) {
return lhs.flags & unsigned(rhs);
}
/// Produce type resolution options with removed flags.
friend TypeResolutionOptions operator-(TypeResolutionOptions lhs,
TypeResolutionFlags rhs) {
return lhs -= rhs;
}
/// Remove the flags from the type resolution options.
friend TypeResolutionOptions &operator-=(TypeResolutionOptions &lhs,
TypeResolutionFlags rhs) {
lhs.flags &= ~unsigned(rhs);
return lhs;
}
/// Strip the contextual options from the given type resolution options.
inline TypeResolutionOptions withoutContext(bool preserveSIL = false) const {
auto copy = *this;
copy.setContext(std::nullopt);
// FIXME: Move SILType to TypeResolverContext.
if (!preserveSIL) copy -= TypeResolutionFlags::SILType;
return copy;
}
inline
TypeResolutionOptions withContext(TypeResolverContext context) const {
auto copy = *this;
copy.setContext(context);
return copy;
}
};
/// A function reference used to "open" the given unbound generic type
/// by introducing generic arguments and constructing a \c BoundGenericType
/// out of them.
///
/// \returns the \c null type on failure.
using OpenUnboundGenericTypeFn = llvm::function_ref<Type(UnboundGenericType *)>;
/// A function reference used to handle a PlaceholderTypeRepr.
using HandlePlaceholderTypeReprFn =
llvm::function_ref<Type(ASTContext &, PlaceholderTypeRepr *)>;
/// A function reference used to replace pack elements with opened
/// element archetypes when resolving a \c PackElementTypeRepr.
using OpenPackElementFn =
llvm::function_ref<Type(Type, PackElementTypeRepr *)>;
/// Handles the resolution of types within a given declaration context,
/// which might involve resolving generic parameters to a particular
/// stage.
class TypeResolution {
DeclContext *dc;
TypeResolutionStage stage;
TypeResolutionOptions options;
OpenUnboundGenericTypeFn unboundTyOpener;
HandlePlaceholderTypeReprFn placeholderHandler;
OpenPackElementFn packElementOpener;
GenericSignature genericSig;
private:
TypeResolution(DeclContext *dc, GenericSignature genericSig,
TypeResolutionStage stage, TypeResolutionOptions options,
OpenUnboundGenericTypeFn unboundTyOpener,
HandlePlaceholderTypeReprFn placeholderHandler,
OpenPackElementFn packElementOpener)
: dc(dc), stage(stage), options(options),
unboundTyOpener(unboundTyOpener),
placeholderHandler(placeholderHandler),
packElementOpener(packElementOpener), genericSig(genericSig) {}
public:
/// Form a type resolution for the structure of a type, which does not
/// attempt to resolve member types of type parameters to a particular
/// associated type.
static TypeResolution
forStructural(DeclContext *dc, TypeResolutionOptions opts,
OpenUnboundGenericTypeFn unboundTyOpener,
HandlePlaceholderTypeReprFn placeholderHandler,
OpenPackElementFn packElementOpener);
/// Form a type resolution for an interface type, which is a complete
/// description of the type using generic parameters.
static TypeResolution
forInterface(DeclContext *dc, TypeResolutionOptions opts,
OpenUnboundGenericTypeFn unboundTyOpener,
HandlePlaceholderTypeReprFn placeholderHandler,
OpenPackElementFn packElementOpener);
/// Form a type resolution for an interface type, which is a complete
/// description of the type using generic parameters.
static TypeResolution
forInterface(DeclContext *dc, GenericSignature genericSig,
TypeResolutionOptions opts,
OpenUnboundGenericTypeFn unboundTyOpener,
HandlePlaceholderTypeReprFn placeholderHandler,
OpenPackElementFn packElementOpener);
/// Form a type resolution for a contextual type, which is a complete
/// description of the type using the archetypes of the given generic
/// environment.
static Type
resolveContextualType(TypeRepr *TyR, DeclContext *dc,
TypeResolutionOptions opts,
OpenUnboundGenericTypeFn unboundTyOpener,
HandlePlaceholderTypeReprFn placeholderHandler,
OpenPackElementFn packElementOpener,
SILTypeResolutionContext *silContext = nullptr);
static Type resolveContextualType(
TypeRepr *TyR, DeclContext *dc, GenericSignature genericSig,
TypeResolutionOptions opts, OpenUnboundGenericTypeFn unboundTyOpener,
HandlePlaceholderTypeReprFn placeholderHandler,
OpenPackElementFn packElementOpener,
SILTypeResolutionContext *silContext = nullptr);
public:
TypeResolution withOptions(TypeResolutionOptions opts) const;
TypeResolution withoutPackElementOpener() const;
public:
/// Retrieve the ASTContext in which this resolution occurs.
ASTContext &getASTContext() const;
/// Retrieve the declaration context in which type resolution will be
/// performed.
DeclContext *getDeclContext() const { return dc; }
/// Retrieve the type resolution stage.
TypeResolutionStage getStage() const { return stage; }
TypeResolutionOptions getOptions() const { return options; }
OpenUnboundGenericTypeFn getUnboundTypeOpener() const {
return unboundTyOpener;
}
HandlePlaceholderTypeReprFn getPlaceholderHandler() const {
return placeholderHandler;
}
OpenPackElementFn getPackElementOpener() const {
return packElementOpener;
}
/// Retrieves the generic signature for the context, or NULL if there is
/// no generic signature to resolve types.
GenericSignature getGenericSignature() const;
/// Resolves a TypeRepr to a type.
///
/// Performs name lookup, checking of generic arguments, and so on in order
/// to create a well-formed type.
///
/// \param TyR The type representation to check.
/// \param silContext Used to look up generic parameters in SIL mode.
///
/// \returns A well-formed type that is never null, or an \c ErrorType in case of an error.
Type resolveType(TypeRepr *TyR,
SILTypeResolutionContext *silContext = nullptr) const;
/// Resolve a reference to a member type of the given (dependent) base and
/// name.
Type resolveDependentMemberType(Type baseTy, DeclContext *DC,
SourceRange baseRange,
QualifiedIdentTypeRepr *repr) const;
/// Determine whether the given two types are equivalent within this
/// type resolution context.
bool areSameType(Type type1, Type type2) const;
/// Resolve a reference to the given type declaration within a particular
/// context.
///
/// This routine aids unqualified name lookup for types by performing the
/// resolution necessary to rectify the declaration found by name lookup with
/// the declaration context from which name lookup started.
///
/// \param typeDecl The type declaration found by name lookup.
/// \param foundDC The declaration context this type reference was found in.
/// \param isSpecialized Whether the type will have generic arguments applied.
///
/// \returns the resolved type.
Type resolveTypeInContext(TypeDecl *typeDecl, DeclContext *foundDC,
bool isSpecialized) const;
/// Apply generic arguments to the unbound generic type represented by the
/// given declaration and parent type.
///
/// This function requires the correct number of generic arguments,
/// whereas applyGenericArguments emits diagnostics in those cases.
///
/// \param decl The declaration that the resulting bound generic type
/// shall reference.
/// \param parentTy The parent type.
/// \param loc The source location for diagnostic reporting.
/// \param genericArgs The list of generic arguments to apply.
///
/// \returns A BoundGenericType bound to the given arguments, or null on
/// error.
///
/// \see applyGenericArguments
Type applyUnboundGenericArguments(GenericTypeDecl *decl, Type parentTy,
SourceLoc loc,
ArrayRef<Type> genericArgs) const;
};
void diagnoseInvalidGenericArguments(SourceLoc loc, ValueDecl *decl,
unsigned argCount, unsigned paramCount,
bool hasParameterPack,
SourceRange angleBrackets);
/// \param repr the repr for the type of the parameter.
/// \param ty the non-error resolved type of the repr.
/// \param ownership the ownership kind of the parameter
/// \returns true iff a diagnostic was emitted and the \c repr was invalidated.
bool diagnoseMissingOwnership(ParamSpecifier ownership,
TypeRepr *repr, Type ty,
const TypeResolution &resolution);
} // end namespace swift
#endif /* SWIFT_SEMA_TYPE_CHECK_TYPE_H */
|