Skip to content

Class<T> is always type-erased to Class #1729

Description

@HT154

Currently there's no way to test that a Class value is the class (or a subclass of) a particular class.

open class A
open class B
class C extends A

foo = C is Class<A>
bar = C is Class<B>

Results in:

foo = true
bar = true

Even though C is not [a subclass of] B.

Pkl should instead not erase the type parameter:

  • Type checks against Class<T> should check that the value is a Class and that the class is [a subclass of] T
  • Class<T> type annotations should forbid non-class types for T, including union, nullable, constrained, parameterized, string literal, and nothing types.

See related: apple/pkl-intellij#222

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions