Files
swift-mirror/test/NameBinding/Inputs/protocol-inheritance.swift
Slava Pestov 8541811edf AST: Fix ProtocolDecl::getInheritedProtocols() for protocols that inherit from compositions
We allow protocols to inherit from protocol compositions
defined via a typealias, eg,

typealias PQ = P & Q

protocol R : PQ {}

Sometimes, ProtocolDecl::getInheritedProtocols() is called before
the protocol's requirement signature has been computed. In this
case, we walk the inheritance clause of the protocol directly.
This walk was only looking at ProtocolType members of the
inheritance clause, ignoring ProtocolCompositionTypes.

As a result, name lookup could fail with an assertion because of
not being able to "see" members inherited via the protocol
composition.

Fixes <rdar://problem/32595988>.
2017-06-17 00:27:45 -07:00

19 lines
292 B
Swift

public protocol Critter {
associatedtype Fur
}
public protocol Pet {}
public typealias Cat = Critter & Pet
public protocol Kitten : Cat {}
extension Kitten {
public func pet() -> Fur {
while true {}
}
}
public final class Meow<Purrs> : Kitten {
public typealias Fur = Purrs
}