GitNexus/gitnexus/test/fixtures/lang-resolution/python-mixin-self-dispatch/mixins.py
EVA f6e70016d6
fix(python): resolve mixin self calls to subtype implementations (#3390)
* fix(python): resolve missing mixin self members through subtypes

* fix: honor Python effective MRO and static mixin targets

* fix: bind Python subtype dispatch to receiver provenance

* fix(python): limit mixin fanout to instance receivers

* fix(python): capture call arity and invalidate stale parsed facts

* fix(python): count bound receivers by method context

Preserve static, free, nested and typed variadic parameters; test renamed target receivers without weakening incompatible-arity rejection. Regenerate capture goldens for receiver metadata and eight mixin fixtures. Record the deliberate missing_target coverage outcome: CI measured Python call drops 5->6 and total call drops 113->114; no shape or scaling threshold relaxed.

* test(python): require a call capture before checking unknown arity

* fix(python): bind subtype dispatch to receiver definition

* test(python): include conditional renamed-receiver target

* fix(python): prove positional mixin targets and report partial coverage

Preserve upstream notebook coordinate mapping and maintainer changes. Reject incompatible/implicit-class targets, retain proven targets across ambiguous alternatives, and report capped or unresolved coverage without confusing edge deduplication.

* fix(python): isolate subtype call proof and preserve lookup boundaries

---------

Co-authored-by: Eva <eva@100yen.org>
Co-authored-by: Gergő Magyar <gergomagyar@icloud.com>
2026-09-28 09:42:56 +05:30

104 lines
2.3 KiB
Python

class HookMixin:
def first(self) -> int:
return self.helper()
def second(self) -> int:
return self.helper()
def renamed(instance) -> int:
return instance.helper()
def missing(self) -> int:
return self.missing_target()
class AnnotatedCaller:
def call_annotated(self, other: HookMixin) -> int:
return other.helper()
class ClassReceiverMixin:
@classmethod
def invoke(receiver, value: int) -> int:
return receiver.class_only(value)
class AmbiguousMixin:
def dispatch(self) -> int:
return self.run()
class VariadicPseudoReceiverMixin:
def variadic_dispatch(*args) -> int:
return args.variadic_target()
class NestedClassReceiverMixin:
@classmethod
def invoke_nested(owner) -> int:
def inner() -> int:
return owner.instance_only()
return inner()
class MroOrderMixin:
def dispatch_order(self) -> int:
return self.order_hook()
class FieldShadowMixin:
def dispatch_shadow(self) -> int:
return self.shadow_hook()
class LifecycleReceiverMixin:
def __init_subclass__(cls) -> int:
return cls.lifecycle_hook()
def __new__(cls) -> int:
cls.allocate()
return cls.new_hook()
@classmethod
def allocate(cls) -> int:
return 1
class GenericMixin:
def __class_getitem__(cls, item: object) -> int:
return cls.class_only()
class ArgumentShapeMixin:
def positional_to_keyword_only(self) -> int:
return self.keyword_only_target(1)
def keyword_to_positional_only(self) -> int:
return self.positional_only_target(value=1)
def positional_missing_required_keyword(self) -> int:
return self.required_keyword_target(1)
class ArgumentForwardingMixin:
def forward_first(self, value: int) -> int:
return self.forward_target(value)
def forward_second(self, value: int) -> int:
return self.forward_target(value)
class PrivateNameMixin:
def dispatch_private(self) -> int:
return self.__private_hook()
class AbstractBoundaryMixin:
def dispatch_abstract(self) -> int:
return self.abstract_hook()
class DuplicateDefinitionMixin:
def dispatch_duplicate(self) -> int:
return self.duplicate_hook(1)