Skip to content

[4.2][CodeComplete] Typecheck SubscriptDecl context prior to completion #17594

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

Conversation

rintaro
Copy link
Member

@rintaro rintaro commented Jun 28, 2018

  • Explaination: Fix assertion failure when code-completing types in subscript signature. Completing signature relies on its GenericEnvironment which is set during typechecking. Previously, completing types in subscript signature regarding generic types used to hit assertion failure or just failed since declaration was not typechecked and thus GenericEnvironment was not set up.
  • Scope: Changes the code-completion code for subscript signature. This change fixes assertion failure and restores expected behavior.
  • Issue: rdar://problem/41227754
  • Risk: Low. Affects code-completion in subscript signature only.
  • Testing: Added regression test cases.
  • Reviewed By: @DougGregor ([CodeComplete] Typecheck SubscriptDecl context prior to completion #17588)

protocol Container {
  associatedtype Element
}
struct MyStruct<T: Container> {}
extension MyStruct {
  public subscript(index: T.<HERE>) -> Int { return 0 }
  public subscript(index: Int) -> T.<HERE> { fatalError() }
}
protocol MyProtocol {
  associatedtype Content: Container
}
extension MyProtocol {
  subscript(index: Content.<HERE>) -> Int { return 0 }
  subscript(index: Int) -> Content.<HERE> { fatalError() }
}

Previously, all completion at <HERE> above used to fail (or hit assertion with assert build).

Completing signature depends on its GenericEnvironment which is set
during typechecking. Previously, completing signature using generic type
used to cause assertion failure. e.g.

  extension Collection {
    subscript(some index: Int) -> Iterator.<COMPLETE HERE>

rdar://problem/41227754
@rintaro
Copy link
Member Author

rintaro commented Jun 28, 2018

@swift-ci Please test

@rintaro rintaro changed the title [CodeComplete] Typecheck SubscriptDecl context prior to completion [4.2][CodeComplete] Typecheck SubscriptDecl context prior to completion Jun 28, 2018
@rintaro
Copy link
Member Author

rintaro commented Jul 2, 2018

@swift-ci Please nominate

@rintaro rintaro merged commit c2e1567 into swiftlang:swift-4.2-branch Jul 2, 2018
@rintaro rintaro deleted the 4.2-ide-complete-rdar41227754 branch July 2, 2018 14:46
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