Skip to content

[5.1][CodeCompletion] Fix a crash in callee analysis #25912

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

Conversation

rintaro
Copy link
Member

@rintaro rintaro commented Jul 1, 2019

Explanation: Since Type::typeOfMember() doesn't map generic param types of the member itself, it may produce type with 'archetype' and 'generic type parameter' contained. That breaks an invariant and caused assertion failures. Instead of using that, perform substitution manually to map the type at the same time.
Scope: Code completion APIs for call argument position.
Issue: rdar://problem/52386176
Risk: Low
Testing: Added regression test
Reviewer: Ben Langmuir (@benlangmuir)

struct Wrap<T> {
  func method<U>(_ fn: (T) -> U) -> Wrap<U> {}
}
func testGenricMethodOnGenericOfArchetype<Val>(value: Wrap<Val>) {
  value.method(#^HERE^#)
}

In this case, the type of value is `Wrap<Val[archetype]>`.
`Type::getTypeOfMember()` for 'method' method returns
`( (Val[archetype]) -> U[generic param]) -> Wrap<U[generic param]>`
which crashs 'mapTypeIntoContext()' because it already hass archetype.

rdar://problem/52386176
(cherry picked from commit dfc4d77)
@rintaro
Copy link
Member Author

rintaro commented Jul 1, 2019

@swift-ci Please test

@rintaro rintaro changed the title [CodeCompletion] Fix a crash in callee analysis [5.1][CodeCompletion] Fix a crash in callee analysis Jul 1, 2019
@rintaro
Copy link
Member Author

rintaro commented Jul 1, 2019

@swift-ci Please nominate

@rintaro
Copy link
Member Author

rintaro commented Jul 1, 2019

@akyrtzi approved.

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.

1 participant