Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion lib/Sema/TypeCheckProtocolInference.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,8 @@ struct TypeReprCycleCheckWalker : ASTWalker {

// If we're inferring `Foo`, don't look at a witness mentioning `Self.Foo`.
if (auto *identTyR = dyn_cast<SimpleIdentTypeRepr>(baseTyR)) {
if (identTyR->getNameRef().getBaseIdentifier() == ctx.Id_Self) {
if (identTyR->getNameRef().getBaseIdentifier() == ctx.Id_Self &&
circularNames.count(memberTyR->getNameRef().getBaseIdentifier()) > 0) {
// But if qualified lookup can find a type with this name without
// looking into protocol members, don't skip the witness, since this
// type might be a candidate witness.
Expand Down
16 changes: 16 additions & 0 deletions test/decl/protocol/req/assoc_type_inference_cycle.swift
Original file line number Diff line number Diff line change
Expand Up @@ -131,3 +131,19 @@ public struct LogTypes: OptionSet {

public let rawValue: Int
}

// rdar://120743365
public struct G<T> {}

public protocol HasAlias {
typealias A = G<Self>
associatedtype B

func f1(_: Self.A, _: Self.B)
func f2(_: Self.A, _: Self.B)
}

public struct ConformsHasAlias: HasAlias {
public func f1(_: Self.A, _: Self.B) {}
public func f2(_: Self.A, _: Int) {}
}