Skip to content
This repository was archived by the owner on Mar 22, 2019. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion inject.go
Original file line number Diff line number Diff line change
Expand Up @@ -563,7 +563,7 @@ func parseTag(t string) (*tag, error) {
}

func isStructPtr(t reflect.Type) bool {
return t.Kind() == reflect.Ptr && t.Elem().Kind() == reflect.Struct
return t != nil && t.Kind() == reflect.Ptr && t.Elem().Kind() == reflect.Struct
}

func isNilOrZero(v reflect.Value, t reflect.Type) bool {
Expand Down
10 changes: 10 additions & 0 deletions inject_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -994,3 +994,13 @@ func TestForSameNameButDifferentPackage(t *testing.T) {
t.Fatal(err)
}
}

func TestInjectNil(t *testing.T) {
var g inject.Graph
err := g.Provide(
&inject.Object{Value: nil},
)
if err == nil {
t.Fatal("expected error when injecting nil")
}
}