File: issue-75389.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 (55 lines) | stat: -rw-r--r-- 1,536 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
// RUN: %target-typecheck-verify-swift

// https://github.com/swiftlang/swift/issues/75389

@available(*, unavailable)
func unavailableFn() -> Int { 0 }
// expected-note@-1 5{{'unavailableFn()' has been explicitly marked unavailable here}}

if case unavailableFn() = 0 {}
// expected-error@-1 {{'unavailableFn()' is unavailable}}

switch Bool.random() {
case true where unavailableFn() == 1:
  // expected-error@-1 {{'unavailableFn()' is unavailable}}
  break
default:
  break
}
switch 0 {
case unavailableFn():
  // expected-error@-1 {{'unavailableFn()' is unavailable}}
  break
default:
  break
}
let _ = {
  switch Bool.random() {
  case true where unavailableFn() == 1:
    // expected-error@-1 {{'unavailableFn()' is unavailable}}
    break
  default:
    break
  }
  switch 0 {
  case unavailableFn():
    // expected-error@-1 {{'unavailableFn()' is unavailable}}
    break
  default:
    break
  }
}

struct S {}

func ~= (lhs: S.Type, rhs: S.Type) -> Bool { true }

if case (S) = S.self {}
// expected-error@-1 {{expected member name or initializer call after type name}}
// expected-note@-2 {{add arguments after the type to construct a value of the type}}
// expected-note@-3 {{use '.self' to reference the type object}}

if case ({ if case (S) = S.self { true } else { false } }()) = true {}
// expected-error@-1 {{expected member name or initializer call after type name}}
// expected-note@-2 {{add arguments after the type to construct a value of the type}}
// expected-note@-3 {{use '.self' to reference the type object}}