Open tciuro opened 11 months ago
And it's interesting that it didn't change this one:
protocol PusherManagerSubscriber {
var id: UUID { get }
func newEventHasArrived<T: Codable>(with object: T)
}
it should have been updated with this, right?
protocol PusherManagerSubscriber {
var id: UUID { get }
func newEventHasArrived(with object: some Codable)
}
The --someany false option is just to prevent the rule replacing cases where T is untyped. To disable the rule altogether, use --disable opaqueGenericParameters
And it's interesting that it didn't change this one:
That might be a bug. I'll investigate.
Ah, cool. Thanks Nick!
@tciuro OK, it's not a bug so much as a missing feature - right now opaqueGenericParameters
doesn't apply to protocol methods. I'm not sure there's any good reason why it shouldn't but it would be a fairly big refactor to make that work so I'm going to treat it as a feature request.
@calda can you see any potential problems with applying opaqueGenericParameters
to protocol methods (besides implementation trickiness)?
Thanks for looking into this, Nick!
Ahh, this isn't applied to protocol requirements right now because protocol methods don't have a body?
I think updating this to apply to protocol should be a safe change. This compiles, which makes sense because the two syntaxes have the same meaning:
protocol PusherManagerSubscriber {
func newEventHasArrived(with object: some Codable)
}
struct MyType: PusherManagerSubscriber {
func newEventHasArrived<T: Codable>(with object: T) {
print(object)
}
}
I've added this to my
.swiftformat
file:However, the following code:
gets changed to the following, even if
--someany false
:Am I missing some additional setting perhaps?