Improve error messages for superclass checks

Also add a test for the inherit-field case for this
This commit is contained in:
Asumu Takikawa 2013-08-06 14:24:23 -04:00
parent c16ace02fa
commit ed94d35105
2 changed files with 13 additions and 7 deletions

View File

@ -444,14 +444,14 @@
(check-same optional-external exp-optional-inits (check-same optional-external exp-optional-inits
"optional init argument")) "optional init argument"))
(check-exists super-method-names this%-override-names (check-exists super-method-names this%-override-names
"override method") "overridable method")
(check-exists super-augment-names this%-augment-names (check-exists super-augment-names this%-augment-names
"augment method") "augmentable method")
(check-exists (set-union super-method-names super-augment-names) (check-exists (set-union super-method-names super-augment-names)
this%-inherit-names this%-inherit-names
"inherited method") "method")
(check-exists super-field-names this%-inherit-field-names (check-exists super-field-names this%-inherit-field-names
"inherited field") "field")
(check-absent super-field-names this%-field-names "public field") (check-absent super-field-names this%-field-names "public field")
(check-absent super-method-names this%-public-names "public method") (check-absent super-method-names this%-public-names "public method")
(check-absent super-augment-names this%-pubment-names (check-absent super-augment-names this%-pubment-names
@ -1113,8 +1113,8 @@
(for/or ([m (in-set required)]) (for/or ([m (in-set required)])
(and (not (set-member? actual m)) m))) (and (not (set-member? actual m)) m)))
(when missing (when missing
(tc-error/expr (~a "class definition missing ~a ~a " (tc-error/expr (~a "superclass missing ~a ~a "
"that is required by the expected type") "that the current class requires")
msg missing))) msg missing)))
;; Set<Symbol> Set<Symbol> String -> Void ;; Set<Symbol> Set<Symbol> String -> Void

View File

@ -348,7 +348,7 @@
(define/override (m y) (* 2 y))))) (define/override (m y) (* 2 y)))))
;; fails, superclass missing public for override ;; fails, superclass missing public for override
(check-err #:exn #rx"missing override method m" (check-err #:exn #rx"superclass missing overridable method m"
(: d% (Class [m (Integer -> Integer)])) (: d% (Class [m (Integer -> Integer)]))
(define d% (class object% (super-new) (define d% (class object% (super-new)
(define/override (m y) (* 2 y))))) (define/override (m y) (* 2 y)))))
@ -578,6 +578,12 @@
(inherit-field [y x]) (inherit-field [y x])
(set! y 1))) (set! y 1)))
;; fails, superclass missing inherited field
(check-err #:exn #rx"superclass missing field"
(class (class object% (super-new))
(super-new)
(inherit-field [y x])))
;; fails, missing super method for inherit ;; fails, missing super method for inherit
(check-err (check-err
(class (class object% (super-new)) (super-new) (inherit z))) (class (class object% (super-new)) (super-new) (inherit z)))