diff options
author | Robert Griesemer <gri@golang.org> | 2021-04-01 18:39:39 -0700 |
---|---|---|
committer | Robert Griesemer <gri@golang.org> | 2021-04-07 05:19:15 +0000 |
commit | 7d5c54eee4718ccc1790fa9ab92bf091e9d56ef7 (patch) | |
tree | 4981b03e55db11aca68549ef4948a619cddf2a03 /src/cmd/compile/internal/types2/infer.go | |
parent | bce85b701153f7671f0e362288ad5c8fdad15093 (diff) | |
download | go-7d5c54eee4718ccc1790fa9ab92bf091e9d56ef7.tar.gz go-7d5c54eee4718ccc1790fa9ab92bf091e9d56ef7.zip |
cmd/compile/internal/types2: remove Config.InferFromConstraints flag
Constraint type inference is part of the proposed language.
Use an internal flag to control the feayure for debugging.
Change-Id: I7a9eaee92b5ffc23c25d9e68a729acc0d705e879
Reviewed-on: https://go-review.googlesource.com/c/go/+/306770
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
Diffstat (limited to 'src/cmd/compile/internal/types2/infer.go')
-rw-r--r-- | src/cmd/compile/internal/types2/infer.go | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/cmd/compile/internal/types2/infer.go b/src/cmd/compile/internal/types2/infer.go index d267787816..995ebd7ea0 100644 --- a/src/cmd/compile/internal/types2/infer.go +++ b/src/cmd/compile/internal/types2/infer.go @@ -11,6 +11,8 @@ import ( "cmd/compile/internal/syntax" ) +const useConstraintTypeInference = true + // infer attempts to infer the complete set of type arguments for generic function instantiation/call // based on the given type parameters tparams, type arguments targs, function parameters params, and // function arguments args, if any. There must be at least one type parameter, no more type arguments @@ -56,7 +58,7 @@ func (check *Checker) infer(pos syntax.Pos, tparams []*TypeName, targs []Type, p // and types inferred via constraint type inference take precedence over types // inferred from function arguments. // If we have type arguments, see how far we get with constraint type inference. - if len(targs) > 0 && check.conf.InferFromConstraints { + if len(targs) > 0 && useConstraintTypeInference { var index int targs, index = check.inferB(tparams, targs, report) if targs == nil || index < 0 { @@ -171,7 +173,7 @@ func (check *Checker) infer(pos syntax.Pos, tparams []*TypeName, targs []Type, p // See how far we get with constraint type inference. // Note that even if we don't have any type arguments, constraint type inference // may produce results for constraints that explicitly specify a type. - if check.conf.InferFromConstraints { + if useConstraintTypeInference { targs, index = check.inferB(tparams, targs, report) if targs == nil || index < 0 { return targs @@ -219,7 +221,7 @@ func (check *Checker) infer(pos syntax.Pos, tparams []*TypeName, targs []Type, p } // Again, follow up with constraint type inference. - if check.conf.InferFromConstraints { + if useConstraintTypeInference { targs, index = check.inferB(tparams, targs, report) if targs == nil || index < 0 { return targs |