Commit Graph

44516 Commits

Author SHA1 Message Date
Ian Lance Taylor bc00f5ba9f [dev.go2go] test: drop type keyword, always provide constraint
This is a rewrite to drop the type keyword for parameterized functions
and types, and to instead always provide a constraint.

We can revert if we don't like this approach.

Change-Id: If4669fb4e2015067e9f955ff8567ed421be639ea
Reviewed-on: https://go-review.googlesource.com/c/go/+/248880
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-08-17 17:54:48 +00:00
Robert Griesemer af48c2e84b [dev.go2go] go/types: use actual (not underlying) types of type list elements for interface satisfaction
This is a rule change in an attempt to streamline interface satisfaction:
If a (constraint) interface contains a type list, a type argument's type
or underlying type must be included in the type list (and the interface's
methods must be present, of course). Until now, a type argument's under-
lying type had to be one of the underlying types of the types in the type
list.

The effect is subtle: Because an underlying type is never a defined type,
if a type list contains defined types, only those defined types satisfy
the interface. If we want the interface to be more flexible, we can in-
clude non-defined types in its type list. In the common case, type lists
simply contain predeclared types (whose underlying types are themselves),
so this doesn't matter. An observable difference appears only for code
that currently uses defined types in constraint type lists: such code
becomes slightly more restrictive.

The primary benefit of this change is that it opens the door for general
(non-constraint) use of interfaces with type lists: Using the same rules
as for constraint satisfaction, a value may be assigned to a variable of
such an interface if it or its underlying type of the value is included
int the interface's type list. If the type list contains only defined types,
the respective interface acts like a sum type: it can only contain values
of those types (and nil).

This CL only changes the rules for constraints. It does not permit
interfaces with type lists for general (non-constraint) use for now.

Change-Id: I3f25b9d883dd865a74c583efee4be2e22258d493
Reviewed-on: https://go-review.googlesource.com/c/go/+/248265
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2020-08-14 23:21:42 +00:00
Robert Griesemer 722af87f62 [dev.go2go] go/types: determine if type declaration is generic based on use of type parameter
This change makes it possible to declare a generic type with exactly
one type parameter and no constraints without any special syntactic
augmentation: Instead, the parser determines whether a declaration
of the form

	type T[P] type_literal

is an array or generic declaration based on how the type parameter
P is used in type_literal. If P appears only in array lengths (if
at all) in type_literal, T is an array type. Otherwise it is a
generic type.

Change-Id: I6c1d62d61d04f322d73ee16840e0f3ffe299f4c7
Reviewed-on: https://go-review.googlesource.com/c/go/+/248438
Reviewed-by: Robert Griesemer <gri@golang.org>
2020-08-14 05:30:01 +00:00
Robert Griesemer c3a77cc2d3 [dev.go2go] go/types: predeclare type any interface{} (experiment)
For fine-tuning the type parameter list notation. If we
proceed with square brackets rather than parentheses, we
don't need the "type" keyword in type parameter lists in
many cases. However, generic type declarations with one
type parameter and no constraint must somehow disambiguate
from array type declarations:

	type T[P] E

could be a generic type, or an array type declaration

	type T [P]E

There's a variety of choices for disambiguation, such as:

	type T[type P] E         // what we do now
	type T[P interface{}] E  // currently permitted
	type T[P any] E          // permitted with this CL
	type T[P,] E             // currently permitted

If we abandon the "type" keyword (currently optional), we
need an alternative. Writing the constraint seems nicer than
the comma option (in Go, all parameter lists permit a trailing
comma, but an array length specification doesn't allow it).
If we write the constraint, which is often the empty interface,
being able to write "any" would be more convenient.

In the past we have refused to add "any" to the language. There
may be many more situations where we need to specify an empty
constraint (any) so perhaps adding "any" is now justified. It
would also streamline a lot of existing code such as

	Printf(format string, args... any)

Change-Id: I366342ba8d981d344c96b1ceb60f61d963e9175a
Reviewed-on: https://go-review.googlesource.com/c/go/+/248263
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2020-08-14 05:13:41 +00:00
Robert Griesemer 2b748f02a0 [dev.go2go] cmd/compile/internal/types2: fix instantiation crash for generic type parameters
Port of go/types CL https://golang.org/cl/247498.

Updates #40038.

Change-Id: Iab002132627b689e0113c087b3f4d38c6356c3a3
Reviewed-on: https://go-review.googlesource.com/c/go/+/248058
Reviewed-by: Robert Griesemer <gri@golang.org>
2020-08-12 00:03:11 +00:00
Robert Griesemer fc29b9010e [dev.go2go] cmd/compile/internal/types2: add special case report for generic map key type
Port of go/types CL https://golang.org/cl/247258. (The typeparamsB.go2
version of typeparams.go2 doesn't exist yet for types2.)

Updates #40551.

Change-Id: If2b329372bd4d160b4def8b66cc87f25ed4823fd
Reviewed-on: https://go-review.googlesource.com/c/go/+/248057
Reviewed-by: Robert Griesemer <gri@golang.org>
2020-08-12 00:03:09 +00:00
tdakkota cb2cbbcda2 [dev.go2go] go/types: fix instantiation crash for generic type parame…
…ters

Fixes #40038.

Change-Id: I5b095d01fd1e3703561c179c34ddc3b43d7510f6
GitHub-Last-Rev: 3e5067a780
GitHub-Pull-Request: golang/go#40644
Reviewed-on: https://go-review.googlesource.com/c/go/+/247498
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2020-08-11 16:59:21 +00:00
tdakkota 6d33075156 [dev.go2go] go/types: add special case report for generic map key type
Fixes #40551.

Change-Id: Ifc10dbdcdbee6af5bdbfc36ec78e1a4361672acc
GitHub-Last-Rev: 8d373dee63
GitHub-Pull-Request: golang/go#40628
Reviewed-on: https://go-review.googlesource.com/c/go/+/247258
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2020-08-11 16:58:03 +00:00
Robert Griesemer ead7e9b351 [dev.go2go] cmd/compile/internal/syntax: add more parser tests
Updated existing tests to more closely match the go/types
tests; added *B.go2 versions for some tests, using [] for
type parameters.

Change-Id: Ie7cfd9f5515f541d9422a2b2ab8a5d3e02d0499a
Reviewed-on: https://go-review.googlesource.com/c/go/+/246261
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2020-08-01 05:14:38 +00:00
Robert Griesemer d8b0f3b91f [dev.go2go] go/parser: p.T(P) is a valid instantiated parameter type (fix bug)
The existing code didn't accept an instantiated imported (qualified) type
as type for a regular function parameter.

Also: Simplified logic around use of typeContext flag when []'s
      are used for type parameters.

Change-Id: Ic6c60e943344a976f5b8546c8a378ebd32a82d90
Reviewed-on: https://go-review.googlesource.com/c/go/+/246260
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2020-08-01 01:12:24 +00:00
Robert Griesemer 417abfbaf1 [dev.go2go] cmd/compile/internal/syntax: accept [] for type parameter lists
Still missing:
- embedded []-instantiated types in interfaces
- *B.go2 tests which exist for go/types

Change-Id: I3dd115fcd67f725144062c90550a91fcded1cbe2
Reviewed-on: https://go-review.googlesource.com/c/go/+/246259
Reviewed-by: Robert Griesemer <gri@golang.org>
2020-08-01 01:12:23 +00:00
Robert Griesemer c77c3236b1 [dev.go2go] cmd/compile/internal/types2: remove most token.Token dependencies
The remaining uses of token.Token are needed for the go/constant API.

Change-Id: I5dc8be1fae16217433da1acb5606fd1d7b8eea54
Reviewed-on: https://go-review.googlesource.com/c/go/+/246257
Reviewed-by: Robert Griesemer <gri@golang.org>
2020-08-01 01:12:22 +00:00
Robert Griesemer 569c893c93 [dev.go2go] types2: update to include the latest go/types changes
This brings types2 (the syntax-based type-checker) up-to-date
with the latest version of the prototype go/types version. It
does not yet include the *B.go2 tests (using square brackets)
or the relevant syntax parser changes.

Tests that check error positions continue to be disabled since
the synax parser records slightly different positions than the
go/parser (to be fixed).

Manually verified that selected *.go2 tests which don't report
errors pass. Type-checks the std library without errors.

Change-Id: If859b180bba8362db86c211eeb4dc2d46255df36
Reviewed-on: https://go-review.googlesource.com/c/go/+/246137
Reviewed-by: Robert Griesemer <gri@golang.org>
2020-07-31 06:05:23 +00:00
Robert Griesemer deb678cebf [dev.go2go] go/types: add testcase for crash 9 of #39634
This test passes type-checking without problems but the
generated code causes a cmd/compile error (filed #40486).

Updates #39634.

Change-Id: If3dd28605f6d8792c6bd5bb032624e9a6140b2c0
Reviewed-on: https://go-review.googlesource.com/c/go/+/245742
Reviewed-by: Robert Griesemer <gri@golang.org>
2020-07-30 04:50:09 +00:00
Robert Griesemer 15144bdc72 [dev.go2go] go/types: fix isParameterized predicate
When checking if a type is parameterized, we only care about
type parameters bound to the specific type, not "free" type
parameters. The old code simply looked for "any" type parameter.

Change-Id: I6a3fe5ac7e3150c5796d4b7576682ab3d4b8558f
Reviewed-on: https://go-review.googlesource.com/c/go/+/245741
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2020-07-30 04:50:01 +00:00
Robert Griesemer 88496095d2 [dev.go2go] go/types: remove incorrect assert and replace with explanatory comment
Addresses crash 26 of #39634.
Also, added test case for crash 25 which was fixed with
https://golang.org/cl/245739.

Updates #39634.

Change-Id: I19793eb79fce63052ba055cde0b1dafdd9476895
Reviewed-on: https://go-review.googlesource.com/c/go/+/245740
Reviewed-by: Robert Griesemer <gri@golang.org>
2020-07-30 04:00:56 +00:00
Robert Griesemer f0e6640956 [dev.go2go] go/types: generic types in selector expressions must be instantiated
Addresses crash 24 of #39634.

Updates #39634.

Change-Id: If44e834834a07719e7f727d12cc24ac4af0997e6
Reviewed-on: https://go-review.googlesource.com/c/go/+/245739
Reviewed-by: Robert Griesemer <gri@golang.org>
2020-07-30 00:57:09 +00:00
Robert Griesemer 0db4da527f [dev.go2go] go/types: don't crash in assignment due to prior errors
Addresses crash #12 of 39634.

Updates #39634.

Change-Id: Ie67545d21b6a1e80fcdec1b2eb101b69c25e2952
Reviewed-on: https://go-review.googlesource.com/c/go/+/245738
Reviewed-by: Robert Griesemer <gri@golang.org>
2020-07-30 00:27:38 +00:00
Robert Griesemer d118bf7ce9 [dev.go2go] go/types: don't crash in lookup of incomplete interface
Also, update some comments.

Updates #39634.

Change-Id: I85c63e4b941e2bc04e8b5a59497fc47e5d578b8b
Reviewed-on: https://go-review.googlesource.com/c/go/+/245737
Reviewed-by: Robert Griesemer <gri@golang.org>
2020-07-30 00:10:38 +00:00
Robert Griesemer df58427917 [dev.go2go] go/types: remove need to enumerate test files, clean up test handling
- Reorganize testdata directory to either contain single-file packages
or (one level of) sub-directories containing multi-file packages.

- Add TestTestdata that runs all the tests in testdata.

- Change TestCheck to only test files explicitly provided via -files.

Providing -v when running these tests now enumerates the packages.
For TestCheck it also prints the type-checking trace.

Change-Id: I66536881789234af030a0a2c9fc096822f593782
Reviewed-on: https://go-review.googlesource.com/c/go/+/244629
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2020-07-24 22:57:29 +00:00
Robert Griesemer 131fbfb416 [dev.go2go] go/types: remove need to enumerate examples and fixedbugs test files
Just traverse the respective directories.

Change-Id: I21432e23550d8331e61d3392e8488c81183ab6f0
Reviewed-on: https://go-review.googlesource.com/c/go/+/244628
Reviewed-by: Robert Griesemer <gri@golang.org>
2020-07-24 20:13:27 +00:00
Robert Griesemer edac449852 [dev.go2go] go/types: clean up test support code and remove global variables
Change-Id: I152d2f4ca95f8217502d796ac49a8c96e5aba60b
Reviewed-on: https://go-review.googlesource.com/c/go/+/244627
Reviewed-by: Robert Griesemer <gri@golang.org>
2020-07-24 19:40:13 +00:00
Robert Griesemer d0e6f20899 [dev.go2go] go/parser: make "type" optional in generic type declarations
Experiment: Make "type" keyword optional in generic type declarations when
it is clear that we can't have an array type declaration. This is the case
when we have one the following:

- more than one type parameter
- a type parameter with a constraint
- a trailing comma in the type parameter list

Change-Id: If6c473ba93b993a7c15ff2f7e7302709cc985f9e
Reviewed-on: https://go-review.googlesource.com/c/go/+/244623
Reviewed-by: Robert Griesemer <gri@golang.org>
2020-07-24 18:10:25 +00:00
Robert Griesemer fad691cf11 [dev.go2go] go/types: don't crash with unsafe.Alignof/Sizeof on a type parameter value
Report an error instead for now until we have a better idea.
(It's unclear what these operations should do as they are
defined to return a compile-time constant which we can't
know in general.)

Fixes #40301.

Change-Id: I22a991311de117bc00d52b67b4ce862ea09d855a
Reviewed-on: https://go-review.googlesource.com/c/go/+/244622
Reviewed-by: Robert Griesemer <gri@golang.org>
2020-07-24 00:25:37 +00:00
Ian Lance Taylor 64148d34c7 [dev.go2go] go/go2go: don't import renamed package twice
We keep an import spec if it uses a local alias. Avoid importing it
again, unless it is required by something else.

Fixes #40318

Change-Id: If90de3bf30412645c9144083372e6b07df3c6a0b
Reviewed-on: https://go-review.googlesource.com/c/go/+/244621
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-07-23 23:17:54 +00:00
Robert Griesemer 0030e13efb [dev.go2go] go/types: add a couple more interesting type inference examples
Change-Id: I28b31e013ae28a71adefb07cce0f47b505b57676
Reviewed-on: https://go-review.googlesource.com/c/go/+/244620
Reviewed-by: Robert Griesemer <gri@golang.org>
2020-07-23 21:52:06 +00:00
Robert Griesemer de8501c203 [dev.go2go] go/parser: change value of UseBrackets constant (fix API check)
Passes all.bash again.

Change-Id: Ie558957b380cef937761faea69458980407bc8db
Reviewed-on: https://go-review.googlesource.com/c/go/+/244619
Reviewed-by: Robert Griesemer <gri@golang.org>
2020-07-23 21:19:31 +00:00
Robert Griesemer c7314f27b3 [dev.go2go] go/*: remove the need for ast.InstantiatedType
Instead, add the field "Brackets" to ast.CallExpr to identify
the bracket used for the (type) parameters. Adjust dependencies.

Change-Id: I6a73b0517ac518d8055e7fadbfb8662dfff585c1
Reviewed-on: https://go-review.googlesource.com/c/go/+/244618
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-07-23 21:19:13 +00:00
Robert Griesemer bed4b05106 [dev.go2go] go/types: implement constraint type inference for functions
1) Implement full bidirectional unification for general use.
2) Implement constraint type inference using bidirectional unification.
3) Add flag Config.InferFromConstraints to enable constraint type
   inference (disabled by default).

If we don't have all type arguments (provided or inferred) for a
function call, constraint type inference attempts to infer them
from type parameter constraints that are "structural", i.e., whose
interfaces contain exactly one (non-interface) type in their type
lists. For instance, given

	[type P interface{}, Q interface{type []P}]

the constraint for Q requires that the (underlying) structure of
the type argument for Q must match the underlying type of the type
argument provided for P. If only a type argument for P is given, say
say int, we can infer a type argument for Q, which would be []int.

Change-Id: I8508412ad96a0969d2033e99510c56db0f78177e
Reviewed-on: https://go-review.googlesource.com/c/go/+/244061
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2020-07-23 06:04:12 +00:00
Robert Griesemer 1576a3d981 [dev.go2go] go/parser: recognize f[a, b] as a (potential) function expression (parser bug)
Change-Id: I6b631a0d7efedfedd6c67640c8cbbff81f9e3af8
Reviewed-on: https://go-review.googlesource.com/c/go/+/244457
Reviewed-by: Robert Griesemer <gri@golang.org>
2020-07-22 23:57:39 +00:00
Rebecca Stambler f41e3f6173 [dev.go2go] go/ast: add *ast.InstantiatedType case to go/ast.Walk
This is necessary for continued support for the prototype in gopls.

Fixes golang/go#40316

Change-Id: Iafab2e78cfdfd7415d2e2419b8ed1abe6e6216c5
Reviewed-on: https://go-review.googlesource.com/c/go/+/243717
Reviewed-by: Robert Griesemer <gri@golang.org>
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
2020-07-20 22:53:49 +00:00
Ian Lance Taylor 893c5ec17b [dev.go2go] cmd/go2go: rewrite tests to use square bracket syntax
We can roll back this CL if we go back to parentheses.

Change-Id: Ide85330f4c362dad6ae964c6cc1fd0fc6c8a6a60
Reviewed-on: https://go-review.googlesource.com/c/go/+/243162
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-07-16 21:30:46 +00:00
Ian Lance Taylor 486b592393 [dev.go2go] cmd/go2go: add -brackets option
Change-Id: I5c3d36df3d84ad85d2fb70152f5692223cf6cfb6
Reviewed-on: https://go-review.googlesource.com/c/go/+/243161
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-07-16 21:28:54 +00:00
Ian Lance Taylor 78c55f923e [dev.go2go] go/go2go: permit caller to require square brackets
Change-Id: Idcb18ea31edee61931aa253f5f4d95923f6bcf6c
Reviewed-on: https://go-review.googlesource.com/c/go/+/243160
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-07-16 21:24:39 +00:00
Ian Lance Taylor ca218546b8 [dev.go2go] test: rewrite generic tests to square bracket syntax
We can roll back this CL if we go back to parentheses.

Change-Id: Ideb7dbe8e3c4499d76518a5c9b6f7931a7c103a4
Reviewed-on: https://go-review.googlesource.com/c/go/+/243158
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-07-16 20:18:10 +00:00
Ian Lance Taylor 6f583c9a5a [dev.go2go] go/go2go: support square bracket generics syntax
Change-Id: If683ad350aaddebcb3ebb691e1235c24c5dc2fe9
Reviewed-on: https://go-review.googlesource.com/c/go/+/243157
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-07-16 20:16:37 +00:00
Robert Griesemer e8f7e323f3 [dev.go2go] go/parser: UseBrackets mode forces parser to use [] for generics
Not setting the UseBracket mode still permits the parser to switch
to using brackets depending on the first generic type or function
declaration.

Change-Id: I2ee1235cfe58108ce1f5fd4a7fa1ce81f9e0ec0a
Reviewed-on: https://go-review.googlesource.com/c/go/+/242904
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-07-16 20:02:53 +00:00
Robert Griesemer a1922594db [dev.go2go] go/parser, go/types: allow both type and func decls to select [] for type params
The first generic type or function declaration encountered in a file chosing
square brackets switches the parser to use square brackets for the remainder of
the file.

Removed the need for extra type declarations in tests solely to switch to [].

Change-Id: Ia8d0c16e69b7e9b0e5397fed7405c5c4afc66451
Reviewed-on: https://go-review.googlesource.com/c/go/+/242899
Reviewed-by: Robert Griesemer <gri@golang.org>
2020-07-16 00:33:55 +00:00
Robert Griesemer ee1823718a [dev.go2go] go/parser: optional "type" keyword for generic functions using [] (experiment)
Change-Id: Ib7ebcd97f970e3be09626ee3d58d110e531aecd8
Reviewed-on: https://go-review.googlesource.com/c/go/+/242897
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-07-15 23:08:25 +00:00
Robert Griesemer 42aea19e55 [dev.go2go] go/printer: initial support for []-enclosed type parameters
Also: Don't strip parentheses around unnamed generic parameter
types when () are used for type instantiations (was bug).

Change-Id: I74edde2be2a01d740d2275e5d8768a5c25fa3302
Reviewed-on: https://go-review.googlesource.com/c/go/+/242717
Reviewed-by: Robert Griesemer <gri@golang.org>
2020-07-15 05:33:40 +00:00
Robert Griesemer 7e7a795836 [dev.go2go] go/types: adjustments to accept [] or () for type parameters
For each testfile xxx.go2, added a corresponding file xxxB.go2
that is using [] instead of () for type parameters. Removed
extra ()'s that are not needed to disambiguate.

See also https://groups.google.com/g/golang-nuts/c/7t-Q2vt60J8

Change-Id: I3d64035b1ca2a22ae50c740ebf4ab8a8f6cab787
Reviewed-on: https://go-review.googlesource.com/c/go/+/242521
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-07-15 00:53:18 +00:00
Robert Griesemer 5bf3aa1e25 [dev.go2go] go/parser, go/ast: accept [] or () for type parameters
- The first type declaration using [] for type parameters
  switches the parser to using [] for type parameters and
  type instantiations. Otherwise it uses ().

- Type parameters are now always accepted with any function
  or method declaration. It is up to the consumer of the AST
  to reject them as necessary.

- Type parameters are now never accepted in the receiver
  or result parameter list.

- testdata/xxxB.go2 tests correspond to the testdata/xxx.go2
  tests but use [] instead of ().

- See also https://groups.google.com/g/golang-nuts/c/7t-Q2vt60J8

Change-Id: I21b14f9463f7f49deba83b64450a0723b4b1d171
Reviewed-on: https://go-review.googlesource.com/c/go/+/242520
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-07-15 00:52:51 +00:00
Robert Griesemer 9fe9a324c4 [dev.go2go] go/*: remove vestiges of contracts - they are not coming back
Change-Id: If929860b51b86206d874b49ac00aaa8df09726e5
Reviewed-on: https://go-review.googlesource.com/c/go/+/241657
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-07-09 00:23:26 +00:00
Ian Lance Taylor 9d9619adc8 [dev.go2go] go/go2go: pass full path when importing Go 1 package
No test case because there is still no test harness for a complex
package heirarchy.

Fixes #40063

Change-Id: Iebe627dd7b2a3e967d437bee61c9d15c7a159fc6
Reviewed-on: https://go-review.googlesource.com/c/go/+/241217
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-07-07 03:47:15 +00:00
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