notFound
wrongName
wrongSig
+ ambigSel
ptrRecv
field
)
}
} else {
for _, m = range methods {
- obj, _, indirect := lookupFieldOrMethodImpl(V, false, m.pkg, m.name, false)
+ obj, index, indirect := lookupFieldOrMethodImpl(V, false, m.pkg, m.name, false)
- // check if m is on *V, or on V with case-folding
+ // check if m is ambiguous, on *V, or on V with case-folding
if obj == nil {
- if indirect {
+ switch {
+ case index != nil:
+ state = ambigSel
+ case indirect:
state = ptrRecv
- break
- }
- obj, _, _ = lookupFieldOrMethodImpl(V, false, m.pkg, m.name, true /* fold case */)
- f, _ = obj.(*Func)
- if f != nil {
- state = wrongName
- break
+ default:
+ state = notFound
+ obj, _, _ = lookupFieldOrMethodImpl(V, false, m.pkg, m.name, true /* fold case */)
+ f, _ = obj.(*Func)
+ if f != nil {
+ state = wrongName
+ }
}
- state = notFound
break
}
}
*cause = check.sprintf("(wrong type for method %s)\n\t\thave %s\n\t\twant %s",
m.Name(), fs, ms)
+ case ambigSel:
+ *cause = check.sprintf("(ambiguous selector %s.%s)", V, m.Name())
case ptrRecv:
*cause = check.sprintf("(method %s has pointer receiver)", m.Name())
case field:
notFound
wrongName
wrongSig
+ ambigSel
ptrRecv
field
)
}
} else {
for _, m = range methods {
- obj, _, indirect := lookupFieldOrMethodImpl(V, false, m.pkg, m.name, false)
+ obj, index, indirect := lookupFieldOrMethodImpl(V, false, m.pkg, m.name, false)
- // check if m is on *V, or on V with case-folding
+ // check if m is ambiguous, on *V, or on V with case-folding
if obj == nil {
- if indirect {
+ switch {
+ case index != nil:
+ state = ambigSel
+ case indirect:
state = ptrRecv
- break
- }
- obj, _, _ = lookupFieldOrMethodImpl(V, false, m.pkg, m.name, true /* fold case */)
- f, _ = obj.(*Func)
- if f != nil {
- state = wrongName
- break
+ default:
+ state = notFound
+ obj, _, _ = lookupFieldOrMethodImpl(V, false, m.pkg, m.name, true /* fold case */)
+ f, _ = obj.(*Func)
+ if f != nil {
+ state = wrongName
+ }
}
- state = notFound
break
}
}
*cause = check.sprintf("(wrong type for method %s)\n\t\thave %s\n\t\twant %s",
m.Name(), fs, ms)
+ case ambigSel:
+ *cause = check.sprintf("(ambiguous selector %s.%s)", V, m.Name())
case ptrRecv:
*cause = check.sprintf("(method %s has pointer receiver)", m.Name())
case field:
)
var (
- _ interface{ xm() } = eD /* ERROR "missing method xm" */ {}
+ _ interface{ xm() } = eD /* ERROR "ambiguous selector eD.xm" */ {}
)
\ No newline at end of file
--- /dev/null
+// Copyright 2023 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package p
+
+type A interface {
+ a()
+}
+
+type AB interface {
+ A
+ b()
+}
+
+type AAB struct {
+ A
+ AB
+}
+
+var _ AB = AAB /* ERROR "ambiguous selector AAB.a" */ {}