New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend transitive availability checking to initial value expressions #22438

Closed
wants to merge 1 commit into
base: master
from

Conversation

Projects
None yet
3 participants
@jrose-apple
Copy link
Member

jrose-apple commented Feb 7, 2019

Because initial value expressions aren't actually considered within the VarDecl or PatternBindingDecl they're initializing, the existing logic to search for availability attributes wasn't kicking in, leading to errors when a conditionally-unavailable value was used in an initial value expression for a conditionally-unavailable binding.

SR-9867 / rdar://problem/47852718

Extend transitive availability checking to initial value expressions
Because initial value expressions aren't actually considered /within/
the VarDecl or PatternBindingDecl they're initializing, the existing
logic to search for availability attributes wasn't kicking in, leading
to errors when a conditionally-unavailable value was used in an
initial value expression for a conditionally-unavailable binding.

https://bugs.swift.org/browse/SR-9867
@jrose-apple

This comment has been minimized.

Copy link
Member Author

jrose-apple commented Feb 7, 2019

@swift-ci Please test

@jrose-apple

This comment has been minimized.

Copy link
Member Author

jrose-apple commented Feb 7, 2019

@swift-ci Please test source compatibility

@brentdax
Copy link
Collaborator

brentdax left a comment

If the comment below doesn't prompt any changes, this looks good to me.

var osx_init_osx = osx() // OK
@available(OSXApplicationExtension, unavailable)
var osx_extension_init_osx = osx() // expected-error {{'osx()' is unavailable}}

This comment has been minimized.

@brentdax

brentdax Feb 7, 2019

Collaborator

Would this test pass?

@available(OSX, unavailable)
var osx_inner_init_osx = { let inner_var = osx() }

If so, is it worth adding to the test suite? If not, do we want to merge this change anyway?

This comment has been minimized.

@jrose-apple

jrose-apple Feb 7, 2019

Author Member

Definitely seems worth adding! I think it'll work with this change, but it's always worth checking.

This comment has been minimized.

@jrose-apple

jrose-apple Feb 7, 2019

Author Member

Aha, it does not work. Important info!

This comment has been minimized.

@jrose-apple

jrose-apple Feb 7, 2019

Author Member

I'm going to look at this this afternoon, and if there's not an easy fix maybe we'll just take this part.

@jrose-apple

This comment has been minimized.

Copy link
Member Author

jrose-apple commented Feb 7, 2019

Found a better approach, will open a new PR for that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment