Skip to content

Commit d80c897

Browse files
authored
---
yaml --- r: 348711 b: refs/heads/master c: 1a1f731 h: refs/heads/master i: 348709: 525ee4f 348707: 3bc6774 348703: 69bf368
1 parent b4ef9c0 commit d80c897

File tree

290 files changed

+2472
-8344
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

290 files changed

+2472
-8344
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: aa00865715aa4416c326fbd9cf3a490dcf4f3a8e
2+
refs/heads/master: 1a1f731aad0ee73653b82f3a3200396e89eb6f15
33
refs/heads/master-next: 203b3026584ecad859eb328b2e12490099409cd5
44
refs/tags/osx-passed: b6b74147ef8a386f532cf9357a1bde006e552c54
55
refs/tags/swift-2.2-SNAPSHOT-2015-12-01-a: 6bb18e013c2284f2b45f5f84f2df2887dc0f7dea

trunk/CHANGELOG.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,38 @@ CHANGELOG
2626
Swift Next
2727
----------
2828

29+
* [SR-11429][]:
30+
31+
The compiler will now correctly strip argument labels from function references
32+
used with the `as` operator in a function call. As a result, the `as` operator
33+
can now be used to disambiguate a call to a function with argument labels.
34+
35+
```swift
36+
func foo(x: Int) {}
37+
func foo(x: UInt) {}
38+
39+
(foo as (Int) -> Void)(5) // Calls foo(x: Int)
40+
(foo as (UInt) -> Void)(5) // Calls foo(x: UInt)
41+
```
42+
43+
Previously this was only possible for functions without argument labels.
44+
45+
This change also means that a generic type alias can no longer be used to
46+
preserve the argument labels of a function reference through the `as`
47+
operator. The following is now rejected:
48+
49+
```swift
50+
typealias Magic<T> = T
51+
func foo(x: Int) {}
52+
(foo as Magic)(x: 5) // error: Extraneous argument label 'x:' in call
53+
```
54+
55+
The function value must instead be called without argument labels:
56+
57+
```swift
58+
(foo as Magic)(5)
59+
```
60+
2961
* [SR-11298][]:
3062

3163
A class-constrained protocol extension, where the extended protocol does
@@ -7825,3 +7857,4 @@ Swift 1.0
78257857
[SR-9043]: <https://bugs.swift.org/browse/SR-9043>
78267858
[SR-9827]: <https://bugs.swift.org/browse/SR-9827>
78277859
[SR-11298]: <https://bugs.swift.org/browse/SR-11298>
7860+
[SR-11429]: <https://bugs.swift.org/browse/SR-11429>

trunk/docs/Diagnostics.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,3 +104,19 @@ Most diagnostics have no reason to change behavior under editor mode. An example
104104
- `%error` - Represents a branch in a `%select` that should never be taken. In debug builds of the compiler this produces an assertion failure.
105105

