Skip to content

Commit

Permalink
Trim exclamation mark from assign-only property types
Browse files Browse the repository at this point in the history
  • Loading branch information
ileitch committed Jan 9, 2024
1 parent 7ce3f96 commit 72bfce3
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Sources/Shared/PropertyTypeSanitizer.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ public struct PropertyTypeSanitizer {

@inlinable
public static func sanitize(_ type: String) -> String {
type.trimmed.trimmingCharacters(in: .init(["?"]))
type.trimmed.trimmingCharacters(in: .init(["?", "!"]))
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ public class FixtureClass123 {
struct CustomType {}

var retainedSimpleProperty: CustomType?
var retainedSimplePropertyImplicitUnwrap: CustomType!
var notRetainedSimpleProperty: String?
var retainedModulePrefixedProperty: Swift.Double?
var notRetainedModulePrefixedProperty: Swift.Bool?
Expand All @@ -20,6 +21,7 @@ public class FixtureClass123 {

public func someFunc() {
retainedSimpleProperty = CustomType()
retainedSimplePropertyImplicitUnwrap = CustomType()
notRetainedSimpleProperty = ""

retainedModulePrefixedProperty = 1
Expand Down
12 changes: 12 additions & 0 deletions Tests/PeripheryTests/RetentionTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1150,10 +1150,22 @@ final class RetentionTest: FixtureSourceGraphTestCase {
analyze(retainPublic: true) {
assertReferenced(.class("FixtureClass123")) {
self.assertReferenced(.varInstance("retainedSimpleProperty"))
self.assertNotAssignOnlyProperty(.varInstance("retainedSimpleProperty"))

self.assertReferenced(.varInstance("retainedSimplePropertyImplicitUnwrap"))
self.assertNotAssignOnlyProperty(.varInstance("retainedSimplePropertyImplicitUnwrap"))

self.assertReferenced(.varInstance("retainedModulePrefixedProperty"))
self.assertNotAssignOnlyProperty(.varInstance("retainedModulePrefixedProperty"))

self.assertReferenced(.varInstance("retainedTupleProperty"))
self.assertNotAssignOnlyProperty(.varInstance("retainedTupleProperty"))

self.assertReferenced(.varInstance("retainedDestructuredPropertyA"))
self.assertNotAssignOnlyProperty(.varInstance("retainedDestructuredPropertyA"))

self.assertReferenced(.varInstance("retainedMultipleBindingPropertyA"))
self.assertNotAssignOnlyProperty(.varInstance("retainedMultipleBindingPropertyA"))

#if canImport(Combine)
self.assertReferenced(.varInstance("retainedAnyCancellable"))
Expand Down

0 comments on commit 72bfce3

Please sign in to comment.