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
|
// RUN: %empty-directory(%t)
// RUN: split-file %s %t
// RUN: %target-swift-frontend -emit-module -emit-module-path %t/Library.swiftmodule -parse-as-library %t/Library.swift -enable-library-evolution
// RUN: %target-swift-frontend -typecheck -verify %t/Client.swift -I %t
// UNSUPPORTED: OS=windows-msvc
//--- Library.swift
public func foo() {}
public func bar() {}
//--- Client.swift
@_weakLinked import Library
if #_hasSymbol(foo) {}
if #_hasSymbol(foo), #_hasSymbol(bar) {}
guard #_hasSymbol(foo) else { fatalError() }
while #_hasSymbol(foo) {}
if #_hasSymbol(foo) == false {} // expected-error {{expected '{' after 'if' condition}}
_ = #_hasSymbol(foo) {} // expected-error {{#_hasSymbol may only be used as condition of}}
(#_hasSymbol(foo) ? 1 : 0) // expected-error {{#_hasSymbol may only be used as condition of}}
if !#_hasSymbol(foo) {} // expected-error {{#_hasSymbol may only be used as condition of}}
if let _ = Optional(5), !#_hasSymbol(foo) {} {} // expected-error {{#_hasSymbol may only be used as condition of}}
if #_hasSymbol {} // expected-error {{expected '(' in #_hasSymbol directive}}
// expected-error@+3 {{expected ')' in #_hasSymbol condition}}
// expected-error@+2 {{expected '{' after 'if' condition}}
// expected-note@+1 {{to match this opening '('}}
if #_hasSymbol(struct) {} // expected-error {{expected expression in #_hasSymbol}}
// expected-error@+3 {{expected ')' in #_hasSymbol condition}}
// expected-error@+2 {{expected '{' after 'if' condition}}
// expected-note@+1 {{to match this opening '('}}
if #_hasSymbol(foo bar) {}
// expected-error@+2 {{expected ')' in #_hasSymbol condition}}
// expected-note@+1 {{to match this opening '('}}
if #_hasSymbol(foo {}
|