Is this a conditional conformance bug?

I just was toying around with generic types and protocols that would 'fake' qualified lookup and stumbled accidentally upon this issue which felt odd to me.

protocol Test {
 associatedtype Foo

struct Generic<Foo, Bar> {}
extension Generic Test where Foo == Bar {}
print(type(of: Generic<String, Int>.Foo.self)) // compiles and prints `String.Type` 

I think this shouldn't even compile, no? I've tested it in Swift 4.1 and with 4.2 (wwdc Xcode 10 beta).

This does look like a bug. Do you want to file it?

A slightly small (and more "exciting") version is:

protocol Test {
    associatedtype Foo

struct Generic<Foo> {}
extension Generic: Test where Foo == Int {}

It prints Int!


Uff that was is even more scary. I‘ll file those.

Edit: SR-7976


1 Like