Commit Graph

44472 Commits

Author SHA1 Message Date
Robert Griesemer 4545287c1b [dev.go2go] go/types: don't panic if receiver type arguments cannot be inferred
This can happen due to earlier errors. This change avoids the panic
but reports a follow-up error. Not ideal, but good enough for now.

Fixes #40056.

Change-Id: I500d4fc2b058cdc70f28883ff8d004df4b43fe4e
Reviewed-on: https://go-review.googlesource.com/c/go/+/241130
Reviewed-by: Robert Griesemer <gri@golang.org>
2020-07-07 03:13:21 +00:00
Robert Griesemer 17564d8957 [dev.go2go] go/types: do not permit generic types in type switch type lists
Fixes #40057.

Change-Id: Ia1a99378614fda1d0cb3d6b9cf53bbf790fc2953
Reviewed-on: https://go-review.googlesource.com/c/go/+/241126
Reviewed-by: Robert Griesemer <gri@golang.org>
2020-07-07 00:22:28 +00:00
Ian Lance Taylor cfb6cac804 [dev.go2go] go/go2go: handle embedded pointers to instantiated types
Change-Id: I47d23dd4a44c644e9ec2f1abbc3cd8cec4a35d04
Reviewed-on: https://go-review.googlesource.com/c/go/+/241125
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-07-06 23:38:47 +00:00
Ian Lance Taylor b97f992a7e [dev.go2go] go/go2go: F(type)() is not a parameterized function
Fixes #40015

Change-Id: I4e70398e693a53268d3400e829a179c76ff70e75
Reviewed-on: https://go-review.googlesource.com/c/go/+/241124
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-07-06 23:18:11 +00:00
Robert Griesemer c583a5d512 [dev.go2go] go/types: add test for crash 15 from issue 39634
This test case doesn't crash anymore.

Updates #39634.

Change-Id: I29b13762265ef1c16c0298d141fdb6cf2c01f4ee
Reviewed-on: https://go-review.googlesource.com/c/go/+/241123
Reviewed-by: Robert Griesemer <gri@golang.org>
2020-07-06 22:08:08 +00:00
Robert Griesemer a599706090 [dev.go2go] go/types: don't crash instantiating defined types that are not fully set up
Addresses crash #16 of #39634.

Updates #39634.

Change-Id: I33063d6e2176586f097d2d1391f490f1775a2202
Reviewed-on: https://go-review.googlesource.com/c/go/+/241122
Reviewed-by: Robert Griesemer <gri@golang.org>
2020-07-06 22:00:41 +00:00
Robert Griesemer 005397e36d [dev.go2go] go/types: don't crash instantiating arrays/slices that are not fully set up
Addresses crash #18 of #39634.

Updates #39634.

Change-Id: I4b1a3d81ce9dc2b59ae9af3146d26f79d8c05973
Reviewed-on: https://go-review.googlesource.com/c/go/+/240904
Reviewed-by: Robert Griesemer <gri@golang.org>
2020-07-06 21:54:48 +00:00
Pavlo Bashynskyi 0e1fc80d04 [dev.go2go] cmd/go2go: correct URL in README
Change-Id: I947c0181512b7d5dd4219cec92262bd1f443b957
GitHub-Last-Rev: 44ec636b89
GitHub-Pull-Request: golang/go#40054
Reviewed-on: https://go-review.googlesource.com/c/go/+/241039
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-07-05 19:48:30 +00:00
Robert Griesemer 34f76220c3 [dev.go2go] go/types: make sure arrays, slices always have an element type
Addresses crash #19 of #39634.

Updates #39634.

Change-Id: I42208511a3fc27432891243dcf4799e80432c2c1
Reviewed-on: https://go-review.googlesource.com/c/go/+/240903
Reviewed-by: Robert Griesemer <gri@golang.org>
2020-07-04 04:55:49 +00:00
Robert Griesemer 6e86f51c54 [dev.go2go] go/types: don't rely on completed interfaces in isParameterized predicate
Also, take type lists into account when computing predicate.
Addresses crash #27 of #39634.

Updates #39634.

