Skip to content

exekall: Add support for associated types

Support methods polymorphic in their return values in the following limited case:

import typing

class Base:
    ASSOCIATED_CLS = typing.TypeVar('ASSOCIATED_CLS')

    def foo(self) -> 'Base.ASSOCIATED_CLS':
        return X

class Derived1(Base):
    X = 1
    ASSOCIATED_CLS = type(X)

class Derived2(Base):
    X = 'hello'
    ASSOCIATED_CLS = type(X)

In that case, exekall will correctly infer that Derived1.foo() returns an int and Derived2.foo() returns a string.

Merge request reports