diff --git a/src/cmd/compile/internal/types2/infer.go b/src/cmd/compile/internal/types2/infer.go index b0c6a4fceac..8425cd60340 100644 --- a/src/cmd/compile/internal/types2/infer.go +++ b/src/cmd/compile/internal/types2/infer.go @@ -128,11 +128,8 @@ func (check *Checker) infer(pos syntax.Pos, tparams []*TypeParam, targs []Type, // named and unnamed types are passed to parameters with identical type, different types // (named vs underlying) may be inferred depending on the order of the arguments. // By ensuring that named types are seen first, order dependence is avoided and unification - // succeeds where it can. - // - // This code is disabled for now pending decision whether we want to address cases like - // these and make the spec on type inference more complicated (see issue #43056). - const enableArgSorting = false + // succeeds where it can (issue #43056). + const enableArgSorting = true if m := len(args); m >= 2 && enableArgSorting { // Determine indices of arguments with named and unnamed types. var named, unnamed []int diff --git a/src/cmd/compile/internal/types2/testdata/examples/functions.go b/src/cmd/compile/internal/types2/testdata/examples/functions.go index ef8953cb43b..d50f79d11f8 100644 --- a/src/cmd/compile/internal/types2/testdata/examples/functions.go +++ b/src/cmd/compile/internal/types2/testdata/examples/functions.go @@ -182,7 +182,7 @@ func _() { type myString string var s1 string g3(nil, "1", myString("2"), "3") - g3(&s1, "1", myString /* ERROR does not match */ ("2"), "3") + g3(& /* ERROR does not match */ s1, "1", myString("2"), "3") _ = s1 type myStruct struct{x int} diff --git a/src/cmd/compile/internal/types2/testdata/fixedbugs/issue43056.go b/src/cmd/compile/internal/types2/testdata/fixedbugs/issue43056.go index 35c7ef592d2..8ff4e7f9b4d 100644 --- a/src/cmd/compile/internal/types2/testdata/fixedbugs/issue43056.go +++ b/src/cmd/compile/internal/types2/testdata/fixedbugs/issue43056.go @@ -14,7 +14,7 @@ func _() { var j func(F) f(i, j) - // f(j, i) // disabled for now + f(j, i) } // example from issue @@ -27,5 +27,5 @@ func _() { var j interface{ Equal(I) bool } g(i, j) - // g(j, i) // disabled for now + g(j, i) } diff --git a/src/go/types/infer.go b/src/go/types/infer.go index 1aa26126387..768efbf73ba 100644 --- a/src/go/types/infer.go +++ b/src/go/types/infer.go @@ -128,11 +128,8 @@ func (check *Checker) infer(posn positioner, tparams []*TypeParam, targs []Type, // named and unnamed types are passed to parameters with identical type, different types // (named vs underlying) may be inferred depending on the order of the arguments. // By ensuring that named types are seen first, order dependence is avoided and unification - // succeeds where it can. - // - // This code is disabled for now pending decision whether we want to address cases like - // these and make the spec on type inference more complicated (see issue #43056). - const enableArgSorting = false + // succeeds where it can (issue #43056). + const enableArgSorting = true if m := len(args); m >= 2 && enableArgSorting { // Determine indices of arguments with named and unnamed types. var named, unnamed []int diff --git a/src/go/types/testdata/examples/functions.go b/src/go/types/testdata/examples/functions.go index 0af77267c5f..1d30075c7c7 100644 --- a/src/go/types/testdata/examples/functions.go +++ b/src/go/types/testdata/examples/functions.go @@ -182,7 +182,7 @@ func _() { type myString string var s1 string g3(nil, "1", myString("2"), "3") - g3(&s1, "1", myString /* ERROR does not match */ ("2"), "3") + g3(& /* ERROR does not match */ s1, "1", myString("2"), "3") type myStruct struct{x int} var s2 myStruct diff --git a/src/go/types/testdata/fixedbugs/issue43056.go b/src/go/types/testdata/fixedbugs/issue43056.go index 35c7ef592d2..8ff4e7f9b4d 100644 --- a/src/go/types/testdata/fixedbugs/issue43056.go +++ b/src/go/types/testdata/fixedbugs/issue43056.go @@ -14,7 +14,7 @@ func _() { var j func(F) f(i, j) - // f(j, i) // disabled for now + f(j, i) } // example from issue @@ -27,5 +27,5 @@ func _() { var j interface{ Equal(I) bool } g(i, j) - // g(j, i) // disabled for now + g(j, i) }