Resolve instantiates and performs a substitution of the instance to get the concrete type or function. This will panic if the instance is not valid, e.g. if there are a different number of type arguments than the type parameters. If `tc` is non-nil, it de-duplicates the instance against previous in
(tc *types.Context)
| 122 | // When resolving several instances in the same context, it is more efficient |
| 123 | // to use NewResolver to take advantage of caching. |
| 124 | func (i Instance) Resolve(tc *types.Context) types.Type { |
| 125 | instType := i.Object.Type() |
| 126 | if len(i.TArgs) > 0 { |
| 127 | var err error |
| 128 | instType, err = types.Instantiate(tc, instType, i.TArgs, true) |
| 129 | if err != nil { |
| 130 | panic(fmt.Errorf("failed to instantiate %v: %w", i, err)) |
| 131 | } |
| 132 | } |
| 133 | return NewResolver(tc, i).Substitute(instType) |
| 134 | } |
| 135 | |
| 136 | // InstanceSet allows collecting and processing unique Instances. |
| 137 | // |