second-state/SOLL

Implement inheritance

LFsWang opened this issue · 0 comments

Add support to inheritance

Parser

  • New keywords
  • abstract
  • is
  • override
  • virtual
  • interface
  • structure
  • identifier-path
  • inheritance-specifier
  • override-specifier
  • Add new ability on AST for inheritance

Analysis

  • Function Overriding
  • Base functions can be overridden by inheriting contracts to change their behavior if they are marked as virtual
  • The overriding function must then use the override keyword in the function header
  • The overriding function may only change the visibility of the overridden function from external to public
  • nonpayable can be overridden by view and pure
  • view can be overridden by pure
  • payable is an exception and cannot be changed to any other mutability.
  • For multiple inheritance, the most derived base contracts that define the same function must be specified explicitly after the override
  • Functions with the private visibility cannot be virtual
  • Public state variables can override external functions if the parameter and return types of the function matches the getter function of the variable:
  • Modifier Overriding (The details is as same as Function Overriding)
  • modifier support.
  • Constructors

  • Multiple Inheritance and Linearization

  • C3 Linearization (Build inheritance graph)
  • Inheriting Different Kinds of Members of the Same Name
  • Abstract Contracts

  • Interfaces

  • They cannot inherit from other contracts, but they can inherit from other interfaces.

  • All declared functions must be external

  • They cannot declare a constructor.

  • They cannot declare state variables.

  • All functions declared in interfaces are implicitly virtual

  • contract injector