File: export-as-in-swiftinterfaces.swift

package info (click to toggle)
swiftlang 6.0.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 2,519,992 kB
  • sloc: cpp: 9,107,863; ansic: 2,040,022; asm: 1,135,751; python: 296,500; objc: 82,456; f90: 60,502; lisp: 34,951; pascal: 19,946; sh: 18,133; perl: 7,482; ml: 4,937; javascript: 4,117; makefile: 3,840; awk: 3,535; xml: 914; fortran: 619; cs: 573; ruby: 573
file content (95 lines) | stat: -rw-r--r-- 4,938 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
/// Test the logic printing the export_as name in public swiftinterfaces
/// and the real source module name in the private swiftinterfaces.

// RUN: %empty-directory(%t)
// RUN: split-file %s %t

/// Build lib with an export_as.
// RUN: %target-swift-frontend -emit-module %t/Exported.swift \
// RUN:   -module-name Exported -swift-version 5 -I %t \
// RUN:   -enable-library-evolution \
// RUN:   -emit-module-path %t/Exported.swiftmodule \
// RUN:   -emit-module-interface-path %t/Exported.swiftinterface \
// RUN:   -emit-private-module-interface-path %t/Exported.private.swiftinterface
// RUN: %target-swift-typecheck-module-from-interface(%t/Exported.private.swiftinterface) -module-name Exported -I %t
// RUN: cat %t/Exported.swiftinterface | %FileCheck -check-prefix=CHECK-USE-EXPORTER %s
// RUN: cat %t/Exported.private.swiftinterface | %FileCheck -check-prefix=CHECK-USE-EXPORTED %s

/// The public swiftinterface only builds under the name of Exporter.
// RUN: sed -e "s/module-name Exported/module-name Exporter/" -ibk %t/Exported.swiftinterface
// RUN: %target-swift-typecheck-module-from-interface(%t/Exported.swiftinterface) -I %t -module-name Exporter

/// Build lib with an @exported import of the exported one.
// RUN: %target-swift-frontend -emit-module %t/Exporter.swift \
// RUN:   -module-name Exporter -swift-version 5 -I %t \
// RUN:   -enable-library-evolution \
// RUN:   -emit-module-path %t/Exporter.swiftmodule \
// RUN:   -emit-module-interface-path %t/Exporter.swiftinterface \
// RUN:   -emit-private-module-interface-path %t/Exporter.private.swiftinterface
// RUN: %target-swift-typecheck-module-from-interface(%t/Exporter.swiftinterface) -I %t
// RUN: %target-swift-typecheck-module-from-interface(%t/Exporter.private.swiftinterface) -module-name Exporter -I %t
// RUN: cat %t/Exporter.swiftinterface | %FileCheck -check-prefix=CHECK-USE-EXPORTER %s
// RUN: cat %t/Exporter.private.swiftinterface | %FileCheck -check-prefix=CHECK-USE-EXPORTED %s

/// Build lib with an @exported import of the exported one.
// RUN: %target-swift-frontend -emit-module %t/Exporter.swift \
// RUN:   -module-name Exporter -swift-version 5 -I %t \
// RUN:   -enable-library-evolution \
// RUN:   -emit-module-path %t/Exporter.swiftmodule \
// RUN:   -emit-module-interface-path %t/Exporter.swiftinterface \
// RUN:   -emit-private-module-interface-path %t/Exporter.private.swiftinterface
// RUN: %target-swift-typecheck-module-from-interface(%t/Exporter.swiftinterface) -I %t
// RUN: %target-swift-typecheck-module-from-interface(%t/Exporter.private.swiftinterface) -module-name Exporter -I %t
// RUN: cat %t/Exporter.swiftinterface | %FileCheck -check-prefix=CHECK-USE-EXPORTER %s
// RUN: cat %t/Exporter.private.swiftinterface | %FileCheck -check-prefix=CHECK-USE-EXPORTED %s

/// Build a client of the exporter lib.
// RUN: %target-swift-frontend -emit-module %t/Client.swift \
// RUN:   -module-name Client -swift-version 5 -I %t \
// RUN:   -enable-library-evolution \
// RUN:   -emit-module-path %t/Client.swiftmodule \
// RUN:   -emit-module-interface-path %t/Client.swiftinterface \
// RUN:   -emit-private-module-interface-path %t/Client.private.swiftinterface
// RUN: %target-swift-typecheck-module-from-interface(%t/Client.swiftinterface) -I %t
// RUN: %target-swift-typecheck-module-from-interface(%t/Client.private.swiftinterface) -module-name Client -I %t
// RUN: cat %t/Client.swiftinterface | %FileCheck -check-prefix=CHECK-USE-EXPORTER %s
// RUN: cat %t/Client.private.swiftinterface | %FileCheck -check-prefix=CHECK-USE-EXPORTED %s

/// Build a client of the exporter lib against the public swiftinterface.
// RUN: rm %t/Exporter.private.swiftinterface %t/Exporter.swiftmodule
// RUN: %target-swift-frontend -emit-module %t/Client.swift \
// RUN:   -module-name Client -swift-version 5 -I %t \
// RUN:   -enable-library-evolution \
// RUN:   -emit-module-path %t/Client.swiftmodule \
// RUN:   -emit-module-interface-path %t/Client.swiftinterface \
// RUN:   -emit-private-module-interface-path %t/Client.private.swiftinterface
// RUN: %target-swift-typecheck-module-from-interface(%t/Client.swiftinterface) -I %t
// RUN: %target-swift-typecheck-module-from-interface(%t/Client.private.swiftinterface) -module-name Client -I %t
// RUN: cat %t/Client.swiftinterface | %FileCheck -check-prefix=CHECK-USE-EXPORTER %s
// RUN: cat %t/Client.private.swiftinterface | %FileCheck -check-prefix=CHECK-USE-EXPORTED %s

//--- module.modulemap
module Exported {
    export_as Exporter
    header "Exported.h"
}

//--- Exported.h
struct exportedClangType {};

//--- Exported.swift
@_exported import Exported

public func foo(a: exportedClangType) {}
// CHECK-USE-EXPORTED: Exported.exportedClangType
// CHECK-USE-EXPORTER: Exporter.exportedClangType

//--- Exporter.swift
@_exported import Exported

public func foo(a: exportedClangType) {}

//--- Client.swift
import Exporter

public func foo(a: exportedClangType) {}