mirror of
https://github.com/erg-lang/erg.git
synced 2025-08-04 10:49:54 +00:00
28 lines
449 B
Python
28 lines
449 B
Python
i = !0
|
|
|
|
@Inheritable
|
|
C = Class()
|
|
C::[<: Self]
|
|
__init__! self =
|
|
print! "initialize C:", self
|
|
i.inc!()
|
|
__del__! self =
|
|
print! "delete C:", self
|
|
i.dec!()
|
|
|
|
p!() =
|
|
c = C.new()
|
|
assert i == 1
|
|
print! c
|
|
|
|
p!()
|
|
assert i == 0
|
|
|
|
D = Inherit C, Additional := { x = Int }
|
|
D::[<: Self]
|
|
@Override
|
|
__init__! self =
|
|
C::__init__! self
|
|
print! "initialize D:", self, self::x
|
|
|
|
_ = D.new { x = 1 }
|