@@ -37,14 +37,15 @@ bool migrator::updateCodeAndEmitRemapIfNeeded(
37
37
llvm::sys::fs::remove (Invocation.getMigratorOptions ().EmitRemapFilePath );
38
38
39
39
Migrator M { Instance, Invocation }; // Provide inputs and configuration
40
+ auto EffectiveVersion = Invocation.getLangOptions ().EffectiveLanguageVersion ;
41
+ auto CurrentVersion = version::Version::getCurrentLanguageVersion ();
40
42
41
43
// Phase 1: Pre Fix-it passes
42
44
// These uses the initial frontend invocation to apply any obvious fix-its
43
45
// to see if we can get an error-free AST to get to Phase 2.
44
46
std::unique_ptr<swift::CompilerInstance> PreFixItInstance;
45
47
if (Instance->getASTContext ().hadError ()) {
46
- PreFixItInstance = M.repeatFixitMigrations (2 ,
47
- Invocation.getLangOptions ().EffectiveLanguageVersion );
48
+ PreFixItInstance = M.repeatFixitMigrations (2 , EffectiveVersion);
48
49
49
50
// If we still couldn't fix all of the errors, give up.
50
51
if (PreFixItInstance == nullptr ||
@@ -56,10 +57,8 @@ bool migrator::updateCodeAndEmitRemapIfNeeded(
56
57
}
57
58
58
59
// Phase 2: Syntactic Transformations
59
- // Don't run these passes if we're already in Swift 4.2
60
- auto Opts = Invocation.getLangOptions ().EffectiveLanguageVersion ;
61
- bool isFourTwo = Opts.size () == 2 && Opts[0 ] == 4 && Opts[1 ] == 2 ;
62
- if (!isFourTwo) {
60
+ // Don't run these passes if we're already in newest Swift version.
61
+ if (EffectiveVersion != CurrentVersion) {
63
62
auto FailedSyntacticPasses = M.performSyntacticPasses ();
64
63
if (FailedSyntacticPasses) {
65
64
return true ;
@@ -75,7 +74,7 @@ bool migrator::updateCodeAndEmitRemapIfNeeded(
75
74
76
75
if (M.getMigratorOptions ().EnableMigratorFixits ) {
77
76
M.repeatFixitMigrations (Migrator::MaxCompilerFixitPassIterations,
78
- { 4 , 0 , 0 } );
77
+ CurrentVersion );
79
78
}
80
79
81
80
// OK, we have a final resulting text. Now we compare against the input
0 commit comments