Regression: Operators in protocol extensions doesn't compile in Swift 6.1 and Swift 6.2 snapshots when the parameters are generalized to take any instance satisfying the protocol and not just Self
#78733
Labels
bug
A deviation from expected or documented behavior. Also: expected but undesirable behavior.
compiler
The Swift compiler itself
operators
Feature: operators
protocol
Feature → type declarations: Protocol declarations
regression
Swift 6.2-dev
type checker
Area → compiler: Semantic analysis
Description
No response
Reproduction
Which can be reduced to:
These examples compile successfully on Swift 6.0.3, but compilation fails on the
swift-6.1-DEVELOPMENT-SNAPSHOT-2025-01-17-a.xctoolchain
andswift-DEVELOPMENT-SNAPSHOT-2025-01-10-a.xctoolchain
snapshots with the diagnostic:Expected behavior
I expected the code to compile on all toolchains as
Self
conforms toEqualById
.Environment
The code compiles with
swift-driver version: 1.115.1 Apple Swift version 6.0.3 (swiftlang-6.0.3.1.10 clang-1600.0.30.1) Target: arm64-apple-macosx15.0
The codes doesn't compile with
Apple Swift version 6.1-dev (LLVM 38a3fc37c5f5e7a, Swift eedae18ae4df60a) Target: arm64-apple-macosx15.0
andApple Swift version 6.2-dev (LLVM 81859ac55f8d09a, Swift 8ec8a1229a7ea14) Target: arm64-apple-macosx15.0
Additional information
The problem is specific to protocol extensions, as the following examples doesn't compile using either toolchain:
The following examples, where the parameters are further generalized, doesn't compile on Swift 6.0.3 either, suggesting that the behavior in Swift 6.1 and 6.2 may be intentional:
The text was updated successfully, but these errors were encountered: