From 649ec8d8234ccda55b81930a0cb07d66b4a855c6 Mon Sep 17 00:00:00 2001 From: Andy Wingo Date: Mon, 26 Jan 2015 17:54:26 +0100 Subject: Accessor methods only apply to subclasses with their slot * libguile/goops.c (is_accessor_method, scm_compute_applicable_methods): Fix regression from 51f66c912078a25ab0380c8fc070abb73d178d98 (2009). Accessor methods are added on each subclass on which the slot is present; therefore if a subclass doesn't have a method, then the methods doesn't apply. Truly fixes #17355, unlike 583a23bf104c84d9617222856e188f3f3af4934d. * module/oop/goops.scm (compute-cmethod, compute-getter-method) (compute-setter-method): Revert earlier changes. * test-suite/tests/goops.test ("accessor slots"): Update for new expectations, in agreement with Guile 1.8. --- module/oop/goops.scm | 54 ++++++++++++++++++++-------------------------------- 1 file changed, 21 insertions(+), 33 deletions(-) (limited to 'module/oop') diff --git a/module/oop/goops.scm b/module/oop/goops.scm index 486a652c0..771a56774 100644 --- a/module/oop/goops.scm +++ b/module/oop/goops.scm @@ -107,35 +107,14 @@ (define (compute-cmethod methods types) (match methods ((method . methods) - (cond - ((is-a? method ) - (match types - ((class . _) - (let* ((name (car (accessor-method-slot-definition method))) - (g-n-s (assq name (slot-ref class 'getters-n-setters))) - (init-thunk (cadr g-n-s)) - (g-n-s (cddr g-n-s))) - (match types - ((class) - (cond ((pair? g-n-s) - (make-generic-bound-check-getter (car g-n-s))) - (init-thunk - (standard-get g-n-s)) - (else - (bound-check-get g-n-s)))) - ((class value) - (if (pair? g-n-s) - (cadr g-n-s) - (standard-set g-n-s)))))))) - (else - (let ((make-procedure (slot-ref method 'make-procedure))) - (if make-procedure - (make-procedure - (if (null? methods) - (lambda args - (no-next-method (method-generic-function method) args)) - (compute-cmethod methods types))) - (method-procedure method)))))))) + (let ((make-procedure (slot-ref method 'make-procedure))) + (if make-procedure + (make-procedure + (if (null? methods) + (lambda args + (no-next-method (method-generic-function method) args)) + (compute-cmethod methods types))) + (method-procedure method)))))) (eval-when (expand load eval) @@ -1138,17 +1117,26 @@ slots (slot-ref class 'getters-n-setters))) (define-method (compute-getter-method (class ) g-n-s) - (let ((name (car g-n-s))) + (let ((init-thunk (cadr g-n-s)) + (g-n-s (cddr g-n-s))) (make #:specializers (list class) - #:procedure (lambda (o) (slot-ref o name)) + #:procedure (cond ((pair? g-n-s) + (make-generic-bound-check-getter (car g-n-s))) + (init-thunk + (standard-get g-n-s)) + (else + (bound-check-get g-n-s))) #:slot-definition g-n-s))) (define-method (compute-setter-method (class ) g-n-s) - (let ((name (car g-n-s))) + (let ((init-thunk (cadr g-n-s)) + (g-n-s (cddr g-n-s))) (make #:specializers (list class ) - #:procedure (lambda (o v) (slot-set! o name v)) + #:procedure (if (pair? g-n-s) + (cadr g-n-s) + (standard-set g-n-s)) #:slot-definition g-n-s))) (define (make-generic-bound-check-getter proc) -- cgit v1.2.3