feat: add Class.supertype primitive and documentation for retrieving superclass
Implement a new `supertype` property on Class objects that returns the superclass of a given class. The primitive `class_supertype` checks if the class has a superclass (returning null for Object) and returns the superclass object. Includes documentation in the class reference and a test file verifying behavior for explicit superclasses, implicit Object inheritance, and Object's null supertype.
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
class Foo {}
|
||||
|
||||
class Bar is Foo {}
|
||||
|
||||
class Baz is Bar {}
|
||||
|
||||
// A class with no explicit superclass inherits Object.
|
||||
IO.print(Foo.supertype == Object) // expect: true
|
||||
|
||||
// Otherwise, it's the superclass.
|
||||
IO.print(Bar.supertype == Foo) // expect: true
|
||||
IO.print(Baz.supertype == Bar) // expect: true
|
||||
|
||||
// Object has no supertype.
|
||||
IO.print(Object.supertype) // expect: null
|
||||
Reference in New Issue
Block a user