pkl icon indicating copy to clipboard operation
pkl copied to clipboard

`toTyped` ignores default values in class

Open holzensp opened this issue 1 year ago • 0 comments

Given

class Bird {
  name: String = "DEFAULT"
  colloquialName: String = name
}

evaluating

new Dynamic { name = "Pigeon" }.toTyped(Bird)

results in

new Bird {
  name = "Pigeon"
  colloquialName = "DEFAULT" // <- unexpected
}

The same holds for the toTyped definition on Map, so the following produces the same result:

new Dynamic { name = "Pigeon" }.toMap().toTyped(Bird)

holzensp avatar Nov 01 '24 17:11 holzensp