File: availability_maccatalyst.swift

package info (click to toggle)
swiftlang 6.1.3-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,791,532 kB
  • sloc: cpp: 9,901,743; ansic: 2,201,431; asm: 1,091,827; python: 308,252; objc: 82,166; f90: 80,126; lisp: 38,358; pascal: 25,559; sh: 20,429; ml: 5,058; perl: 4,745; makefile: 4,484; awk: 3,535; javascript: 3,018; xml: 918; fortran: 664; cs: 573; ruby: 396
file content (77 lines) | stat: -rw-r--r-- 3,053 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
// RUN: %target-swift-frontend(mock-sdk: %clang-importer-sdk) -target %target-cpu-apple-ios13.1-macabi -typecheck -verify -I %S/Inputs/custom-modules %s

// REQUIRES: maccatalyst_support

import Foundation
import AvailabilityExtras

func test_unavailable_because_deprecated() {
  print(NSRealMemoryAvailable()) // expected-error {{APIs deprecated as of iOS 7 and earlier are unavailable in Swift}}
}

func test_swift_unavailable_wins() {
  unavailableWithOS() // expected-error {{'unavailableWithOS()' is unavailable in Swift}}
}

func test_maccatalyst_unavailable_wins() {
  availableOnIOSButUnavailableOnmacCatalyst() // expected-error {{'availableOnIOSButUnavailableOnmacCatalyst()' is unavailable}}
}

func test_maccatalyst_deprecated_wins() {
  availableOnIOSButDeprecatedOnmacCatalyst() // expected-warning {{'availableOnIOSButDeprecatedOnmacCatalyst()' was deprecated in Mac Catalyst 9.0}}
}


func test_ios_unavailable_is_also_unavailable_on_maccatalyst() {
  unavailableOnIOS() // expected-error {{'unavailableOnIOS()' is unavailable}}
}

func test_deprecation_on_ios_not_inherited_when_not_specified_on_maccatalyst() {
  deprecatedOniOSButNotOnmacCatalyst(); // no-warning
}

func test_ios_app_extension() {
  availableOnIOSButUnavailableOniOSAppExtension() // no-error
  availableOnIOSAppExtensionButUnavailableOnmacCatalystAppExtension() // no-error

  availableOnIOSButDeprecatedOniOSAppExtension() // no-warning
  availableOnIOSAppExtensionButDeprecatedOnmacCatalystAppExtension() // no-warning
}

// Test platform inheritance for imported decls unavailable in iOS.
// rdar://68597591

@available(iOS, unavailable)
func unavailableFunctionUsingAnUnavailableType(_ p: UnavailableOniOS) { }

@available(iOS, unavailable)
func unavailableOniOS(_ p: UnavailableOniOS) { } // ok

func functionUsingAnUnavailableType(_ p: UnavailableOniOS) { } // expected-error {{'UnavailableOniOS' is unavailable in Mac Catalyst}}

public extension UnavailableOniOS { // expected-error {{'UnavailableOniOS' is unavailable in Mac Catalyst}}
  func someMethod1(_ p: UnavailableOniOS) { } // expected-error {{'UnavailableOniOS' is unavailable in Mac Catalyst}}
}

@available(iOS, unavailable)
public extension UnavailableOniOS { // ok
  func someMethod2(_ p: UnavailableOniOS) { }
}

public extension AvailableOnMacCatalystOnly { } // ok

public extension UnavailableOnMacCatalystOnly { } // expected-error {{UnavailableOnMacCatalystOnly' is unavailable in Mac Catalyst}}

@available(iOS, unavailable)
@available(macCatalyst, introduced: 13.0)
struct StructAvailableOnMacCatalystOnly {
  func nestedCheck(_ p: AvailableOnMacCatalystOnly) {}
  func invertedNestedCheck(_ p: UnavailableOnMacCatalystOnly) {} // expected-error {{UnavailableOnMacCatalystOnly' is unavailable in Mac Catalyst}}
}

@available(iOS, introduced: 13.0)
@available(macCatalyst, unavailable)
struct StructUnavailableOnMacCatalystOnly {
  func nestedCheck(_ p: UnavailableOnMacCatalystOnly) {}
  func invertedNestedCheck(_ p: AvailableOnMacCatalystOnly) {} // Would error for an iOS target.
}