diff --git a/collects/tests/typed-racket/succeed/variance-test.rkt b/collects/tests/typed-racket/succeed/variance-test.rkt new file mode 100644 index 00000000..63ac07cc --- /dev/null +++ b/collects/tests/typed-racket/succeed/variance-test.rkt @@ -0,0 +1,16 @@ +#lang typed/racket + +;; Test a variance regression + +(struct: (A) Foo ([elems : (Vectorof A)])) + +(: make-foo (All (A) (A -> (Foo A)))) +(define (make-foo x) (Foo (vector x))) + +;; Need a module+ here because this test failed +;; originally when variance information wasn't preserved +;; across modules. +(module+ test + ;; should type check, but won't if the element has + ;; the Any type incorrectly + (+ 1 (vector-ref (Foo-elems (make-foo 1)) 0))) diff --git a/collects/typed-racket/rep/free-variance.rkt b/collects/typed-racket/rep/free-variance.rkt index 8ded52ed..77e5e793 100644 --- a/collects/typed-racket/rep/free-variance.rkt +++ b/collects/typed-racket/rep/free-variance.rkt @@ -46,7 +46,7 @@ (match var ((== Covariant) #'Covariant) ((== Contravariant) #'Contravariant) - ((== Invariant) #'Contravariant) + ((== Invariant) #'Invariant) ((== Constant) #'Constant) ((== Dotted) #'Dotted)))