aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/cmd/compile/internal/noder/writer.go15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/cmd/compile/internal/noder/writer.go b/src/cmd/compile/internal/noder/writer.go
index 72c7a1fc86..178c3eb1a9 100644
--- a/src/cmd/compile/internal/noder/writer.go
+++ b/src/cmd/compile/internal/noder/writer.go
@@ -123,14 +123,25 @@ func (pw *pkgWriter) unexpected(what string, p poser) {
}
func (pw *pkgWriter) typeAndValue(x syntax.Expr) syntax.TypeAndValue {
- tv := x.GetTypeInfo()
- if tv.Type == nil {
+ tv, ok := pw.maybeTypeAndValue(x)
+ if !ok {
pw.fatalf(x, "missing Types entry: %v", syntax.String(x))
}
return tv
}
+
func (pw *pkgWriter) maybeTypeAndValue(x syntax.Expr) (syntax.TypeAndValue, bool) {
tv := x.GetTypeInfo()
+
+ // If x is a generic function whose type arguments are inferred
+ // from assignment context, then we need to find its inferred type
+ // in Info.Instances instead.
+ if name, ok := x.(*syntax.Name); ok {
+ if inst, ok := pw.info.Instances[name]; ok {
+ tv.Type = inst.Type
+ }
+ }
+
return tv, tv.Type != nil
}