apple / apple/pkl

`toTyped` ignores default values in class

Open
#768 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
11.5k
Forks
402
Avg merge
1d 15h
Merged PRs (30d)
20

Description

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)
```

Contributor guide

Open the contributing guide

Research direction

No source file or test is named in the issue. Reproduce the examples for Dynamic.toTyped and Map.toTyped, then trace their handling of class defaults; done means both conversions preserve the supplied name while deriving colloquialName from it rather than using the declared default.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
compilers
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.