Skip to content

Commit

Permalink
go/types, types2: enable interface inference
Browse files Browse the repository at this point in the history
This CL sets enableInterfaceInference to true.
If problems arise due to this during the freeze, revert this CL.

Fixes #41176.
Fixes #57192.

Change-Id: I881ea6842e9c1101b24d9780323c6af365a40d3e
Reviewed-on: https://go-review.googlesource.com/c/go/+/497657
TryBot-Result: Gopher Robot <[email protected]>
Auto-Submit: Robert Griesemer <[email protected]>
Run-TryBot: Robert Griesemer <[email protected]>
Reviewed-by: Robert Findley <[email protected]>
Reviewed-by: Robert Griesemer <[email protected]>
  • Loading branch information
griesemer authored and gopherbot committed May 23, 2023
1 parent 948f11b commit 6b7aab7
Show file tree
Hide file tree
Showing 6 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/cmd/compile/internal/types2/unify.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ const (
// If enableInterfaceInference is set, type inference uses
// shared methods for improved type inference involving
// interfaces.
enableInterfaceInference = false
enableInterfaceInference = true

// If traceInference is set, unification will print a trace of its operation.
// Interpretation of trace:
Expand Down
2 changes: 1 addition & 1 deletion src/go/types/unify.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/internal/types/testdata/fixedbugs/issue39976.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ func NewCache[K, V any](p policy[K, V]) {}
func _() {
var lru LRU[int, string]
NewCache[int, string](&lru)
NewCache(& /* ERROR "does not match policy[K, V] (cannot infer K and V)" */ lru)
NewCache /* ERROR "cannot infer K" */ (&lru)
}
2 changes: 1 addition & 1 deletion src/internal/types/testdata/fixedbugs/issue41176.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ type I[T any] interface {
func f[T any](x I[T]) {}

func _() {
f(S /* ERROR "cannot infer T" */ {})
f(S{})
}
2 changes: 1 addition & 1 deletion src/internal/types/testdata/fixedbugs/issue53692.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ type LRU[K comparable, V any] struct{}
func WithLocking2[K comparable, V any](Cache[K, V]) {}

func _() {
WithLocking2[string](LRU /* ERROR "type LRU[string, int] of LRU[string, int]{} does not match inferred type Cache[string, int] for Cache[string, V]" */ [string, int]{})
WithLocking2 /* ERROR "cannot infer V" */ [string](LRU[string, int]{})
}
2 changes: 1 addition & 1 deletion src/internal/types/testdata/fixedbugs/issue57192.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,5 @@ var V2 I2[int]
func g[T any](I1[T]) {}
func _() {
g(V1)
g(V2 /* ERROR "type I2[int] of V2 does not match inferred type I1[int] for I1[T]" */)
g(V2)
}

0 comments on commit 6b7aab7

Please sign in to comment.