Make sure superclass mandatory inits are provided

original commit: b1627984e258df8f23d1295ec554fe0d5b128ea5
This commit is contained in:
Asumu Takikawa 2013-05-20 23:21:57 -04:00
parent a91d41a453
commit 6fd920cee9
2 changed files with 14 additions and 1 deletions

View File

@ -377,7 +377,13 @@
list
(#%plain-app cons (quote init-id) arg:expr)
...))
(for ([init-id (syntax->datum #'(init-id ...))]
(define provided-inits (syntax->datum #'(init-id ...)))
(for ([(name val) (in-dict super-inits)]
#:when (not (cadr val)))
(unless (member name provided-inits)
(tc-error/expr "mandatory superclass init ~a not provided"
name)))
(for ([init-id provided-inits]
[init-arg (syntax->list #'(arg ...))])
(define maybe-expected (dict-ref super-inits init-id #f))
(if maybe-expected

View File

@ -338,6 +338,13 @@
(init x)))
(new d%))
;; fails, mandatory super-class init not provided
(check-err
(class: (class: object% (super-new)
(: x Integer)
(init x))
(super-new)))
;; test different internal/external names
(check-ok
(define c% (class: object% (super-new)