serenity
serenity copied to clipboard
AK: Work around Xcode 15 beta mishandling trailing `requires` clauses
Xcode 15 betas 1-3 lack https://reviews.llvm.org/D135772, which fixes a bug that causes trailing requires clauses to be evaluated twice, failing the second time. Reported as FB12284201.
This caused compile errors when instantiating types derived from RefPtr:
error: invalid reference to function 'NonnullRefPtr': constraints not satisfied note: because substituted constraint expression is ill-formed: value of type '<dependent type>' is not contextually convertible to 'bool'.
This commit works around the issue by moving the requires clauses after the template parameter list.
In most cases, trailing requires clauses and those specified after the template parameter list, so this change should not impact the code's behavior. The only difference is that trailing requires clauses are evaluated after constrained placeholder types (i.e. Integral auto i function parameter).
Should we land workarounds for beta software? Maybe it'll be fixed in the stable release.
The way I see it, this workaround is zero-cost: we are not adding any extra logic or inefficiency to our code; and it's not just me that has run into this. Having this superficial issue fixed will allow for more people to beta-test Xcode for Ladybird, which will let us discover more serious issues (like the addc miscompile) more likely.
From the commit message:
In most cases, trailing
requiresclauses and those specified after the template parameter list, so this change should not impact the code's behavior.
I think there's something missing from the first part of this sentence?
🤦 should be fixed
This seems harmless enough. Might be tricky to avoid letting more of these show up, but we don't use requires that often, so it's probably fine.