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 154f9d1b..86930808 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 @@ -1348,7 +1348,12 @@ (cond [(not init-rest-name) super-init-rest] [(dict-ref annotation-table init-rest-name #f)] [else (-lst Univ)])) - (make-Instance (make-Class super-row init-types field-types + (make-Instance (make-Class ;; only inherit parent row if it's a variable + ;; FIXME: fix this when substitution with rows + ;; is made more sensible + (and (or (F? super-row) (B? super-row)) + super-row) + init-types field-types public-types augment-types init-rest-type))) ;; function->method : Function Type -> Function 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 22714d7b..27958711 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 @@ -1035,6 +1035,19 @@ #:row (make-Row null `([x ,-Integer]) null null #f) #:field ([x -Integer]))) -true-filter)] + ;; test bad manipulation of rows for inheritance + [tc-e (let () + (: c% (Class (init [x String] [y String]))) + (define c% (class object% (super-new) (init x y))) + (: f (All (r #:row) (-> (Class #:row-var r) (Class #:row-var r)))) + (define (f x) x) + ;; should have the same type as c% + (define c2% (f c%)) + (: d% (Class (init [y String]))) + ;; should be the same as inheriting from c% + (define d% (class c2% (super-new [x "foo"]))) + (void)) + -Void] ;; Check simple use of pubment [tc-e (let () (define c%