From ab47d1bb2561d2c4ed3c42ce47dd0b10385bb630 Mon Sep 17 00:00:00 2001 From: Asumu Takikawa Date: Sun, 7 Sep 2014 17:18:40 -0400 Subject: [PATCH] Handle methods that have opt args but no kws Closes PR 14726 --- .../typed-racket/typecheck/check-class-unit.rkt | 2 +- .../tests/typed-racket/unit-tests/class-tests.rkt | 14 +++++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/typecheck/check-class-unit.rkt b/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/typecheck/check-class-unit.rkt index 278cc255a9..c6480f824f 100644 --- a/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/typecheck/check-class-unit.rkt +++ b/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/typecheck/check-class-unit.rkt @@ -1421,7 +1421,7 @@ core-body ...))) method-body ...)]) m) - kw:kw-lambda^) + (~or kw:kw-lambda^ opt:opt-lambda^)) (do-register #'self-param #'meth-name)] ;; case-lambda methods [(let-values ([(meth-name:id) diff --git a/pkgs/typed-racket-pkgs/typed-racket-test/tests/typed-racket/unit-tests/class-tests.rkt b/pkgs/typed-racket-pkgs/typed-racket-test/tests/typed-racket/unit-tests/class-tests.rkt index 2f43ca82c2..3cdceaff89 100644 --- a/pkgs/typed-racket-pkgs/typed-racket-test/tests/typed-racket/unit-tests/class-tests.rkt +++ b/pkgs/typed-racket-pkgs/typed-racket-test/tests/typed-racket/unit-tests/class-tests.rkt @@ -1493,4 +1493,16 @@ [tc-err (make-object (ann object% ClassTop)) #:msg #rx"cannot instantiate.*ClassTop"] [tc-err (make-object 3) - #:msg #rx"value of a non-class type"])) + #:msg #rx"value of a non-class type"] + ;; PR 14726 + ;; test opt-arg but non-keyword method + [tc-e (let () + (define-type-alias A% + (Class [foo (->* [Integer] Void)])) + (: a% A%) + (define a% + (class object% + (super-new) + (define/public (foo [i #f]) (void)))) + (new a%)) + (-object #:method ([foo (t:-> -Integer -Void)]))]))