Skip to content

Commit 5e6bb0a

Browse files
authored
Merge branch 'swift-4.0-branch-06-23-2017' into infer-downgrade-exhaustivity-check-4.0b3
2 parents 2e2afe7 + 77a492e commit 5e6bb0a

File tree

10 files changed

+365
-10
lines changed

10 files changed

+365
-10
lines changed

lib/Migrator/APIDiffMigratorPass.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
#include "swift/AST/USRGeneration.h"
1414
#include "swift/AST/ASTVisitor.h"
15+
#include "swift/Basic/StringExtras.h"
1516
#include "swift/Frontend/Frontend.h"
1617
#include "swift/IDE/Utils.h"
1718
#include "swift/Index/Utils.h"
@@ -611,8 +612,12 @@ struct APIDiffMigratorPass : public ASTMigratorPass, public SourceEntityWalker {
611612
Arg->getStartLoc().getAdvancedLoc(1));
612613

613614
// Replace "x.getY(" with "x.Y =".
614-
Editor.replace(ReplaceRange, (llvm::Twine(Walker.Result.str().
615-
substr(3)) + " = ").str());
615+
auto Replacement = (llvm::Twine(Walker.Result.str()
616+
.substr(3)) + " = ").str();
617+
SmallString<64> Scratch;
618+
Editor.replace(ReplaceRange,
619+
camel_case::toLowercaseInitialisms(Replacement, Scratch));
620+
616621
// Remove ")"
617622
Editor.remove(CharSourceRange(SM, Arg->getEndLoc(), Arg->getEndLoc().
618623
getAdvancedLoc(1)));

stdlib/public/SDK/Dispatch/Source.swift

Lines changed: 318 additions & 5 deletions
Large diffs are not rendered by default.

stdlib/public/SDK/Dispatch/Time.swift

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,18 +114,30 @@ extension DispatchWallTime {
114114
}
115115
}
116116

117-
public enum DispatchTimeInterval {
117+
public enum DispatchTimeInterval : Equatable {
118118
case seconds(Int)
119119
case milliseconds(Int)
120120
case microseconds(Int)
121121
case nanoseconds(Int)
122+
@_downgrade_exhaustivity_check
123+
case never
122124

123125
internal var rawValue: Int64 {
124126
switch self {
125127
case .seconds(let s): return Int64(s) * Int64(NSEC_PER_SEC)
126128
case .milliseconds(let ms): return Int64(ms) * Int64(NSEC_PER_MSEC)
127129
case .microseconds(let us): return Int64(us) * Int64(NSEC_PER_USEC)
128130
case .nanoseconds(let ns): return Int64(ns)
131+
case .never: return Int64.max
132+
}
133+
}
134+
135+
public static func ==(lhs: DispatchTimeInterval, rhs: DispatchTimeInterval) -> Bool {
136+
switch (lhs, rhs) {
137+
case (.never, .never): return true
138+
case (.never, _): return false
139+
case (_, .never): return false
140+
default: return lhs.rawValue == rhs.rawValue
129141
}
130142
}
131143
}

test/Migrator/Inputs/API.json

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,17 @@
127127
"RightComment": "",
128128
"ModuleName": "bar"
129129
},
130+
{
131+
"DiffItemKind": "CommonDiffItem",
132+
"NodeKind": "Function",
133+
"NodeAnnotation": "SetterToProperty",
134+
"ChildIndex": "0",
135+
"LeftUsr": "c:objc(cs)PropertyUserInterface(im)setURL:",
136+
"LeftComment": "",
137+
"RightUsr": "",
138+
"RightComment": "",
139+
"ModuleName": "bar"
140+
},
130141
{
131142
"DiffItemKind": "CommonDiffItem",
132143
"NodeKind": "Function",

test/Migrator/mock-sdk/Bar.framework/Headers/Bar.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ enum BarForwardDeclaredEnum {
2525
- (int) field;
2626
- (int * _Nullable) field2;
2727
- (void) setField:(int)info;
28+
- (void) setURL:(int)url;
2829
+ (int) fieldPlus;
2930
+ (void) methodPlus:(int)info;
3031
+ (void) methodPlus;

test/Migrator/pre_fixit_pass.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,5 +11,6 @@ Old()
1111

1212
func foo(_ a : PropertyUserInterface) {
1313
a.setField(1)
14+
a.setURL(1)
1415
_ = a.field()
1516
}

test/Migrator/pre_fixit_pass.swift.expected

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ struct Old {}
1010
New()
1111

1212
func foo(_ a : PropertyUserInterface) {
13-
a.Field = 1
13+
a.field = 1
14+
a.url = 1
1415
_ = a.field
1516
}

test/Migrator/property.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import Bar
77

88
func foo(_ a : PropertyUserInterface) {
99
a.setField(1)
10+
a.setURL(1)
1011
_ = a.field()
1112
}
1213

test/Migrator/property.swift.expected

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
import Bar
77

88
func foo(_ a : PropertyUserInterface) {
9-
a.Field = 1
9+
a.field = 1
10+
a.url = 1
1011
_ = a.field
1112
}
1213

test/stdlib/Dispatch.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -508,3 +508,12 @@ if #available(OSX 10.13, iOS 11.0, watchOS 4.0, tvOS 11.0, *) {
508508
expectTrue(result == .success)
509509
}
510510
}
511+
512+
#if swift(>=4.0)
513+
DispatchAPI.test("DispatchTimeInterval.never.equals") {
514+
expectTrue(DispatchTimeInterval.never == DispatchTimeInterval.never)
515+
expectTrue(DispatchTimeInterval.seconds(10) != DispatchTimeInterval.never);
516+
expectTrue(DispatchTimeInterval.never != DispatchTimeInterval.seconds(10));
517+
expectTrue(DispatchTimeInterval.seconds(10) == DispatchTimeInterval.seconds(10));
518+
}
519+
#endif

0 commit comments

Comments
 (0)