Universal Self

Description

See https://www.hackingwithswift.com/articles/182/whats-new-in-swift-5-1

We need to review cases where `Self` was unsupported, and thus we were using the (hardcoded) class name instead of `Self`.
Now the `Self` keyword is available in a almost or all contexts.

Environment

None

Activity

Show:
Alex Petuschak
September 6, 2019, 12:28 PM

I have completely removed TypeAccessor.TranslateSelfType() method and related code:
https://cl.ly/a07f81a8abf7

From now on, `Self` is never translated to the actual type.
Note that Swift 5.1 still does not seem to accept `Self` in some contexts.

Example (from `ShouldConvertTypeofSelfToSelfWhenClassNameIsUnknown()` test, running on Xcode 11 beta 6):
https://cl.ly/72595fb72a25

I still found it better to never translate `Self` to the underlying class to simplify the converter code (since this did not add any new errors in the set of test projects).
If we find real-world cases when a variable declaration uses `typeof(self)` as a type name, let's revisit that.

Assignee

Alex Petuschak

Reporter

Alex Petuschak

Labels

None

Git Branch Name

None

Components

Fix versions

Priority

Medium
Configure