Skip to content

Commit 2e73ce4

Browse files
committed
---
yaml --- r: 348777 b: refs/heads/master c: b2c1540 h: refs/heads/master i: 348775: b4a8335
1 parent fa4aa26 commit 2e73ce4

File tree

477 files changed

+14641
-9996
lines changed

Some content is hidden

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

477 files changed

+14641
-9996
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: 0746d1e896ee6a05b1c80c287a24d201f0a4555f
2+
refs/heads/master: b2c1540ca2a1b9c913bef5af1e39d60532933485
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: 0 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -26,38 +26,6 @@ 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-
6129
* [SR-11298][]:
6230

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

trunk/docs/CToSwiftNameTranslation.md

Lines changed: 3 additions & 108 deletions
Original file line numberDiff line numberDiff line change
@@ -212,29 +212,6 @@ Additionally, typedefs for `void *` or `const void *` that are themselves annota
212212
If a typedef's underlying type is itself a "CF pointer" typedef, the "alias" typedef will be imported as a regular typealias, with the suffix "Ref" still dropped from its name (if present) unless doing so would conflict with another declaration in the same module as the typedef.
213213

214214

215-
## Objective-C Properties
216-
217-
By default, most property names are not transformed at all. However, if the getter of a property overrides a superclass or adopted protocol method that is also a property accessor, the Swift name of the overridden accessor's property will be used for consistency. If there's more than one such name, one is chosen arbitrarily.
218-
219-
Properties with the type `BOOL` or `Boolean` use the name of the getter as the name of the Swift property by default, rather than the name of the property in Objective-C. This accounts for a difference in Swift and Objective-C naming conventions for boolean properties that use "is".
220-
221-
```objc
222-
@property(getter=isContrivedExample) BOOL contrivedExample;
223-
@property BOOL hasAnotherForm;
224-
```
225-
226-
```swift
227-
var isContrivedExample: Bool { get set }
228-
var hasAnotherForm: Bool { get set }
229-
```
230-
231-
_This rule should probably have applied to C's native `bool` as well._
232-
233-
A property declaration with the `SwiftImportPropertyAsAccessors` API note will not be imported at all, and its accessors will be imported as methods. Additionally, properties whose names start with "accessibility" in the NSAccessibility protocol are always imported as methods, as are properties whose names start with "accessibility" in an `@interface` declaration (class or category) that provides the adoption of NSAccessibility.
234-
235-
_Objective-C code has historically not been consistent about whether the NSAccessibility declarations should be considered properties and therefore the Swift compiler chooses to import them as methods, as a sort of lowest common denominator._
236-
237-
238215
## `swift_private`
239216

240217
The `swift_private` Clang attribute prepends `__` onto the base name of any declaration being imported except initializers. For initializers with no arguments, a dummy `Void` argument with the name `__` is inserted; otherwise, the label for the first argument has `__` prepended. This transformation takes place after any other name manipulation, unless the declaration has a custom name. It will not occur if the declaration is an override; in that case the name needs to match the overridden declaration.
@@ -275,8 +252,6 @@ __attribute__((swift_name("SpacecraftCoordinates")))
275252
struct SPKSpacecraftCoordinates {
276253
double x, y, z, t; // space and time, of course
277254
};
278-
279-
// Usually seen as NS_SWIFT_NAME.
280255
```
281256
282257
```swift
@@ -312,10 +287,12 @@ The `swift_name` attribute can be used to give a C function a custom name. The v
312287
```objc
313288
__attribute__((swift_name("doSomething(to:bar:)")))
314289
void doSomethingToFoo(Foo *foo, int bar);
290+
291+
// Usually seen as NS_SWIFT_NAME.
315292
```
316293
317294
```swift
318-
func doSomething(to foo: UnsafeMutablePointer<Foo>, bar: Int32)
295+
func doSomething(foo: UnsafeMutablePointer<Foo>, bar: Int32)
319296
```
320297

321298
An underscore can be used in place of an empty parameter label, as in Swift.
@@ -453,86 +430,4 @@ Although enumerators always have global scope in C, they are often imported as m
453430

454431
_Currently, `swift_name` does not even allow importing an enum case as a member of the enum type itself, even if the enum is not recognized as an `@objc` enum, error code enum, or option set (i.e. the situation where a case is imported as a global constant)._
455432

