diff --git a/CHANGELOG.md b/CHANGELOG.md index be786e3de4..3c4bb662e7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -78,6 +78,11 @@ ### Bug Fixes +* Recognize `isolated` as an isolation modifier in `modifier_order`, so it can + be ordered via the `isolation` entry in `preferred_modifier_order`. + [leno23](https://github.com/leno23) + [#6164](https://github.com/realm/SwiftLint/issues/6164) + * Detect and autocorrect missing whitespace before `else` in `guard` statements for the `statement_position` rule. [theamodhshetty](https://github.com/theamodhshetty) diff --git a/Source/SwiftLintBuiltInRules/Rules/Style/ModifierOrderRule.swift b/Source/SwiftLintBuiltInRules/Rules/Style/ModifierOrderRule.swift index 5c4b286926..ac492bf490 100644 --- a/Source/SwiftLintBuiltInRules/Rules/Style/ModifierOrderRule.swift +++ b/Source/SwiftLintBuiltInRules/Rules/Style/ModifierOrderRule.swift @@ -135,7 +135,7 @@ private extension SwiftDeclarationAttributeKind.ModifierGroup { self = .lazy case "dynamic": self = .dynamic - case "nonisolated": + case "isolated", "nonisolated": self = .isolation case "private", "fileprivate", "internal", "public", "open": self = .acl diff --git a/Tests/FrameworkTests/ModifierOrderTests.swift b/Tests/FrameworkTests/ModifierOrderTests.swift index e41697d4ed..e5e1a9e286 100644 --- a/Tests/FrameworkTests/ModifierOrderTests.swift +++ b/Tests/FrameworkTests/ModifierOrderTests.swift @@ -408,6 +408,12 @@ final class ModifierOrderTests: SwiftLintTestCase { } """), Example(""" + @MainActor + class Foo { + isolated public func bar() {} + } + """), + Example(""" class RegularClass { @MainActor public func bar() {} } @@ -426,6 +432,12 @@ final class ModifierOrderTests: SwiftLintTestCase { private nonisolated func heavyWork() {} } """), + Example(""" + @MainActor + class Foo { + public isolated func bar() {} + } + """), ]) .with(corrections: [ Example(""" @@ -440,6 +452,18 @@ final class ModifierOrderTests: SwiftLintTestCase { nonisolated public func bar() {} } """), + Example(""" + @MainActor + class Foo { + public isolated func bar() {} + } + """): + Example(""" + @MainActor + class Foo { + isolated public func bar() {} + } + """), ]) verifyRule(descriptionOverride,