]> Cypherpunks repositories - gostls13.git/commit
go/types, types2: simplify missingMethodReason
authorRobert Griesemer <gri@golang.org>
Thu, 3 Feb 2022 05:36:50 +0000 (21:36 -0800)
committerRobert Griesemer <gri@golang.org>
Fri, 4 Feb 2022 23:42:47 +0000 (23:42 +0000)
commitef843ae49c8a8ad6494da294fc46b0e80147e715
tree9e3a81c7ed1d95247b6f2852cd7a1edeaf42f2ec
parentd9eba71a643f31e509dd08884509c5b2c1ab26a4
go/types, types2: simplify missingMethodReason

Added a funcString helper so we don't need to rewrite strings
with strings.Replace.

Use compiler format for error message about wrong method type;
this removes another unnecessary variation.

Simplify conditions for pointer-to-interface related error:
if one of the involved types is an interface pointer, it can't
have any methods.

Rewrite logic so we don't need all the else-if branches.

Adjusted a test case for types2 accordingly. The go/types version
of this test case has a different error because the implementation
of Checker.typeAssertion is different in the two type checkers
(the types2 version gives errors closer to the 1.17 compiler).

Change-Id: I19e604d7063c3e31e8290bd78384a9f38bb0d740
Reviewed-on: https://go-review.googlesource.com/c/go/+/382694
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
src/cmd/compile/internal/types2/lookup.go
src/cmd/compile/internal/types2/testdata/check/issues.src
src/go/types/lookup.go