Skip to content

Conversation

@ahoppen
Copy link
Member

@ahoppen ahoppen commented May 8, 2018

This PR makes the migrator automatically add as Any coercions when the base type is an implicitly unwrapped optional.

Fixes rdar://40050875

@ahoppen ahoppen requested a review from nathawes May 8, 2018 18:30
@ahoppen
Copy link
Member Author

ahoppen commented May 8, 2018

@swift-ci Please smoke test

@nathawes nathawes requested a review from rudkx May 8, 2018 18:32
void emitSilenceOptionalAnyWarningWithCoercion(Expr *E, Type destType) {
Diag<Type, StringRef> silenceDiag = diag::silence_optional_to_any;

if (auto declRefExpr = dyn_cast<DeclRefExpr>(E)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should use hasImplicitlyUnwrappedResult which I added in #16434.

I handles function calls, subscripts, and member references.

let _: Any = x

let y: Int? = 1
let _: Any = y
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add tests for member references, function calls, subscripts, as well a test where the code already has 'as Any' (and thus we wouldn't expect the note, nor the migration).

@ahoppen ahoppen closed this Oct 21, 2019
@ahoppen ahoppen deleted the iuo-any-migrator branch October 21, 2019 22:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

2 participants