Change-Id: Id6e1d0d86ac1cb9d79828a3b5fdfbeba0e6aace0
Reviewed-on: https://go-review.googlesource.com/c/go/+/240902
Reviewed-by: Robert Griesemer <gri@golang.org>
2020-07-03 22:37:04 +00:00
Robert Griesemer 167909e5f5 [dev.go2go] go/types: don't modify Named.underlying when checking validity
Addresses crash #20 of #39634.
Added test, also for some of the other cases that don't crash
anymore.

Updates #39634.

Change-Id: I999e376985a443ac435f64a7c249f891e7b7a6d7
Reviewed-on: https://go-review.googlesource.com/c/go/+/240901
Reviewed-by: Robert Griesemer <gri@golang.org>
2020-07-03 22:20:59 +00:00
Ian Lance Taylor 4dde96e380 [dev.go2go] go/go2go: resolve pointers in sameType
Fixes #39982

Change-Id: Ieb33381716662b44464104e0073a52ab5c19b7c6
Reviewed-on: https://go-review.googlesource.com/c/go/+/240899
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-07-03 19:26:32 +00:00
Robert Griesemer 85ed317eb2 [dev.go2go] go/types: fix computation of type hash
Fixes #39982.

Change-Id: I4e7b52c34bf8df63f2063dc2504a8125ca7585a0
Reviewed-on: https://go-review.googlesource.com/c/go/+/240737
Reviewed-by: Robert Griesemer <gri@golang.org>
2020-07-02 00:33:43 +00:00
Robert Griesemer 182889ccf5 [dev.go2go] go/types: better error message when converting to a constraint interface
Fixes #39699.

Change-Id: Ib2a756a275c0f96201800d947a72db49d3319a3e
Reviewed-on: https://go-review.googlesource.com/c/go/+/240720
Reviewed-by: Robert Griesemer <gri@golang.org>
2020-07-01 22:50:35 +00:00
Robert Griesemer 05f750de93 [dev.go2go] go/types: HasTypeList, IsComparable, IsConstraint predicates for interfaces
HasTypeList existed before but now is also written such that it doesn't
expect an interface to be complete.

Change-Id: I43e8d652c6be755473b201a64bf41d363214881c
Reviewed-on: https://go-review.googlesource.com/c/go/+/240719
Reviewed-by: Robert Griesemer <gri@golang.org>
2020-07-01 22:50:26 +00:00
Robert Griesemer d014fca6d4 [dev.go2go] go/types: fix assertion failure, better error message for inference failure
Fixes #39976.

Change-Id: Idc304a615193847337438e7024e43140472e7bae
Reviewed-on: https://go-review.googlesource.com/c/go/+/240718
Reviewed-by: Robert Griesemer <gri@golang.org>
2020-07-01 20:30:10 +00:00
Robert Griesemer 6cf6bf162c [dev.go2go] go/types: report inferred type when a type argument doesn't match
Fixes #39725.

Change-Id: I48248283ae0eb635d489d8661512f32b98700c1a
Reviewed-on: https://go-review.googlesource.com/c/go/+/240523
Reviewed-by: Robert Griesemer <gri@golang.org>
2020-07-01 00:31:32 +00:00
Ian Lance Taylor 938e96e732 [dev.go2go] go/go2go: instantiate embedded field when needed
If an embedded field is an instantiated type, we need to instantiate
it when instantiating the whole type, in case the type arguments
themselves need instantiation.

Fixes #39953

Change-Id: I80b57456aa4f8e8b2eff82359066c37a9c2a40f5
Reviewed-on: https://go-review.googlesource.com/c/go/+/240522
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-06-30 23:46:04 +00:00
Robert Griesemer 08b9fd164c [dev.go2go] go/types: better error message when confusing a type parameter with an interface
Fixes #39948.

Change-Id: I868d2264a674a92c39fbe31d89bc002dd74c26fe
Reviewed-on: https://go-review.googlesource.com/c/go/+/240520
Reviewed-by: Robert Griesemer <gri@golang.org>
2020-06-30 19:00:27 +00:00
Robert Griesemer 1e27b76ebd [dev.go2go] go/types: report "inifinite expansion" cycles across instantiated types
Fixes #39938.

