[Migrator] Don't run AST passes when in Swift 4 or later

AST passes assume that you are migrating from a version earlier
than Swift 4, where declaration references and type names may be
unconditionally renamed if their USRs match.

For example, this can happen for TypeMemberDiffItem entries where the
Objective-C USR is the same in Swift 3 and Swift 4, but the type is
spelled differently in Swift 4. A concrete example of this is:

`NSDocumentTypeDocumentAttribute` (Swift 3) ->
  `NSAttributedString.DocumentAttributeKey` (Swift 4).

Although this declaration is imported differently in Swift 4, its
Objective-C USR is `c:@NSDocumentTypeDocumentAttribute` for both.

rdar://problem/32604558
This commit is contained in:
David Farler
2017-06-23 14:04:07 -07:00
parent ce8c0eb4c8
commit 12ff3794bc
5 changed files with 31 additions and 4 deletions

View File

@@ -53,9 +53,11 @@ bool migrator::updateCodeAndEmitRemap(CompilerInstance *Instance,
}
// Phase 2: Syntactic Transformations
auto FailedSyntacticPasses = M.performSyntacticPasses();
if (FailedSyntacticPasses) {
return true;
if (Invocation.getLangOptions().EffectiveLanguageVersion[0] < 4) {
auto FailedSyntacticPasses = M.performSyntacticPasses();
if (FailedSyntacticPasses) {
return true;
}
}
// Phase 3: Post Fix-it Passes