Skip to content

[CodeCompletion] Suggest static members on protocol extensions with Self bound in unresolved member lookup #71760

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
Mar 1, 2024

Conversation

ahoppen
Copy link
Member

@ahoppen ahoppen commented Feb 20, 2024

rdar://122758029

@ahoppen
Copy link
Member Author

ahoppen commented Feb 20, 2024

@swift-ci Please smoke test

@ahoppen ahoppen force-pushed the ahoppen/self-bound-extension branch from f184baa to 0b5e00c Compare February 22, 2024 00:07
@ahoppen
Copy link
Member Author

ahoppen commented Feb 22, 2024

Thanks for the suggestions @slavapestov. Could you take another look at the updated code?

@ahoppen
Copy link
Member Author

ahoppen commented Feb 22, 2024

@swift-ci Please smoke test

extension MyProto where Self: MyOtherProto {
static var constrainedonMyInheritanceOfOtherProto: MyOtherProto { fatalError() }
}
extension MyProto where Self == MyOtherProto {
Copy link
Contributor

@slavapestov slavapestov Feb 22, 2024

Choose a reason for hiding this comment

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

Shouldn't this be rejected? (Protocol doesn't self-conform)

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, but I still want to check that we don’t suggest it in code completion.

@ahoppen
Copy link
Member Author

ahoppen commented Feb 22, 2024

@swift-ci Please test Windows

3 similar comments
@ahoppen
Copy link
Member Author

ahoppen commented Feb 23, 2024

@swift-ci Please test Windows

@ahoppen
Copy link
Member Author

ahoppen commented Feb 23, 2024

@swift-ci Please test Windows

@ahoppen
Copy link
Member Author

ahoppen commented Feb 23, 2024

@swift-ci Please test Windows

let _: MyProto = .#^ON_MY_PROTO^#
// ON_MY_PROTO: Begin completions, 1 items
// ON_MY_PROTO-DAG: Decl[StaticVar]/CurrNominal/TypeRelation[Convertible]: constrainedOnMyStruct[#MyStruct#];
}
Copy link
Member

Choose a reason for hiding this comment

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

Could you add a test case for a case like

func testOpaqueMyProto() -> some MyProto {
   return .#^HERE^#
}

which doesn't seems work either currently.

Copy link
Member Author

Choose a reason for hiding this comment

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

Oh, good idea. We handle it now.

…elf bound in unresolved member lookup

rdar://122758029
@ahoppen ahoppen force-pushed the ahoppen/self-bound-extension branch from 0b5e00c to a176c07 Compare February 29, 2024 21:55
@ahoppen
Copy link
Member Author

ahoppen commented Feb 29, 2024

@swift-ci Please smoke test

@ahoppen ahoppen enabled auto-merge March 1, 2024 00:01
@ahoppen ahoppen merged commit ffc2d9f into swiftlang:main Mar 1, 2024
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.

3 participants