456-
457-
### Fields of structs and unions; Objective-C properties
458-
459-
The `swift_name` attribute can be applied to rename a struct or union field or an Objective-C property (whether on a class or a protocol). The value of the attribute must be a valid Swift identifier.
460-
461-
```objc
462-
struct SPKSpaceflightBooking {
463-
const SPKLocation * _Nullable destination;
464-
bool roundTrip __attribute__((swift_name("isRoundTrip")));
465-
};
466-
```
467-
468-
```swift
469-
struct SPKSpaceflightBooking {
470-
var destination: UnsafePointer<SPKLocation>?
471-
var isRoundTrip: Bool
472-
}
473-
```
474-
475-
476-
### Objective-C methods
477-
478-
The `swift_name` attribute can be used to give an Objective-C method a custom name. The value of the attribute must be a full Swift function name, including parameter labels.
479-
480-
```objc
481-
- (void)doSomethingToFoo:(Foo *)foo bar:(int)bar
482-
__attribute__((swift_name("doSomethingImportant(to:bar:)")));
483-
```
484-
485-
```swift
486-
func doSomethingImportant(to foo: UnsafeMutablePointer<Foo>, bar: Int32)
487-
```
488-
489-
As with functions, an underscore can be used to represent an empty parameter label.
490-
491-
Methods that follow the NSError out-parameter convention may provide one fewer parameter label than the number of parameters in the original method to indicate that a parameter should be dropped, but they do not have to. The `swift_error` attribute is still respected even when using a custom name for purposes of transforming an NSError out-parameter and the method return type.
492-
493-
```objc
494-
- (BOOL)doSomethingRiskyAndReturnError:(NSError **)error
495-
__attribute__((swift_name("doSomethingRisky()")));
496-
- (BOOL)doSomethingContrived:(NSString *)action error:(NSError **)outError
497-
__attribute__((swift_name("doSomethingContrived(_:error:)")));
498-
```
499-
500-
```swift
501-
func doSomethingRisky() throws
502-
func doSomethingContrived(_ action: String, error: ()) throws
503-
```
504-
505-
A base name of "init" can be used on a *class* method that returns `instancetype` or the containing static type in order to import that method as an initializer. Any other custom name *prevents* a class method from being imported as an initializer even if it would normally be inferred as one.
506-
507-
```objc
508-
+ (Action *)makeActionWithHandler:(void(^)(void))handler
509-
__attribute__((swift_name("init(handler:)")));
510-
+ (instancetype)makeActionWithName:(NSString *)name
511-
__attribute__((swift_name("init(name:)")));
512-
```
513-
514-
```swift
515-
/* non-inherited */ init(handler: () -> Void)
516-
init(name: String)
517-
```
518-
519-
A no-argument method imported as an initializer can be given a dummy argument label to disambiguate it from the no-argument `init()`, whether the method is an init-family instance method or a factory class method in Objective-C.
520-
521-
```objc
522-
- (instancetype)initSafely
523-
__attribute__((swift_name("init(safe:)")));
524-
+ (instancetype)makeDefaultAction
525-
__attribute__((swift_name("init(default:)")));
526-
```
527-
528-
```swift
529-
init(safe: ())
530-
init(default: ())
531-
```
532-
533-
A custom name on an instance method with one of Objective-C's subscript selectors (`objectAtIndexedSubscript:`, `objectForKeyedSubscript:`, `setObject:atIndexedSubscript:`, or `setObject:forKeyedSubscript:`) prevents that method from being imported as a subscript or used as the accessor for another subscript.
534-
535-
_Currently, this only works if *both* methods in a read/write subscript are given custom names; if just one is, a read/write subscript will still be formed. A read-only subscript only has one method to rename._
536-
537-
538433
## More to come...

trunk/docs/Diagnostics.md

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -104,19 +104,3 @@ 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``. For further explanation of `-verify` mode, see [Diagnostics.md](Diagnostics.md).
235+
%s``.
236236

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

trunk/docs/WindowsBuild.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -186,11 +186,13 @@ cmake -G "Visual Studio 2017" -A x64 -T "host=x64"^ ...
186186
md "S:\b\lldb"
187187
cd "S:\b\lldb"
188188
cmake -G Ninja^
189-
-DLLVM_DIR="S:/b/llvm/lib/cmake/llvm"^
190-
-DClang_DIR="S:/b/llvm/lib/cmake/clang"^
191-
-DSwift_DIR="S:/b/swift/lib/cmake/swift"^
192189
-DCMAKE_BUILD_TYPE=RelWithDebInfo^
193190
-DLLDB_ALLOW_STATIC_BINDINGS=YES^
191+
-DLLDB_PATH_TO_CLANG_SOURCE="S:\clang"^
192+
-DLLDB_PATH_TO_SWIFT_SOURCE="S:\swift"^
193+
-DLLDB_PATH_TO_CLANG_BUILD="S:\b\llvm"^
194+
-DLLDB_PATH_TO_LLVM_BUILD="S:\b\llvm"^
195+
-DLLDB_PATH_TO_SWIFT_BUILD="S:\b\swift"^
194196
-DLLVM_ENABLE_ASSERTIONS=ON^
195197
-DPYTHON_HOME="%ProgramFiles(x86)%\Microsoft Visual Studio\Shared\Python37_64"^
196198
S:\lldb

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(GenericSignature sig,
293-
GenericSignature contextSig = nullptr);
292+
bool appendGenericSignature(const 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::PointerUnion<Expr*, Stmt*, Decl*> {
39+
struct ASTNode : public llvm::PointerUnion3<Expr*, Stmt*, Decl*> {
4040
// Inherit the constructors from PointerUnion.
41-
using PointerUnion::PointerUnion;
42-
41+
using PointerUnion3::PointerUnion3;
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,7 +17,6 @@
1717

1818
SWIFT_TYPEID(AncestryFlags)
1919
SWIFT_TYPEID(CtorInitializerKind)
20-
SWIFT_TYPEID(GenericSignature)
2120
SWIFT_TYPEID(PropertyWrapperBackingPropertyInfo)
2221
SWIFT_TYPEID(PropertyWrapperTypeInfo)
2322
SWIFT_TYPEID(Requirement)
@@ -27,6 +26,7 @@ SWIFT_TYPEID(TypePair)
2726
SWIFT_TYPEID_NAMED(CustomAttr *, CustomAttr)
2827
SWIFT_TYPEID_NAMED(Decl *, Decl)
2928
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

0 commit comments

Comments
 (0)