// set (and don't store it!), so that we still compute the full
// type set eventually. Instead, return the top type set and
// let any follow-on errors play out.
+ //
+ // TODO(gri) Consider recording when this happens and reporting
+ // it as an error (but only if there were no other errors so to
+ // to not have unnecessary follow-on errors).
if !ityp.complete {
return &topTypeSet
}
case explicit:
if check != nil {
err := check.newError(DuplicateDecl)
- err.addf(pos, "duplicate method %s", m.name)
- err.addf(mpos[other.(*Func)], "other declaration of %s", m.name)
+ err.addf(atPos(pos), "duplicate method %s", m.name)
+ err.addf(atPos(mpos[other.(*Func)]), "other declaration of %s", m.name)
err.report()
}
default:
// error message.
if check != nil {
check.later(func() {
- if !check.allowVersion(m.pkg, pos, go1_14) || !Identical(m.typ, other.Type()) {
+ if !check.allowVersion(m.pkg, atPos(pos), go1_14) || !Identical(m.typ, other.Type()) {
err := check.newError(DuplicateDecl)
- err.addf(pos, "duplicate method %s", m.name)
- err.addf(mpos[other.(*Func)], "other declaration of %s", m.name)
+ err.addf(atPos(pos), "duplicate method %s", m.name)
+ err.addf(atPos(mpos[other.(*Func)]), "other declaration of %s", m.name)
err.report()
}
- }).describef(pos, "duplicate method check for %s", m.name)
+ }).describef(atPos(pos), "duplicate method check for %s", m.name)
}
}
}
assert(!isTypeParam(typ))
tset := computeInterfaceTypeSet(check, pos, u)
// If typ is local, an error was already reported where typ is specified/defined.
- if check != nil && check.isImportedConstraint(typ) && !check.verifyVersionf(pos, go1_18, "embedding constraint interface %s", typ) {
+ if check != nil && check.isImportedConstraint(typ) && !check.verifyVersionf(atPos(pos), go1_18, "embedding constraint interface %s", typ) {
continue
}
comparable = tset.comparable
}
terms = tset.terms
case *Union:
- if check != nil && !check.verifyVersionf(pos, go1_18, "embedding interface element %s", u) {
+ if check != nil && !check.verifyVersionf(atPos(pos), go1_18, "embedding interface element %s", u) {
continue
}
tset := computeUnionTypeSet(check, unionSets, pos, u)
if !isValid(u) {
continue
}
- if check != nil && !check.verifyVersionf(pos, go1_18, "embedding non-interface type %s", typ) {
+ if check != nil && !check.verifyVersionf(atPos(pos), go1_18, "embedding non-interface type %s", typ) {
continue
}
terms = termlist{{false, typ}}
allTerms = allTerms.union(terms)
if len(allTerms) > maxTermCount {
if check != nil {
- check.errorf(pos, InvalidUnion, "cannot handle more than %d union terms (implementation limitation)", maxTermCount)
+ check.errorf(atPos(pos), InvalidUnion, "cannot handle more than %d union terms (implementation limitation)", maxTermCount)
}
unionSets[utyp] = &invalidTypeSet
return unionSets[utyp]
+// Code generated by "go test -run=Generate -write=all"; DO NOT EDIT.
+
// Copyright 2021 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.
mpos[m] = pos
case explicit:
if check != nil {
- check.errorf(atPos(pos), DuplicateDecl, "duplicate method %s", m.name)
- check.errorf(atPos(mpos[other.(*Func)]), DuplicateDecl, "\tother declaration of %s", m.name) // secondary error, \t indented
+ err := check.newError(DuplicateDecl)
+ err.addf(atPos(pos), "duplicate method %s", m.name)
+ err.addf(atPos(mpos[other.(*Func)]), "other declaration of %s", m.name)
+ err.report()
}
default:
// We have a duplicate method name in an embedded (not explicitly declared) method.
if check != nil {
check.later(func() {
if !check.allowVersion(m.pkg, atPos(pos), go1_14) || !Identical(m.typ, other.Type()) {
- check.errorf(atPos(pos), DuplicateDecl, "duplicate method %s", m.name)
- check.errorf(atPos(mpos[other.(*Func)]), DuplicateDecl, "\tother declaration of %s", m.name) // secondary error, \t indented
+ err := check.newError(DuplicateDecl)
+ err.addf(atPos(pos), "duplicate method %s", m.name)
+ err.addf(atPos(mpos[other.(*Func)]), "other declaration of %s", m.name)
+ err.report()
}
}).describef(atPos(pos), "duplicate method check for %s", m.name)
}