Add this as a self type (#1708)

This commit is contained in:
Jen Basch
2026-09-02 09:04:15 -07:00
committed by GitHub
parent 1208fa9438
commit 2b697015c7
305 changed files with 1487 additions and 561 deletions
+2 -2
View File
@@ -46,7 +46,7 @@ import "pkl:yaml"
/// ```
abstract external class Any {
/// Returns the class of [this].
external function getClass(): Class
external function getClass(): Class<this>
/// Returns a string representation of [this].
///
@@ -57,7 +57,7 @@ abstract external class Any {
///
/// This method is the complement of the `??` operator and the equivalent of an `Option` type's
/// `map` and `flatMap` methods.
external function ifNonNull<Result>(transform: (NonNull) -> Result): Result?
external function ifNonNull<Result>(transform: (this) -> Result): Result?
}
/// The type of [null] and null values created with [Null()].
+1 -1
View File
@@ -210,7 +210,7 @@ external class Reference<out D, out T> {
abstract class Domain {
/// Determines how [Reference] instances are transformed to strings by [Reference.toString()] and
/// string interpolation.
abstract function renderReference(reference: Reference<Domain, Any>): String
abstract function renderReference(reference: Reference<this, Any>): String
}
/// A property or subscript access as part of a [Reference]'s path.
+8
View File
@@ -107,6 +107,9 @@ const bytesType: DeclaredType = DeclaredType(Class(Bytes))
/// A mirror for the `module` type.
external const moduleType: ModuleType
/// A mirror for the `this` type.
external const thisType: ThisType
/// A mirror for the `unknown` type.
external const unknownType: UnknownType
@@ -431,6 +434,11 @@ external class FunctionType extends Type {
/// [moduleType] is an instance of this class.
class ModuleType extends Type
/// The `this` type.
///
/// [thisType] is an instance of this class.
class ThisType extends Type
/// The `unknown` type.
///
/// [unknownType] is an instance of this class.