mirror of
https://github.com/apple/pkl.git
synced 2026-01-11 22:30:54 +01:00
[PR #510] [CLOSED] Restore late-binding for constraints within typealiases #592
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/apple/pkl/pull/510
Author: @bioball
Created: 5/30/2024
Status: ❌ Closed
Base:
main← Head:typealias-late-binding📝 Commits (1)
5900247Restore late-binding for constraints within typealiases📊 Changes
12 files changed (+92 additions, -7 deletions)
View changed files
📝
pkl-core/src/main/java/org/pkl/core/ast/type/ResolveQualifiedDeclaredTypeNode.java(+2 -1)📝
pkl-core/src/main/java/org/pkl/core/ast/type/TypeNode.java(+11 -4)📝
pkl-core/src/main/java/org/pkl/core/ast/type/UnresolvedTypeNode.java(+20 -2)📝
pkl-core/src/main/java/org/pkl/core/runtime/VmTyped.java(+10 -0)➕
pkl-core/src/test/files/LanguageSnippetTests/input/types/helpers/someModule2.pkl(+3 -0)➕
pkl-core/src/test/files/LanguageSnippetTests/input/types/helpers/someModule3.pkl(+3 -0)➕
pkl-core/src/test/files/LanguageSnippetTests/input/types/typeAliasConstraint3.pkl(+25 -0)➕
pkl-core/src/test/files/LanguageSnippetTests/input/types/typeAliasConstraint4.pkl(+5 -0)➕
pkl-core/src/test/files/LanguageSnippetTests/output/types/helpers/someModule2.pcf(+1 -0)➕
pkl-core/src/test/files/LanguageSnippetTests/output/types/helpers/someModule3.pcf(+1 -0)➕
pkl-core/src/test/files/LanguageSnippetTests/output/types/typeAliasConstraint3.pcf(+9 -0)➕
pkl-core/src/test/files/LanguageSnippetTests/output/types/typeAliasConstraint4.pcf(+2 -0)📄 Description
This is one proposal to fix https://github.com/apple/pkl/issues/446.
This changes the behavior of typealiases such that:
This implies that the meaning of a typealias can change depending on where it is resolved from. Given the following:
These two properties have different type checks:
Despite this, they are considered the same typealias.
This is somewhat quirky. An alternative solution to this problem is to require any references from a constraint to be
const. This is just like how classes work. However, this solution would limit the usefulness of typealiases.🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.