Skip to content

Trait vtable computation misses methods from non-direct ancestor traits #1189

@VaggelisD

Description

@VaggelisD

Minimum repro:

from typing import Any
from mypy_extensions import trait, mypyc_attr

@mypyc_attr(allow_interpreted_subclasses=True)
@trait
class Base:
    def value(self) -> Any: ...


@mypyc_attr(allow_interpreted_subclasses=True)
@trait
class Middle(Base):
    pass


@mypyc_attr(allow_interpreted_subclasses=True)
@trait
class Child(Middle):
    def derived(self) -> Any:
        return self.value()

mypy --version
mypy 1.19.1 (compiled: yes)mypyc single_file.py
Traceback (most recent call last):
  ...
  File "mypyc/ir/class_ir.py", line 248, in vtable_entry
AssertionError: 'Child' has no attribute 'value'

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions