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
5 changes: 4 additions & 1 deletion lib/AST/TypeSubstitution.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@ class TypeSubstituter : public TypeTransform<TypeSubstituter> {
std::optional<Type> transformLocalArchetypeType(LocalArchetypeType *local,
TypePosition pos);

SubstitutionMap transformSubstitutionMap(SubstitutionMap subs);
// SubstitutionMap transformSubstitutionMap(SubstitutionMap subs);

CanType transformSILField(CanType fieldTy, TypePosition pos);
};
Expand Down Expand Up @@ -474,10 +474,13 @@ Type TypeSubstituter::transformDependentMemberType(DependentMemberType *dependen
return result;
}

// FIXME: This exposes a scalability issue; see test/SILGen/opaque_result_type_slow.swift.
/*
SubstitutionMap TypeSubstituter::transformSubstitutionMap(SubstitutionMap subs) {
// FIXME: Take level into account? Move level down into IFS?
return subs.subst(IFS);
}
*/

CanType TypeSubstituter::transformSILField(CanType fieldTy, TypePosition pos) {
// Type substitution does not walk into the SILBoxType's field types, because
Expand Down
74 changes: 74 additions & 0 deletions test/Generics/rdar158774099.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
// RUN: %empty-directory(%t)
// RUN: split-file %s %t

// RUN: %target-swift-frontend -typecheck -verify \
// RUN: %t/View.swift %t/Modifier.swift %t/MyStorage.swift %t/Storage.swift %t/WrappedStorage.swift

//--- Storage.swift

protocol Representable {
associatedtype Outputs
typealias Context = RepresentableContext<Self>
}

struct RepresentableContext<R: Representable> {}

struct Inputs<Outputs> {
}

protocol Storage<Value> {
associatedtype Value
associatedtype R: Representable

func body(content: Content) -> Value

typealias Content = Inputs<R.Outputs>
}

//--- WrappedStorage.swift
private struct WrappedStorage<Base: Storage>: Storage where Base.Value == MyStorage.Value {
typealias R = Base.R

init(base: Base, body: @escaping (Base.Value) -> Void) {
}

func body(content: Content) -> Base.Value { fatalError() }
}

extension Storage where Value == MyStorage.Value {
func withStorage(body: @escaping (Value) -> Void) -> some Storage<Value> {
WrappedStorage(base: self, body: body)
}
}

//--- MyStorage.swift
struct MyRepresentable: Representable {
struct Outputs {}
}

struct MyStorage: Storage {
typealias R = MyRepresentable

struct Value: Equatable {}

func body(content: Content) -> Value {
fatalError()
}
}

//--- Modifier.swift
extension P {
func storage(_: some Storage) -> some P { Test() }
}

//--- View.swift
protocol P {
}

struct Test: P {
}

func test() -> some P {
let storage = MyStorage().withStorage { value in }
return Test().storage(storage)
}