Skip to content

SPICE-0029: Self Type - #32

Open
HT154 wants to merge 1 commit into
apple:mainfrom
HT154:self-type
Open

SPICE-0029: Self Type#32
HT154 wants to merge 1 commit into
apple:mainfrom
HT154:self-type

Conversation

@HT154

@HT154 HT154 commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

No description provided.

Comment thread spices/SPICE-0029-self-type.adoc Outdated
Comment thread spices/SPICE-0029-self-type.adoc Outdated
Comment thread spices/SPICE-0029-self-type.adoc Outdated
Comment thread spices/SPICE-0029-self-type.adoc
@HT154
HT154 force-pushed the self-type branch 2 times, most recently from 2a615fb to 86557c9 Compare July 15, 2026 22:58
@HT154
HT154 requested a review from bioball July 15, 2026 22:58

@bioball bioball left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

There's a fair bit left to define about what the this type means; e.g.

  • in object body param (foo { bar: this -> }) (should be the outer enclosing object, not the inner object!)
  • inside object inside class body (class Foo { obj { local bar: this = ... } })
  • in let expression (let (foo: this) ...)
  • in for generator (for (foo: this in bar))
  • in annotation @this { foo = ... }
  • explicit new expr (new this {})

Do you mind going through the grammar and detailing each of these scenarios?

Also: maybe we can structure this SPICE by talking about what this means in different parts of the grammar.
Then, note about resolving to the visibly outer scope can be a sub-bullet point of type test/type cast expressions I think.

=== Semantics

The `this` type is an alias for the class of the current receiver (`this` value).
For open classes, `this` admits values whose class is a subclass of the receiver.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Suggested change
For open classes, `this` admits values whose class is a subclass of the receiver.
For open or abstract classes, `this` is the specific subclass of that class

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