cadence icon indicating copy to clipboard operation
cadence copied to clipboard

Interface Implementation Requirements

Open turbolent opened this issue 3 years ago • 2 comments

Description

An earlier version of the language reference specified an unimplemented feature: Interface implementation requirements:

Interfaces can require implementing types to also implement other interfaces of the same kind. Interface implementation requirements can be declared by following the interface name with a colon (:) and one or more names of interfaces of the same kind, separated by commas.

// Declare a structure interface named `Shape`.
//
pub struct interface Shape {}

// Declare a structure interface named `Polygon`.
// Require implementing types to also implement the structure interface `Shape`.
//
pub struct interface Polygon: Shape {}

// Declare a structure named `Hexagon` that implements the `Polygon` interface.
// This also is required to implement the `Shape` interface,
// because the `Polygon` interface requires it.
//
pub struct Hexagon: Polygon, Shape {}

This feature is needed for the new FT / NFT standards.

turbolent avatar Sep 09 '22 23:09 turbolent

cc @joshuahannan @dsainati1

turbolent avatar Sep 10 '22 00:09 turbolent

Thank you! I'm excited to have this feature! :)

joshuahannan avatar Sep 12 '22 14:09 joshuahannan

Added with https://github.com/onflow/cadence/pull/2112

SupunS avatar May 31 '23 19:05 SupunS

FLIP: https://github.com/onflow/flips/pull/40

turbolent avatar Jul 06 '23 21:07 turbolent