Skip to content

Commit 0f51f30

Browse files
committed
Support targets outside of macOS 13+
1 parent b2c4c3c commit 0f51f30

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

lib/Macros/Sources/SwiftMacros/DebugDescriptionMacro.swift

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ extension DebugDescriptionMacro: MemberAttributeMacro {
5959
let substring = "\(propertyName)__vg"
6060
// Ex: "15description__vg"
6161
let runlengthSubstring = "\(substring.count)\(substring)"
62-
guard !mangledName.contains(runlengthSubstring) else {
62+
guard !mangledName.hasSubstring(runlengthSubstring) else {
6363
return []
6464
}
6565

@@ -366,7 +366,6 @@ extension DeclGroupSyntax {
366366
// New types of decls are not presumed to be valid.
367367
return nil
368368
}
369-
return nil
370369
}
371370
}
372371

@@ -485,3 +484,18 @@ extension Collection {
485484
count == 1 ? first : nil
486485
}
487486
}
487+
488+
extension String {
489+
fileprivate func hasSubstring(_ substring: String) -> Bool {
490+
if #available(macOS 13, *) {
491+
return self.contains(substring)
492+
}
493+
494+
for index in self.indices {
495+
if self.suffix(from: index).hasPrefix(substring) {
496+
return true
497+
}
498+
}
499+
return false
500+
}
501+
}

0 commit comments

Comments
 (0)