Open malaba opened 2 years ago
@malaba this is a known limitation of SwiftFormat's per-file formatting implementation. Currently no information is shared between files in a project, so it cannot know about a @dynamicMemberLookup
declaration in another file. The only workaround for now is to use --selfrequired
or disable the redundantSelf
rule for that file.
@nicklockwood Could --selfrequired
perhaps accept type names in addition to function names?
What happens:
It appear that when the definition of the type with
@dynamicMemberLookup
isn't in the same file as an extension that use those member access, the mandatoryself
is removed byswiftformat
.Xcode project here.
The code compile, but once you run swiftformat at the root directory, it doesn't compile anymore.
Test on latest: Xcode v13.2.1, Swiftformat 0.49.4.
What is expected:
That swiftformat see that dynamic member lookup need
self
and it isn't removed.Or if that is impossible (file parsed one by one without context from other files ?) then an option to specify some member lookup need the
self
(similar to--selfrequired
for@ autoclosure
).