We're updating the issue view to help you get more done. 

implements? may report false positives

Description

The cljs.core/implements? checks whether a protocol is implemented via a property on the tested object. When implementing the protocol this property will be set to true.

1 2 3 4 5 6 7 8 // the implementation protocol.check.Dummy.prototype.protocol$check$TheProtocol$ = true; // the check (implements? TheProtocol x) ((!((x == null)))?(((false) || (x.protocol$check$TheProtocol$))?true:false):false) // only the relevant bit x.protocol$check$TheProtocol$

This works fine under :none but :advanced may rename this to something like x.A. If you now try to check (implements? TheProtocol js/window) for example it may (or may not) report a false positive. For larger projects the likelyhood of creating a false positives goes way up since window contains all the variables created by the advanced compiled js.

The attached patch changes the patch the emitted code to check x.protocol$check$TheProtocol$ === true which reduces the chance of a false positive by a lot. We might chose another sentinel value instead to reduce the chance some more, this seems good enough though.

Environment

None

Status

Assignee

Unassigned

Reporter

Thomas Heller

Labels

None

Approval

None

Patch

Code

Priority

Minor