internal/wire: factor out common code in solve (#98)

- Fixed a bug when a interface is bind to a value wire would fail to record it is used.
- Also rename ProvidedType.ConcreteType to Type since it doesn't necessarily returns a concrete type.

Fixes #72
This commit is contained in:
shantuo
2018-12-14 12:56:01 -08:00
committed by Ross Light
parent f9328a1d90
commit 4243b011bd
7 changed files with 103 additions and 41 deletions

View File

@@ -939,8 +939,14 @@ func (pt ProvidedType) IsNil() bool {
return pt.p == nil && pt.v == nil && pt.a == nil
}
// ConcreteType returns the concrete type that was provided.
func (pt ProvidedType) ConcreteType() types.Type {
// Type returns the output type.
//
// - For a function provider, this is the first return value type.
// - For a struct provider, this is either the struct type or the pointer type
// whose element type is the struct type.
// - For a value, this is the type of the expression.
// - For an argument, this is the type of the argument.
func (pt ProvidedType) Type() types.Type {
return pt.t
}