mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
When referencing a function in the type checker, drop argument labels when we don't need them to type-check an immediate call to that function. This provides the semantic behavior of SE-0111, e.g., references to functions as values produce unlabeled function types, without the representational change of actually dropping argument labels from the type system. At the moment, this only works for bare references to functions. It still needs to be pushed through more of the type checker and more AST nodes to work in the general case. Keep this work behind the frontend flag -suppress-argument-labels-in-types for now.
51 lines
1.8 KiB
C++
51 lines
1.8 KiB
C++
//===--- FunctionRefKind.h - Function reference kind ------------*- C++ -*-===//
|
|
//
|
|
// This source file is part of the Swift.org open source project
|
|
//
|
|
// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
|
|
// Licensed under Apache License v2.0 with Runtime Library Exception
|
|
//
|
|
// See http://swift.org/LICENSE.txt for license information
|
|
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
//
|
|
// This file defines the FunctionRefKind enum, which is used to describe how
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#ifndef SWIFT_AST_FUNCTION_REF_KIND_H
|
|
#define SWIFT_AST_FUNCTION_REF_KIND_H
|
|
|
|
namespace swift {
|
|
|
|
/// Describes how a function is referenced within an expression node,
|
|
/// which dictates whether argument labels are part of the resulting
|
|
/// function type or not.
|
|
///
|
|
/// How a function is referenced comes down to how it was spelled in
|
|
/// the source code, e.g., was it called in the source code and was it
|
|
/// spelled as a compound name.
|
|
enum class FunctionRefKind : unsigned {
|
|
/// The function was referenced using a bare function name (e.g.,
|
|
/// 'f') and not directly called.
|
|
Unapplied,
|
|
/// The function was referenced using a bare function name and was
|
|
/// directly applied once, e.g., "f(a: 1, b: 2)".
|
|
SingleApply,
|
|
/// The function was referenced using a bare function name and was
|
|
/// directly applied two or more times, e.g., "g(x)(y)".
|
|
DoubleApply,
|
|
/// The function was referenced using a compound function name,
|
|
/// e.g., "f(a:b:)".
|
|
Compound,
|
|
};
|
|
|
|
/// Produce a string describing a function reference kind, for
|
|
/// debugging purposes.
|
|
StringRef getFunctionRefKindStr(FunctionRefKind refKind);
|
|
|
|
}
|
|
|
|
#endif // SWIFT_AST_FUNCTION_REF_KIND_H
|