From c07f80cc07b1999eba98ef45a396c4c18815f04c Mon Sep 17 00:00:00 2001 From: Asumu Takikawa Date: Wed, 21 Aug 2013 17:24:58 -0400 Subject: [PATCH] Allow polymorphic method types original commit: 7d7f23589f31eab49cec51e63c40d7065b0e2596 --- .../typed-racket/typecheck/check-class-unit.rkt | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) 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 85419fdf..26e3f385 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 @@ -1165,7 +1165,13 @@ (match-define (arr: doms rng rest drest kws) arr) (make-arr (cons self-type doms) rng rest drest kws))) (make-Function fixed-arrs)] - [_ (tc-error "function->method: internal error")])) + [(Poly: ns body) + (make-Poly ns (function->method body self-type))] + [(PolyDots: ns body) + (make-PolyDots ns (function->method body self-type))] + [(PolyRow: ns constraints body) + (make-PolyRow ns constraints (function->method body self-type))] + [_ (int-err "function->method: ~a" type)])) ;; method->function : Function -> Function ;; Turn a "real" method type back into a function type @@ -1177,6 +1183,12 @@ (match-define (arr: doms rng rest drest kws) arr) (make-arr (cdr doms) rng rest drest kws))) (make-Function fixed-arrs)] + [(Poly: ns body) + (make-Poly ns (method->function body))] + [(PolyDots: ns body) + (make-PolyDots ns (method->function type))] + [(PolyRow: ns constraints body) + (make-PolyRow ns constraints (method->function type))] [_ (tc-error/expr "expected a function type for method")])) ;; annotate-method : Syntax Type -> Syntax