From 63efae6fffa97eff75f135e50c61564c90290fda Mon Sep 17 00:00:00 2001 From: Asumu Takikawa Date: Wed, 23 Apr 2014 11:45:19 -0400 Subject: [PATCH] Remove unnecessary class typechecking code Also add a test for this part of TR. In particular, it handles registering syntax definitions that are found in a class body. original commit: 92bdd84b079b23f91c0d6088dd5f3690d2d7f796 --- .../typed-racket/base-env/class-prims.rkt | 8 ++------ .../tests/typed-racket/unit-tests/class-tests.rkt | 12 +++++++++++- 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/base-env/class-prims.rkt b/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/base-env/class-prims.rkt index e63e45b6..fcae3455 100644 --- a/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/base-env/class-prims.rkt +++ b/pkgs/typed-racket-pkgs/typed-racket-lib/typed-racket/base-env/class-prims.rkt @@ -274,7 +274,6 @@ ;; this is mostly cribbed from class-internal.rkt (define (expand-expressions stxs ctx def-ctx) (define (class-expand stx) - ;; try using syntax-local-expand-expression? (local-expand stx ctx stop-forms def-ctx)) (let loop ([stxs stxs]) (cond [(null? stxs) null] @@ -288,12 +287,9 @@ ;; i.e., macro definitions in the class body ;; see class-internal.rkt as well [(define-syntaxes (name:id ...) rhs:expr) - (define/with-syntax expanded-rhs - (local-transformer-expand #'rhs 'expression null)) (syntax-local-bind-syntaxes - (syntax->list #'(name ...)) #'expanded-rhs def-ctx) - (cons #'(define-syntaxes (name ...) expanded-rhs) - (loop (cdr stxs)))] + (syntax->list #'(name ...)) #'rhs def-ctx) + (cons stx (loop (cdr stxs)))] [(define-values (name:id ...) rhs:expr) (syntax-local-bind-syntaxes (syntax->list #'(name ...)) #f def-ctx) 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 2487d4f4..cf9c2c39 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 @@ -1413,4 +1413,14 @@ (init x))) #:ret (ret (-poly (A) (-class #:init ([x A #f])))) #:expected (ret (-poly (A) (-class #:init ([x A #f]))) -no-filter -no-obj)] - )) + ;; test uses of a macro in the body of the class + [tc-e + (let () + (define c% + (class object% + (super-new) + (define-syntax-rule (my-meth (m arg ...) . body) + (define/public (m arg ...) . body)) + (my-meth (hello) (displayln "hello world")))) + (send (new c%) hello)) + -Void]))