diff --git a/collects/scheme/private/class-internal.ss b/collects/scheme/private/class-internal.ss index 638d34418a..6fd91108d9 100644 --- a/collects/scheme/private/class-internal.ss +++ b/collects/scheme/private/class-internal.ss @@ -2862,6 +2862,7 @@ (unless (null? (class/c-inits ctc)) (let () + (define inits+contracts (map cons (class/c-inits ctc) (class/c-init-contracts ctc))) (define (grab-same-inits lst) (if (null? lst) (values null null) @@ -2889,8 +2890,7 @@ (blame-swap blame))]) (loop (cdr init-args) (cdr inits/c) - (cons (cons (car init-arg) - (p (cdr init-arg))) + (cons (cons (car init-arg) (p (cdr init-arg))) handled-args)))] [else (loop (cdr init-args) inits/c @@ -2899,7 +2899,7 @@ c (lambda (the-obj super-go si_c si_inited? si_leftovers init-args) (let ([init-args - (let loop ([inits/c (map cons (class/c-inits ctc) (class/c-init-contracts ctc))] + (let loop ([inits/c inits+contracts] [handled-args init-args]) (if (null? inits/c) handled-args diff --git a/collects/tests/mzscheme/contract-test.ss b/collects/tests/mzscheme/contract-test.ss index e39ee9aab6..401b4b43e0 100644 --- a/collects/tests/mzscheme/contract-test.ss +++ b/collects/tests/mzscheme/contract-test.ss @@ -4650,6 +4650,49 @@ 'neg)] [d% (class c% (super-new) (inherit m) (define/public (f) (m 5)))]) (send (new d%) f))) + + (test/spec-passed + 'class/c-higher-order-init-1 + '(let ([c% (contract (class/c (init [a number?])) + (class object% (super-new) (init a)) + 'pos + 'neg)]) + (new c% [a 3]))) + + (test/neg-blame + 'class/c-higher-order-init-2 + '(let ([c% (contract (class/c (init [a number?])) + (class object% (super-new) (init a)) + 'pos + 'neg)]) + (new c% [a #t]))) + + (test/spec-passed + 'class/c-higher-order-init-3 + '(let ([c% (class object% (super-new) (init a))] + [d% (contract (class/c (init [a number?] [a string?])) + (class a% (super-new) (init a)) + 'pos + 'neg)]) + (new c% [a 3] [a "foo"]))) + + (test/neg-blame + 'class/c-higher-order-init-4 + '(let ([c% (class object% (super-new) (init a))] + [d% (contract (class/c (init [a number?] [a string?])) + (class a% (super-new) (init a)) + 'pos + 'neg)]) + (new c% [a 3] [a 4]))) + + (test/spec-blame + 'class/c-higher-order-init-5 + '(let ([c% (class object% (super-new) (init a))] + [d% (contract (class/c (init [a number?] [a string?])) + (class a% (super-new) (init a)) + 'pos + 'neg)]) + (new c% [a "bar"] [a "foo"]))) (test/spec-passed 'class/c-higher-order-method-1