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
@@ -48,6 +48,8 @@ nullable: Person?
stringLiteral: "yes"
constrained: String(length.isBetween(3, 10))
aliased: MyMap<Person>
mod: module
self: this
hidden hiddenProp: String
const constProp: String = "the const prop"
@@ -0,0 +1 @@
typealias MyList<T> = List<T>
@@ -0,0 +1,6 @@
open module moduleTypeProperty
x = 1
y = mod.x
modName = module.getClass().toString()
hidden mod: module
@@ -1,8 +1,9 @@
import "pkl:math"
import "pkl:ref"
import "pkl:test"
class D extends ref.Domain {
function renderReference(reference: ref.Reference<D, Any>): String =
function renderReference(reference: ref.Reference<this, Any>): String =
let (data = reference.getData())
let (root = if (data is Resource) data.name else data.toString())
let (
@@ -19,13 +20,12 @@ typealias Ref<T> = ref.Reference<D, T>
abstract class Resource {
name: String
hidden fixed $: Ref<Resource>
hidden fixed $: Ref<this> = ref.Reference(d, getClass(), this)
}
class A extends Resource {
id: String
hidden outputs: AProperties
hidden fixed $: Ref<A> = ref.Reference(d, A, this)
}
/// Test doc comment
@@ -42,7 +42,6 @@ class AProperties {
class B extends Resource {
id: String
hidden outputs: BProperties
hidden fixed $: Ref<B> = ref.Reference(d, B, this)
}
class BProperties {
@@ -128,6 +127,13 @@ class TypeHolder {
prop: Listing<String | Boolean | Number>
}
class BadResource extends Resource {
// return a reference with referent that isn't `this`
fixed $ = ref.Reference(d, A, this)
}
badThisRef = test.catch(() -> new BadResource { name = "bad" }.$.toString())
output {
renderer {
converters {
@@ -48,6 +48,8 @@ facts {
modClassProps["aliased"].type ==
reflect.DeclaredType(reflect.TypeAlias(BaseModule.MyMap))
.withTypeArgument(reflect.DeclaredType(reflect.Class(BaseModule.Person)))
modClassProps["mod"].type == reflect.moduleType
modClassProps["self"].type == reflect.thisType
}
["Reflecting a class"] {
@@ -3,7 +3,7 @@ amends "../snippetTest.pkl"
import "pkl:ref"
local class D extends ref.Domain {
function renderReference(reference: ref.Reference<D, Any>): String = reference.getData().toString()
function renderReference(reference: ref.Reference<this, Any>): String = reference.getData().toString()
}
local const d: D = new {}
@@ -1,7 +1,7 @@
import "pkl:ref"
class D extends ref.Domain {
function renderReference(reference: ref.Reference<D, Any>): String = throw("not supported")
function renderReference(reference: ref.Reference<this, Any>): String = throw("not supported")
}
local d: D = new {}
typealias Ref<T> = ref.Reference<D, T>
@@ -1,7 +1,7 @@
import "pkl:ref"
class D extends ref.Domain {
function renderReference(reference: ref.Reference<D, Any>): String = throw("not supported")
function renderReference(reference: ref.Reference<this, Any>): String = throw("not supported")
}
typealias Ref<T> = ref.Reference<D, T>
local d: D = new {}
@@ -1,7 +1,7 @@
import "pkl:ref"
class D extends ref.Domain {
function renderReference(reference: ref.Reference<D, Any>): String = throw("not supported")
function renderReference(reference: ref.Reference<this, Any>): String = throw("not supported")
}
typealias Ref<T> = ref.Reference<D, T>
local d: D = new {}
@@ -1,7 +1,7 @@
import "pkl:ref"
class D extends ref.Domain {
function renderReference(reference: ref.Reference<D, Any>): String = throw("not supported")
function renderReference(reference: ref.Reference<this, Any>): String = throw("not supported")
}
typealias RefAlias1 = ref.Reference<D, Alias1?>
local d: D = new {}
@@ -1,7 +1,7 @@
import "pkl:ref"
class D extends ref.Domain {
function renderReference(reference: ref.Reference<D, Any>): String = throw("not supported")
function renderReference(reference: ref.Reference<this, Any>): String = throw("not supported")
}
local d: D = new {}
@@ -1,7 +1,7 @@
import "pkl:ref"
class D extends ref.Domain {
function renderReference(reference: ref.Reference<D, Any>): String = throw("not supported")
function renderReference(reference: ref.Reference<this, Any>): String = throw("not supported")
}
local d: D = new {}
@@ -1,7 +1,7 @@
import "pkl:ref"
class D extends ref.Domain {
function renderReference(reference: ref.Reference<D, Any>): String = throw("not supported")
function renderReference(reference: ref.Reference<this, Any>): String = throw("not supported")
}
local d: D = new {}
@@ -3,7 +3,7 @@ import "pkl:ref"
import ".../input-helper/errors/ReferencedModule.pkl"
class D extends ref.Domain {
function renderReference(reference: ref.Reference<D, Any>): String = throw("not supported")
function renderReference(reference: ref.Reference<this, Any>): String = throw("not supported")
}
local d: D = new {}
@@ -3,7 +3,7 @@ import "pkl:ref"
import ".../input-helper/errors/ReferencedModuleWithOutputOverride.pkl"
class D extends ref.Domain {
function renderReference(reference: ref.Reference<D, Any>): String = throw("not supported")
function renderReference(reference: ref.Reference<this, Any>): String = throw("not supported")
}
local d: D = new {}
@@ -5,7 +5,7 @@ import ".../input-helper/errors/ReferencedModuleWithOutputOverride.pkl"
class ModuleSubclass extends ReferencedModuleWithOutputOverride
class D extends ref.Domain {
function renderReference(reference: ref.Reference<D, Any>): String = throw("not supported")
function renderReference(reference: ref.Reference<this, Any>): String = throw("not supported")
}
local d: D = new {}
@@ -5,7 +5,7 @@ class A {
}
class D extends ref.Domain {
function renderReference(reference: ref.Reference<D, Any>): String = throw("not supported")
function renderReference(reference: ref.Reference<this, Any>): String = throw("not supported")
}
local d: D = new {}
@@ -1,7 +1,7 @@
import "pkl:ref"
class D extends ref.Domain {
function renderReference(reference: ref.Reference<D, Any>): String = throw("not supported")
function renderReference(reference: ref.Reference<this, Any>): String = throw("not supported")
}
local d: D = new {}
typealias Ref<T> = ref.Reference<D, T>
@@ -5,11 +5,11 @@ class A {
}
class D extends ref.Domain {
function renderReference(reference: ref.Reference<D, Any>): String = throw("not supported")
function renderReference(reference: ref.Reference<this, Any>): String = throw("not supported")
}
local d: D = new {}
local test = ref.Reference(d, A, "").foo
testInterpolation = "test:\(test)"
// this tests that the interpolation appears in the output when referenceToString throws
// this tests that the interpolation appears in the output when renderReference throws
@@ -0,0 +1,45 @@
// interactions between references and self types
import "pkl:ref"
class D extends ref.Domain {
function renderReference(r: ref.Reference<this, Any>): String =
r.getPath().map((it) -> it.property ?? it.key.toString()).join(".")
}
// this type in a final class
class Node {
parent: this?
children: List<this>
}
// this type in an open class
open class Node2 {
parent: this?
children: List<this>
}
typealias R = ref.Reference<D, Node?>
typealias R2 = ref.Reference<D, Node2?>
res0: R = ref.Reference(new D {}, Node, null)
res1: R = res0.parent
res2: R = res0.parent.parent
res3: R = res0.children[0]
res4: R = res0.children[0].parent
res5: R = res0.children[0].children[0]
res0a: R2 = ref.Reference(new D {}, Node2, null)
res1a: R2 = res0a.parent
res2a: R2 = res0a.parent.parent
res3a: R2 = res0a.children[0]
res4a: R2 = res0a.children[0].parent
res5a: R2 = res0a.children[0].children[0]
output {
renderer {
converters {
[ref.Reference] = (it) -> it.toString()
}
}
}
@@ -0,0 +1,32 @@
open module reference29
// interactions between references and self types
// module type in an open module
import "pkl:ref"
import "reference29.pkl"
class D extends ref.Domain {
function renderReference(r: ref.Reference<this, Any>): String =
r.getPath().map((it) -> it.property ?? it.key.toString()).join(".")
}
hidden parent: module?
hidden children: List<module>
typealias R = ref.Reference<D, reference29?>
res0 = ref.Reference(new D {}, getClass(), null)
res1: R = res0.parent
res2: R = res0.parent.parent
res3: R = res0.children[0]
res4: R = res0.children[0].parent
res5: R = res0.children[0].children[0]
output {
renderer {
converters {
[ref.Reference] = (it) -> it.toString()
}
}
}
@@ -1,7 +1,7 @@
import "pkl:ref"
class D extends ref.Domain {
function renderReference(reference: ref.Reference<D, Any>): String = throw("not supported")
function renderReference(reference: ref.Reference<this, Any>): String = throw("not supported")
}
local d: D = new {}
typealias Ref<T> = ref.Reference<D, T>
@@ -0,0 +1,30 @@
// interactions between references and self types
// module type in a final module
import "pkl:ref"
import "reference30.pkl"
class D extends ref.Domain {
function renderReference(r: ref.Reference<this, Any>): String =
r.getPath().map((it) -> it.property ?? it.key.toString()).join(".")
}
hidden parent: module?
hidden children: List<module>
typealias R = ref.Reference<D, reference30?>
res0 = ref.Reference(new D {}, getClass(), null)
res1: R = res0.parent
res2: R = res0.parent.parent
res3: R = res0.children[0]
res4: R = res0.children[0].parent
res5: R = res0.children[0].children[0]
output {
renderer {
converters {
[ref.Reference] = (it) -> it.toString()
}
}
}
@@ -1,7 +1,7 @@
import "pkl:ref"
class D extends ref.Domain {
function renderReference(reference: ref.Reference<D, Any>): String = throw("not supported")
function renderReference(reference: ref.Reference<this, Any>): String = throw("not supported")
}
local d: D = new {}
typealias Ref<T> = ref.Reference<D, T>
@@ -1,13 +1,13 @@
import "pkl:ref"
class D extends ref.Domain {
function renderReference(reference: ref.Reference<D, Any>): String = throw("not supported")
function renderReference(reference: ref.Reference<this, Any>): String = throw("not supported")
}
local d: D = new {}
typealias Ref<T> = ref.Reference<D, T>
class D2 extends ref.Domain {
function renderReference(reference: ref.Reference<D, Any>): String = throw("not supported")
function renderReference(reference: ref.Reference<this, Any>): String = throw("not supported")
}
local d2: D2 = new {}
@@ -1,7 +1,7 @@
import "pkl:ref"
class D extends ref.Domain {
function renderReference(reference: ref.Reference<D, Any>): String = throw("not supported")
function renderReference(reference: ref.Reference<this, Any>): String = throw("not supported")
}
local d: D = new {}
typealias Ref<T> = ref.Reference<D, T>
@@ -1,7 +1,7 @@
import "pkl:ref"
class D extends ref.Domain {
function renderReference(reference: ref.Reference<D, Any>): String = throw("not supported")
function renderReference(reference: ref.Reference<this, Any>): String = throw("not supported")
}
local d: D = new {}
typealias Ref<T> = ref.Reference<D, T>
@@ -1,7 +1,7 @@
import "pkl:ref"
class D extends ref.Domain {
function renderReference(reference: ref.Reference<D, Any>): String = throw("not supported")
function renderReference(reference: ref.Reference<this, Any>): String = throw("not supported")
}
typealias Ref<T> = ref.Reference<D, T>
local d: D = new {}
@@ -1,7 +1,7 @@
import "pkl:ref"
class D extends ref.Domain {
function renderReference(reference: ref.Reference<D, Any>): String = throw("not supported")
function renderReference(reference: ref.Reference<this, Any>): String = throw("not supported")
}
typealias Ref<T> = ref.Reference<D, T>
local d: D = new {}
@@ -42,15 +42,15 @@ output {
// force eval but don't render to prevent recursion
value =
let (r1 = res1)
let (r2 = res2)
let (r3 = res3)
let (r4 = res4)
let (r5 = res5)
let (r6 = res6)
let (r6a = res6a)
let (r7 = res7)
let (r8 = res8)
let (r9 = res9)
let (r10 = res10)
new Dynamic { result = "ok" }
let (r2 = res2)
let (r3 = res3)
let (r4 = res4)
let (r5 = res5)
let (r6 = res6)
let (r6a = res6a)
let (r7 = res7)
let (r8 = res8)
let (r9 = res9)
let (r10 = res10)
new Dynamic { result = "ok" }
}
@@ -44,15 +44,15 @@ output {
// force eval but don't render to prevent recursion
value =
let (r1 = res1)
let (r2 = res2)
let (r3 = res3)
let (r4 = res4)
let (r5 = res5)
let (r6 = res6)
let (r6a = res6a)
let (r7 = res7)
let (r8 = res8)
let (r9 = res9)
let (r10 = res10)
new Dynamic { result = "ok" }
let (r2 = res2)
let (r3 = res3)
let (r4 = res4)
let (r5 = res5)
let (r6 = res6)
let (r6a = res6a)
let (r7 = res7)
let (r8 = res8)
let (r9 = res9)
let (r10 = res10)
new Dynamic { result = "ok" }
}
@@ -0,0 +1,21 @@
typealias Foo = module
@Baz { valid = true is module }
class Bar {
baz: module
}
class Baz extends Annotation {
valid: Boolean
}
const qux = true is module
const function quux() = true is module
const corge = new {
grault {
garply = true is module
}
}
hidden const waldo = (x: module) -> true
@@ -0,0 +1,7 @@
open module currentModuleType5
import ".../input-helper/types/aliasHolder.pkl"
local foo: aliasHolder.MyList<module> = List(this)
x = 1
y = foo.first.x
@@ -0,0 +1,21 @@
import "pkl:test"
import ".../input-helper/types/moduleTypeProperty.pkl"
class ModuleSubclass extends moduleTypeProperty {
x = 2
hidden mod2: module
mod2x = mod2.x
}
x = -1
res1 = new moduleTypeProperty {}
res2 = new moduleTypeProperty {
mod = new ModuleSubclass {}
}
res3 = new ModuleSubclass {}
res4 =
test.catch(() -> new ModuleSubclass {
mod = new moduleTypeProperty {}
}.output.text)
@@ -0,0 +1,150 @@
open module thisType1
import "pkl:test"
import "pkl:reflect"
hidden x: Int = 1
hidden res1: this = module
res1a = res1.res2.x
res1b = res1.res3.x
res1c = res1.res5[1].x
res1d = res1.res6a.x
res1e = res1.res6b.x
hidden res2: this = this
hidden res3: this = (this) { x = super.x + 1 }
res4: this? = null
hidden res5: List<this> = List(this, (this) { x = super.x + 2 })
hidden res6: List<this> = fun(this)
hidden res6a: this = res6[0]
hidden res6b: this = fun(new Good { x = 3 })[0]
function fun(m: this): List<this> =
let (_x = x)
List((m) { x = super.x + _x })
typealias Foo<T> = T
function fun2(m: Foo<this>): List<this> =
let (_x = x)
List((m) { x = super.x + _x + 1 })
class Bad {
res7: this = "abc"
res8: this = new Person {}
res9: this? = new Person {}
res10: List<this> = List(new Person {})
}
class Person
res7 = test.catch(() -> new Bad {}.res7)
res8 = test.catch(() -> new Bad {}.res8)
res9 = test.catch(() -> new Bad {}.res9)
res10 = test.catch(() -> new Bad {}.res10)
class Good extends module {
x = 2
}
local res11 = new Good {}
res11a = res11.res2.x
res11b = res11.res3.x
res11c = res11.res5[1].x
res11d = res11.res6a.x
res12 = test.catch(() -> res11.fun(module)[0].x)
// this type not affected by custom this scope:
hidden res13: List(this is List<this>) = List(module)
res13a = res13[0].x
// test generic typealias through inheritance from module
res14 = fun2(this).map((it) -> it.x)
res14a = test.catch(() -> res11.fun2(this))
res14b = res11.fun2(res11)[0].x
// test generic typealias without inheritance from module
open class A {
x: Int = 1
function fun2(m: Foo<this>): List<this> =
let (_x = x)
List((m) { x = super.x + _x + 1 })
}
class B extends A
local a = new A {}
local b = new B {}
res15 = a.fun2(a)
res15a = test.catch(() -> b.fun2(a))
res15b = b.fun2(b)
// test function type, function literal param, object body param
local c: (this) -> Dynamic = (xx: this) -> new Dynamic { x = xx.x * 2 }
local d = (c) { xx: this ->
x = super.x + xx.x * 3
}
res16 = d.apply(this).x
res16a = test.catch(() -> d.apply(new Dynamic { x = 1 }).x)
// let expr binding type
res17 =
let (xx: this = new module { x = 3 })
xx.x
// for/when generator vars skip a level
res18: Listing<Int> = new {
for (xx: this in List(module)) {
xx.x
}
}
// object property/method param/method return
res19 = new Dynamic {
local foo: this = new Dynamic { x = 1 }
local function bar(a: this): this = new { x = foo.x + a.x }
baz = bar(new Dynamic { x = 2 })
}
// type cast, explicit new expr
hidden res20 = new this { x = 6 } as this
res20a = res20.x
// constrained
hidden res21: this(this.x > 5) = res20
res21a = res21.x
// lazy type check and default value
hidden res22: Listing<this> = new {
new { x = 1 }
new Good {}
new { x = 3 }
new Good { x = 4 }
}
res22a = module.res22.toList().map((it) -> "\(it.getClass()): \(it.x)").toListing()
res22b = new Good {}.res22.toList().map((it) -> "\(it.getClass()): \(it.x)").toListing()
// annotation type
open class ThisAnnotation extends Annotation {
@this { y = 1 }
y: Int
}
open class ThatAnnotation extends ThisAnnotation
@ThisAnnotation { y = 2 }
hidden annThis: Int = 1
res23 = reflect.Class(getClass()).properties["annThis"].annotations.single
res23a = res23.getClass().toString()
res23b = reflect.Class(res23.getClass()).allProperties["y"].annotations.single.getClass().toString()
@ThatAnnotation { y = 2 }
hidden annThat: Int = 1
res24 = reflect.Class(getClass()).properties["annThat"].annotations.single
res24a = res24.getClass().toString()
res24b = reflect.Class(res24.getClass()).allProperties["y"].annotations.single.getClass().toString()
@@ -0,0 +1 @@
typealias Foo = this
@@ -0,0 +1,21 @@
// cover custom this contexts in a final module
local foo: Listing(any((it) -> it is this)) = new { bar }
local bar: Listing = new { foo }
res1 = foo.length
local baz: Listing = new {
new Listing { "hello" }
new Mapping { ["hello"] = "world" }
module
}
res2 = (baz) {
[[this is this]] {
res2 = "blah"
}
when (module is this) {
123
}
module is this
}
@@ -0,0 +1,22 @@
open module thisType4
// cover custom this contexts in an open module
local foo: Listing(any((it) -> it is this)) = new { bar }
local bar: Listing = new { foo }
res1 = foo.length
local baz: Listing = new {
new Listing { "hello" }
new Mapping { ["hello"] = "world" }
module
}
res2 = (baz) {
[[this is this]] {
res2 = "blah"
}
when (module is this) {
123
}
module is this
}
@@ -0,0 +1,16 @@
// test this type interacting with local class
local class Foo {
bar: this? = new { bar = null }
baz = new Foo {} is this
function qux(a: this): this = this
function quux(a: Any): Boolean = a is this
}
local foo = new Foo {}
res1 = foo.bar
res2 = foo.baz
res3 = foo.qux(new Foo {})
res4 = foo.quux(new Foo {})
@@ -0,0 +1,3 @@
open module thisType6
class Foo extends this
@@ -60,3 +60,4 @@ aValuesJoined = """
${b.outputs.nonString}
"""
typeArgs = "${null.prop}"
badThisRef = "Expected value of type `pkl.ref#Reference<reference#D, this>`, but got type `pkl.ref#Reference<reference#D, reference#A>`. Value: Reference(new D {}, reference#A, new BadResource { name = ? })"
@@ -26,6 +26,8 @@ facts {
true
true
true
true
true
}
["Reflecting a class"] {
true
@@ -67,7 +69,7 @@ facts {
}
examples {
["Reflected module properties of unknown type metadata"] {
Set("int", "float", "string", "boolean", "duration", "dataSize", "pair", "list", "set", "map", "listing", "mapping", "dynamic", "typed", "int2", "float2", "string2", "boolean2", "duration2", "dataSize2", "pair2", "list2", "set2", "map2", "listing2", "mapping2", "dynamic2", "typed2", "any", "noth", "unkn", "union", "nullable", "stringLiteral", "constrained", "aliased", "hiddenProp", "constProp", "fixedProp")
Set("int", "float", "string", "boolean", "duration", "dataSize", "pair", "list", "set", "map", "listing", "mapping", "dynamic", "typed", "int2", "float2", "string2", "boolean2", "duration2", "dataSize2", "pair2", "list2", "set2", "map2", "listing2", "mapping2", "dynamic2", "typed2", "any", "noth", "unkn", "union", "nullable", "stringLiteral", "constrained", "aliased", "mod", "self", "hiddenProp", "constProp", "fixedProp")
new {
hasExpectedLocation = true
docComment = "module property doc comment"
@@ -1,8 +1,8 @@
–– Pkl Error ––
not supported
x | function renderReference(reference: ref.Reference<D, Any>): String = throw("not supported")
^^^^^^^^^^^^^^^^^^^^^^
x | function renderReference(reference: ref.Reference<this, Any>): String = throw("not supported")
^^^^^^^^^^^^^^^^^^^^^^
at reference20#D.renderReference (file:///$snippetsDir/input/errors/reference20.pkl)
xxx | function toString(): String = getDomain().renderReference(this)
@@ -0,0 +1,12 @@
res0 = ""
res1 = "parent"
res2 = "parent.parent"
res3 = "children.0"
res4 = "children.0.parent"
res5 = "children.0.children.0"
res0a = ""
res1a = "parent"
res2a = "parent.parent"
res3a = "children.0"
res4a = "children.0.parent"
res5a = "children.0.children.0"
@@ -0,0 +1,6 @@
res0 = ""
res1 = "parent"
res2 = "parent.parent"
res3 = "children.0"
res4 = "children.0.parent"
res5 = "children.0.children.0"
@@ -0,0 +1,6 @@
res0 = ""
res1 = "parent"
res2 = "parent.parent"
res3 = "children.0"
res4 = "children.0.parent"
res5 = "children.0.children.0"
@@ -0,0 +1,5 @@
result = "ok"
pkl: WARN: Cannot reference `module` type within a class body. This will be an error in a future release. (file:///$snippetsDir/input/types/currentModuleType1.pkl)
pkl: WARN: Cannot reference `module` type within a class body. This will be an error in a future release. (file:///$snippetsDir/input/types/currentModuleType1.pkl)
pkl: WARN: Cannot reference `module` type within a class body. This will be an error in a future release. (file:///$snippetsDir/input/types/currentModuleType1.pkl)
pkl: WARN: Cannot reference `module` type within a class body. This will be an error in a future release. (file:///$snippetsDir/input/types/currentModuleType1.pkl)
@@ -1 +0,0 @@
result = "ok"
@@ -0,0 +1,5 @@
result = "ok"
pkl: WARN: Cannot reference `module` type within a class body. This will be an error in a future release. (file:///$snippetsDir/input/types/currentModuleType2.pkl)
pkl: WARN: Cannot reference `module` type within a class body. This will be an error in a future release. (file:///$snippetsDir/input/types/currentModuleType2.pkl)
pkl: WARN: Cannot reference `module` type within a class body. This will be an error in a future release. (file:///$snippetsDir/input/types/currentModuleType2.pkl)
pkl: WARN: Cannot reference `module` type within a class body. This will be an error in a future release. (file:///$snippetsDir/input/types/currentModuleType2.pkl)
@@ -1 +0,0 @@
result = "ok"
@@ -0,0 +1,5 @@
result = "ok"
pkl: WARN: Cannot reference `module` type within a class body. This will be an error in a future release. (file:///$snippetsDir/input/types/currentModuleType2.pkl)
pkl: WARN: Cannot reference `module` type within a class body. This will be an error in a future release. (file:///$snippetsDir/input/types/currentModuleType2.pkl)
pkl: WARN: Cannot reference `module` type within a class body. This will be an error in a future release. (file:///$snippetsDir/input/types/currentModuleType2.pkl)
pkl: WARN: Cannot reference `module` type within a class body. This will be an error in a future release. (file:///$snippetsDir/input/types/currentModuleType2.pkl)
@@ -1 +0,0 @@
result = "ok"
@@ -0,0 +1,13 @@
qux = false
corge {
grault {
garply = false
}
}
pkl: WARN: Cannot reference `module` type within an annotation body. This will be an error in a future release. (file:///$snippetsDir/input/types/currentModuleType4.pkl)
pkl: WARN: Cannot reference `module` type within a class body. This will be an error in a future release. (file:///$snippetsDir/input/types/currentModuleType4.pkl)
pkl: WARN: Cannot reference `module` type within a type alias body. This will be an error in a future release. (file:///$snippetsDir/input/types/currentModuleType4.pkl)
pkl: WARN: Cannot reference `module` type from const property `currentModuleType4#qux`. This will be an error in a future release. (file:///$snippetsDir/input/types/currentModuleType4.pkl)
pkl: WARN: Cannot reference `module` type from const property `currentModuleType4#corge`. This will be an error in a future release. (file:///$snippetsDir/input/types/currentModuleType4.pkl)
pkl: WARN: Cannot reference `module` type from const property `currentModuleType4#waldo`. This will be an error in a future release. (file:///$snippetsDir/input/types/currentModuleType4.pkl)
pkl: WARN: Cannot reference `module` type from const method `currentModuleType4#quux`. This will be an error in a future release. (file:///$snippetsDir/input/types/currentModuleType4.pkl)
@@ -0,0 +1,2 @@
x = 1
y = 1
@@ -0,0 +1,19 @@
x = -1
res1 {
x = 1
y = 1
modName = "moduleTypeProperty"
}
res2 {
x = 1
y = 2
modName = "moduleTypeProperty"
}
res3 {
x = 2
y = 2
modName = "currentModuleType6#ModuleSubclass"
mod2x = -1
}
res4 = "Expected value of type `currentModuleType6#ModuleSubclass`, but got type `moduleTypeProperty`. Value: new ModuleClass { x = ?; y = ?; modName = ? }"
pkl: WARN: Cannot reference `module` type within a class body. This will be an error in a future release. (file:///$snippetsDir/input/types/currentModuleType6.pkl)
@@ -0,0 +1,61 @@
res1a = 1
res1b = 2
res1c = 3
res1d = 2
res1e = 4
res4 = null
res7 = "Expected value of type `thisType1#Bad`, but got type `String`. Value: \"abc\""
res8 = "Expected value of type `thisType1#Bad`, but got type `thisType1#Person`. Value: new Person {}"
res9 = "Expected value of type `thisType1#Bad`, but got type `thisType1#Person`. Value: new Person {}"
res10 = "Expected value of type `thisType1#Bad`, but got type `thisType1#Person`. Value: new Person {}"
res11a = 2
res11b = 3
res11c = 4
res11d = 4
res12 = "Expected value of type `thisType1#Good`, but got type `thisType1`. Value: new ModuleClass { res1a = 1; res1b = 2; res1c = 3; res1d = 2; res1e = 4; res4..."
res13a = 1
res14 = List(3)
res14a = "Expected value of type `thisType1#Good`, but got type `thisType1`. Value: new ModuleClass { res1a = 1; res1b = 2; res1c = 3; res1d = 2; res1e = 4; res4..."
res14b = 5
res15 = List(new {
x = 3
})
res15a = "Expected value of type `thisType1#B`, but got type `thisType1#A`. Value: new A { x = 1 }"
res15b = List(new {
x = 3
})
res16 = 5
res16a = "Expected value of type `thisType1`, but got type `Dynamic`. Value: new Dynamic { x = ? }"
res17 = 3
res18 {
1
}
res19 {
baz {
x = 3
}
}
res20a = 6
res21a = 6
res22a {
"thisType1: 1"
"thisType1#Good: 2"
"thisType1: 3"
"thisType1#Good: 4"
}
res22b {
"thisType1#Good: 1"
"thisType1#Good: 2"
"thisType1#Good: 3"
"thisType1#Good: 4"
}
res23 {
y = 2
}
res23a = "thisType1#ThisAnnotation"
res23b = "thisType1#ThisAnnotation"
res24 {
y = 2
}
res24a = "thisType1#ThatAnnotation"
res24b = "thisType1#ThisAnnotation"
@@ -0,0 +1,6 @@
–– Pkl Error ––
Cannot reference `this` type within a type alias body.
x | typealias Foo = this
^^^^
at thisType2#Foo (file:///$snippetsDir/input/types/thisType2.pkl)
@@ -0,0 +1,15 @@
res1 = 1
res2 {
new {
"hello"
}
new {
["hello"] = "world"
}
new {
res1 = 1
res2 = "blah"
}
123
false
}
@@ -0,0 +1,15 @@
res1 = 1
res2 {
new {
"hello"
}
new {
["hello"] = "world"
}
new {
res1 = 1
res2 = "blah"
}
123
false
}
@@ -0,0 +1,13 @@
res1 {
bar = null
baz = true
}
res2 = true
res3 {
bar {
bar = null
baz = true
}
baz = true
}
res4 = true
@@ -0,0 +1,6 @@
–– Pkl Error ––
`this` is not a valid supertype.
x | class Foo extends this
^^^^
at thisType6#Foo (file:///$snippetsDir/input/types/thisType6.pkl)
@@ -1,3 +1,4 @@
pkl: WARN: Cannot reference `module` type within a type alias body. This will be an error in a future release. (file:///$snippetsDir/input-helper/types/typeAliasModule.pkl)
–– Pkl Error ––
Expected value of type `typeAliasModule`, but got type `typeAlias6`.
Value: new ModuleClass { res = ? }