Skip to content

[Sema] Diagnose availability via TypeReprs rather than Types. #6036

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

Merged
merged 1 commit into from
Dec 2, 2016

Conversation

DougGregor
Copy link
Member

The code that diagnosed availability for types was reverse-engineering
the Type itself, rather than making use of the declaration already
stored within the TypeRepr.

More importantly, it would completely skip nested types, so it would
fail to diagnose a deprecated/unavailable “Bar” in “Foo.Bar”.

Replace the type-inspecting check with a much-simpler walk over the
components of the IdentTypeRepr that looks at the declarations stored
in the IdentTypeRepr directly. This provides proper source-location
information and handles nested types.

This is a source-breaking change for ill-formed Swift 3 code that used
nested type references to refer to something that should be unavailable.
Given that such Swift 3 code was ill-formed, and most uses of it would
crash at runtime, we likely do not need to provide specific logic to
address this in Swift 3 compatibility mode.

The code that diagnosed availability for types was reverse-engineering
the Type itself, rather than making use of the declaration already
stored within the TypeRepr. 

More importantly, it would completely skip nested types, so it would
fail to diagnose a deprecated/unavailable “Bar” in “Foo.Bar”. 

Replace the type-inspecting check with a much-simpler walk over the 
components of the IdentTypeRepr that looks at the declarations stored 
in the IdentTypeRepr directly. This provides proper source-location
information and handles nested types.

This is a source-breaking change for ill-formed Swift 3 code that used
nested type references to refer to something that should be unavailable.
Given that such Swift 3 code was ill-formed, and most uses of it would
crash at runtime, we likely do not need to provide specific logic to
address this in Swift 3 compatibility mode.
@DougGregor
Copy link
Member Author

@swift-ci please smoke test and merge

@swift-ci swift-ci merged commit 6fffae7 into swiftlang:master Dec 2, 2016
@DougGregor DougGregor deleted the typerepr-availability branch December 2, 2016 23:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants