Just remove this line:

```
&& D_DECL_STATIC_CHAIN (decl_tree) == 1
```

Reason being in non-release code, in/out contracts from templates could be emitted in multiple places.