Skip to content

Commit fef4952

Browse files
committed
migrator: ensure we collect post-migration fixits from the compiler. rdar://40925061
1 parent a831110 commit fef4952

File tree

3 files changed

+38
-2
lines changed

3 files changed

+38
-2
lines changed

lib/Migrator/FixitApplyDiagnosticConsumer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,12 @@ handleDiagnostic(SourceManager &SM, SourceLoc Loc,
5959

6060
// Ignore meaningless Fix-its.
6161
if (Length == 0 && Text.size() == 0)
62-
return;
62+
continue;
6363

6464
// Ignore pre-applied equivalents.
6565
Replacement R { Offset, Length, Text };
6666
if (Replacements.count(R)) {
67-
return;
67+
continue;
6868
} else {
6969
Replacements.insert(R);
7070
}

test/Migrator/post_fixit_pass.swift

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// RUN: %empty-directory(%t) && %target-swift-frontend -c -update-code -primary-file %s -emit-migrated-file-path %t/post_fixit_pass.swift.result -o /dev/null -F %S/mock-sdk -swift-version 3
2+
// RUN: diff -u %S/post_fixit_pass.swift.expected %t/post_fixit_pass.swift.result
3+
4+
#if swift(>=4)
5+
public struct SomeAttribute: RawRepresentable {
6+
public init(rawValue: Int) { self.rawValue = rawValue }
7+
public init(_ rawValue: Int) { self.rawValue = rawValue }
8+
public var rawValue: Int
9+
public typealias RawValue = Int
10+
}
11+
#else
12+
public typealias SomeAttribute = Int
13+
#endif
14+
15+
func foo(_ d: SomeAttribute) {
16+
let i: Int = d
17+
}
18+
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// RUN: %empty-directory(%t) && %target-swift-frontend -c -update-code -primary-file %s -emit-migrated-file-path %t/post_fixit_pass.swift.result -o /dev/null -F %S/mock-sdk -swift-version 3
2+
// RUN: diff -u %S/post_fixit_pass.swift.expected %t/post_fixit_pass.swift.result
3+
4+
#if swift(>=4)
5+
public struct SomeAttribute: RawRepresentable {
6+
public init(rawValue: Int) { self.rawValue = rawValue }
7+
public init(_ rawValue: Int) { self.rawValue = rawValue }
8+
public var rawValue: Int
9+
public typealias RawValue = Int
10+
}
11+
#else
12+
public typealias SomeAttribute = Int
13+
#endif
14+
15+
func foo(_ d: SomeAttribute) {
16+
let i: Int = d.rawValue
17+
}
18+

0 commit comments

Comments
 (0)