Skip to content

Interface type within interface should be checked for "implements" instead as normal type while "implements" validation #7539

@lrills

Description

@lrills

In following fail example, Foo and A seem to be compared as subtype and supertype and cause it fail. But interface B is actually being fullfilled that you can totally operate Bar#b as an A.
Consider the iterable and iterator case which an object got [Symbol.iterator] method that retrurns iterator should implements iterable , this kind of behavior should be resonable.

interface A {
  a: 'a'
}

interface B {
  b: A
}

class Foo implements A {
  a = 'a';
}

class Bar implements B {
  b: Foo;
}

Flow version: 0.94.0

Expected behavior

Interface types within interfaces should be treated and validated as interface implemantation but not as normal type while validating an "implements" check.

Actual behavior

    14:   b: Foo
             ^ Cannot implement `B` [1] with `Bar` because `Foo` [2] is incompatible with `A` [3] in property `b`.
        References:
        13: class Bar implements B {
                                 ^ [1]
        14:   b: Foo
                 ^ [2]
        6:   b: A
                ^ [3]

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions