Skip to content

Commit 6a90011

Browse files
authored
Merge pull request #70831 from slavapestov/slava/fix-120743365-5.10
Sema: Fix logic error in TypeReprCycleCheckWalker handling of 'Self.Foo' [5.10]
2 parents 30b5fa9 + cdff1ef commit 6a90011

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

lib/Sema/TypeCheckProtocolInference.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,8 @@ struct TypeReprCycleCheckWalker : ASTWalker {
211211

212212
// If we're inferring `Foo`, don't look at a witness mentioning `Self.Foo`.
213213
if (auto *identTyR = dyn_cast<SimpleIdentTypeRepr>(baseTyR)) {
214-
if (identTyR->getNameRef().getBaseIdentifier() == ctx.Id_Self) {
214+
if (identTyR->getNameRef().getBaseIdentifier() == ctx.Id_Self &&
215+
circularNames.count(memberTyR->getNameRef().getBaseIdentifier()) > 0) {
215216
// But if qualified lookup can find a type with this name without
216217
// looking into protocol members, don't skip the witness, since this
217218
// type might be a candidate witness.

test/decl/protocol/req/assoc_type_inference_cycle.swift

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,3 +131,19 @@ public struct LogTypes: OptionSet {
131131

132132
public let rawValue: Int
133133
}
134+
135+
// rdar://120743365
136+
public struct G<T> {}
137+
138+
public protocol HasAlias {
139+
typealias A = G<Self>
140+
associatedtype B
141+
142+
func f1(_: Self.A, _: Self.B)
143+
func f2(_: Self.A, _: Self.B)
144+
}
145+
146+
public struct ConformsHasAlias: HasAlias {
147+
public func f1(_: Self.A, _: Self.B) {}
148+
public func f2(_: Self.A, _: Int) {}
149+
}

0 commit comments

Comments
 (0)