]> Cypherpunks repositories - gostls13.git/commitdiff
[dev.typeparams] cmd/compile/internal/types2: fix a panic in missingMethod
authorRob Findley <rfindley@google.com>
Wed, 4 Aug 2021 00:36:02 +0000 (20:36 -0400)
committerRobert Findley <rfindley@google.com>
Wed, 4 Aug 2021 11:07:03 +0000 (11:07 +0000)
When static == false, missingMethod incorrectly continues with a nil
Func.

Also remove some unnecessary type names from typeterm_test.go, which was
done in the go/types port.

Change-Id: I21fa637ac82b115563d3601314a470a5a43f9ae0
Reviewed-on: https://go-review.googlesource.com/c/go/+/339672
Trust: Robert Findley <rfindley@google.com>
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
src/cmd/compile/internal/types2/lookup.go
src/cmd/compile/internal/types2/typeterm_test.go

index 41e5bc7811a34054358f6e5f3475ba557b24be7d..f62c3771d28b42c82d095de3ef4790a2c4d9ad7a 100644 (file)
@@ -308,7 +308,10 @@ func (check *Checker) missingMethod(V Type, T *Interface, static bool) (method,
                for _, m := range T.typeSet().methods {
                        _, f := ityp.typeSet().LookupMethod(m.pkg, m.name)
 
-                       if f == nil && static {
+                       if f == nil {
+                               if !static {
+                                       continue
+                               }
                                return m, f
                        }
 
index 4676fb04373c2abaa52ec9ee79efc2fcd5a9e04e..cc4e30d9893faa2322aa36171ca78fc44c875243 100644 (file)
@@ -11,11 +11,11 @@ import (
 
 var testTerms = map[string]*term{
        "∅":       nil,
-       "⊤":       &term{},
-       "int":     &term{false, Typ[Int]},
-       "~int":    &term{true, Typ[Int]},
-       "string":  &term{false, Typ[String]},
-       "~string": &term{true, Typ[String]},
+       "⊤":       {},
+       "int":     {false, Typ[Int]},
+       "~int":    {true, Typ[Int]},
+       "string":  {false, Typ[String]},
+       "~string": {true, Typ[String]},
        // TODO(gri) add a defined type
 }