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

[SR-11723] .swiftinterface round trip error: "conditional conformance of type 'xxx' to protocol 'yyy' does not imply conformance to inherited protocol 'zzz'" #54132

Open
dan-zheng opened this issue Nov 6, 2019 · 3 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself conditional conformances Feature → protocol → conformances: conditional conformances conformances Feature → protocol: protocol conformances swift 6.0 textual interfaces unexpected error Bug: Unexpected error

Comments

@dan-zheng
Copy link
Collaborator

dan-zheng commented Nov 6, 2019

Previous ID SR-11723
Radar None
Original Reporter @dan-zheng
Type Bug
Environment

DEVELOPMENT-SNAPSHOT-2019-11-01-a: https://swift.org/builds/development/xcode/swift-DEVELOPMENT-SNAPSHOT-2019-11-01-a/swift-DEVELOPMENT-SNAPSHOT-2019-11-01-a-osx.pkg

Apple Swift version 5.1.1-dev (Swift 74328cdda2)
Target: x86_64-apple-darwin18.7.0
Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, ParseableInterfaces
Assignee None
Priority Medium

md5: 50cbe79c7c7f05f6213fca70dcb9d645

Issue Description:

// sr-11723.swift
public protocol Proto1 {}
public protocol Proto2: Proto1 {}

public struct Struct<Scalar> {}
extension Struct : Proto1 & Proto2 where Scalar : Proto2 {}

swift sr-11723.swift and swiftc sr-11723.swift work fine, but the following does not:

$ swift -frontend -typecheck -emit-module-interface-path - sr-11723.swift -enable-library-evolution -module-name Module > Module.swiftinterface
$ swift -frontend -compile-module-from-interface Module.swiftinterface -o Module.swiftmodule
Module.swiftinterface:11:1: error: conditional conformance of type 'Struct<Scalar>' to protocol 'Proto2' does not imply conformance to inherited protocol 'Proto1'
extension Struct : Module.Proto2 where Scalar : Module.Proto2 {
^
Module.swiftinterface:11:1: note: did you mean to explicitly state the conformance like 'extension Struct: Proto1 where ...'?
extension Struct : Module.Proto2 where Scalar : Module.Proto2 {
^
<unknown>:0: error: failed to load module 'Module'

If the where clause (where Scalar : Proto2) is removed from extension Struct : Proto1 & Proto2 where Scalar : Proto2, then there is no error:

// sr-11723.swift
public protocol Proto1 {}
public protocol Proto2: Proto1 {}

public struct Struct<Scalar> {}
extension Struct : Proto1 & Proto2 {} // no error
@dan-zheng
Copy link
Collaborator Author

cc @harlanhaskins

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@AnthonyLatsis AnthonyLatsis added textual interfaces conformances Feature → protocol: protocol conformances conditional conformances Feature → protocol → conformances: conditional conformances unexpected error Bug: Unexpected error and removed ParseableInterfaces labels Oct 24, 2023
@AnthonyLatsis
Copy link
Collaborator

AnthonyLatsis commented Oct 24, 2023

The problem is that Proto1 & Proto2 gets canonicalized to Proto2.

@slavapestov Speaking of conditional conformances specifically, do we intentionally accept extension Struct : Proto1 & Proto2 where Scalar : Proto2 {} as a alternative to extension Struct : Proto1, Proto2 where Scalar : Proto2 {}?

@AnthonyLatsis
Copy link
Collaborator

cc @DougGregor

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. compiler The Swift compiler in itself conditional conformances Feature → protocol → conformances: conditional conformances conformances Feature → protocol: protocol conformances swift 6.0 textual interfaces unexpected error Bug: Unexpected error
Projects
None yet
Development

No branches or pull requests

2 participants