From: Robert Griesemer Date: Fri, 19 Nov 2021 00:11:10 +0000 (-0800) Subject: spec: adjust assignability rules for type parameters X-Git-Tag: go1.18beta1~189 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=939480033aa2c09f1b511a1928c0b465f41a45da;p=gostls13.git spec: adjust assignability rules for type parameters Change-Id: I3c4d8bdb5e92ee7fdca9593fb043f94f467755e8 Reviewed-on: https://go-review.googlesource.com/c/go/+/365434 Trust: Robert Griesemer Reviewed-by: Ian Lance Taylor --- diff --git a/doc/go_spec.html b/doc/go_spec.html index 186600f015..904132adf0 100644 --- a/doc/go_spec.html +++ b/doc/go_spec.html @@ -1848,21 +1848,22 @@ A value x is assignable to a variable
  • x's type V and T have identical -underlying types and at least one of V -or T is not a defined type. +underlying types and at least one of V +or T is not a named type.
  • -T is an interface type and -x implements T. +x's type V and T are channel types with +identical element types, V is a bidirectional channel, +and at least one of V or T is not a named type.
  • -x is a bidirectional channel value, T is a channel type, -x's type V and T have identical element types, -and at least one of V or T is not a defined type. +T is an interface type, but not a type parameter, and +x implements T.
  • x is the predeclared identifier nil and T -is a pointer, function, slice, map, channel, or interface type. +is a pointer, function, slice, map, channel, or interface type, +but not a type parameter.
  • x is an untyped constant @@ -1871,6 +1872,29 @@ by a value of type T.
  • +

    +Additionally, if x's type V or T are type parameters +with specific types, x +is assignable to a variable of type T if one of the following conditions applies: +

    + +
      +
    • +x is the predeclared identifier nil, T is +a type parameter, and x is assignable to each specific type of +T. +
    • +
    • +V is not a named type, T is +a type parameter, and x is assignable to each specific type of +T. +
    • +
    • +V is a type parameter and T is not a named type, +and values of each specific type of V are assignable +to T. +
    • +

    Representability