[swift-dev] Simple question about ParameterTypeFlags
Slava Pestov
spestov at apple.com
Mon Dec 11 15:58:34 CST 2017
I think perhaps __shared @escaping and __shared @autoclosure should be OK. You’re just passing the context as a +0 value instead of +1. Also __shared varargs make sense for the same reason. But it’s not important to get that working right now.
The others look OK.
Slava
> On Dec 11, 2017, at 1:15 PM, David Zarzycki via swift-dev <swift-dev at swift.org> wrote:
>
> Hello! I’m trying to test which ParameterTypeFlags flag combinations are valid. I wrote the following test case. Are the results “as expected”, or are some of the failures incorrect?
>
> // RUN: %target-typecheck-verify-swift
>
>
> //
> // isVariadic is NOT compatible with any flag combinations
> //
> // expected-error at +1 {{@autoclosure must not be used on variadic parameters}}
> func v_and_autoclosure(arg : @autoclosure ()->()...) {}
> // expected-error at +1 {{@escaping attribute may only be used in function parameter position}}
> func v_and_escaping(arg : @escaping ()->()...) {}
> // expected-error at +1 {{'inout' must not be used on variadic parameters}}
> func v_and_inout(arg : inout Int...) {}
> // expected-error at +1 {{'__shared' must not be used on variadic parameters}}
> func v_and_shared(arg : __shared Int...) {}
>
> //
> // 'inout' is NOT compatible with remaining parameter flag combinations
> //
> // expected-error at +1 {{parameter must not have multiple '__owned', 'inout', '__shared', 'var', or 'let' specifiers}}
> func inout_and_shared(arg : inout __shared Int) {}
> // expected-error at +1 {{'inout' may only be used on parameters}}
> func inout_and_escaping(arg : @escaping inout ()->()) {}
> // expected-error at +1 {{@escaping attribute may only be used in function parameter position}}
> func escaping_and_inout(arg : inout @escaping ()->()) {}
> // expected-error at +1 {{@autoclosure may only be used on parameters}}
> func inout_and_autoclosure(arg : inout @autoclosure ()->()) {}
> // expected-error at +1 {{'inout' may only be used on parameters}}
> func autoclosure_and_inout(arg : @autoclosure inout ()->()) {}
>
> //
> // '__shared' is NOT compatible with remaining parameter flag combinations
> //
> // expected-error at +1 {{'__shared' may only be used on parameters}}
> func autoclosure_and_shared(arg : @autoclosure __shared ()->()) {}
> // expected-error at +1 {{@autoclosure may only be used on parameters}}
> func shared_and_autoclosure(arg : __shared @autoclosure ()->()) {}
> // expected-error at +1 {{'__shared' may only be used on parameters}}
> func escaping_and_shared(arg : @escaping __shared ()->()) {}
> // expected-error at +1 {{@escaping attribute may only be used in function parameter position}}
> func shared_and_escaping(arg : __shared @escaping ()->()) {}
>
> //
> // @autoclosure and @escaping are the only valid parameter flag combinations
> //
> func autoclosure_and_escaping(arg : @autoclosure @escaping ()->()) {}
> func escaping_and_autoclosure(arg : @escaping @autoclosure ()->()) {}
> _______________________________________________
> swift-dev mailing list
> swift-dev at swift.org
> https://lists.swift.org/mailman/listinfo/swift-dev
More information about the swift-dev
mailing list