|
| 1 | +// RUN: %empty-directory(%t) |
| 2 | +// RUN: %empty-directory(%t/SDK) |
| 3 | +// RUN: split-file %s %t |
| 4 | +// |
| 5 | +// RUN: mkdir -p %t/SDK/Frameworks/FakeSystem.framework/Modules/FakeSystem.swiftmodule |
| 6 | +// RUN: %target-swift-frontend \ |
| 7 | +// RUN: -emit-module \ |
| 8 | +// RUN: -module-name FakeSystem \ |
| 9 | +// RUN: -o %t/SDK/Frameworks/FakeSystem.framework/Modules/FakeSystem.swiftmodule/%module-target-triple.swiftmodule \ |
| 10 | +// RUN: -swift-version 5 \ |
| 11 | +// RUN: %t/FakeSystem.swift |
| 12 | +// |
| 13 | +// RUN: %empty-directory(%t/idx) |
| 14 | +// RUN: %empty-directory(%t/modulecache) |
| 15 | +// |
| 16 | +// --- Built with indexing |
| 17 | +// RUN: %target-swift-frontend \ |
| 18 | +// RUN: -typecheck \ |
| 19 | +// RUN: -index-system-modules \ |
| 20 | +// RUN: -index-ignore-stdlib \ |
| 21 | +// RUN: -index-store-path %t/idx \ |
| 22 | +// RUN: -sdk %t/SDK \ |
| 23 | +// RUN: -Fsystem %t/SDK/Frameworks \ |
| 24 | +// RUN: -module-cache-path %t/modulecache \ |
| 25 | +// RUN: %t/view.swift |
| 26 | +// |
| 27 | +// --- Check the index. |
| 28 | +// RUN: c-index-test core -print-record %t/idx | %FileCheck %s |
| 29 | +// |
| 30 | + |
| 31 | +//--- FakeSystem.swift |
| 32 | +public protocol View { |
| 33 | +} |
| 34 | + |
| 35 | +public protocol ViewModifier { |
| 36 | + associatedtype Body: View |
| 37 | + typealias Content = _HiddenView<Self> |
| 38 | + func body(content: Self.Content) -> Self.Body |
| 39 | +} |
| 40 | + |
| 41 | +public struct _HiddenView<M>: View where M: ViewModifier { |
| 42 | + init(m: M) {} |
| 43 | +} |
| 44 | + |
| 45 | +public struct _HiddenModifier: ViewModifier { |
| 46 | + public func body(content: Content) -> some View { |
| 47 | + return _HiddenView(m: self) |
| 48 | + } |
| 49 | +} |
| 50 | + |
| 51 | +extension View { |
| 52 | + public func background() -> some View { |
| 53 | + return _HiddenView(m: _HiddenModifier()) |
| 54 | + } |
| 55 | +} |
| 56 | + |
| 57 | +//--- view.swift |
| 58 | +import FakeSystem |
| 59 | + |
| 60 | +private struct Mod: FakeSystem.ViewModifier { |
| 61 | + func body(content: Content) -> some View { |
| 62 | + content |
| 63 | + .background() |
| 64 | + // CHECK: 6:8 | instance-method/Swift | s:10FakeSystem4ViewPAAE10backgroundQryF | Ref,Call,Dyn{{.*}} |
| 65 | + } |
| 66 | +} |
0 commit comments