Skip to content

enforce constraints on implemented functions; start by at least checking their signatures #4

@gabejohnson

Description

@gabejohnson

Barring static types, it would be nice to have checks ensuring that if a protocol intends a field to be a method that an implementation at least defines is as a function (preferably of the same length).

protocol A {
  a; // maybe a function
  b(); // definitely a function
  c(d, e); // definitely a function of at least length two
}

class B {
  [A.c](d, e){}
}

B.prototype[A.a] = 'a';
B.prototype[A.b] = 'b';

B implements A; // Error: Symbol(A.b) must be a function

class C {
  [A.b](){}
  [A.c](){}
}

C.prototype[A.a] = 42;

C implements A; // Error: Symbol(A.c) must be a function of length >= 2

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions