# An Implementation Model for Rational Protocol Conformance Behavior

**URL:** <https://forums.swift.org/t/an-implementation-model-for-rational-protocol-conformance-behavior/37171>\
**Category:** Pitches\
**Tags:** generics\
**Created:** [June 3, 2020, 12:38am UTC](https://forums.swift.org/t/an-implementation-model-for-rational-protocol-conformance-behavior/37171 "2020-06-03T00:38:15Z")\
**Posts on this page:** 1\
**Showing post:** 85

<div class="post-metadata">

**Author:** ![dabrahams](https://sea2.discourse-cdn.com/swift/user_avatar/forums.swift.org/dabrahams/32/9815_2.png) [@dabrahams](https://forums.swift.org/u/dabrahams)\
**Post date:** [June 11, 2020, 4:44am UTC](https://forums.swift.org/t/an-implementation-model-for-rational-protocol-conformance-behavior/37171/85 "2020-06-11T04:44:08Z")

</div>

> [@mattrips](#):
>
> Protocol conformance gets really weird when there are conflicting conformances imported into a module.

Yup.

> [@](#):
>
> Expanding on the `uniqueXs` example, starting with the fully-implemented version that you posted. Let's add a _second file_ to Module `D` , as follows:
> 
> ```swift
> import A
> func whichConformanceGetsCalled() {
> print( X(y: 0) == X(y: 1) )
> }
> 
> ```
> 
> _Should_ that compile? I'm not sure. The `==` needs an implementation that takes operands of type `X`.
> 
> Are either of the conformances of `X` to `Equatable` visible in this second file? Perhaps, the conformances to `Equatable` should not be visible, because they have not been imported, and so that should not compile.

Yeah, I've seen [variants of this problem](https://bugs.swift.org/browse/SR-12513?focusedCommentId=56878&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-56878) before. It would be awesome if you could file a bug with a reduced case that focuses just on this problem.

> [@](#):
>
> _If that does compile_ , which conformance to `Equatable` _should_ be used? I posit that it is indeterminate, and so an ambiguity error should be raised on the `==` operator at compile time (assuming that it hadn't already failed on account of the absence of a conformance to `Equatable` ).

IMO it should not compile because no `X: Equatable` conformance is in scope; otherwise, what does it mean that imports are written in particular files?

I think it should work if you import just one of `B` or `C`, and as I [noted](https://bugs.swift.org/browse/SR-12513?focusedCommentId=56878&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-56878) earlier, I don't think it should be possible to use `X` at all in a context that imports both of them.

---

_[View the full topic](https://forums.swift.org/t/an-implementation-model-for-rational-protocol-conformance-behavior/37171)._
