]> Cypherpunks.ru repositories - gostls13.git/commit
[dev.typeparams] cmd/compile/internal/types2: review of unify.go
authorRobert Griesemer <gri@golang.org>
Tue, 15 Dec 2020 20:17:01 +0000 (12:17 -0800)
committerRobert Griesemer <gri@golang.org>
Wed, 16 Dec 2020 17:03:29 +0000 (17:03 +0000)
commitf38da2cbb66cadebd3b6887c48919269f37ca69d
tree1e84446399edbd78523df870892e589dc1b4e7e7
parentceb77db24f06584628cb02702cf8aa5998de1a66
[dev.typeparams] cmd/compile/internal/types2: review of unify.go

Make unify.go match the corresponding and reviewed go/types version.
The remaining differences are due to other differences in the packages.
Also, this version of unify opted to preserve the longer comment around
case tj > 0.

$ diff $GOROOT/src/cmd/compile/internal/types2/unify.go $GOROOT/src/go/types/unify.go
7c7
< package types2
---
> package types
9c9,12
< import "sort"
---
> import (
>  "go/token"
>  "sort"
> )
120,123d122
<  // This case is handled like the default case.
<  // case tj > 0:
<  //  // Only the type parameter for y has an inferred type. Use y slot for x.
<  //  u.x.setIndex(i, tj)
125,126c124,125
<  // Neither type parameter has an inferred type. Use y slot for x
<  // (or x slot for y, it doesn't matter).
---
>  // Either the type parameter for y has an inferred type, or neither type
>  // parameter has an inferred type. In either case, use y slot for x.
216c215
<  // basic types and type parameters. We use Named() because we only
---
>  // basic types and type parameters. We use asNamed() because we only
219,222c218,221
<  case !isNamed(x) && y != nil && y.Named() != nil:
<  return u.nify(x, y.Under(), p)
<  case x != nil && x.Named() != nil && !isNamed(y):
<  return u.nify(x.Under(), y, p)
---
>  case !isNamed(x) && y != nil && asNamed(y) != nil:
>  return u.nify(x, under(y), p)
>  case x != nil && asNamed(x) != nil && !isNamed(y):
>  return u.nify(under(x), y, p)
353,354c352,353
<  u.check.completeInterface(nopos, x)
<  u.check.completeInterface(nopos, y)
---
>  u.check.completeInterface(token.NoPos, x)
>  u.check.completeInterface(token.NoPos, y)

Change-Id: Icb246d4befedfa82cc3dcfdb7dd162cd4127fbe9
Reviewed-on: https://go-review.googlesource.com/c/go/+/278572
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>
src/cmd/compile/internal/types2/unify.go