Skip to content

[CodeCompletion] Suggest 'Self' inside struct, enum and classe #32053

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 May 28, 2020

In protocol, Self is implicitly declared as a generic parameter.
In struct and enum, Self is just an alias for the nominal type.
In class, Self is a dynamic type and usable only in result types and inside function bodies.

rdar://problem/61307680

@rintaro
Copy link
Member Author

rintaro commented May 28, 2020

@swift-ci Please smoke test

@rintaro rintaro requested a review from benlangmuir May 28, 2020 01:11
@rintaro
Copy link
Member Author

rintaro commented May 28, 2020

@swift-ci Please smoke test Linux

1 similar comment
@rintaro
Copy link
Member Author

rintaro commented May 28, 2020

@swift-ci Please smoke test Linux

Copy link
Contributor

@benlangmuir benlangmuir left a comment

Choose a reason for hiding this comment

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

LGTM; one suggestion for an additional test, which could be a follow-up.

@rintaro
Copy link
Member Author

rintaro commented May 29, 2020

@benlangmuir I guess you were suggesting test cases in where clause or somewhere else?

@rintaro
Copy link
Member Author

rintaro commented May 29, 2020

@swift-ci Please smoke test Linux

@benlangmuir
Copy link
Contributor

Huh, I don't know where my comment went. I suggested testing Self inside a computed property body,

var foo: String { "\(Self.self)" }

In 'protocol', 'Self' is implicitly declared as a generic parameter.
In 'struct' and 'enum', 'Self' is just an alias for the nominal type.
In 'class', 'Self' is a dynamic type and usable only in result types and
inside function bodies.

rdar://problem/61307680
@rintaro rintaro force-pushed the ide-completion-sself-rdar61307680 branch from b93f70a to 3b97b86 Compare June 2, 2020 21:58
@rintaro
Copy link
Member Author

rintaro commented Jun 2, 2020

@swift-ci Please smoke test

@rintaro
Copy link
Member Author

rintaro commented Jun 2, 2020

@swift-ci Please smoke test macOS

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