File: package-cmo-opaque-result.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 (54 lines) | stat: -rw-r--r-- 1,681 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
// RUN: %empty-directory(%t)
// RUN: split-file %s %t

// RUN: %target-build-swift %t/Lib.swift \
// RUN: -module-name=Lib -package-name Pkg \
// RUN: -parse-as-library -emit-module -emit-module-path %t/Lib.swiftmodule -I%t \
// RUN: -Xfrontend -experimental-package-cmo -Xfrontend -experimental-allow-non-resilient-access \
// RUN: -O -wmo -enable-library-evolution -Xfrontend -disable-availability-checking

// RUN: %target-build-swift -module-name=Main -package-name Pkg -I%t -emit-sil -O %t/main.swift -o %t/Main-res.sil
// RUN: %FileCheck %s --check-prefixes=CHECK-OPAQUE < %t/Main-res.sil

// REQUIRES: swift_in_compiler

//--- main.swift

import Lib

// CHECK-OPAQUE: sil @$s4Main023testPackageInSerializedC4FuncyyF : $@convention(thin) () -> ()
// CHECK-OPAQUE: struct $Thing
// CHECK-OPAQUE: struct $Thing1
// CHECK-OPAQUE: function_ref @$s3Lib13getSomeProto2QryF
// CHECK-OPAQUE: function_ref @$s3Lib13getSomeProto3QryF
// CHECK-OPAQUE: } // end sil function '$s4Main023testPackageInSerializedC4FuncyyF'

public func testPackageInSerializedPackageFunc() {
    print(getSomeProto())
    print(getSomeProto1())
    print(getSomeProto2())
    print(getSomeProto3())
}

//--- Lib.swift

public protocol SomeProto {}

public struct Thing : SomeProto {}
package struct Thing1 : SomeProto {}
internal struct Thing2 : SomeProto {}
private struct Thing3 : SomeProto {}

// Don't crash on this example.
public func getSomeProto() -> some SomeProto {
    return Thing()
}
public func getSomeProto1() -> some SomeProto {
    return Thing1()
}
public func getSomeProto2() -> some SomeProto {
    return Thing2()
}
public func getSomeProto3() -> some SomeProto {
    return Thing3()
}