Adjust type variable syntax for typed classes

This makes it consistent with other forms like the
new `lambda` form.
This commit is contained in:
Asumu Takikawa 2014-02-21 11:47:08 -05:00
parent 315034bbe5
commit 8ce376f503
3 changed files with 6 additions and 8 deletions

View File

@ -50,8 +50,8 @@ library.
expr expr
(begin class-clause ...)] (begin class-clause ...)]
[maybe-type-parameters (code:line) [maybe-type-parameters (code:line)
(code:line #:forall type-variable) (code:line #:forall (type-variable ...))
(code:line #:forall (type-variable ...))] (code:line #: (type-variable ...))]
[init-decl id/type [init-decl id/type
[renamed] [renamed]
[renamed : type-expr] [renamed : type-expr]

View File

@ -123,9 +123,7 @@
(:)) (:))
(define-splicing-syntax-class maybe-type-parameter (define-splicing-syntax-class maybe-type-parameter
(pattern (~seq #:forall type-variable:id) (pattern (~seq (~or #:∀ #:forall) (type-variable:id ...))
#:attr type-variables #'(type-variable))
(pattern (~seq #:forall (type-variable:id ...))
#:attr type-variables #'(type-variable ...)) #:attr type-variables #'(type-variable ...))
(pattern (~seq) (pattern (~seq)
#:attr type-variables #'())) #:attr type-variables #'()))

View File

@ -3322,7 +3322,7 @@
[tc-e (let () [tc-e (let ()
(define point% (define point%
(class object% (class object%
#:forall X #:(X)
(super-new) (super-new)
(init-field [x : X] [y : X]))) (init-field [x : X] [y : X])))
(new (inst point% Integer) [x 0] [y 5]) (new (inst point% Integer) [x 0] [y 5])
@ -3359,13 +3359,13 @@
#:msg #rx"expected: X.*given: String"] #:msg #rx"expected: X.*given: String"]
;; fails because default init value cannot be polymorphic ;; fails because default init value cannot be polymorphic
[tc-err (class object% [tc-err (class object%
#:forall Z #:forall (Z)
(super-new) (super-new)
(init-field [x : Z] [y : Z 0])) (init-field [x : Z] [y : Z 0]))
#:msg #rx"Default init value has wrong type"] #:msg #rx"Default init value has wrong type"]
;; fails because default field value cannot be polymorphic ;; fails because default field value cannot be polymorphic
[tc-err (class object% [tc-err (class object%
#:forall Z #:forall (Z)
(super-new) (super-new)
(field [x : Z "a"])) (field [x : Z "a"]))
#:msg #rx"expected: Z.*given: String"] #:msg #rx"expected: Z.*given: String"]