Skip to content

Commit af070cb

Browse files
committed
Sema: Pass down tentative type witnesses in substCurrentTypeWitnesses()
1 parent acb0e9a commit af070cb

File tree

2 files changed

+38
-1
lines changed

2 files changed

+38
-1
lines changed

lib/Sema/TypeCheckProtocolInference.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1126,6 +1126,8 @@ void AssociatedTypeInference::collectAbstractTypeWitnesses(
11261126
}
11271127

11281128
Type AssociatedTypeInference::substCurrentTypeWitnesses(Type type) {
1129+
auto substOptions = getSubstOptionsWithCurrentTypeWitnesses();
1130+
11291131
// Local function that folds dependent member types with non-dependent
11301132
// bases into actual member references.
11311133
std::function<Type(Type)> foldDependentMemberTypes;
@@ -1148,7 +1150,8 @@ Type AssociatedTypeInference::substCurrentTypeWitnesses(Type type) {
11481150
auto *module = dc->getParentModule();
11491151

11501152
// Try to substitute into the base type.
1151-
Type result = depMemTy->substBaseType(module, baseTy);
1153+
Type result = depMemTy->substBaseType(
1154+
baseTy, LookUpConformanceInModule(module), substOptions);
11521155
if (!result->hasError())
11531156
return result;
11541157

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
// RUN: %target-typecheck-verify-swift -enable-experimental-associated-type-inference
2+
// RUN: %target-typecheck-verify-swift
3+
4+
// We would fail here when Indices was explicitly specified, as in X2.
5+
6+
public struct X1: RandomAccessCollection {
7+
public var startIndex: Int {
8+
return 0
9+
}
10+
11+
public var endIndex: Int {
12+
return 0
13+
}
14+
15+
public subscript(position: Int) -> String {
16+
return ""
17+
}
18+
}
19+
20+
public struct X2: RandomAccessCollection {
21+
public typealias Indices = Range<Int>
22+
23+
public var startIndex: Int {
24+
return 0
25+
}
26+
27+
public var endIndex: Int {
28+
return 0
29+
}
30+
31+
public subscript(position: Int) -> String {
32+
return ""
33+
}
34+
}

0 commit comments

Comments
 (0)