Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Protocol conformance ignored when Self used #76543

Open
vojtarylko opened this issue Sep 18, 2024 · 0 comments
Open

Protocol conformance ignored when Self used #76543

vojtarylko opened this issue Sep 18, 2024 · 0 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. triage needed This issue needs more specific labels

Comments

@vojtarylko
Copy link

Description

Compiler behaves in surprising ways when stating protocols using Self and/or typealias.

Reproduction

// Arbitrary protocol
protocol P1 { func someFunc() }

// Unexpected: Compiles fine even though we don't implement `someFunc()`
//
struct S1: Self.Conforms {
    typealias Conforms = P1
}

// Regresion: Fails to compile for Swift 6.1 with confusing
// error message:
//
// Swift 5.10 fails with:
//   `error: type 'S2' does not conform to protocol 'P1'`
//
//
// Swift 6.1 (84e93a26ea8ccf5) fails with:
//
//    struct S2: S2.Conforms {
//           `- note: through reference here
//        typealias Conforms = P1
//                  |- error: circular reference
//                  `- note: through reference here
//    }
//
struct S2: S2.Conforms {
    typealias Conforms = P1
}

Expected behavior

There shouldn't be difference between struct S1: Self.Conforms and struct S1: S1.Conforms

Environment

  1. swift-driver version: 1.90.11.1 Apple Swift version 5.10 (swiftlang-5.10.0.13 clang-1500.3.9.4)
  2. Swift version 6.1-dev (LLVM b5c60054ab3ee7b, Swift 84e93a26ea8ccf5)

Additional information

No response

@vojtarylko vojtarylko added bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. triage needed This issue needs more specific labels labels Sep 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. triage needed This issue needs more specific labels
Projects
None yet
Development

No branches or pull requests

1 participant