Add ClassTop type
Still TODO are better error messages when a ClassTop is encountered for subclassing or instantiation. original commit: e26742e736f59ebb4beada50dd813105de89948d
This commit is contained in:
parent
6eb16b9f2f
commit
d70a59d5cb
|
@ -58,6 +58,13 @@ library.
|
|||
clause may appear in a class type.
|
||||
}
|
||||
|
||||
@defidform[ClassTop]{
|
||||
The supertype of all class types. A value of this type
|
||||
cannot be used for subclassing, object creation, or most
|
||||
other class functions. Its primary use is for reflective
|
||||
operations such as @racket[is-a?].
|
||||
}
|
||||
|
||||
@defform[#:literals (field)
|
||||
(Object object-type-clause ...)
|
||||
#:grammar ([object-type-clause name+type
|
||||
|
|
|
@ -22,6 +22,8 @@
|
|||
(only-in (types numeric-tower) [-Number N])
|
||||
(only-in (rep type-rep)
|
||||
make-Class
|
||||
make-ClassTop
|
||||
make-Instance
|
||||
make-Name
|
||||
make-ValuesDots
|
||||
make-MPairTop
|
||||
|
@ -962,6 +964,9 @@
|
|||
|
||||
;; Section 6.2 (Classes)
|
||||
[object% (make-Class #f null null null null)]
|
||||
[is-a? (-> (make-Instance (make-Class #f null null null null))
|
||||
(make-ClassTop)
|
||||
-Boolean)]
|
||||
|
||||
;; Section 9.1
|
||||
[exn:misc:match? (-> Univ B)]
|
||||
|
|
|
@ -114,6 +114,7 @@
|
|||
[Prompt-TagTop -Prompt-TagTop]
|
||||
[Continuation-Mark-KeyTop -Continuation-Mark-KeyTop]
|
||||
[Struct-TypeTop (make-StructTypeTop)]
|
||||
[ClassTop (make-ClassTop)]
|
||||
[Keyword -Keyword]
|
||||
[Thread -Thread]
|
||||
[Resolved-Module-Path -Resolved-Module-Path]
|
||||
|
|
|
@ -487,6 +487,10 @@
|
|||
(map list mname (map type-rec-id mty))
|
||||
(map list aname (map type-rec-id aty)))])])
|
||||
|
||||
;; Supertype of all Class types, cannot instantiate
|
||||
;; or subclass these
|
||||
(def-type ClassTop () [#:fold-rhs #:base])
|
||||
|
||||
;; row-ext : Option<(U F B Row)>
|
||||
;; row : Row
|
||||
;;
|
||||
|
|
|
@ -499,6 +499,7 @@
|
|||
[(Syntax: t) `(Syntaxof ,(t->s t))]
|
||||
[(Instance: (and (? has-name?) cls)) `(Instance ,(t->s cls))]
|
||||
[(Instance: (? Class? cls)) (class->sexp cls #:object? #t)]
|
||||
[(ClassTop:) 'ClassTop]
|
||||
[(? Class?) (class->sexp type)]
|
||||
[(Result: t (FilterSet: (Top:) (Top:)) (Empty:)) (type->sexp t)]
|
||||
[(Result: t fs (Empty:)) `(,(type->sexp t) : ,(filter->sexp fs))]
|
||||
|
|
|
@ -599,6 +599,7 @@
|
|||
(and ;; Note that init & augment clauses don't matter for objects
|
||||
(subtype-clause? method-map method-map*)
|
||||
(subtype-clause? field-map field-map*))]
|
||||
[((? Class?) (ClassTop:)) A0]
|
||||
[((Class: row inits fields methods augments)
|
||||
(Class: row* inits* fields* methods* augments*))
|
||||
;; TODO: should the result be folded instead?
|
||||
|
|
Loading…
Reference in New Issue
Block a user