]> Cypherpunks repositories - gostls13.git/commitdiff
go/types: add test for imported constraints pre-1.18
authorRobert Findley <rfindley@google.com>
Thu, 18 Nov 2021 01:22:32 +0000 (20:22 -0500)
committerRobert Findley <rfindley@google.com>
Thu, 18 Nov 2021 16:18:50 +0000 (16:18 +0000)
This is a port of CL 363834 from types2 to go/types.

Change-Id: I32583ead4bce626e0761f4c327678050404a15c9
Reviewed-on: https://go-review.googlesource.com/c/go/+/364937
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
src/go/types/check_test.go
src/go/types/testdata/fixedbugs/issue47818.go2

index 75b26e34bd266c203d0be58456ddcbd420a89e45..2f80d9b7b672c48971e4bca4261021077a35d8f9 100644 (file)
@@ -31,6 +31,7 @@ import (
        "go/parser"
        "go/scanner"
        "go/token"
+       "internal/buildcfg"
        "internal/testenv"
        "os"
        "path/filepath"
@@ -199,11 +200,27 @@ func asGoVersion(s string) string {
        return ""
 }
 
+// excludedForUnifiedBuild lists files that cannot be tested
+// when using the unified build's export data.
+// TODO(gri) enable as soon as the unified build supports this.
+var excludedForUnifiedBuild = map[string]bool{
+       "issue47818.go2": true,
+}
+
 func testFiles(t *testing.T, sizes Sizes, filenames []string, srcs [][]byte, manual bool, imp Importer) {
        if len(filenames) == 0 {
                t.Fatal("no source files")
        }
 
+       if buildcfg.Experiment.Unified {
+               for _, f := range filenames {
+                       if excludedForUnifiedBuild[filepath.Base(f)] {
+                               t.Logf("%s cannot be tested with unified build - skipped", f)
+                               return
+                       }
+               }
+       }
+
        if strings.HasSuffix(filenames[0], ".go1") {
                // TODO(rfindley): re-enable this test by using GoVersion.
                t.Skip("type params are enabled")
index e3e5a99637b6af353a434f9c4b240e283baf155d..2631118baed94a7f8163693a3f928c95c080a778 100644 (file)
@@ -8,6 +8,8 @@
 
 package go1_17
 
+import "constraints"
+
 type T[P /* ERROR type parameters require go1\.18 or later */ any /* ERROR undeclared name: any \(requires version go1\.18 or later\) */ ] struct{}
 
 // for init (and main, but we're not in package main) we should only get one error
@@ -56,4 +58,4 @@ type (
        _ = C2
 )
 
-// TODO(gri) need test cases for imported constraint types (see also issue #47967)
+type Ordered constraints /* ERROR using type constraint constraints\.Ordered requires go1\.18 or later */ .Ordered