[go: up one dir, main page]

compute-applicable-methods-using-classes incorrect

Hi,

Compute-applicable-methods-using-classes is incorrect. Here is an example that illustrates the problem:

    > (defclass a () ())

    #<The STANDARD-CLASS COMMON-LISP-USER::A>
    > (defclass b () ())

    #<The STANDARD-CLASS COMMON-LISP-USER::B>
    > (defclass c (a b) ())

    #<The STANDARD-CLASS COMMON-LISP-USER::C>
    > (defmethod f ((o a)))

    #<standard-method F (#<The STANDARD-CLASS COMMON-LISP-USER::A>)>
    > (defmethod f ((o b)))

    #<standard-method F (#<The STANDARD-CLASS COMMON-LISP-USER::B>)>
    > (clos:compute-applicable-methods-using-classes #'f (list (find-class 'c)))

    Condition of type: SIMPLE-ERROR
    The type specifiers #<The STANDARD-CLASS COMMON-LISP-USER::B> and #<The STANDARD-CLASS COMMON-LISP-USER::A> can not be disambiguatedwith respect to the argument specializer: #<The STANDARD-CLASS STANDARD-CLASS>

    Available restarts:

    1. (RESTART-TOPLEVEL) Go back to Top-Level REPL.

    Broken at SI:BYTECODES. [Evaluation of: (CLOS:COMPUTE-APPLICABLE-METHODS-USING-CLASSES #'F ...)] In: #<process TOP-LEVEL>.

The problem is caused by line 269 in src/clos/kernel.lsp, where class-of of each args is taken although sort-applicable-methods is already called with classes from std-compute-applicable-methods-using-classes (line 262). The behaviour of sort-applicable-methods is correct when being called from std-compute-applicable-methods, though (line 222).

The best way to fix this is probably to move the computation of args-specializers (line 269) out of sort-applicable-methods into std-compute-applicable-methods, such that sort-applicable-methods always receives classes from both methods.