diff --git a/pkgs/racket-test/tests/racket/contract/collapsible-arrow.rkt b/pkgs/racket-test/tests/racket/contract/collapsible-arrow.rkt index ef4a8a4085..f8e4a41689 100644 --- a/pkgs/racket-test/tests/racket/contract/collapsible-arrow.rkt +++ b/pkgs/racket-test/tests/racket/contract/collapsible-arrow.rkt @@ -887,10 +887,33 @@ '(3 2 1)) (test/spec-passed/result - 'calculate-drops-2 + 'calculate-drops:trusted-chaperone + '(let* ([ctc1 (coerce-contract/f (box/c symbol?))] + [ctcs (list ctc1 ctc1 ctc1 ctc1 ctc1)]) + (calculate-drops ctcs)) + '(3 2 1)) + + (test/spec-passed/result + 'calculate-drops:trusted-impersonator '(let* ([ctc1 (coerce-contract/f (object/c))] [ctcs (list ctc1 ctc1 ctc1 ctc1 ctc1)]) (calculate-drops ctcs)) + '(3 2 1)) + + (test/spec-passed/result + 'calculate-drops:untrusted-chaperone + '(let* ([lnp (λ (v np) v)] + [ctc1 (coerce-contract/f (make-chaperone-contract #:late-neg-projection lnp))] + [ctcs (list ctc1 ctc1 ctc1)]) + (calculate-drops ctcs)) + '()) + + (test/spec-passed/result + 'calculate-drops:untrusted-impersonator + '(let* ([lnp (λ (v np) v)] + [ctc1 (coerce-contract/f (make-contract #:late-neg-projection lnp))] + [ctcs (list ctc1 ctc1 ctc1)]) + (calculate-drops ctcs)) '()) (test/spec-passed/result @@ -918,7 +941,7 @@ [c4 (coerce-contract/f (object/c))] [ctcs (list c1 c2 c3 c4 c4 c2 c3 c1 c3 c2 c4 c1 c4)]) (calculate-drops ctcs)) - '(7 5 6)) + '(10 7 4 5 6)) (test/spec-passed/result 'calculate-drops-6 diff --git a/racket/collects/racket/contract/private/collapsible-common.rkt b/racket/collects/racket/contract/private/collapsible-common.rkt index 6da76248fe..2776930076 100644 --- a/racket/collects/racket/contract/private/collapsible-common.rkt +++ b/racket/collects/racket/contract/private/collapsible-common.rkt @@ -183,7 +183,11 @@ ([flat (in-list flats)] [i (in-naturals)]) (cond - [(or (flat-contract-struct? flat) (chaperone-contract-struct? flat)) + [(or (flat-contract-struct? flat) + (trusted-contract-struct? flat)) + ;; Drop contracts that (1) do not change their behavior and (2) are + ;; between other eq? contracts. (Trusted chaperones and + ;; impersonators definitely don't change themselves.) (cond [(hash-ref seen flat #f) (define maybe-index (hash-ref maybe-drop flat #f))