handle aliases to foreign named types properly
When such an alias name was used to define an embedded field, we handled that case gracefully via the code using: tf.info.Uses[node].(*types.TypeName) Unfortunately, when the same field name was used elsewhere, such as a composite literal, tf.Info.Uses gave us a *types.Var, not a *types.TypeName, meaning we could no longer tell if this was an alias, or what it pointed to. Thus, we failed to obfuscate the name properly in the added test case: > garble build [stderr] # test/main/sub xxWZf66u.go:36: unknown field 'foreignAlias' in struct literal of type smhWelwn It doesn't seem like any of the go/types APIs allows us to obtain the *types.TypeName directly in this scenario. Thus, use a trick that we used before: after typechecking, but before obfuscating, record all embedded struct field *types.Var which are aliases via a map, where the value holds the *types.TypeName for the alias. Updates #349.pull/352/head
parent
e2ddce75a7
commit
64317883c9
Loading…
Reference in New Issue