compiler: don't generate stubs for ambiguous direct interface methods
Current implementation checks whether it has to generate a stub method for a
promoted method of an embedded struct field in Type::build_stub_methods(). If
the promoted method is ambiguous it's simply skipped. But struct types that
can fit in an interface value (e.g. structs that consist of a single pointer
field) get a second chance in Type::build_direct_iface_stub_methods().
This patch adds the same check used by Type::build_stub_methods() to
Type::build_direct_iface_stub_methods().
Fixes golang/go#52870
Change-Id: If679e7bda8793b3cdc411419806fa36d5536faa4
Reviewed-on: https://go-review.googlesource.com/c/gofrontend/+/405974
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
diff --git a/go/types.cc b/go/types.cc
index a8e3090..eb3afd9 100644
--- a/go/types.cc
+++ b/go/types.cc
@@ -11891,7 +11891,7 @@
need_stub = true;
if (!in_heap && !m->is_value_method())
need_stub = true;
- if (!need_stub)
+ if (!need_stub || m->is_ambiguous())
continue;
Type* receiver_type = const_cast<Type*>(type);