pulumi/pkg/codegen/internal/test/testdata/cyclic-types
Pat Gavlin 0a45f8d3ab
[codegen/go] Rewrite cyclic types. (#8049)
When computing the type name for a field of an object type, we must
ensure that we do not generate invalid recursive struct types. A struct
type T contains invalid recursion if the closure of its fields and its
struct-typed fields' fields includes a field of type T. A few examples:

Directly invalid:

    type T struct { Invalid T }

Indirectly invalid:

    type T struct { Invalid S }

    type S struct { Invalid T }

In order to avoid generating invalid struct types, we replace all
references to types involved in a cyclical definition with *T. The
examples above therefore become:

(1) type T struct { Valid *T }

(2) type T struct { Valid *S }

    type S struct { Valid *T }

We do this using a rewriter that turns all fields involved in reference
cycles into optional fields.

These changes also include an enhancement to the SDK codegen test
driver in the interest of making iterating and debugging more convenient:  if the -sdk.no-checks flag is passed, the driver will not run post-generation checks.
2021-09-28 07:33:14 -07:00
..
docs [codegen/go] Rewrite cyclic types. (#8049) 2021-09-28 07:33:14 -07:00
dotnet [codegen/go] Rewrite cyclic types. (#8049) 2021-09-28 07:33:14 -07:00
go [codegen/go] Rewrite cyclic types. (#8049) 2021-09-28 07:33:14 -07:00
nodejs [codegen/go] Rewrite cyclic types. (#8049) 2021-09-28 07:33:14 -07:00
python [codegen/go] Rewrite cyclic types. (#8049) 2021-09-28 07:33:14 -07:00
schema.yaml [codegen/go] Rewrite cyclic types. (#8049) 2021-09-28 07:33:14 -07:00