File: availability_versions_multi.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 (56 lines) | stat: -rw-r--r-- 2,425 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
// RUN: %swift -typecheck -primary-file %s %S/Inputs/availability_multi_other.swift -verify
// REQUIRES: OS=macosx

func callToEnsureNotInScriptMode() { }
// Add an expected error to express expectation that we're not in script mode
callToEnsureNotInScriptMode() // expected-error {{expressions are not allowed at the top level}}

@available(OSX, introduced: 10.9)
var globalAvailableOn10_9: Int = 9

@available(OSX, introduced: 99.51)
var globalAvailableOn99_51: Int = 10

@available(OSX, introduced: 99.52)
var globalAvailableOn99_52: Int = 11

// Top level should reflect the minimum deployment target.
let ignored1: Int = globalAvailableOn10_9

let ignored2: Int = globalAvailableOn99_51 // expected-error {{'globalAvailableOn99_51' is only available in macOS 99.51 or newer}}
    // expected-note@-1 {{add @available attribute to enclosing let}}

let ignored3: Int = globalAvailableOn99_52 // expected-error {{'globalAvailableOn99_52' is only available in macOS 99.52 or newer}}
    // expected-note@-1 {{add @available attribute to enclosing let}}

@available(OSX, introduced: 99.51)
func useFromOtherOn99_51() {
  // This will trigger validation of OtherIntroduced99_51 in
  // in availability_multi_other.swift
  let o99_51 = OtherIntroduced99_51()
  o99_51.extensionMethodOnOtherIntroduced99_51()

  let o10_9 = OtherIntroduced10_9()
  o10_9.extensionMethodOnOtherIntroduced10_9AvailableOn99_51(o99_51)
  _ = o99_51.returns99_52Introduced99_52() // expected-error {{'returns99_52Introduced99_52()' is only available in macOS 99.52 or newer}}

  _ = OtherIntroduced99_52()
      // expected-error@-1 {{'OtherIntroduced99_52' is only available in macOS 99.52 or newer}}

  o99_51.extensionMethodOnOtherIntroduced99_51AvailableOn99_52() // expected-error {{'extensionMethodOnOtherIntroduced99_51AvailableOn99_52()' is only available in macOS 99.52 or newer}}

  _ = OtherIntroduced99_51.NestedIntroduced99_52()
      // expected-error@-1 {{'NestedIntroduced99_52' is only available in macOS 99.52 or newer}}
}

@available(OSX, introduced: 99.52)
func useFromOtherOn99_52() {
  _ = OtherIntroduced99_52()

  let n99_52 = OtherIntroduced99_51.NestedIntroduced99_52()
  _ = n99_52.returns99_52()
  _ = n99_52.returns99_53() // expected-error {{'returns99_53()' is only available in macOS 99.53 or newer}}

  // This will trigger validation of the global in availability_in_multi_other.swift
  _ = globalFromOtherOn99_52
}