Skip to content

Commit 5861c1f

Browse files
committed
[Sema] Avoid setting original type for ErrorType in transformDependentMemberType
`substBase` here can contain type variables
1 parent 6d0da8d commit 5861c1f

File tree

2 files changed

+24
-5
lines changed

2 files changed

+24
-5
lines changed

lib/AST/TypeSubstitution.cpp

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -445,10 +445,9 @@ Type TypeSubstituter::transformDependentMemberType(DependentMemberType *dependen
445445
auto conformance = IFS.lookupConformance(origBase, proto, level);
446446

447447
auto result = conformance.getTypeWitness(assocType, IFS.getOptions());
448-
if (result->is<ErrorType>()) {
449-
auto substBase = origBase.subst(IFS);
450-
return DependentMemberType::get(ErrorType::get(substBase), assocType);
451-
}
448+
if (result->is<ErrorType>())
449+
return DependentMemberType::get(ErrorType::get(ctx), assocType);
450+
452451
return result;
453452
}
454453

@@ -1242,4 +1241,4 @@ ProtocolConformanceRef ReplaceExistentialArchetypesWithConcreteTypes::operator()
12421241

12431242
return subs.lookupConformance(
12441243
getInterfaceType(existentialArchetype)->getCanonicalType(), proto);
1245-
}
1244+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// RUN: %target-swift-ide-test -code-completion -code-completion-token=COMPLETE -source-filename=%s
2+
3+
// https://github.com/swiftlang/swift/pull/82147
4+
5+
protocol P {
6+
associatedtype X
7+
}
8+
9+
struct S<T> {
10+
init<U, V>() where T == (U, V) {}
11+
}
12+
extension S : P where T : P {
13+
typealias X = T.X
14+
}
15+
16+
func foo<T: P, U>(_: () -> T) where U == T.X {}
17+
18+
foo {
19+
S(#^COMPLETE^#)
20+
}

0 commit comments

Comments
 (0)