aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/compile/internal/types2/named.go
diff options
context:
space:
mode:
authorRobert Griesemer <gri@golang.org>2021-08-04 12:57:23 -0700
committerRobert Griesemer <gri@golang.org>2021-08-05 19:37:01 +0000
commitf78d538858a2d9aae975b2e2c144d23bcc22c22e (patch)
tree1db864f65d92302851e6f8a359e2caeec94f7bf2 /src/cmd/compile/internal/types2/named.go
parentc5b6c36ddd0ecdee401c4e78da1addf64bdc6376 (diff)
downloadgo-f78d538858a2d9aae975b2e2c144d23bcc22c22e.tar.gz
go-f78d538858a2d9aae975b2e2c144d23bcc22c22e.zip
[dev.typeparams] cmd/compile/internal/types2: cleanup panic calls
End-users are not expected to deal with the details of panics, so providing extra information such as an "internal error" prefix or the name of the function invoking the panic are not helpful. Remove unnecessary panic verbiage if it is readily available from a stack trace (such as the function where it happens, and the fact that is is an "internal error"). Change-Id: I5f86bae6d2cca7c04ce692d17257da7ddee206d7 Reviewed-on: https://go-review.googlesource.com/c/go/+/339969 Trust: Robert Griesemer <gri@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
Diffstat (limited to 'src/cmd/compile/internal/types2/named.go')
-rw-r--r--src/cmd/compile/internal/types2/named.go12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/cmd/compile/internal/types2/named.go b/src/cmd/compile/internal/types2/named.go
index 8ded197df5..14e073bfae 100644
--- a/src/cmd/compile/internal/types2/named.go
+++ b/src/cmd/compile/internal/types2/named.go
@@ -33,7 +33,7 @@ type Named struct {
// The underlying type must not be a *Named.
func NewNamed(obj *TypeName, underlying Type, methods []*Func) *Named {
if _, ok := underlying.(*Named); ok {
- panic("types2.NewNamed: underlying type must not be *Named")
+ panic("underlying type must not be *Named")
}
return (*Checker)(nil).newNamed(obj, nil, underlying, nil, methods)
}
@@ -100,7 +100,7 @@ func (check *Checker) newNamed(obj *TypeName, orig *Named, underlying Type, tpar
check.later(func() {
switch typ.under().(type) {
case *Named:
- panic("internal error: unexpanded underlying type")
+ panic("unexpanded underlying type")
}
typ.check = nil
})
@@ -140,10 +140,10 @@ func (t *Named) Method(i int) *Func { return t.load().methods[i] }
// SetUnderlying sets the underlying type and marks t as complete.
func (t *Named) SetUnderlying(underlying Type) {
if underlying == nil {
- panic("types2.Named.SetUnderlying: underlying type must not be nil")
+ panic("underlying type must not be nil")
}
if _, ok := underlying.(*Named); ok {
- panic("types2.Named.SetUnderlying: underlying type must not be *Named")
+ panic("underlying type must not be *Named")
}
t.load().underlying = underlying
}
@@ -191,7 +191,7 @@ func (n0 *Named) under() Type {
}
if n0.check == nil {
- panic("internal error: Named.check == nil but type is incomplete")
+ panic("Named.check == nil but type is incomplete")
}
// Invariant: after this point n0 as well as any named types in its
@@ -242,7 +242,7 @@ func (n0 *Named) under() Type {
// Also, doing so would lead to a race condition (was issue #31749).
// Do this check always, not just in debug mode (it's cheap).
if n.obj.pkg != check.pkg {
- panic("internal error: imported type with unresolved underlying type")
+ panic("imported type with unresolved underlying type")
}
n.underlying = u
}