Change-Id: I482b211189cefdc098df5acb4f858f6f1635ce60
Reviewed-on: https://go-review.googlesource.com/c/go/+/240519
Reviewed-by: Robert Griesemer <gri@golang.org>
2020-06-30 17:48:56 +00:00
Robert Griesemer 236ad5a280 [dev.go2go] go/types: fix broken test case
While at it, simplified test case a bit.

Fixes #39935.
Updates #39754.

Change-Id: Ia3b51f23807d25e62113757c51a660c7e3a9b381
Reviewed-on: https://go-review.googlesource.com/c/go/+/240478
Reviewed-by: Robert Griesemer <gri@golang.org>
2020-06-30 03:51:21 +00:00
tdakkota 71c7be55eb [dev.go2go] go/types: fix type check skipping for constraints when th…
…ere’s more than one generic constraint.

Check of first constraint was breaking the loop, so other constraints was skipped

Fixes #39754.

Change-Id: I48caa380472371a438c2d2029d1383d03dbf22df
GitHub-Last-Rev: bf418db782
GitHub-Pull-Request: golang/go#39902
Reviewed-on: https://go-review.googlesource.com/c/go/+/240339
Reviewed-by: Robert Griesemer <gri@golang.org>
2020-06-29 16:07:10 +00:00
Ian Lance Taylor 10ea225e28 [dev.go2go] go/go2go: translate types to AST
We were relying on calling typeString and treating that as an AST ident,
with special handling for instantiated types, but that fails if there is
an instantiated type within a type literal.

Fixes #39881

Change-Id: I793fe359868d8d73e830aa8dc67cf52de99355a8
Reviewed-on: https://go-review.googlesource.com/c/go/+/240197
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-06-26 22:32:53 +00:00
Ian Lance Taylor 93014c51d1 [dev.go2go] go/go2go: avoid crashing on predeclared error type
It has no package, so we need to check for Pkg() == nil.

Fixes #39878

Change-Id: I14a47c5098f97ce42dfa8cc875819f244a2b0201
Reviewed-on: https://go-review.googlesource.com/c/go/+/240013
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-06-26 18:43:49 +00:00
Ian Lance Taylor 1b08acee45 [dev.go2go] go/go2go: don't add importable name to test file
No test case because we will don't have a general test harness.

Fixes #39851

Change-Id: If7b1262404f390eba80d53c2c1d40724252a5833
Reviewed-on: https://go-review.googlesource.com/c/go/+/240004
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-06-25 23:22:18 +00:00
Ian Lance Taylor 4dfbf5ab9c [dev.go2go] go/go2go: add package qualifier when needed
Fixes #39842

Change-Id: I5046f1bdd7dbc6d1e17cf3835826933aaadf1581
Reviewed-on: https://go-review.googlesource.com/c/go/+/239711
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-06-25 02:57:14 +00:00
Ian Lance Taylor a9f31a8c68 [dev.go2go] cmd/go2go: doc: instantiations can't refer to unexported names
For #39840

