Add readonly to function types in typing_print json
commit20a8aa789607d248061a5357c947b1696ed1387f
authorJames Wu <jjwu@fb.com>
Fri, 13 May 2022 23:58:25 +0000 (13 16:58 -0700)
committerFacebook GitHub Bot <facebook-github-bot@users.noreply.github.com>
Fri, 13 May 2022 23:58:25 +0000 (13 16:58 -0700)
tree3c32151178674ca2e201ffb20653991ab998b55a
parent39d50d460c185f4ba3b8e3a4b34814970e3b202b
Add readonly to function types in typing_print json

Summary:
Implement some extra readonly info into json for typing_print. This allows `--type-at-pos-batch` to read readonlyness of parameters, return types, and readonly_this.

This field only appears when a function has the readonly property, so backwards compatibility is preserved.

Specifically,
a function type will contain the following optional JSON fields:

```
{
"kind": "function",
"readonly_this": true # if the function is readonly
"params": ...
"readonly_return":true # if the function returns a readonly result
"result": ...
}
```
Parameters will have a readonly field:
```
{
callConvention: ...
readonly: true # if parameter is readonly
type: ...
}
```

Reviewed By: viratyosin

Differential Revision: D36384909

fbshipit-source-id: b2ef532991737e6ad25856907d517756fa285541
hphp/hack/src/typing/typing_print.ml
hphp/hack/test/integration/common_tests.py
hphp/hack/test/integration/data/simple_repo/foo_readonly.php [new file with mode: 0644]