compiler: better error messages for missing interface method

For golang/go#10700

Change-Id: I1d7232f7f5beb0da55515c9d14c6077ee79c8378
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/273886
Trust: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
diff --git a/go/types.cc b/go/types.cc
index 286ecc1..23d1647 100644
--- a/go/types.cc
+++ b/go/types.cc
@@ -12052,6 +12052,15 @@
 		    ambig2.c_str());
       else if (found_pointer_method)
 	go_error_at(location, "method requires a pointer receiver");
+      else if (it != NULL && it->is_empty())
+	go_error_at(location,
+		    "reference to method %qs in interface with no methods",
+		    Gogo::message_name(name).c_str());
+      else if (it == NULL && type->deref()->interface_type() != NULL)
+	go_error_at(location,
+		    ("reference to method %qs in type that is "
+		     "pointer to interface, not interface"),
+		    Gogo::message_name(name).c_str());
       else if (nt == NULL && st == NULL && it == NULL)
 	go_error_at(location,
 		    ("reference to field %qs in object which "