-
Notifications
You must be signed in to change notification settings - Fork 10.6k
Open
Labels
Self in classFeature → types: The 'Self' type in classesFeature → types: The 'Self' type in classesactorFeature → concurrency: `actor` declarationsFeature → concurrency: `actor` declarationscompilerThe Swift compiler itselfThe Swift compiler itselfconcurrencyFeature: umbrella label for concurrency language featuresFeature: umbrella label for concurrency language featuresdeclarationsFeature: declarationsFeature: declarationstype checkerArea → compiler: Semantic analysisArea → compiler: Semantic analysis
Description
Description
In classes the type of Self is dynamic like this:
class C {
func f() { self /* self is a C */ }
func f() -> Self { self /* self is a Self */ }
}
this is because of inheritance.
Inside an actor this causes perhaps surprising errors like this:
dy.swift:3:22: error: cannot convert value of type 'C' to expected argument type 'Self'
{ (x: Self) in }(self)
^
as! Self
Actors do not allow inheritance, and therefore we could say that self
is always Self
.
This would set in stone that actors cannot have inheritance though.
Additional information
Radar: rdar://121091417
Metadata
Metadata
Assignees
Labels
Self in classFeature → types: The 'Self' type in classesFeature → types: The 'Self' type in classesactorFeature → concurrency: `actor` declarationsFeature → concurrency: `actor` declarationscompilerThe Swift compiler itselfThe Swift compiler itselfconcurrencyFeature: umbrella label for concurrency language featuresFeature: umbrella label for concurrency language featuresdeclarationsFeature: declarationsFeature: declarationstype checkerArea → compiler: Semantic analysisArea → compiler: Semantic analysis