]> Cypherpunks repositories - gostls13.git/commit
go/types, types2: do not run CTI before FTI
authorRobert Griesemer <gri@golang.org>
Tue, 11 Jan 2022 01:29:21 +0000 (17:29 -0800)
committerRobert Griesemer <gri@golang.org>
Wed, 12 Jan 2022 01:49:33 +0000 (01:49 +0000)
commit3d3f5d912b776424e50be276bc3a4ae02bf8d143
tree78a05c2b7ab9408049681216591dd94366bdde8d
parent3df44722013b54790e97a32aff945708bd1b62f7
go/types, types2: do not run CTI before FTI

Until now, CTI (constraint type inference) was run before
FTI (function type inference). This lead to situations
where CTI infered a type that is missing necessary methods
even though a function argument of correct type was given.
This can happen when constraint type inference produces a
inferred type that is the structural type of multiple types,
which then is an underlying type, possibly without methods.

This CL removes the initial CTI step; it is only applied
after FTI with type arguments is run, and again after FTI
with untyped arguments is run.

Various comments are adjusted to reflect the new reality.

Fixes #50426.

Change-Id: I700ae6e762d7aa00d742943a2880f1a1db33c2b8
Reviewed-on: https://go-review.googlesource.com/c/go/+/377594
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
src/cmd/compile/internal/types2/infer.go
src/cmd/compile/internal/types2/testdata/fixedbugs/issue50426.go2 [new file with mode: 0644]
src/go/types/infer.go
src/go/types/testdata/fixedbugs/issue50426.go2 [new file with mode: 0644]