Files
swift-mirror/test/attr/attr_preInverseGenerics.swift
Kavon Farvardin 2bdaa53b5d Convert PreInverseGenericsExcept to a SUPPRESSIBLE_EXPERIMENTAL_FEATURE
The suppression can help us avoid a typechecking condfail,
though the mangled names of any symbols will be wrong as we simply
omit the attribute in this simplistic suppression strategy.

related to rdar://176395527
2026-05-20 17:35:12 -07:00

19 lines
1.2 KiB
Swift

// RUN: %target-typecheck-verify-swift
// The bare @_preInverseGenerics does NOT require the experimental feature.
@_preInverseGenerics
func bare<T: ~Copyable>(_ t: borrowing T) {}
// The 'except:' form DOES require the experimental feature.
@_preInverseGenerics(except: ~Copyable) // expected-error {{'@_preInverseGenerics' is an experimental feature; use '-enable-experimental-feature PreInverseGenericsExcept'}}
func exceptCopyable<T: ~Copyable & ~Escapable>(_ t: borrowing T) {}
// An invalid attribute with 'except:' still DOES require the feature.
@_preInverseGenerics(except: Int) // expected-error {{'@_preInverseGenerics' is an experimental feature; use '-enable-experimental-feature PreInverseGenericsExcept'}}
// expected-error@-1 {{'except' argument to '@_preInverseGenerics' must consist only of inverse constraints such as '~Copyable' or '~Escapable'}}
func exceptInt<T: ~Copyable & ~Escapable>(_ t: borrowing T) {}
// The shorthand alias also requires the experimental feature.
@_preInverseGenericsExceptCopyable // expected-error {{'@_preInverseGenerics' is an experimental feature; use '-enable-experimental-feature PreInverseGenericsExcept'}}
func exceptCopyableShorthand<T: ~Copyable & ~Escapable>(_ t: borrowing T) {}