|
| 1 | +// RUN: %empty-directory(%t) |
| 2 | +// RUN: %target-swift-frontend -emit-module %S/Inputs/opaque_result_type_slow_other.swift -emit-module -emit-module-path %t/opaque_result_type_slow_other.swiftmodule -enable-library-evolution |
| 3 | +// RUN: %target-swift-emit-silgen %s -I %t |
| 4 | + |
| 5 | +import opaque_result_type_slow_other |
| 6 | + |
| 7 | +struct G<T: P & Q>: P & Q {} |
| 8 | + |
| 9 | +public func myWrap<T: P & Q>(_ t: T) -> some P & Q { |
| 10 | + return G<T>() |
| 11 | +} |
| 12 | + |
| 13 | +public func wrapWrap<T: P & Q>(_ t: T) -> some P & Q { |
| 14 | + return wrap(wrap(myWrap(t))) |
| 15 | +} |
| 16 | + |
| 17 | +public struct S: P, Q {} |
| 18 | + |
| 19 | +// We generate a series of substitution maps where each one contains an opaque archetype, |
| 20 | +// and an abstract conformance of this opaque archetype to a protocol. Each opaque archetype |
| 21 | +// then has a substitution map of the same form, and so on. |
| 22 | +// |
| 23 | +// Transforming each substitution map then visits each opaque archetype twice: once as part |
| 24 | +// of the replacement type, and again as part of the conformance. |
| 25 | +// |
| 26 | +// What saves us is that we would skip the conformance substitution in some cases, and perform |
| 27 | +// a lookup instead. This lookup is now load bearing, because changing it into a substitution |
| 28 | +// makes this program intractably slow. |
| 29 | +// |
| 30 | +// The correct fix is to probably cache substituted opaque GenericEnvironments, or |
| 31 | +// substituted SubstitutionMaps, inside of the InFlightSubstitution. |
| 32 | +let x = wrapWrap(wrapWrap(wrapWrap(wrapWrap(wrapWrap(wrapWrap(wrapWrap(wrapWrap(wrapWrap(S()))))))))) |
0 commit comments