This changes how the language performs typechecks for mappings and
listings.
Currently, Pkl will shallow-force any Mapping and Listing to check
the type parameter (e.g. Listing<Person> means each element is checked
to be an instance of Person).
This changes the language to check each member's type when the member
is accessed.
This PR is designed to be reviewed as two separate commits.
The first one contains business logic that changes how mapping/listing
typechecks work.
The second one adjusts the test runner to handle errors thrown within
tests.
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.
## 📋 Pull Request Information
**Original PR:** https://github.com/apple/pkl/pull/628
**Author:** [@bioball](https://github.com/bioball)
**Created:** 8/16/2024
**Status:** ✅ Merged
**Merged:** 9/7/2024
**Merged by:** [@bioball](https://github.com/bioball)
**Base:** `main` ← **Head:** `mapping-listing-typechecks`
---
### 📝 Commits (6)
- [`834ef8c`](https://github.com/apple/pkl/commit/834ef8cb2114912bada61c6cac774854aba573e2) Overhaul typechecks for Mapping/Listing
- [`670d67e`](https://github.com/apple/pkl/commit/670d67e17c0ad10a0e73b158147a6ba2ff00880a) Adjust test runner to handle thrown errors from within tests
- [`997c5e7`](https://github.com/apple/pkl/commit/997c5e79a1df1051b9b6ebc7a45593936ad255e6) Address PR comments
- [`d75eec2`](https://github.com/apple/pkl/commit/d75eec2e7e426d77a9e1084271a86ed08b0aa441) Address PR comments, add optimizations
- [`410358e`](https://github.com/apple/pkl/commit/410358e97df9a8d1a7016e0c381b07ccb761a66f) Abort early on shouldEagerCheck
- [`be207a7`](https://github.com/apple/pkl/commit/be207a71d670b10f790a3dd1fcc784e550c6572a) Adjust comments
### 📊 Changes
**86 files changed** (+3341 additions, -384 deletions)
<details>
<summary>View changed files</summary>
📝 `pkl-cli/src/test/kotlin/org/pkl/cli/CliTestRunnerTest.kt` (+182 -0)
📝 `pkl-core/src/main/java/org/pkl/core/ast/MemberNode.java` (+0 -14)
📝 `pkl-core/src/main/java/org/pkl/core/ast/builder/AstBuilder.java` (+14 -6)
📝 `pkl-core/src/main/java/org/pkl/core/ast/expression/generator/GeneratorPredicateMemberNode.java` (+1 -1)
📝 `pkl-core/src/main/java/org/pkl/core/ast/expression/literal/EntriesLiteralNode.java` (+2 -2)
📝 `pkl-core/src/main/java/org/pkl/core/ast/expression/literal/SpecializedObjectLiteralNode.java` (+1 -1)
📝 `pkl-core/src/main/java/org/pkl/core/ast/expression/member/ReadLocalPropertyNode.java` (+1 -1)
📝 `pkl-core/src/main/java/org/pkl/core/ast/expression/primary/ResolveVariableNode.java` (+2 -2)
📝 `pkl-core/src/main/java/org/pkl/core/ast/member/FunctionNode.java` (+1 -1)
➕ `pkl-core/src/main/java/org/pkl/core/ast/member/ListingOrMappingTypeCastNode.java` (+64 -0)
📝 `pkl-core/src/main/java/org/pkl/core/ast/member/LocalTypedPropertyNode.java` (+1 -2)
📝 `pkl-core/src/main/java/org/pkl/core/ast/member/ObjectMember.java` (+2 -1)
📝 `pkl-core/src/main/java/org/pkl/core/ast/member/PropertyTypeNode.java` (+2 -3)
📝 `pkl-core/src/main/java/org/pkl/core/ast/member/TypeCheckedPropertyNode.java` (+4 -4)
📝 `pkl-core/src/main/java/org/pkl/core/ast/member/TypedPropertyNode.java` (+3 -2)
📝 `pkl-core/src/main/java/org/pkl/core/ast/type/IdentityMixinNode.java` (+1 -1)
📝 `pkl-core/src/main/java/org/pkl/core/ast/type/ResolveDeclaredTypeNode.java` (+2 -2)
📝 `pkl-core/src/main/java/org/pkl/core/ast/type/TypeCastNode.java` (+3 -2)
📝 `pkl-core/src/main/java/org/pkl/core/ast/type/TypeNode.java` (+1014 -172)
📝 `pkl-core/src/main/java/org/pkl/core/ast/type/TypeTestNode.java` (+5 -1)
_...and 66 more files_
</details>
### 📄 Description
This follows this SPICE: https://github.com/apple/pkl-evolution/pull/11
This changes how the language performs typechecks for mappings and
listings.
Currently, Pkl will shallow-force any Mapping and Listing to check
the type parameter (e.g. `Listing<Person>` means each element is checked
to be an instance of `Person`).
This changes the language to check each member's type when the member
is accessed.
This PR is designed to be reviewed as two separate commits.
The first one contains business logic that changes how mapping/listing
typechecks work.
The second one adjusts the test runner to handle errors thrown within
tests.
Closes https://github.com/apple/pkl/issues/405
Closes https://github.com/apple/pkl/issues/406
---
<sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
📋 Pull Request Information
Original PR: https://github.com/apple/pkl/pull/628
Author: @bioball
Created: 8/16/2024
Status: ✅ Merged
Merged: 9/7/2024
Merged by: @bioball
Base:
main← Head:mapping-listing-typechecks📝 Commits (6)
834ef8cOverhaul typechecks for Mapping/Listing670d67eAdjust test runner to handle thrown errors from within tests997c5e7Address PR commentsd75eec2Address PR comments, add optimizations410358eAbort early on shouldEagerCheckbe207a7Adjust comments📊 Changes
86 files changed (+3341 additions, -384 deletions)
View changed files
📝
pkl-cli/src/test/kotlin/org/pkl/cli/CliTestRunnerTest.kt(+182 -0)📝
pkl-core/src/main/java/org/pkl/core/ast/MemberNode.java(+0 -14)📝
pkl-core/src/main/java/org/pkl/core/ast/builder/AstBuilder.java(+14 -6)📝
pkl-core/src/main/java/org/pkl/core/ast/expression/generator/GeneratorPredicateMemberNode.java(+1 -1)📝
pkl-core/src/main/java/org/pkl/core/ast/expression/literal/EntriesLiteralNode.java(+2 -2)📝
pkl-core/src/main/java/org/pkl/core/ast/expression/literal/SpecializedObjectLiteralNode.java(+1 -1)📝
pkl-core/src/main/java/org/pkl/core/ast/expression/member/ReadLocalPropertyNode.java(+1 -1)📝
pkl-core/src/main/java/org/pkl/core/ast/expression/primary/ResolveVariableNode.java(+2 -2)📝
pkl-core/src/main/java/org/pkl/core/ast/member/FunctionNode.java(+1 -1)➕
pkl-core/src/main/java/org/pkl/core/ast/member/ListingOrMappingTypeCastNode.java(+64 -0)📝
pkl-core/src/main/java/org/pkl/core/ast/member/LocalTypedPropertyNode.java(+1 -2)📝
pkl-core/src/main/java/org/pkl/core/ast/member/ObjectMember.java(+2 -1)📝
pkl-core/src/main/java/org/pkl/core/ast/member/PropertyTypeNode.java(+2 -3)📝
pkl-core/src/main/java/org/pkl/core/ast/member/TypeCheckedPropertyNode.java(+4 -4)📝
pkl-core/src/main/java/org/pkl/core/ast/member/TypedPropertyNode.java(+3 -2)📝
pkl-core/src/main/java/org/pkl/core/ast/type/IdentityMixinNode.java(+1 -1)📝
pkl-core/src/main/java/org/pkl/core/ast/type/ResolveDeclaredTypeNode.java(+2 -2)📝
pkl-core/src/main/java/org/pkl/core/ast/type/TypeCastNode.java(+3 -2)📝
pkl-core/src/main/java/org/pkl/core/ast/type/TypeNode.java(+1014 -172)📝
pkl-core/src/main/java/org/pkl/core/ast/type/TypeTestNode.java(+5 -1)...and 66 more files
📄 Description
This follows this SPICE: https://github.com/apple/pkl-evolution/pull/11
This changes how the language performs typechecks for mappings and
listings.
Currently, Pkl will shallow-force any Mapping and Listing to check
the type parameter (e.g.
Listing<Person>means each element is checkedto be an instance of
Person).This changes the language to check each member's type when the member
is accessed.
This PR is designed to be reviewed as two separate commits.
The first one contains business logic that changes how mapping/listing
typechecks work.
The second one adjusts the test runner to handle errors thrown within
tests.
Closes https://github.com/apple/pkl/issues/405
Closes https://github.com/apple/pkl/issues/406
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.