From f4f6f8c52c70e3baa3ceb10b8e15b7dcfeaa32fe Mon Sep 17 00:00:00 2001 From: Asumu Takikawa Date: Tue, 22 May 2012 15:22:49 -0400 Subject: [PATCH] For abstracts, the super method just calls void. Since mixins rely on super calls to possibly abstract methods, we want to ensure that the super call will not error when it gets to an abstract method. However, external method calls should still raise an error for abstract methods. --- collects/racket/private/class-internal.rkt | 5 +++++ collects/tests/racket/object.rktl | 4 ++-- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/collects/racket/private/class-internal.rkt b/collects/racket/private/class-internal.rkt index 9d7e5a7211..1567de0a59 100644 --- a/collects/racket/private/class-internal.rkt +++ b/collects/racket/private/class-internal.rkt @@ -2411,6 +2411,11 @@ (append new-augonly-indices new-final-indices new-abstract-indices new-normal-indices) new-methods) + ;; Add only abstracts, making sure the super method just calls (void) + (let ([dummy (lambda args (void))]) + (for-each (lambda (index) + (vector-set! super-methods index dummy)) + new-abstract-indices)) ;; Override old methods: (for-each (lambda (index method id) (when (eq? 'final (vector-ref meth-flags index)) diff --git a/collects/tests/racket/object.rktl b/collects/tests/racket/object.rktl index 5c16338370..7ae4ad33e9 100644 --- a/collects/tests/racket/object.rktl +++ b/collects/tests/racket/object.rktl @@ -825,13 +825,13 @@ (test 11 'abstract (send o bar)) (test 15 'abstract (send o baz))) -;; super calls to an abstract should raise an error +;; super calls to an abstract should just be (void) (let ([foo% (class (class object% (super-new) (abstract m)) (super-new) (define/override (m) (super m)))]) - (err/rt-test (send (new foo%) m) exn:fail:object?)) + (test (void) 'super (send (new foo%) m))) ;; failing to implement abstract methods (define bad-leaf% (class bt% (inherit-field number)))