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 c0bfa7a1..ce512923 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 @@ -528,8 +528,8 @@ (λ (e) (tc-error/expr "Default init value has wrong type"))]) (parameterize ([delay-errors? #f]) (with-lexical-env/extend - (list #'self #'init-args #'extract-arg) - (list (make-Univ) (make-Univ) extract-arg-type) + (list #'extract-arg) + (list extract-arg-type) (tc-expr form))))] ;; If the type can't be found, it means that there was no ;; expected type or no annotation was provided via (: ...). @@ -566,8 +566,8 @@ (λ (e) (tc-error/expr "Default init value has wrong type"))]) (parameterize ([delay-errors? #f]) (with-lexical-env/extend - (list #'self #'init-args #'extract-arg) - (list (make-Univ) (make-Univ) extract-arg-type) + (list #'extract-arg) + (list extract-arg-type) (tc-expr form))))] [else (tc-error/expr "Init argument ~a has no type annotation" @@ -580,8 +580,7 @@ (#%plain-app local-setter:id obj2:id y:id))) #:when (free-identifier=? #'x #'y) #:when (free-identifier=? #'obj1 #'obj2) - (with-lexical-env/extend (list #'self) (list (make-Univ)) - (tc-expr form))] + (tc-expr form)] [_ (void)]))) ;; Syntax -> Dict Dict 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 aa7e3385..5513c475 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 @@ -536,6 +536,15 @@ (: x (Instance (Class))) (define x (new c%))) + ;; test use of `this` in field default + (check-ok + (class: object% + (super-new) + (: x Integer) + (field [x 0]) + (: y Integer) + (field [y (get-field x this)]))) + ;; test different internal/external names (check-ok (define c% (class: object% (super-new)