Skip to content
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

[SR-14546] Code completion does not consider overridden protocol methods for dot completion base #56898

Open
ahoppen opened this issue Apr 28, 2021 · 1 comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. code completion Area → source tooling: code completion found by stress tester Flag: An issue found by the SourceKit stress tester source tooling Area: IDE support, SourceKit, and other source tooling

Comments

@ahoppen
Copy link
Contributor

ahoppen commented Apr 28, 2021

Previous ID SR-14546
Radar rdar://problem/77262632
Original Reporter @ahoppen
Type Bug
Additional Detail from JIRA
Votes 0
Component/s CodeCompletion
Labels Bug, FoundByStressTester
Assignee None
Priority Medium

md5: 1d9049a0e584d46b34249a957afb2256

Issue Description:

In the new test case below COMPLETE_OVERRIDDEN_PROTOCOL_METHOD only suggests s2 and not s1, most likely because the call of bar is resolved as the method defined in S3 and the implementation of bar in Foo is not considered. Overridden methods are suggested correctly for class inheritance (second test case).

// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=COMPLETE_OVERRIDDEN_PROTOCOL_METHOD | %FileCheck %s
// RUN: %target-swift-ide-test -code-completion -source-filename %s -code-completion-token=COMPLETE_OVERRIDDEN_CLASS_METHOD | %FileCheck %s

struct S1 {
  func s1() {}
}
struct S2 {
  func s2() {}
}

protocol Foo {
  func bar() -> S1
}
extension Foo {
  func bar() -> S1 { return S1() }
}

struct S3: Foo {
  func bar() -> S2 {
    return S2()
  }
}

func testOverridenProtocolMethod(x: S3) {
  x.bar().#^COMPLETE_OVERRIDDEN_PROTOCOL_METHOD^#
}

class C1 {
  func bar() -> S1 { return S1() }
}
class C2: C1 {
  func bar() -> S2 { return S2() }
}
func testOverridenClassMethod(x: C2) {
  x.bar().#^COMPLETE_OVERRIDDEN_CLASS_METHOD^#
}
// CHECK: Begin completions, 4 items
// CHECK: Keyword[self]/CurrNominal:          self[#S2#];
// CHECK: Decl[InstanceMethod]/CurrNominal:   s2()[#Void#];
// CHECK: Keyword[self]/CurrNominal:          self[#S1#];
// CHECK: Decl[InstanceMethod]/CurrNominal:   s1()[#Void#];
// CHECK: End completions
@ahoppen
Copy link
Contributor Author

ahoppen commented Apr 28, 2021

@swift-ci create

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@AnthonyLatsis AnthonyLatsis added the source tooling Area: IDE support, SourceKit, and other source tooling label Feb 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. code completion Area → source tooling: code completion found by stress tester Flag: An issue found by the SourceKit stress tester source tooling Area: IDE support, SourceKit, and other source tooling
Projects
None yet
Development

No branches or pull requests

2 participants