]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: use types.IdealFoo directly in predecl
authorCuong Manh Le <cuong.manhle.vn@gmail.com>
Thu, 8 Oct 2020 12:51:57 +0000 (19:51 +0700)
committerCuong Manh Le <cuong.manhle.vn@gmail.com>
Thu, 8 Oct 2020 18:55:53 +0000 (18:55 +0000)
Instead of using untype(Ctype) to get corresponding untyped type.

Passes toolstash-check.

Change-Id: I311fe6c94b1f8eb2e1615101a379cd06dcab835b
Reviewed-on: https://go-review.googlesource.com/c/go/+/260698
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
src/cmd/compile/internal/gc/bexport.go
src/cmd/compile/internal/gc/iexport.go

index 5ced66c0da8f124fdc15a0a1a5ddfce7e62f39d2..f82925347c9b9cc03f07981a0b406d44f3600b2d 100644 (file)
@@ -126,30 +126,6 @@ const (
        aliasTag
 )
 
-// untype returns the "pseudo" untyped type for a Ctype (import/export use only).
-// (we can't use a pre-initialized array because we must be sure all types are
-// set up)
-func untype(ctype Ctype) *types.Type {
-       switch ctype {
-       case CTINT:
-               return types.Idealint
-       case CTRUNE:
-               return types.Idealrune
-       case CTFLT:
-               return types.Idealfloat
-       case CTCPLX:
-               return types.Idealcomplex
-       case CTSTR:
-               return types.Idealstring
-       case CTBOOL:
-               return types.Idealbool
-       case CTNIL:
-               return types.Types[TNIL]
-       }
-       Fatalf("exporter: unknown Ctype")
-       return nil
-}
-
 var predecl []*types.Type // initialized lazily
 
 func predeclared() []*types.Type {
@@ -184,13 +160,13 @@ func predeclared() []*types.Type {
                        types.Errortype,
 
                        // untyped types
-                       untype(CTBOOL),
-                       untype(CTINT),
-                       untype(CTRUNE),
-                       untype(CTFLT),
-                       untype(CTCPLX),
-                       untype(CTSTR),
-                       untype(CTNIL),
+                       types.Idealbool,
+                       types.Idealint,
+                       types.Idealrune,
+                       types.Idealfloat,
+                       types.Idealcomplex,
+                       types.Idealstring,
+                       types.Types[TNIL],
 
                        // package unsafe
                        types.Types[TUNSAFEPTR],
index 3be3b0a21386ecf0da91328b459b8acf97046f38..3ccaf60f40c2e0dcb613c574bbc4a83f5fc06d86 100644 (file)
@@ -780,8 +780,8 @@ func constTypeOf(typ *types.Type) Ctype {
 }
 
 func (w *exportWriter) value(typ *types.Type, v Val) {
-       if typ.IsUntyped() {
-               typ = untype(v.Ctype())
+       if vt := idealType(v.Ctype()); typ.IsUntyped() && typ != vt {
+               Fatalf("exporter: untyped type mismatch, have: %v, want: %v", typ, vt)
        }
        w.typ(typ)