}
base.ErrorfAt(m.makeXPos(terr.Pos), terr.Code, "%s", msg)
},
- Importer: &importer,
- Sizes: &gcSizes{},
- InferMaxDefaultType: true, // #58671
+ Importer: &importer,
+ Sizes: &gcSizes{},
}
info := &types2.Info{
StoreTypesInSyntax: true,
// If DisableUnusedImportCheck is set, packages are not checked
// for unused imports.
DisableUnusedImportCheck bool
-
- // If InferMaxDefaultType is set, the minimum (smallest) default
- // type that fits all untyped constant arguments for the same type
- // parameter is selected in type inference. (go.dev/issue/58671)
- InferMaxDefaultType 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.InferMaxDefaultType, "inferMaxDefaultType", false, "")
if err := parseFlags(filenames[0], nil, flags); err != nil {
t.Fatal(err)
}
u.tracef("== untyped arguments: %v", untyped)
}
- if check.conf.InferMaxDefaultType {
+ // We need a poser/positioner for check.allowVersion below.
+ // We should really use pos (argument to infer) but currently
+ // the generator that generates go/types/infer.go has trouble
+ // with that. For now, do a little dance to get a position if
+ // we need one. (If we don't have untyped arguments left, it
+ // doesn't matter which branch we take below.)
+ // TODO(gri) adjust infer signature or adjust the rewriter.
+ var at syntax.Pos
+ if len(untyped) > 0 {
+ at = params.At(untyped[0]).pos
+ }
+
+ if check.allowVersion(check.pkg, atPos(at), go1_21) {
// Some generic parameters with untyped arguments may have been given a type by now.
// Collect all remaining parameters that don't have a type yet and determine the
// maximum untyped type for each of those parameters, if possible.
file, err := syntax.ParseFile(filename, nil, nil, 0)
if err == nil {
conf := Config{
- GoVersion: goVersion,
- Importer: stdLibImporter,
- InferMaxDefaultType: true,
+ GoVersion: goVersion,
+ Importer: stdLibImporter,
}
_, err = conf.Check(filename, []*syntax.File{file}, nil)
}
// If DisableUnusedImportCheck is set, packages are not checked
// for unused imports.
DisableUnusedImportCheck bool
-
- // If _InferMaxDefaultType is set, the minimum (smallest) default
- // type that fits all untyped constant arguments for the same type
- // parameter is selected in type inference. (go.dev/issue/58671)
- _InferMaxDefaultType 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, "_InferMaxDefaultType"), "inferMaxDefaultType", false, "")
if err := parseFlags(filenames[0], srcs[0], flags); err != nil {
t.Fatal(err)
}
"infer.go": func(f *ast.File) {
fixTokenPos(f)
fixInferSig(f)
- renameIdent(f, "InferMaxDefaultType", "_InferMaxDefaultType")
},
// "initorder.go": fixErrErrorfCall, // disabled for now due to unresolved error_ use implications for gopls
"instantiate.go": func(f *ast.File) { fixTokenPos(f); fixCheckErrorfCall(f) },
u.tracef("== untyped arguments: %v", untyped)
}
- if check.conf._InferMaxDefaultType {
+ // We need a poser/positioner for check.allowVersion below.
+ // We should really use pos (argument to infer) but currently
+ // the generator that generates go/types/infer.go has trouble
+ // with that. For now, do a little dance to get a position if
+ // we need one. (If we don't have untyped arguments left, it
+ // doesn't matter which branch we take below.)
+ // TODO(gri) adjust infer signature or adjust the rewriter.
+ var at token.Pos
+ if len(untyped) > 0 {
+ at = params.At(untyped[0]).pos
+ }
+
+ if check.allowVersion(check.pkg, atPos(at), go1_21) {
// Some generic parameters with untyped arguments may have been given a type by now.
// Collect all remaining parameters that don't have a type yet and determine the
// maximum untyped type for each of those parameters, if possible.
GoVersion: goVersion,
Importer: stdLibImporter,
}
- *boolFieldAddr(&conf, "_InferMaxDefaultType") = true
_, err = conf.Check(filename, fset, []*ast.File{file}, nil)
}
var _ float64 = f7([]float64{}...)
var _ = f7[float64](1, 2.3)
var _ = f7(float64(1), 2.3)
-var _ = f7(1, 2.3 /* ERROR "does not match" */ )
-var _ = f7(1.2, 3 /* ERROR "does not match" */ )
+var _ = f7(1, 2.3)
+var _ = f7(1.2, 3)
func f8[A, B any](A, B, ...B) int { panic(0) }
var _ = f8(1) /* ERROR "not enough arguments" */
var _ = f8(1, 2.3)
var _ = f8(1, 2.3, 3.4, 4.5)
-var _ = f8(1, 2.3, 3.4, 4 /* ERROR "does not match" */ )
+var _ = f8(1, 2.3, 3.4, 4)
var _ = f8[int, float64](1, 2.3, 3.4, 4)
var _ = f8[int, float64](0, 0, nil...) // test case for #18268
-// -inferMaxDefaultType
-
// Copyright 2023 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.