Skip to content

[CodeComplete] Fix crasher when completing inout IUO variable #17926

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
Jul 13, 2018

Conversation

rintaro
Copy link
Member

@rintaro rintaro commented Jul 13, 2018

func test(arg: inout Int!) {
   <COMPLETE>
}

Here, type of arg is

(inout_type
  (optional_type
    (struct_type decl=Swift.(file).Int)))

Previously, it's assumed that the type was OptionalType. That used to fail getOptionalObjectType(). Instead, use PrintOptionalAsImplicitlyUnwrapped option that prints ! for outer most optional type.

rdar://problem/40956846

@rintaro rintaro requested a review from rudkx July 13, 2018 07:52
@rintaro
Copy link
Member Author

rintaro commented Jul 13, 2018

@swift-ci Please smoke test

@rudkx
Copy link
Contributor

rudkx commented Jul 13, 2018

Can you add a test case with an inout IUO that requires parens to be printed around the underlying object type for it to display correctly?

For example func test(_ fn: ((Int)->Int)!) { }

// RDAR_40956846: Begin completions
// RDAR_40956846-DAG: Decl[LocalVar]/Local: arg_40956846_1[#inout Int!#]; name=arg_40956846_1
// RDAR_40956846-DAG: Decl[LocalVar]/Local: arg_40956846_2[#Void!#]; name=arg_40956846_2
// RDAR_40956846-DAG: Decl[LocalVar]/Local: arg_40956846_3[#(() -> Int)!#]; name=arg_40956846_3
Copy link
Member Author

@rintaro rintaro Jul 13, 2018

Choose a reason for hiding this comment

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

@rudkx I already have a test case for (() -> Int)!.

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh I didn't paste in the right example - I meant an inout variant of that, like inout (() -> Int)!.

Copy link
Contributor

@rudkx rudkx left a comment

Choose a reason for hiding this comment

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

LGTM, but it would be nice to have another test that is inout that requires the underlying type to have parentheses.

Use `PrintOptionalAsImplicitlyUnwrapped` option.

rdar://problem/40956846
@rintaro rintaro force-pushed the ide-complete-rdar40956846 branch from 4579245 to fb9c65e Compare July 13, 2018 15:53
@rintaro
Copy link
Member Author

rintaro commented Jul 13, 2018

Thank you! Added a test case.
@swift-ci Please smoke test

@rintaro rintaro merged commit 456952e into swiftlang:master Jul 13, 2018
@rintaro rintaro deleted the ide-complete-rdar40956846 branch July 13, 2018 16:49
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