Skip to content

Commit 78e2af6

Browse files
authored
Merge pull request #83883 from xedin/rdar-158774099
Revert "AST: Re-enable TypeSubstituter::transformSubstitutionMap() again"
2 parents db8b848 + beb05fb commit 78e2af6

File tree

2 files changed

+78
-1
lines changed

2 files changed

+78
-1
lines changed

lib/AST/TypeSubstitution.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -358,7 +358,7 @@ class TypeSubstituter : public TypeTransform<TypeSubstituter> {
358358
std::optional<Type> transformLocalArchetypeType(LocalArchetypeType *local,
359359
TypePosition pos);
360360

361-
SubstitutionMap transformSubstitutionMap(SubstitutionMap subs);
361+
// SubstitutionMap transformSubstitutionMap(SubstitutionMap subs);
362362

363363
CanType transformSILField(CanType fieldTy, TypePosition pos);
364364
};
@@ -474,10 +474,13 @@ Type TypeSubstituter::transformDependentMemberType(DependentMemberType *dependen
474474
return result;
475475
}
476476

477+
// FIXME: This exposes a scalability issue; see test/SILGen/opaque_result_type_slow.swift.
478+
/*
477479
SubstitutionMap TypeSubstituter::transformSubstitutionMap(SubstitutionMap subs) {
478480
// FIXME: Take level into account? Move level down into IFS?
479481
return subs.subst(IFS);
480482
}
483+
*/
481484

482485
CanType TypeSubstituter::transformSILField(CanType fieldTy, TypePosition pos) {
483486
// Type substitution does not walk into the SILBoxType's field types, because

test/Generics/rdar158774099.swift

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
// RUN: %empty-directory(%t)
2+
// RUN: split-file %s %t
3+
4+
// RUN: %target-swift-frontend -typecheck -verify \
5+
// RUN: %t/View.swift %t/Modifier.swift %t/MyStorage.swift %t/Storage.swift %t/WrappedStorage.swift
6+
7+
//--- Storage.swift
8+
9+
protocol Representable {
10+
associatedtype Outputs
11+
typealias Context = RepresentableContext<Self>
12+
}
13+
14+
struct RepresentableContext<R: Representable> {}
15+
16+
struct Inputs<Outputs> {
17+
}
18+
19+
protocol Storage<Value> {
20+
associatedtype Value
21+
associatedtype R: Representable
22+
23+
func body(content: Content) -> Value
24+
25+
typealias Content = Inputs<R.Outputs>
26+
}
27+
28+
//--- WrappedStorage.swift
29+
private struct WrappedStorage<Base: Storage>: Storage where Base.Value == MyStorage.Value {
30+
typealias R = Base.R
31+
32+
init(base: Base, body: @escaping (Base.Value) -> Void) {
33+
}
34+
35+
func body(content: Content) -> Base.Value { fatalError() }
36+
}
37+
38+
extension Storage where Value == MyStorage.Value {
39+
func withStorage(body: @escaping (Value) -> Void) -> some Storage<Value> {
40+
WrappedStorage(base: self, body: body)
41+
}
42+
}
43+
44+
//--- MyStorage.swift
45+
struct MyRepresentable: Representable {
46+
struct Outputs {}
47+
}
48+
49+
struct MyStorage: Storage {
50+
typealias R = MyRepresentable
51+
52+
struct Value: Equatable {}
53+
54+
func body(content: Content) -> Value {
55+
fatalError()
56+
}
57+
}
58+
59+
//--- Modifier.swift
60+
extension P {
61+
func storage(_: some Storage) -> some P { Test() }
62+
}
63+
64+
//--- View.swift
65+
protocol P {
66+
}
67+
68+
struct Test: P {
69+
}
70+
71+
func test() -> some P {
72+
let storage = MyStorage().withStorage { value in }
73+
return Test().storage(storage)
74+
}

0 commit comments

Comments
 (0)