106106
- `%%` - Emits a literal percent sign.
107+
108+
### Diagnostic Verifier ###
109+
110+
(This section is specific to the Swift compiler's diagnostic engine.)
111+
112+
If the `-verify` frontend flag is used, the Swift compiler will check emitted diagnostics against specially formatted comments in the source. This feature is used extensively throughout the test suite to ensure diagnostics are emitted with the correct message and source location.
113+
114+
An expected diagnostic is denoted by a comment which begins with `expected-error`, `expected-warning`, `expected-note`, or `expected-remark`. It is followed by:
115+
116+
- (Optional) Location information. By default, the comment will match any diagnostic emitted on the same line. However, it's possible to override this behavior and/or specify column information as well. `// expected-error@-1 ...` looks for an error on the previous line, `// expected-warning@+1:3 ...` looks for a warning on the next line at the third column, and `// expected-note@:7 ...` looks for a note on the same line at the seventh column.
117+
118+
- (Optional) A match count which specifies how many times the diagnostic is expected to appear. This may be a positive integer or `*`, which allows for zero or more matches. The match count must be surrounded by whitespace if present. For example, `// expected-error 2 ...` looks for two matching errors, and `// expected-warning * ...` looks for any number of matching warnings.
119+
120+
- (Required) The expected error message. The message should be enclosed in double curly braces and should not include the `error:`/`warning:`/`note:`/`remark:` prefix. For example, `// expected-error {{invalid redeclaration of 'y'}}` would match an error with that message on the same line. The expected message does not need to match the emitted message verbatim. As long as the expected message is a substring of the original message, they will match.
121+
122+
- (Optional) Expected fix-its. These are each enclosed in double curly braces and appear after the expected message. An expected fix-it consists of a column range followed by the text it's expected to be replaced with. For example, `let r : Int i = j // expected-error{{consecutive statements}} {{12-12=;}}` will match a fix-it attached to the consecutive statements error which inserts a semicolon at column 12, just after the 't' in 'Int'. The special {{none}} specifier is also supported, which will cause the diagnostic match to fail if unexpected fix-its are produced.

trunk/docs/Testing.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ code for the target that is not the build machine:
232232

233233
* ``%target-typecheck-verify-swift``: parse and type check the current Swift file
234234
for the target platform and verify diagnostics, like ``swift -frontend -typecheck -verify
235-
%s``.
235+
%s``. For further explanation of `-verify` mode, see [Diagnostics.md](Diagnostics.md).
236236

237237
Use this substitution for testing semantic analysis in the compiler.
238238

trunk/include/swift/AST/ASTContext.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -857,7 +857,7 @@ class ASTContext final {
857857
/// Register the given generic signature builder to be used as the canonical
858858
/// generic signature builder for the given signature, if we don't already
859859
/// have one.
860-
void registerGenericSignatureBuilder(GenericSignature *sig,
860+
void registerGenericSignatureBuilder(GenericSignature sig,
861861
GenericSignatureBuilder &&builder);
862862
friend class GenericSignatureBuilder;
863863

@@ -876,8 +876,8 @@ class ASTContext final {
876876
CanGenericSignature getExistentialSignature(CanType existential,
877877
ModuleDecl *mod);
878878

879-
GenericSignature *getOverrideGenericSignature(const ValueDecl *base,
880-
const ValueDecl *derived);
879+
GenericSignature getOverrideGenericSignature(const ValueDecl *base,
880+
const ValueDecl *derived);
881881

882882
enum class OverrideGenericSignatureReqCheck {
883883
/// Base method's generic requirements are satisifed by derived method

trunk/include/swift/AST/ASTMangler.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -155,20 +155,20 @@ class ASTMangler : public Mangler {
155155
ModuleDecl *Module);
156156

157157
std::string mangleKeyPathGetterThunkHelper(const AbstractStorageDecl *property,
158-
GenericSignature *signature,
158+
GenericSignature signature,
159159
CanType baseType,
160160
SubstitutionMap subs,
161161
ResilienceExpansion expansion);
162162
std::string mangleKeyPathSetterThunkHelper(const AbstractStorageDecl *property,
163-
GenericSignature *signature,
163+
GenericSignature signature,
164164
CanType baseType,
165165
SubstitutionMap subs,
166166
ResilienceExpansion expansion);
167167
std::string mangleKeyPathEqualsHelper(ArrayRef<CanType> indices,
168-
GenericSignature *signature,
168+
GenericSignature signature,
169169
ResilienceExpansion expansion);
170170
std::string mangleKeyPathHashHelper(ArrayRef<CanType> indices,
171-
GenericSignature *signature,
171+
GenericSignature signature,
172172
ResilienceExpansion expansion);
173173

174174
std::string mangleTypeForDebugger(Type decl, const DeclContext *DC);
@@ -289,8 +289,8 @@ class ASTMangler : public Mangler {
289289
///
290290
/// \returns \c true if a generic signature was appended, \c false
291291
/// if it was empty.
292-
bool appendGenericSignature(const GenericSignature *sig,
293-
GenericSignature *contextSig = nullptr);
292+
bool appendGenericSignature(GenericSignature sig,
293+
GenericSignature contextSig = nullptr);
294294

295295
void appendRequirement(const Requirement &reqt);
296296

@@ -316,8 +316,8 @@ class ASTMangler : public Mangler {
316316
void appendBackingInitializerEntity(const VarDecl *var);
317317

318318
CanType getDeclTypeForMangling(const ValueDecl *decl,
319-
GenericSignature *&genericSig,
320-
GenericSignature *&parentGenericSig);
319+
GenericSignature &genericSig,
320+
GenericSignature &parentGenericSig);
321321

322322
void appendDeclType(const ValueDecl *decl, bool isFunctionMangling = false);
323323

trunk/include/swift/AST/ASTNode.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,10 @@ namespace swift {
3636
enum class DeclKind : uint8_t;
3737
enum class StmtKind;
3838

39-
struct ASTNode : public llvm::PointerUnion3<Expr*, Stmt*, Decl*> {
39+
struct ASTNode : public llvm::PointerUnion<Expr*, Stmt*, Decl*> {
4040
// Inherit the constructors from PointerUnion.
41-
using PointerUnion3::PointerUnion3;
42-
41+
using PointerUnion::PointerUnion;
42+
4343
SourceRange getSourceRange() const;
4444

4545
/// Return the location of the start of the statement.

trunk/include/swift/AST/ASTTypeIDZone.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
SWIFT_TYPEID(AncestryFlags)
1919
SWIFT_TYPEID(CtorInitializerKind)
20+
SWIFT_TYPEID(GenericSignature)
2021
SWIFT_TYPEID(PropertyWrapperBackingPropertyInfo)
2122
SWIFT_TYPEID(PropertyWrapperTypeInfo)
2223
SWIFT_TYPEID(Requirement)
@@ -26,7 +27,6 @@ SWIFT_TYPEID(TypePair)
2627
SWIFT_TYPEID_NAMED(CustomAttr *, CustomAttr)
2728
SWIFT_TYPEID_NAMED(Decl *, Decl)
2829
SWIFT_TYPEID_NAMED(GenericParamList *, GenericParamList)
29-
SWIFT_TYPEID_NAMED(GenericSignature *, GenericSignature)
3030
SWIFT_TYPEID_NAMED(GenericTypeParamType *, GenericTypeParamType)
3131
SWIFT_TYPEID_NAMED(InfixOperatorDecl *, InfixOperatorDecl)
3232
SWIFT_TYPEID_NAMED(IterableDeclContext *, IterableDeclContext)

trunk/include/swift/AST/AnyFunctionRef.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ class AnyFunctionRef {
198198
llvm_unreachable("unexpected AnyFunctionRef representation");
199199
}
200200

201-
GenericSignature *getGenericSignature() const {
201+
GenericSignature getGenericSignature() const {
202202
if (auto afd = TheFunction.dyn_cast<AbstractFunctionDecl *>()) {
203203
return afd->getGenericSignature();
204204
}

trunk/include/swift/AST/Attr.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1279,27 +1279,27 @@ class SpecializeAttr : public DeclAttribute {
12791279

12801280
private:
12811281
TrailingWhereClause *trailingWhereClause;
1282-
GenericSignature *specializedSignature;
1282+
GenericSignature specializedSignature;
12831283

12841284
SpecializeAttr(SourceLoc atLoc, SourceRange Range,
12851285
TrailingWhereClause *clause, bool exported,
12861286
SpecializationKind kind,
1287-
GenericSignature *specializedSignature);
1287+
GenericSignature specializedSignature);
12881288

12891289
public:
12901290
static SpecializeAttr *create(ASTContext &Ctx, SourceLoc atLoc,
12911291
SourceRange Range, TrailingWhereClause *clause,
12921292
bool exported, SpecializationKind kind,
1293-
GenericSignature *specializedSignature
1293+
GenericSignature specializedSignature
12941294
= nullptr);
12951295

12961296
TrailingWhereClause *getTrailingWhereClause() const;
12971297

1298-
GenericSignature *getSpecializedSgnature() const {
1298+
GenericSignature getSpecializedSgnature() const {
12991299
return specializedSignature;
13001300
}
13011301

1302-
void setSpecializedSignature(GenericSignature *newSig) {
1302+
void setSpecializedSignature(GenericSignature newSig) {
13031303
specializedSignature = newSig;
13041304
}
13051305

trunk/include/swift/AST/Decl.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1497,7 +1497,7 @@ class alignas(8) _GenericContext {
14971497
TrailingWhereClause *TrailingWhere = nullptr;
14981498

14991499
/// The generic signature of this declaration.
1500-
llvm::PointerIntPair<GenericSignature *, 1, bool> GenericSigAndBit;
1500+
llvm::PointerIntPair<GenericSignature, 1, bool> GenericSigAndBit;
15011501
};
15021502

15031503
class GenericContext : private _GenericContext, public DeclContext {
@@ -1541,7 +1541,7 @@ class GenericContext : private _GenericContext, public DeclContext {
15411541
}
15421542

15431543
/// Retrieve the generic signature for this context.
1544-
GenericSignature *getGenericSignature() const;
1544+
GenericSignature getGenericSignature() const;
15451545

15461546
/// Retrieve the generic context for this context.
15471547
GenericEnvironment *getGenericEnvironment() const;
@@ -1553,7 +1553,7 @@ class GenericContext : private _GenericContext, public DeclContext {
15531553
ArrayRef<Requirement> getGenericRequirements() const;
15541554

15551555
/// Set the generic signature of this context.
1556-
void setGenericSignature(GenericSignature *genericSig);
1556+
void setGenericSignature(GenericSignature genericSig);
15571557

15581558
/// Retrieve the position of any where clause for this context's
15591559
/// generic parameters.
@@ -2880,7 +2880,7 @@ class OpaqueTypeDecl : public GenericTypeDecl {
28802880
/// The generic signature of the opaque interface to the type. This is the
28812881
/// outer generic signature with an added generic parameter representing the
28822882
/// underlying type.
2883-
GenericSignature *OpaqueInterfaceGenericSignature;
2883+
GenericSignature OpaqueInterfaceGenericSignature;
28842884

28852885
/// The generic parameter that represents the underlying type.
28862886
GenericTypeParamType *UnderlyingInterfaceType;
@@ -2897,7 +2897,7 @@ class OpaqueTypeDecl : public GenericTypeDecl {
28972897
OpaqueTypeDecl(ValueDecl *NamingDecl,
28982898
GenericParamList *GenericParams,
28992899
DeclContext *DC,
2900-
GenericSignature *OpaqueInterfaceGenericSignature,
2900+
GenericSignature OpaqueInterfaceGenericSignature,
29012901
GenericTypeParamType *UnderlyingInterfaceType);
29022902

29032903
ValueDecl *getNamingDecl() const { return NamingDecl; }
@@ -2913,7 +2913,7 @@ class OpaqueTypeDecl : public GenericTypeDecl {
29132913
/// function could also be the getter of a storage declaration.
29142914
bool isOpaqueReturnTypeOfFunction(const AbstractFunctionDecl *func) const;
29152915

2916-
GenericSignature *getOpaqueInterfaceGenericSignature() const {
2916+
GenericSignature getOpaqueInterfaceGenericSignature() const {
29172917
return OpaqueInterfaceGenericSignature;
29182918
}
29192919

@@ -4810,7 +4810,7 @@ class VarDecl : public AbstractStorageDecl {
48104810
};
48114811

48124812
protected:
4813-
PointerUnion3<PatternBindingDecl *, Stmt *, VarDecl *> Parent;
4813+
PointerUnion<PatternBindingDecl *, Stmt *, VarDecl *> Parent;
48144814

48154815
VarDecl(DeclKind kind, bool isStatic, Introducer introducer,
48164816
bool issCaptureList, SourceLoc nameLoc, Identifier name,

trunk/include/swift/AST/DeclContext.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ class alignas(1 << DeclContextAlignInBits) DeclContext {
357357

358358
/// Retrieve the innermost generic signature of this context or any
359359
/// of its parents.
360-
GenericSignature *getGenericSignatureOfContext() const;
360+
GenericSignature getGenericSignatureOfContext() const;
361361

362362
/// Retrieve the innermost archetypes of this context or any
363363
/// of its parents.

trunk/include/swift/AST/DiagnosticsClangImporter.def

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,6 @@ WARNING(implicit_bridging_header_imported_from_module,none,
9191
"is deprecated and will be removed in a later version of Swift",
9292
(StringRef, Identifier))
9393

94-
WARNING(clang_vfs_overlay_is_ignored,none,
95-
"ignoring '-ivfsoverlay' options provided to '-Xcc' in favor of "
96-
"'-vfsoverlay'", ())
97-
9894
#ifndef DIAG_NO_UNDEF
9995
# if defined(DIAG)
10096
# undef DIAG

trunk/include/swift/AST/FileUnit.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -337,7 +337,7 @@ class LoadedFile : public FileUnit {
337337
/// \returns \c true if this module file supports retrieving all of the
338338
/// generic signatures, \c false otherwise.
339339
virtual bool getAllGenericSignatures(
340-
SmallVectorImpl<GenericSignature*> &genericSignatures) {
340+
SmallVectorImpl<GenericSignature> &genericSignatures) {
341341
return false;
342342
}
343343

trunk/include/swift/AST/GenericEnvironment.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ class QueryInterfaceTypeSubstitutions {
5757
///
5858
class alignas(1 << DeclAlignInBits) GenericEnvironment final
5959
: private llvm::TrailingObjects<GenericEnvironment, Type> {
60-
GenericSignature *Signature = nullptr;
60+
GenericSignature Signature = GenericSignature();
6161
GenericSignatureBuilder *Builder = nullptr;
6262

6363
friend TrailingObjects;
@@ -74,7 +74,7 @@ class alignas(1 << DeclAlignInBits) GenericEnvironment final
7474
/// generic signature.
7575
ArrayRef<Type> getContextTypes() const;
7676

77-
GenericEnvironment(GenericSignature *signature,
77+
GenericEnvironment(GenericSignature signature,
7878
GenericSignatureBuilder *builder);
7979

8080
friend ArchetypeType;
@@ -85,7 +85,7 @@ class alignas(1 << DeclAlignInBits) GenericEnvironment final
8585
friend QueryInterfaceTypeSubstitutions;
8686

8787
public:
88-
GenericSignature *getGenericSignature() const {
88+
GenericSignature getGenericSignature() const {
8989
return Signature;
9090
}
9191

@@ -94,7 +94,7 @@ class alignas(1 << DeclAlignInBits) GenericEnvironment final
9494
/// Create a new, "incomplete" generic environment that will be populated
9595
/// by calls to \c addMapping().
9696
static
97-
GenericEnvironment *getIncomplete(GenericSignature *signature,
97+
GenericEnvironment *getIncomplete(GenericSignature signature,
9898
GenericSignatureBuilder *builder);
9999

100100
/// Add a mapping of a generic parameter to a specific type (which may be

0 commit comments

Comments
 (0)