SymABIs string "help:\"read symbol ABIs from `file`\""
TraceProfile string "help:\"write an execution trace to `file`\""
TrimPath string "help:\"remove `prefix` from recorded source file paths\""
- WB bool "help:\"enable write barrier\"" // TODO: remove
- OldComparable bool "help:\"enable old comparable semantics\"" // TODO: remove for Go 1.21
+ WB bool "help:\"enable write barrier\"" // TODO: remove
PgoProfile string "help:\"read profile from `file`\""
// Configuration derived from flags; not a flag itself.
}
base.ErrorfAt(m.makeXPos(terr.Pos), "%s", msg)
},
- Importer: &importer,
- Sizes: &gcSizes{},
- OldComparableSemantics: base.Flag.OldComparable, // default is new comparable semantics
+ Importer: &importer,
+ Sizes: &gcSizes{},
}
info := &types2.Info{
StoreTypesInSyntax: true,
// If DisableUnusedImportCheck is set, packages are not checked
// for unused imports.
DisableUnusedImportCheck bool
-
- // If OldComparableSemantics is set, ordinary (non-type parameter)
- // interfaces do not satisfy the comparable constraint.
- // TODO(gri) remove this flag for Go 1.21
- OldComparableSemantics bool
}
func srcimporter_setUsesCgo(conf *Config) {
flags := flag.NewFlagSet("", flag.PanicOnError)
flags.StringVar(&conf.GoVersion, "lang", "", "")
flags.BoolVar(&conf.FakeImportC, "fakeImportC", false, "")
- flags.BoolVar(&conf.OldComparableSemantics, "oldComparableSemantics", false, "")
if err := parseFlags(filenames[0], nil, flags); err != nil {
t.Fatal(err)
}
if comparable(V, false /* strict comparability */, nil, nil) {
return true
}
- // If check.conf.OldComparableSemantics is set (by the compiler or
- // a test), we only consider strict comparability and we're done.
- // TODO(gri) remove this check for Go 1.21
- if check != nil && check.conf.OldComparableSemantics {
- if cause != nil {
- *cause = check.sprintf("%s does not %s comparable", V, verb)
- }
- return false
- }
// For constraint satisfaction, use dynamic (spec) comparability
// so that ordinary, non-type parameter interfaces implement comparable.
if constraint && comparable(V, true /* spec comparability */, nil, nil) {
// If DisableUnusedImportCheck is set, packages are not checked
// for unused imports.
DisableUnusedImportCheck bool
-
- // If oldComparableSemantics is set, ordinary (non-type parameter)
- // interfaces do not satisfy the comparable constraint.
- // TODO(gri) remove this flag for Go 1.21
- oldComparableSemantics bool
}
func srcimporter_setUsesCgo(conf *Config) {
flags := flag.NewFlagSet("", flag.PanicOnError)
flags.StringVar(&conf.GoVersion, "lang", "", "")
flags.BoolVar(&conf.FakeImportC, "fakeImportC", false, "")
- flags.BoolVar(boolFieldAddr(&conf, "oldComparableSemantics"), "oldComparableSemantics", false, "")
if err := parseFlags(filenames[0], srcs[0], flags); err != nil {
t.Fatal(err)
}
if comparable(V, false /* strict comparability */, nil, nil) {
return true
}
- // If check.conf.OldComparableSemantics is set (by the compiler or
- // a test), we only consider strict comparability and we're done.
- // TODO(gri) remove this check for Go 1.21
- if check != nil && check.conf.oldComparableSemantics {
- if cause != nil {
- *cause = check.sprintf("%s does not %s comparable", V, verb)
- }
- return false
- }
// For constraint satisfaction, use dynamic (spec) comparability
// so that ordinary, non-type parameter interfaces implement comparable.
if constraint && comparable(V, true /* spec comparability */, nil, nil) {
-// -oldComparableSemantics
-
// Copyright 2020 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
eql(x, x)
eql(y, y)
eql(y, nil /* ERROR "cannot use nil as Y value in argument to eql" */ )
- eql[io /* ERROR "does not satisfy comparable" */ .Reader](nil, nil)
+ eql[io.Reader](nil, nil)
}
// If we have a receiver of pointer to type parameter type (below: *T)
-// -oldComparableSemantics
-
// Copyright 2022 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
func _[P comparable, Q ~int, R any]() {
_ = f1[int]
- _ = f1[T /* ERROR "T does not satisfy comparable" */ ]
- _ = f1[any /* ERROR "any does not satisfy comparable" */ ]
+ _ = f1[T]
+ _ = f1[any]
_ = f1[P]
_ = f1[Q]
_ = f1[R /* ERROR "R does not satisfy comparable" */]
_ = f2[int]
- _ = f2[T /* ERROR "T does not satisfy comparable" */ ]
- _ = f2[any /* ERROR "any does not satisfy comparable" */ ]
+ _ = f2[T]
+ _ = f2[any]
_ = f2[P]
_ = f2[Q]
_ = f2[R /* ERROR "R does not satisfy comparable" */]
-// -oldComparableSemantics
-
// Copyright 2022 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
func _[P1 comparable, P2 S2]() {
_ = f[S1]
- _ = f[S2 /* ERROR "S2 does not satisfy comparable" */ ]
- _ = f[S3 /* ERROR "S3 does not satisfy comparable" */ ]
+ _ = f[S2]
+ _ = f[S3]
type L1 struct { x P1 }
type L2 struct { x P2 }
type T struct{ x any }
func main() {
- NewSetFromSlice /* ERROR "T does not satisfy comparable" */ ([]T{
+ NewSetFromSlice([]T{
{"foo"},
{5},
})
+++ /dev/null
-// -oldComparableSemantics
-
-// Copyright 2022 The Go Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style
-// license that can be found in the LICENSE file.
-
-package p
-
-func f1[_ comparable]() {}
-func f2[_ interface{ comparable }]() {}
-
-type T interface{ m() }
-
-func _[P comparable, Q ~int, R any]() {
- _ = f1[int]
- _ = f1[T /* ERROR "T does not satisfy comparable" */]
- _ = f1[any /* ERROR "any does not satisfy comparable" */]
- _ = f1[P]
- _ = f1[Q]
- _ = f1[R /* ERROR "R does not satisfy comparable" */]
-
- _ = f2[int]
- _ = f2[T /* ERROR "T does not satisfy comparable" */]
- _ = f2[any /* ERROR "any does not satisfy comparable" */]
- _ = f2[P]
- _ = f2[Q]
- _ = f2[R /* ERROR "R does not satisfy comparable" */]
-}