if points.last != points.first {
// 💥 Operator function '!=' requires that
// 'NonEmpty<NonEmpty<Array<Self.CoordinateSystem.Point>>>.Element'
// (aka 'Self.CoordinateSystem.Point') conform to 'Equatable'
Is there a compiler flag or an annotation I could use to silence those warnings? I'd prefer writing too many redundant constraints and help the compiler, rather than having an exponential compile time… and errors
If there is no simple answer, I'll take some time to write down my type tree and add more code samples. I just don't want to spend a lot of time on it if there is one I'm not even sure if I can create a minimal reproductible example, as the problem comes from a too complex type tree
My environment
Xcode 13.3 (13E113)
Apple Swift version 5.6 (swiftlang-5.6.0.323.62 clang-1316.0.20.8)
This seems like it could an issue with the new generics implementation in Swift 5.6. You should be able to use the workaround here to see if disabling the new implementation fixes your problem.
Redundancy warnings are emitted after generic signature minimization, and Swift 5.6 still uses the old generics implementation for signature minimization and requirement diagnostics. I actually just implemented redundancy diagnostics for the new implementation on main, so you could try a development toolchain from Swift.org - Download Swift and build with the flags -Xfrontend -requirement-machine-protocol-signatures=on -Xfrontend -requirement-machine-inferred-signatures=on to see if it's fixed with the new implementation. If not, I'll take a look!
Note that redundant requirements don't help the compiler (though I think they can help the programmer if the requirement isn't obvious!) - the compiler will always canonicalize generic signatures in order to type check calls to a generic function, etc, so this computation would be done even if the compiler did not report warnings for redundant requirements.
As far as I can tell the requirement really is redundant, because it can be derived from Self.Point == Self.BoundingBox.Point. With -Xfrontend -requirement-machine-protocol-signatures=on the program builds both with and without the redundant requirement, so this bug will be fixed once this flag becomes the default.
This appears to be a bug in the GenericSignatureBuilder, and briefly looking at the code I see that the Point, BoundingBox, Line, CoordinateSystem, MultiPoint protocols are mutually inter-dependent. This is one of the scenarios the GSB did not handle very well.
I confirmed that in 5.6, -Xfrontend -requirement-machine=off does not fix the issue. As Holly already explained, the term rewriting engine is 'downstream' of the GenericSignatureBuilder in 5.6 so we would not expect behavior to change either way here.
The call to takesP4() in 'testP1()` should succeed, but it fails in 5.6. It succeeds on main with the new minimization algorithm. I'll add it to our test suite.
Thank you very much for your work, it fixes my problem
(Just a note: you pasted the arguments twice Edit: I just hadn't seen the difference (protocol / inferred) )
I am using a Swift Package, so for those searching a "copy-paste" solution, here is what I had to change:
With -Xfrontend -requirement-machine-inferred-signatures=on, it compiles.
With -Xfrontend -requirement-machine-protocol-signatures=on, I get Abort trap: 6.
With the four of them, I get Abort trap: 6 too.
-Xfrontend is an instruction to the swift driver that says "pass the next command I give you on to the front end". You're passing two different flags to the front end so you need to us that command for each one.
Try -Xfrontend -enable-requirement-machine-loop-normalization. It addressed the slow build times for me. This flag will become the default shortly.
Can you share the build log? I didn't see this issue when I was building your project.
EDIT: Are you using the developer toolchain from swift.org, or Swift 5.6 that shipped with Xcode? The latter had these flags because I was just starting to implement this functionality when the branch was cut, but it won't actually work. You need the latest toolchain.