Change-Id: Ifc2a95fbd50cbf785251d05042e554872e1e79cc
Reviewed-on: https://go-review.googlesource.com/c/go/+/239709
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-06-24 23:56:06 +00:00
Ian Lance Taylor acd7923802 [dev.go2go] go/go2go: add IDs for test files
No test because the test harness doesn't support test packages.
(But probably we'll need a better test harness.)

Fixes #39839

Change-Id: I4532b1443dbdd081552ffb78477cbe5039183416
Reviewed-on: https://go-review.googlesource.com/c/go/+/239708
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-06-24 23:41:00 +00:00
Ian Lance Taylor 2dce748bd8 [dev.go2go] go/go2go: if we have an import path, pass it to go/types
No test because it doesn't really fit into the current test harness.

FIxes #39797

Change-Id: I410217a0e6b3af6808a111d0edbafaa3047b12f1
Reviewed-on: https://go-review.googlesource.com/c/go/+/239707
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-06-24 22:35:01 +00:00
Ian Lance Taylor f04e0ee126 [dev.go2go] go/go2go: include package in instantation of ident
If an instantiated function from a different package uses a plain
identifier to instantiate a generic type or function, include the
package name in the generated identifier.

Fixes #39834

Change-Id: I4c786bac8972475e180cb41178520439343a36ea
Reviewed-on: https://go-review.googlesource.com/c/go/+/239706
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-06-24 22:15:29 +00:00
Ian Lance Taylor 5b16464101 [dev.go2go] test: keep translated .go2 files if -k
Change-Id: I8f696c201c00d422b176a65ae72e384cc11e1efb
Reviewed-on: https://go-review.googlesource.com/c/go/+/239704
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-06-24 21:34:54 +00:00
Ian Lance Taylor af16dac1b0 [dev.go2go] go/go2go: don't import both "./a" and "a"
For #39797

Change-Id: I4063a0138062ce8dc1f35cc7fef7c6773c939362
Reviewed-on: https://go-review.googlesource.com/c/go/+/239703
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-06-24 21:33:55 +00:00
Ian Lance Taylor fa201df81e [dev.go2go] go/go2go: update name of embedded pointer to instantiation
Fixes #39774

Change-Id: Icb2948ae19e06a3766e7edb01ef40de50e7aca7e
Reviewed-on: https://go-review.googlesource.com/c/go/+/239702
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-06-24 21:01:03 +00:00
DeedleFake 2dc2987ac8 cmd/go2go: standardize help flag with other tools
A very small change because the `--help` flag printing nothing was bugging me.

Change-Id: I221c657ba055e94db7a574c8e8fd044bb135f8b1
GitHub-Last-Rev: 8781a1a29f
GitHub-Pull-Request: golang/go#39788
Reviewed-on: https://go-review.googlesource.com/c/go/+/239537
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-06-23 23:41:16 +00:00
Ian Lance Taylor e6e8041d02 [dev.go2go] go/go2go: resolve type alias of parameterized type
Fixes #39792

Change-Id: I9eab19a4f516be5a71e71f04b91c4e46b189fba9
Reviewed-on: https://go-review.googlesource.com/c/go/+/239598
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-06-23 23:35:25 +00:00
Robert Griesemer 2faeebf4e5 [dev.go2go] go/types: permit alias to generic type
Fixes #39768.

Change-Id: I68c8fbec5adc50e448dabe90b212ef147a384a06
Reviewed-on: https://go-review.googlesource.com/c/go/+/239387
Reviewed-by: Robert Griesemer <gri@golang.org>
2020-06-23 04:54:48 +00:00
Robert Griesemer 6ca930a00a [dev.go2go] go/types: add internal TODO for future simplification
Change-Id: I8e4e8eebf8c64962ccf5f0e225dd007f691c373a
Reviewed-on: https://go-review.googlesource.com/c/go/+/239384
Reviewed-by: Robert Griesemer <gri@golang.org>
2020-06-22 23:46:33 +00:00
Ian Lance Taylor dfb538cec8 [dev.go2go] go/go2go: don't permit underscore as type argument
The go/types package doesn't give us an easy way to get the type,
so just reject it.

Fixes #39743

Change-Id: I5404c10baede0fd2cf67980b06fbebd214a50dff
Reviewed-on: https://go-review.googlesource.com/c/go/+/239382
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-06-22 23:30:28 +00:00
Ian Lance Taylor 404a12f056 [dev.go2go] go/go2go: use package name, not package path
types.TypeString defaults to using the package path for references to names.
Provide our own types.Qualifier that uses just the package name,
since that is what the translated code has to use.

Fixes #39744

Change-Id: Icde289b2ed0fdd9b0a9aae6aae4557a8951d25a4
Reviewed-on: https://go-review.googlesource.com/c/go/+/239381
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-06-22 23:05:26 +00:00
Ian Lance Taylor a367b7d270 [dev.go2go] go/go2go: check for instantiation with locally defined type
Fixes #39738

Change-Id: I1a3536484a982ec713019572ff7b3c0c36af9784
Reviewed-on: https://go-review.googlesource.com/c/go/+/239380
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-06-22 22:19:20 +00:00
Ian Lance Taylor 9b13ca00f8 [dev.go2go] go/go2go: ignore struct tags
Ignore struct tags when generating an instantiated names, and when
comparing types for identity.

Fixes #39737

Change-Id: I53e67fa1d09214dafc4088a59eb00e1a6f18ef3d
Reviewed-on: https://go-review.googlesource.com/c/go/+/239379
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-06-22 22:07:26 +00:00
Robert Griesemer da7932368b [dev.go2go] go/types: implement a few more predicates for type list sums
Also: Don't convert an untyped nil to a type parameter when
checking if an untyped value (nil) can be coverted to a target
type.

Fixes #39755.

Change-Id: Ib2645759dc659b9c80c2d0a457180eb9616c7cb9
Reviewed-on: https://go-review.googlesource.com/c/go/+/239338
Reviewed-by: Robert Griesemer <gri@golang.org>
2020-06-22 19:06:44 +00:00
Ian Lance Taylor e643c9792f [dev.go2go] go/go2go: avoid multiple identical instantiations
Move tracking of instantiations from translator to Importer,
so that we can track all instantiations within a package
to avoid duplicates.

Fixes #39749

Change-Id: If6cd5bcdc6e19c2d6481e62a6187ddf7f4fac72a
Reviewed-on: https://go-review.googlesource.com/c/go/+/239337
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-06-22 18:38:41 +00:00
Ian Lance Taylor 6500ed4790 [dev.go2go] go/go2go: instantiate local type specs
Fixes #39741

Change-Id: I75e3b98afa5184b87d4a7bbf360761e5cc6c6217
Reviewed-on: https://go-review.googlesource.com/c/go/+/239297
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-06-22 17:38:38 +00:00
Robert Griesemer 0a030888da [dev.go2go] go/types: use the underlying type of type list entries
Type lists can contain defined types, make sure we use their
underlying types when computing operational types.

Change-Id: I8b6b11302f6b28977916e495f1486cc7b352e859
Reviewed-on: https://go-review.googlesource.com/c/go/+/239163
Reviewed-by: Robert Griesemer <gri@golang.org>
2020-06-20 04:46:40 +00:00
Robert Griesemer c0c872e8b0 [dev.go2go] go/types: the underlying type of a type parameter is itself
No need to call Under() when we know that we have a type parameter.

While at it: Turn off debug mode.

Change-Id: Ia0b39d88191c8e5ac580e7e84a512061911c40cf
Reviewed-on: https://go-review.googlesource.com/c/go/+/239162
Reviewed-by: Robert Griesemer <gri@golang.org>
2020-06-20 03:57:21 +00:00
Robert Griesemer cbdb93d5a7 [dev.go2go] go/types: a type constraint must be an interface
In particular, it cannot be a type parameter
with an operational type that is an interface.

Fixes #39723.

Change-Id: Ia6b65eaecd472dd71b1c9f7631ce1872f06e5a6d
Reviewed-on: https://go-review.googlesource.com/c/go/+/239161
Reviewed-by: Robert Griesemer <gri@golang.org>
2020-06-20 03:49:15 +00:00
Ian Lance Taylor 815b29d859 [dev.go2go] go/go2go: get package name from package, not import path
No test because the test framework doesn't easily support
package paths containing a dot.

Fixes #39722

Change-Id: If43dc768b28f521d10bd2ef4288aa789aa4bee01
Reviewed-on: https://go-review.googlesource.com/c/go/+/239160
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-06-20 00:45:10 +00:00
Robert Griesemer 7473c4383e [dev.go2go] go/types: check for duplicate types after interfaces were completed
Fixes #39711.

Change-Id: Id0efb854a42bd88a66be8165fa3444e33d1c8f8d
Reviewed-on: https://go-review.googlesource.com/c/go/+/239158
Reviewed-by: Robert Griesemer <gri@golang.org>
2020-06-20 00:41:07 +00:00
Ian Lance Taylor ccaf3f5560 [dev.go2go] go/go2go: don't crash on an unnamed receiver
Fixes #39707

Change-Id: I20e5fe2990ceda5429f1a22edf48494d2c6496a2
Reviewed-on: https://go-review.googlesource.com/c/go/+/239159
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-06-20 00:36:20 +00:00