fix object/c & fields that just have to exist

closes PR 14437
This commit is contained in:
Robby Findler 2014-04-07 22:18:16 -05:00
parent 74a2b677e8
commit a3d77986cb
2 changed files with 30 additions and 2 deletions

View File

@ -158,4 +158,32 @@
'pos 'pos
'neg)]) 'neg)])
(set-field! n pre-o #t) (set-field! n pre-o #t)
(get-field n o)))) (get-field n o)))
(test/spec-passed/result
'object/c-field-existence
'(send (contract
(object/c
(field foo bar)
(baz (->m integer? integer?)))
(new (class object%
(super-new)
(field (foo 0) (bar 0))
(define/public (baz n) n)))
'pos 'neg)
baz 1)
1)
(test/spec-passed/result
'object/c-field-existence2
'(send (contract
(object/c
(field foo bar)
(baz (->m integer? (listof integer?))))
(new (class object%
(super-new)
(field (foo 0) (bar 1))
(define/public (baz n) (list foo bar))))
'pos 'neg)
baz 1)
'(0 1)))

View File

@ -1307,7 +1307,7 @@
(unless (null? fields) (unless (null? fields)
(for ([f (in-list fields)] (for ([f (in-list fields)]
[c (in-list field-contracts)]) [c (in-list field-contracts)])
(when c (unless (just-check-existence? c)
(define fi (hash-ref field-ht f)) (define fi (hash-ref field-ht f))
(define p-pos ((contract-projection c) (blame-add-field-context blame f #:swap? #f))) (define p-pos ((contract-projection c) (blame-add-field-context blame f #:swap? #f)))
(define p-neg ((contract-projection c) (blame-add-field-context blame f #:swap? #t))) (define p-neg ((contract-projection c) (blame-add-field-context blame f #:swap? #t)))