Add this as a self type - #1708
Open
HT154 wants to merge 10 commits into
Open
Conversation
HT154
force-pushed
the
this-type
branch
3 times, most recently
from
June 28, 2026 18:50
6fb74b2 to
fa93f3d
Compare
HT154
force-pushed
the
this-type
branch
3 times, most recently
from
June 29, 2026 20:05
a1d16f8 to
55f923c
Compare
HT154
force-pushed
the
this-type
branch
19 times, most recently
from
July 2, 2026 22:29
71958eb to
a8c3282
Compare
HT154
commented
Jul 2, 2026
HT154
commented
Jul 2, 2026
HT154
force-pushed
the
this-type
branch
2 times, most recently
from
August 3, 2026 17:04
97dac9c to
7e94e96
Compare
bioball
requested changes
Aug 11, 2026
HT154
force-pushed
the
this-type
branch
2 times, most recently
from
August 14, 2026 18:09
01dd026 to
866dbc4
Compare
bioball
requested changes
Aug 14, 2026
bioball
left a comment
Member
There was a problem hiding this comment.
I think this is getting close; did another pass.
One major comment here is: I think that we're missing a bunch of tests; there's a lot of positions in our grammar that can produce type nodes, which aren't tested.
Some of the ones that I can think of are:
- Object body param (
foo { bar: this -> /* etc */ }) - Supertype (
class Bar extends this {}) - Function literal type annotation (
(arg: this) -> ...) - For-generator variable
- Let expr variable
- Local object property
new { local x: this = ... } - Object method arguments (
new { local function foo(bar: this): this = ... }) - Type cast expressions (
foo as this) - Constraint property type (
foo: this(...)) - Function property type (
foo: this -> this) Listing<this>(test lazy check and default value behavior)
HT154
force-pushed
the
this-type
branch
2 times, most recently
from
August 19, 2026 16:01
1544122 to
f73c4fd
Compare
HT154
force-pushed
the
this-type
branch
3 times, most recently
from
August 19, 2026 18:26
b44b110 to
afbf930
Compare
bioball
approved these changes
Aug 31, 2026
bioball
left a comment
Member
There was a problem hiding this comment.
Some minor nits and a test refactor, but otherwise LGTM!
Approving to unblock
HT154
force-pushed
the
this-type
branch
2 times, most recently
from
September 1, 2026 18:02
b0806e0 to
2ad6f5d
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Depends on #1796
This PR:
this, a fully featured self type for use in modules or classes.thisin typealias bodies.moduletype in const scopes (class and typealias bodies, annotations, const properties/methods) with a warning, to be an error in a future release.moduletypes as typelias type args are evaluated in the context of the alias's module, not wheremoduleis used #1712).thisor a self-import and use of the current module.thisin the standard library:pkl.base#Any.getClass()now returnsClass<this>.pkl.base#Any.ifNonNull()now accepts an argument of type(this) -> Result.pkl.ref#Domain.renderReference()now accepts aReference<this, Any>.ReferenceTypeNode,moduletypes, and type aliases that causedmoduletypes in the referent position to always be resolved to the module where theReferencetype annotation is instead of wheremoduleis used.Loggerthrough toAstBuilderso warnings/traces can be printed from it.For ease of review, this PR consists of two commits; the first is all implementation changes, the second includes regenerated pkl-doc test output.
Resolves #1612
Resolves #1712