A variable of an interface class type holds a handle of an object whose
class implements it; a method called through it runs the implementation
of the object's class, including methods the interface class inherits
from the interface classes it extends (IEEE 1800-2023 8.26). Each method
of an interface class gets a dispatcher like a virtual method's.
A handle may only be assigned to a variable of its class, a base class or
an interface class it implements; any other assignment to a variable, a
property or from `C::new` is rejected (8.16, 8.26.5).
`$cast` to a class handle calls a subroutine generated for the
destination class: it assigns a source that is `null` or whose object's
class derives from or implements the class and returns 1, and otherwise
returns 0, leaving the destination unchanged. Called as a task, a failing
cast reports an error. A cast between classes that are not cast
compatible fails without a call (8.16).
Interface classes are now lowered; one whose methods use its own typedefs
or type parameters is left without subroutines and rejected only where
its handles are used.
sv-tests: 8.26.5--cast_between_interface_classes now passes in both state
modes (543 / 545). Verilator's failing interface-to-interface casts and
inherited interface methods, and Icarus's missing $cast and interface
classes, are recorded as limitations.
BREAKING CHANGE: `AnalyzerError` has an `IncompatibleClassHandle` variant,
and assignments of incompatible class handles that were accepted are now
rejected.
Change-Id: I1edcc030c35a6bec183c76b567cff49e1319a7e5
A variable of an interface class type holds a handle of an object whose
class implements it; a method called through it runs the implementation
of the object's class, including methods the interface class inherits
from the interface classes it extends (IEEE 1800-2023 8.26). Each method
of an interface class gets a dispatcher like a virtual method's.
A handle may only be assigned to a variable of its class, a base class or
an interface class it implements; any other assignment to a variable, a
property or from
C::newis rejected (8.16, 8.26.5).$castto a class handle calls a subroutine generated for thedestination class: it assigns a source that is
nullor whose object'sclass derives from or implements the class and returns 1, and otherwise
returns 0, leaving the destination unchanged. Called as a task, a failing
cast reports an error. A cast between classes that are not cast
compatible fails without a call (8.16).
Interface classes are now lowered; one whose methods use its own typedefs
or type parameters is left without subroutines and rejected only where
its handles are used.
sv-tests: 8.26.5--cast_between_interface_classes now passes in both state
modes (543 / 545). Verilator's failing interface-to-interface casts and
inherited interface methods, and Icarus's missing $cast and interface
classes, are recorded as limitations.
BREAKING CHANGE:
AnalyzerErrorhas anIncompatibleClassHandlevariant,and assignments of incompatible class handles that were accepted are now
rejected.
Depends-On: #1724