reflect: add Type.Implements, Type.AssignableTo, Value.CallSlice; make Set match Go

This CL makes reflect require that values be assignable to the target type
in exactly the same places where that is the rule in Go.  It also adds
the Implements and AssignableTo methods so that callers can check
the types themselves so as to avoid a panic.

Before this CL, reflect required strict type identity.

This CL expands Call to accept and correctly marshal arbitrary
argument lists for variadic functions; it introduces CallSlice for use
in the case where the slice for the variadic argument is already known.

Fixes #327.
Fixes #1212.

R=r, dsymonds
CC=golang-dev
https://golang.org/cl/4439058
diff --git a/src/pkg/reflect/all_test.go b/src/pkg/reflect/all_test.go
index 79fef90..726713f 100644
--- a/src/pkg/reflect/all_test.go
+++ b/src/pkg/reflect/all_test.go
@@ -5,6 +5,7 @@
 package reflect_test
 
 import (
+	"bytes"
 	"container/vector"
 	"fmt"
 	"io"
@@ -1449,3 +1450,20 @@
 		t.Errorf("xa.Slice(2, 5) = %v", v)
 	}
 }
+
+func TestVariadic(t *testing.T) {
+	var b bytes.Buffer
+	V := NewValue
+
+	b.Reset()
+	V(fmt.Fprintf).Call([]Value{V(&b), V("%s, %d world"), V("hello"), V(42)})
+	if b.String() != "hello, 42 world" {
+		t.Errorf("after Fprintf Call: %q != %q", b.String(), "hello 42 world")
+	}
+
+	b.Reset()
+	V(fmt.Fprintf).CallSlice([]Value{V(&b), V("%s, %d world"), V([]interface{}{"hello", 42})})
+	if b.String() != "hello, 42 world" {
+		t.Errorf("after Fprintf CallSlice: %q != %q", b.String(), "hello 42 world")
+	}
+}