Browse files

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.
  • Loading branch information...
1 parent 11c589a commit f4f6f8c52c70e3baa3ceb10b8e15b7dcfeaa32fe @takikawa takikawa committed May 22, 2012
Showing with 7 additions and 2 deletions.
  1. +5 −0 collects/racket/private/class-internal.rkt
  2. +2 −2 collects/tests/racket/object.rktl
@@ -2411,6 +2411,11 @@
(append new-augonly-indices new-final-indices
new-abstract-indices new-normal-indices)
+ ;; 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))
@@ -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%
(abstract m))
(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)))

0 comments on commit f4f6f8c

Please sign in to comment.