This is a clean port of CL 363154 from types2 to go/types.
Change-Id: I26c18767041db096390e84ba9200ec69b66778d0
Reviewed-on: https://go-review.googlesource.com/c/go/+/364234
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
This is a port of CL 363075 from types2 to go/types, adjusted for the
different error reporting API, and to adjust positions of error messages
in tests.
Change-Id: Ic6bfedf1152eff94bad20725b56e6ba804b2e3e8
Reviewed-on: https://go-review.googlesource.com/c/go/+/363991
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
This is a port of CL 362997 from types2 to go/types. Some error
positions were adjusted in tests.
Change-Id: I6a932aee1a8d9bcbf4cd8c16a95bbb41b5c7e13f
Reviewed-on: https://go-review.googlesource.com/c/go/+/363990
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
This is a clean port of CL 362995 from types2 to go/types.
Change-Id: Iefc37b28178795ea944e0bc0ff91982251de2944
Reviewed-on: https://go-review.googlesource.com/c/go/+/363989
Trust: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
This is a clean port of CL 362994 from types2 to go/types.
Change-Id: I51b38c35ec3306274ef0355516e2d5557e7d8b46
Reviewed-on: https://go-review.googlesource.com/c/go/+/363988
Trust: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
This is a clean port of CL 362895 from types2 to go/types.
Change-Id: Icd0631127c51aec80ce9450df2be71bf4b96b2df
Reviewed-on: https://go-review.googlesource.com/c/go/+/363987
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
Update the vendored x/tools to pick up the fix for #49597, using the
following commands:
go get -d golang.org/x/tools@4adea5033c5c6f39a900d4b963c4b496448b1655
go mod tidy
go mod vendor
Fixes#49597
Change-Id: Ib1bc43aacbdc707b605194012134f048a336e176
Reviewed-on: https://go-review.googlesource.com/c/go/+/363986
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
On a non-nil err, buildinfo.ReadFile will always return a nil
*Buildinfo. In scanFile, we need to return early if that happens.
Fixes#49181
Change-Id: I354348d206ab084804937c6f922eadb61435e7b5
Reviewed-on: https://go-review.googlesource.com/c/go/+/359154
Trust: Alberto Donizetti <alb.donizetti@gmail.com>
Run-TryBot: Alberto Donizetti <alb.donizetti@gmail.com>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
This CL is clean port of CL 362800 from go/types to types2.
Change-Id: I66443b5a82b3a9c2f608a0fe012fbb099db996f3
Reviewed-on: https://go-review.googlesource.com/c/go/+/364155
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
This CL is a clean port of CL 362799 from go/types to types2.
Change-Id: Id670aa4b1ca0b568a79bb6e4855747807dcf00f3
Reviewed-on: https://go-review.googlesource.com/c/go/+/364154
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
This is a clean port of CL 362798 from go/types to types2,
with an additional comment adjustment in types2 and go/types.
Change-Id: Ifa3d11f512f794f8ae2b6aca50b625a4a44672de
Reviewed-on: https://go-review.googlesource.com/c/go/+/364135
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
Also mention local types restriction.
We probably want to say more at some point, this is just a
placeholder to start.
Update #47631
Change-Id: I828e451e1e8504d21cb55c7132e9cb330b160a54
Reviewed-on: https://go-review.googlesource.com/c/go/+/364134
Trust: Keith Randall <khr@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
For #45435
Change-Id: I728accd9a53c1826243f52aa04dc2a0a1dfdaadf
Reviewed-on: https://go-review.googlesource.com/c/go/+/363672
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
For #47694
Change-Id: I39594c273aeb038702457587ee1c46e4b3920bb6
Reviewed-on: https://go-review.googlesource.com/c/go/+/363359
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
Trust: Jeremy Faller <jeremy@golang.org>
When a DW_FORM_line_strp is used without a debug_line_str section a
good error message (about the missing section) is generated but
immediately overwritten by the underflow error generated by trying to
read the non-existent section.
Updates #49590
Change-Id: I1c431392123a86c78c95ef1f185ebd6f17f2476a
Reviewed-on: https://go-review.googlesource.com/c/go/+/363894
Run-TryBot: Alessandro Arzilli <alessandro.arzilli@gmail.com>
Trust: David Chase <drchase@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
But exclude the test when running unified build for now
(the unified builder's importers are not yet updated to
handle extended interfaces).
Also, fix respective error position.
Fixes#47967.
Change-Id: I4e3d829b5c12001c024b9eefcc27f97b10c1d1e5
Reviewed-on: https://go-review.googlesource.com/c/go/+/363834
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Type constraint satisfaction is interface implementation.
Adjusted a few error messages.
Change-Id: I4266af78e83131a76b1e3e44c847a21de760ac6e
Reviewed-on: https://go-review.googlesource.com/c/go/+/363839
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
Because the underlying type of a type parameter is an interface,
the questions whether *P for a type parameter P has methods or
not is settled: P is also an interface pointers to interfaces
don't have methods.
This allows us to eliminate the now unneccesary test in "implements"
and also allows us to remove a special case for type parameters in
"lookupFieldOrMethod".
Change-Id: I8b218f81584a8e42e75884089a44293365b700df
Reviewed-on: https://go-review.googlesource.com/c/go/+/363838
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
Checker.implements implements the complete interface
"implements" predicate. Use it instead of Checker.satisfies.
This is mostly a refactoring of the code but the constraint
types have already been instatiated with the respective type
arguments as needed before calling "implements".
Future CLs will address the various TODOs.
Change-Id: If530cca36643a561282361348f1526157a7182de
Reviewed-on: https://go-review.googlesource.com/c/go/+/363837
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
Report the error at the first place (which is to say, latest index)
causing the error.
Change-Id: I31cf0a4d243fc66cfab84b7fec98055f4eb60ddf
Reviewed-on: https://go-review.googlesource.com/c/go/+/363671
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
As a result, slightly narrow position tolerance for tests.
Change-Id: I543dc2b7b9a7940b0684067d1961165b2b4812bb
Reviewed-on: https://go-review.googlesource.com/c/go/+/363670
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
Change-Id: Ia09f7b1af0e84858fb73ab7e2592c5c3e983dc0e
Reviewed-on: https://go-review.googlesource.com/c/go/+/363669
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
Most of the time we don't have a type parameter. Avoid using a
closure in that case.
While at it, rename argument from typ to t (to match style in
that file), and clarify the doc string.
Change-Id: Ie62821073f60f353526263f8b380bad9f72d842e
Reviewed-on: https://go-review.googlesource.com/c/go/+/363668
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
Change-Id: Idb02449ef1b06d5f47eeb4a4413e56e2cd5d0d96
Reviewed-on: https://go-review.googlesource.com/c/go/+/363836
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
We hope to support this feature one day, but it doesn't work currently.
Issue a nice error message instead of having the compiler crash.
Update #47631
Change-Id: I0359411410acbaf9a5b9dbb988cd933de1bb8438
Reviewed-on: https://go-review.googlesource.com/c/go/+/364054
Trust: Keith Randall <khr@golang.org>
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Dan Scales <danscales@google.com>
A recent change to error message formatting was missing a nil check.
Fixes#49592
Change-Id: Ic1843e0277ba75eec0e8e41fe34b59c323d7ea31
Reviewed-on: https://go-review.googlesource.com/c/go/+/364034
Trust: Robert Findley <rfindley@google.com>
Trust: Dan Scales <danscales@google.com>
Trust: Daniel Martí <mvdan@mvdan.cc>
Run-TryBot: Robert Findley <rfindley@google.com>
Reviewed-by: Dan Scales <danscales@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
The bare error message "%s is not a generic type" is probably never
sufficient, so change the signature of genericType to instead return an
message that may be formatted as additional context in errors.
Along the way, refactor instantiatedType to have access to the entire
index expression.
Fixes#48827
Change-Id: I0c455c1ce46ac3f1ef2990c997da19e5fc6c4eae
Reviewed-on: https://go-review.googlesource.com/c/go/+/363994
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
During development, we used placeholder _Todo error codes for new
errors related to generics. Add real error codes in these places.
As a result, 9 new error codes are added for ~50 call sites.
Change-Id: Ib57b4cd9f0a2e160971a3aeea18f9fe26fc0f835
Reviewed-on: https://go-review.googlesource.com/c/go/+/363874
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
The main fix is that we should call ir.SetPos() at the beginning of
(*subster).node.edit function, since that is analogous to the
ir.SetPos() at the beginning of typecheck.typecheck(). It ensures that
transform functions can use base.Pos() with appropriate results, just
like their corresponding tc*() functions do.
A small fix is to make sure that the new nodes creates for dictionary
references have the correct position based on the location of the
function call.
Another small fix is to the use of base.Pos when creating a new selector
expression (including implicit XDOTs) for a method expression in
buildClosure().
Also, I converted the final use of base.Pos in stencil.go to src.NoXPos,
since the nodes created by AddImplicitDots will be checked for their
type, but won't actually be used.
I also needed to add an ir.SetPos() at the beginning of transformCall(),
since transformCall() is called in the modify and dict passes, when we
base.Pos is not being set for each node.
This change fixes all the line numbering problems printed out from
Alessandro's program, except for auto-generated functions (which I think
are fine).
Fixes#49523
Change-Id: I9836a497b7beba25ecafdde653a6c2036a3020d3
Reviewed-on: https://go-review.googlesource.com/c/go/+/363835
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Dan Scales <danscales@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Currently "released" is not accumulated bytes released. If the last
attempt to scavenge ends up as 0, then the scavenger will go to sleep
too soon. This is an artifact from the old code where scavenge would
only be called into once.
Change-Id: I85aa2261f1504a6fb5bf086daa029eecb0e09cf4
Reviewed-on: https://go-review.googlesource.com/c/go/+/363416
Trust: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
If the call to gcWriteBarrier is via PLT, the PLT stub will
clobber R1. Mark R1 clobbered.
For #49386.
Change-Id: I72df5bb3b8d10381fec5c567b15749aaf7d2ad70
Reviewed-on: https://go-review.googlesource.com/c/go/+/363698
Trust: Cherry Mui <cherryyz@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
We want package names exposed by reflect to be things like
main.F[main.foo], not main.F["".foo].
Fixes#49547
Change-Id: I182411a75d56ce1f64fde847e5b9ee74ce44e00b
Reviewed-on: https://go-review.googlesource.com/c/go/+/363656
Trust: Keith Randall <khr@golang.org>
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Dan Scales <danscales@google.com>
The simplified version of under exposed a bug (by crashing):
When a pointer base is used before the pointer is fully set
up, the base is nil. Set the pointer base to Typ[Invalid]
when creating the pointer, and add an extra safety check
into deref. Reviewed all code that creates pointers.
The same error cannot happen with other types because
accessing parts of another type results in an expression
that is not a type, and thus these kids of cycles cannot
happen.
Change-Id: I8332a281a534c094cfbb3623a636960865813ff6
Reviewed-on: https://go-review.googlesource.com/c/go/+/363665
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
Most of them are fixed, but some of them have been rewritten to refer
to specific issues.
For #45713
Change-Id: Id24d9bd47afeac089835f7a26e7025332fb6119c
Reviewed-on: https://go-review.googlesource.com/c/go/+/359794
Trust: Michael Matloob <matloob@golang.org>
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Instantiate already returns an error when validation fails. Panicking on
an incorrect number of type arguments means that callers must both
pre-validate the number of type arguments and handle resulting errors.
Returning an error rather than panicking allows eliminating
pre-validation at the call-site.
Also update the Instantiate docstring to correct some stale/inaccurate
information, and to clarify its behavior more precisely.
Updates #47916
Change-Id: I997ef30b3486760a90b0db4c3ea7111280d74a81
Reviewed-on: https://go-review.googlesource.com/c/go/+/363635
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
Add a test that exercises the fall-back logic in Context to handle hash
collisions by de-duplicating using Identical.
This has to be a somewhat invasive test because we don't know any actual
cases of hash collisions.
Change-Id: Idf00f7a6ab8c7517ed0f91fdc42d54f5e736b1b9
Reviewed-on: https://go-review.googlesource.com/c/go/+/363517
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
This test is failing with -G=0, so specify -G=3.
Change-Id: I4c74707d0a43f8191cb0b156204604458ba85136
Reviewed-on: https://go-review.googlesource.com/c/go/+/363699
Trust: Robert Findley <rfindley@google.com>
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Dan Scales <danscales@google.com>
Now that we have a Context type the context (unexported) type is
particularly confusing. Rename it to environment.
Change-Id: I7d280439b8263d9ebfd561fc4d59c6d43c8d3e3f
Reviewed-on: https://go-review.googlesource.com/c/go/+/363176
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
Users can re-use a type checking context by passing it via types.Config.
There is no need for us to expose the internal type checking context
when the config context is unset, and in fact doing so could lead to a
memory leak for users that re-use types.Config, expecting it to be small
and immutable.
Keep track of the Context on Checker instead, and zero it out at the end
of type checking.
Change-Id: Iff5b328a09cd0af76fcd4869f5f15352131b5986
Reviewed-on: https://go-review.googlesource.com/c/go/+/363175
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
The interface type string preserves certain non-semantic attributes of
the type, such as embedded interfaces. We want the hash to represent the
interface identity, so hash the type set representation of the interface
instead.
Change-Id: I14081ac20b738c5fe11785e0846a9b4358594768
Reviewed-on: https://go-review.googlesource.com/c/go/+/363115
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
Type parameter names don't matter for the purposes of generic type
identity, so mask them with numeric placeholders when hashing.
Change-Id: Iacb4c23abecdd733fc292ae13ecac6baa2c5524c
Reviewed-on: https://go-review.googlesource.com/c/go/+/363114
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
Extend the type checking context to allow de-duplicating *Signature
instances, in addition to *Named instances.
Naively we would deduplicate instances of different-but-identical origin
*Signature types. That may be OK, but it seems a bit strange to get the
same signature when instantiating two different functions. For now,
differentiate *Signature types by prepending a unique identifier for the
origin pointer, thus guaranteeing that instances de-duplicated if they
come from the exact same (pointer identical) origin type.
Updates #47103
Change-Id: I93cc3cacad195267fe0a5801f9c5a3b1e61eb907
Reviewed-on: https://go-review.googlesource.com/c/go/+/362801
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
Added/clarified some comments.
Change-Id: Ib08d3343ff08c23cc8880a27a0148d1ff077a80f
Reviewed-on: https://go-review.googlesource.com/c/go/+/363654
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
In the few remaining places where we use asNamed, if the argument
is indeed a *Named, we either don't need to look "inside" it, or
we call under() (which calls Named.underlying() which does resolve);
so there's no need for an implicit resolution (which was done by
asNamed). The only place where we do need to resolve is in lookup,
so added the explicit resolve call in that case.
Change-Id: Iff0a19fde7581e94149e89b9e48157c1981db105
Reviewed-on: https://go-review.googlesource.com/c/go/+/363441
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
Reviewed the code and simplified slightly. No semantic changes.
Change-Id: Ib785b912fbee97746324af87ac0c14a4bdb69477
Reviewed-on: https://go-review.googlesource.com/c/go/+/363440
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
This CL enables the mode in which the underlying type of
type parameters is the underlying type of their constraints.
Change-Id: Id3471578dab098695dbd1e0429356ebcc9c5e224
Reviewed-on: https://go-review.googlesource.com/c/go/+/363155
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
Until now, the type checker operated with the definition that the
underlying type of a type parameter is itself. This leads to some
inconcistencies and caused us to disallow type declarations where
the RHS is a stand-alone type parameter.
This change implements an alernative definition: the underlying
type of a type parameter is the underlying type of its constraint;
i.e., the underlying type of a type parameter is always an interface
(because constraints must be interfaces). This matches the theory
closely and also resolves some inconsistencies. For example, we
don't need to prohibit stand-alone type parameters on the RHS of
a type declaration (though, for the sake of keeping the tests the
same, we still do in this CL). We also get a clear understanding of
what it would mean to use a type assertion or type switch on a type
parameter (still disabled with this CL). Finally, the declaration
of a type parameter now very closely matches the definition of an
ordinary type.
The main consequence is that the rules for assignment need to be
slightly modified: even though a type parameter is an interface,
we cannot simply assign to it per the rules for interfaces: the
type parameter's type is fixed for the instantiation and we need
to reflect that accordingly when checking for assignability.
This CL does not enable the new mode, it implements it in parallel
to the existing mode; the internal flag tparamIsIface is used to
switch between the modes.
The changes to the code are numerous, but straight-forward: when-
ever we deal with an underlying type that might be a type parameter
(or newly, an interface), we need to act slightly differently. For
the time being this leads to some code duplication because the code
supports both modes.
While some of the code for the new mode seems more complicated
(e.g., when we have an interface, the code checks that it is not
the underlying type of a type parameter), in reality many of the
extra checks are redundant and only present because of an abundance
of caution: interfaces with specific type sets are not permitted as
types for ordinary variables, and so even if we were to hit those
cases w/o excluding type parameters the behavior would be the same.
Runs all tests with tparamIsIface enabled and disabled.
Current setting: disabled.
Change-Id: I7bb6453f4fe2569d92face222058fb4e17b12f25
Reviewed-on: https://go-review.googlesource.com/c/go/+/359016
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
Server handlers may set a "Transfer-Encoding: identity" header on
responses to disable chunking, but this header should not be sent
on the wire.
Fixes#49194.
Change-Id: I46a9e3b8ff9d93edd7d1c34d264fc309fa322ad5
Reviewed-on: https://go-review.googlesource.com/c/go/+/359176
Trust: Damien Neil <dneil@google.com>
Run-TryBot: Damien Neil <dneil@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>