diff options
author | Cherry Mui <cherryyz@google.com> | 2024-03-13 18:35:29 +0000 |
---|---|---|
committer | Cherry Mui <cherryyz@google.com> | 2024-03-13 19:10:25 +0000 |
commit | 140b37d659ab7c12f9be655d31690dfa5ff7b3c0 (patch) | |
tree | 2b6bda29f50914efe91c84a1acdb19269c46b688 | |
parent | 6d229889d864c9f7a02fb107952832f508f9b40d (diff) | |
download | go-140b37d659ab7c12f9be655d31690dfa5ff7b3c0.tar.gz go-140b37d659ab7c12f9be655d31690dfa5ff7b3c0.zip |
[release-branch.go1.21] Revert "go/types, types2: don't do version checks for embedded types of imported interfaces"
This reverts CL 571075.
Reason for revert: We might want to do a security-only minor release. Back off the release branch to a clean state from the previous minor release. Sorry for the inconvenience.
Change-Id: Ifc8c7e00e6faea3aa547b883eed44180ddb447de
Reviewed-on: https://go-review.googlesource.com/c/go/+/571355
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Findley <rfindley@google.com>
-rw-r--r-- | src/cmd/compile/internal/types2/typeset.go | 11 | ||||
-rw-r--r-- | src/go/types/typeset.go | 11 | ||||
-rw-r--r-- | src/internal/types/testdata/fixedbugs/issue66064.go | 15 |
3 files changed, 12 insertions, 25 deletions
diff --git a/src/cmd/compile/internal/types2/typeset.go b/src/cmd/compile/internal/types2/typeset.go index 14039ac9d6..8d33597ffd 100644 --- a/src/cmd/compile/internal/types2/typeset.go +++ b/src/cmd/compile/internal/types2/typeset.go @@ -255,8 +255,9 @@ func computeInterfaceTypeSet(check *Checker, pos syntax.Pos, ityp *Interface) *_ allTerms := allTermlist allComparable := false for i, typ := range ityp.embeddeds { - // The embedding position is nil for imported interfaces. - // We don't need to do version checks in those cases. + // The embedding position is nil for imported interfaces + // and also for interface copies after substitution (but + // in that case we don't need to report errors again). var pos syntax.Pos // embedding position if ityp.embedPos != nil { pos = (*ityp.embedPos)[i] @@ -269,7 +270,7 @@ func computeInterfaceTypeSet(check *Checker, pos syntax.Pos, ityp *Interface) *_ assert(!isTypeParam(typ)) tset := computeInterfaceTypeSet(check, pos, u) // If typ is local, an error was already reported where typ is specified/defined. - if pos.IsKnown() && check != nil && check.isImportedConstraint(typ) && !check.verifyVersionf(pos, go1_18, "embedding constraint interface %s", typ) { + if check != nil && check.isImportedConstraint(typ) && !check.verifyVersionf(pos, go1_18, "embedding constraint interface %s", typ) { continue } comparable = tset.comparable @@ -278,7 +279,7 @@ func computeInterfaceTypeSet(check *Checker, pos syntax.Pos, ityp *Interface) *_ } terms = tset.terms case *Union: - if pos.IsKnown() && check != nil && !check.verifyVersionf(pos, go1_18, "embedding interface element %s", u) { + if check != nil && !check.verifyVersionf(pos, go1_18, "embedding interface element %s", u) { continue } tset := computeUnionTypeSet(check, unionSets, pos, u) @@ -292,7 +293,7 @@ func computeInterfaceTypeSet(check *Checker, pos syntax.Pos, ityp *Interface) *_ if u == Typ[Invalid] { continue } - if pos.IsKnown() && check != nil && !check.verifyVersionf(pos, go1_18, "embedding non-interface type %s", typ) { + if check != nil && !check.verifyVersionf(pos, go1_18, "embedding non-interface type %s", typ) { continue } terms = termlist{{false, typ}} diff --git a/src/go/types/typeset.go b/src/go/types/typeset.go index a7d4485d0e..4cd118a226 100644 --- a/src/go/types/typeset.go +++ b/src/go/types/typeset.go @@ -253,8 +253,9 @@ func computeInterfaceTypeSet(check *Checker, pos token.Pos, ityp *Interface) *_T allTerms := allTermlist allComparable := false for i, typ := range ityp.embeddeds { - // The embedding position is nil for imported interfaces. - // We don't need to do version checks in those cases. + // The embedding position is nil for imported interfaces + // and also for interface copies after substitution (but + // in that case we don't need to report errors again). var pos token.Pos // embedding position if ityp.embedPos != nil { pos = (*ityp.embedPos)[i] @@ -267,7 +268,7 @@ func computeInterfaceTypeSet(check *Checker, pos token.Pos, ityp *Interface) *_T assert(!isTypeParam(typ)) tset := computeInterfaceTypeSet(check, pos, u) // If typ is local, an error was already reported where typ is specified/defined. - if pos.IsValid() && check != nil && check.isImportedConstraint(typ) && !check.verifyVersionf(atPos(pos), go1_18, "embedding constraint interface %s", typ) { + if check != nil && check.isImportedConstraint(typ) && !check.verifyVersionf(atPos(pos), go1_18, "embedding constraint interface %s", typ) { continue } comparable = tset.comparable @@ -276,7 +277,7 @@ func computeInterfaceTypeSet(check *Checker, pos token.Pos, ityp *Interface) *_T } terms = tset.terms case *Union: - if pos.IsValid() && check != nil && !check.verifyVersionf(atPos(pos), go1_18, "embedding interface element %s", u) { + if check != nil && !check.verifyVersionf(atPos(pos), go1_18, "embedding interface element %s", u) { continue } tset := computeUnionTypeSet(check, unionSets, pos, u) @@ -290,7 +291,7 @@ func computeInterfaceTypeSet(check *Checker, pos token.Pos, ityp *Interface) *_T if u == Typ[Invalid] { continue } - if pos.IsValid() && check != nil && !check.verifyVersionf(atPos(pos), go1_18, "embedding non-interface type %s", typ) { + if check != nil && !check.verifyVersionf(atPos(pos), go1_18, "embedding non-interface type %s", typ) { continue } terms = termlist{{false, typ}} diff --git a/src/internal/types/testdata/fixedbugs/issue66064.go b/src/internal/types/testdata/fixedbugs/issue66064.go deleted file mode 100644 index d4a361754b..0000000000 --- a/src/internal/types/testdata/fixedbugs/issue66064.go +++ /dev/null @@ -1,15 +0,0 @@ -// -lang=go1.16 - -// Copyright 2024 The Go Authors. All rights reserved. -// Use of this source code is governed by a BSD-style -// license that can be found in the LICENSE file. - -//go:build go1.21 - -package main - -import "slices" - -func main() { - _ = slices.Clone([]string{}) // no error should be reported here -} |