Skip to content

go/types: generic methods possibly violate Info.Instances invariant #79657

@dominikh

Description

@dominikh

The documentation for types.Info.Instances states the following invariant:

// Invariant: Instantiating Uses[id].Type() with Instances[id].TypeArgs
// results in an equivalent of Instances[id].Type.

Depending on how we interpret "equivalent", this might not be true for calls of generic methods. Entries in Instances will have signatures without receivers, while using types.Instantiate maintains receivers: https://go.dev/play/p/ffy1wUtHGX1?v=gotip

Now, the documentation of types.Signature states that "[t]he receiver is ignored when comparing signatures for identity", but it is not clear whether "equivalent" refers to type identity. I find the loss of the receiver inconvenient either way.

@griesemer

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type
No fields configured for issues without a type.

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions