Skip to content

Commit b95ea20

Browse files
griesemergopherbot
authored andcommitted
cmd/compile: add support for alternative comparable semantics
Add the experimental compiler flag -altcomparable. If set, the compiler uses alternative comparable semantics: any ordinary (non-type parameter) interface implements the comparable constraint. This permits experimenting with this alternative semantics akin to what is proposed in #52509. For #52509. Change-Id: I64192eee6f2a550eeb50de011079f2f0b994cf94 Reviewed-on: https://go-review.googlesource.com/c/go/+/444636 Run-TryBot: Robert Griesemer <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Reviewed-by: Ian Lance Taylor <[email protected]> Auto-Submit: Robert Griesemer <[email protected]> Reviewed-by: Robert Griesemer <[email protected]> Reviewed-by: Robert Findley <[email protected]>
1 parent 2dcc9ac commit b95ea20

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

src/cmd/compile/internal/base/flag.go

+2-1
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,8 @@ type CmdFlags struct {
122122
SymABIs string "help:\"read symbol ABIs from `file`\""
123123
TraceProfile string "help:\"write an execution trace to `file`\""
124124
TrimPath string "help:\"remove `prefix` from recorded source file paths\""
125-
WB bool "help:\"enable write barrier\"" // TODO: remove
125+
WB bool "help:\"enable write barrier\"" // TODO: remove
126+
AltComparable bool "help:\"enable alternative comparable semantics\"" // experiment - remove eventually
126127

127128
// Configuration derived from flags; not a flag itself.
128129
Cfg struct {

src/cmd/compile/internal/noder/irgen.go

+3-2
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,9 @@ func checkFiles(noders []*noder) (posMap, *types2.Package, *types2.Info) {
5555
}
5656
base.ErrorfAt(m.makeXPos(terr.Pos), "%s", msg)
5757
},
58-
Importer: &importer,
59-
Sizes: &gcSizes{},
58+
Importer: &importer,
59+
Sizes: &gcSizes{},
60+
AltComparableSemantics: base.Flag.AltComparable, // experiment - remove eventually
6061
}
6162
info := &types2.Info{
6263
StoreTypesInSyntax: true,

0 commit comments

Comments
 (0)