Add ClassTop type
Still TODO are better error messages when a ClassTop is encountered for subclassing or instantiation.
This commit is contained in:
parent
afb1417114
commit
e26742e736
|
@ -58,6 +58,13 @@ library.
|
||||||
clause may appear in a class type.
|
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)
|
@defform[#:literals (field)
|
||||||
(Object object-type-clause ...)
|
(Object object-type-clause ...)
|
||||||
#:grammar ([object-type-clause name+type
|
#:grammar ([object-type-clause name+type
|
||||||
|
|
|
@ -22,6 +22,8 @@
|
||||||
(only-in (types numeric-tower) [-Number N])
|
(only-in (types numeric-tower) [-Number N])
|
||||||
(only-in (rep type-rep)
|
(only-in (rep type-rep)
|
||||||
make-Class
|
make-Class
|
||||||
|
make-ClassTop
|
||||||
|
make-Instance
|
||||||
make-Name
|
make-Name
|
||||||
make-ValuesDots
|
make-ValuesDots
|
||||||
make-MPairTop
|
make-MPairTop
|
||||||
|
@ -962,6 +964,9 @@
|
||||||
|
|
||||||
;; Section 6.2 (Classes)
|
;; Section 6.2 (Classes)
|
||||||
[object% (make-Class #f null null null null)]
|
[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
|
;; Section 9.1
|
||||||
[exn:misc:match? (-> Univ B)]
|
[exn:misc:match? (-> Univ B)]
|
||||||
|
|
|
@ -114,6 +114,7 @@
|
||||||
[Prompt-TagTop -Prompt-TagTop]
|
[Prompt-TagTop -Prompt-TagTop]
|
||||||
[Continuation-Mark-KeyTop -Continuation-Mark-KeyTop]
|
[Continuation-Mark-KeyTop -Continuation-Mark-KeyTop]
|
||||||
[Struct-TypeTop (make-StructTypeTop)]
|
[Struct-TypeTop (make-StructTypeTop)]
|
||||||
|
[ClassTop (make-ClassTop)]
|
||||||
[Keyword -Keyword]
|
[Keyword -Keyword]
|
||||||
[Thread -Thread]
|
[Thread -Thread]
|
||||||
[Resolved-Module-Path -Resolved-Module-Path]
|
[Resolved-Module-Path -Resolved-Module-Path]
|
||||||
|
|
|
@ -487,6 +487,10 @@
|
||||||
(map list mname (map type-rec-id mty))
|
(map list mname (map type-rec-id mty))
|
||||||
(map list aname (map type-rec-id aty)))])])
|
(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-ext : Option<(U F B Row)>
|
||||||
;; row : Row
|
;; row : Row
|
||||||
;;
|
;;
|
||||||
|
|
|
@ -499,6 +499,7 @@
|
||||||
[(Syntax: t) `(Syntaxof ,(t->s t))]
|
[(Syntax: t) `(Syntaxof ,(t->s t))]
|
||||||
[(Instance: (and (? has-name?) cls)) `(Instance ,(t->s cls))]
|
[(Instance: (and (? has-name?) cls)) `(Instance ,(t->s cls))]
|
||||||
[(Instance: (? Class? cls)) (class->sexp cls #:object? #t)]
|
[(Instance: (? Class? cls)) (class->sexp cls #:object? #t)]
|
||||||
|
[(ClassTop:) 'ClassTop]
|
||||||
[(? Class?) (class->sexp type)]
|
[(? Class?) (class->sexp type)]
|
||||||
[(Result: t (FilterSet: (Top:) (Top:)) (Empty:)) (type->sexp t)]
|
[(Result: t (FilterSet: (Top:) (Top:)) (Empty:)) (type->sexp t)]
|
||||||
[(Result: t fs (Empty:)) `(,(type->sexp t) : ,(filter->sexp fs))]
|
[(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
|
(and ;; Note that init & augment clauses don't matter for objects
|
||||||
(subtype-clause? method-map method-map*)
|
(subtype-clause? method-map method-map*)
|
||||||
(subtype-clause? field-map field-map*))]
|
(subtype-clause? field-map field-map*))]
|
||||||
|
[((? Class?) (ClassTop:)) A0]
|
||||||
[((Class: row inits fields methods augments)
|
[((Class: row inits fields methods augments)
|
||||||
(Class: row* inits* fields* methods* augments*))
|
(Class: row* inits* fields* methods* augments*))
|
||||||
;; TODO: should the result be folded instead?
|
;; TODO: should the result be folded instead?
|
||||||
|
|
Loading…
Reference in New Issue
Block a user