]> Cypherpunks repositories - gostls13.git/commit
go/types, types2: use Identical rather than unification in missingMethod
authorRobert Findley <rfindley@google.com>
Thu, 20 Jan 2022 03:00:42 +0000 (22:00 -0500)
committerRobert Findley <rfindley@google.com>
Thu, 20 Jan 2022 14:59:17 +0000 (14:59 +0000)
commit9284279b44418b52221b4d68d400fa9220521726
tree6fd41ac990e44aae2d0bcd79aaf315ee842827e5
parente7d5857a5a82551b8a70b6174ec73422442250ce
go/types, types2: use Identical rather than unification in missingMethod

Now that we instantiate methods on instantiated types, there is no need
to use unification to match signatures inside of missingMethod.

Generally, we should never encounter uninstantiated signatures within
statements. If we do encounter signatures that contain type parameters,
it is because the signatures are themselves defined or instantiated
using type parameters declared in the function scope (see example
below). The current unification logic would not handle this.

type S[T any] struct{}
func (S[T]) m(T)

func _[P any]() bool {
var v interface{m(int)}
_, ok = v.(S[P])
return ok
}

Change-Id: I754fb5535bba2fc7a209dc7419fd4015c413c9a6
Reviewed-on: https://go-review.googlesource.com/c/go/+/379540
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
src/cmd/compile/internal/types2/lookup.go
src/go/types/lookup.go