From: Russ Cox Date: Tue, 14 Dec 2021 15:49:07 +0000 (-0500) Subject: cmd/compile: fix any in -G=0 mode X-Git-Tag: go1.18beta1~2 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=c1f012a0d9b4c7bc9f2a1474f4935e53eccd1794;p=gostls13.git cmd/compile: fix any in -G=0 mode Fixes go test -gcflags=all=-G=0 -short std, except for the packages with generics in their tests (constraints, encoding/xml), and except for the go/internal/gcimporter and go/types tests, because the compiler does not preserve any in its -G=0 export information. (That's probably acceptable for now.) Fixes cd test/; GO_BUILDER_NAME=longtest go run run.go completely, which should fix the longtest builder. Fixes #50159. Change-Id: I9390972239c18831833edd6530191da2842b876b Reviewed-on: https://go-review.googlesource.com/c/go/+/371715 Trust: Russ Cox Run-TryBot: Russ Cox Reviewed-by: Cherry Mui TryBot-Result: Gopher Robot --- diff --git a/src/cmd/compile/internal/types/universe.go b/src/cmd/compile/internal/types/universe.go index f845614e13..54b04bda22 100644 --- a/src/cmd/compile/internal/types/universe.go +++ b/src/cmd/compile/internal/types/universe.go @@ -57,7 +57,7 @@ func InitTypes(defTypeName func(sym *Sym, typ *Type) Object) { SimType[et] = et } - Types[TANY] = newType(TANY) + Types[TANY] = newType(TANY) // note: an old placeholder type, NOT the new builtin 'any' alias for interface{} Types[TINTER] = NewInterface(LocalPkg, nil, false) CheckSize(Types[TINTER]) @@ -91,6 +91,7 @@ func InitTypes(defTypeName func(sym *Sym, typ *Type) Object) { // int32 Hence, (bytetype|runtype).Sym.isAlias() is false. // TODO(gri) Should we get rid of this special case (at the cost // of less informative error messages involving bytes and runes)? + // NOTE(rsc): No, the error message quality is important. // (Alternatively, we could introduce an OTALIAS node representing // type aliases, albeit at the cost of having to deal with it everywhere). ByteType = defBasic(TUINT8, BuiltinPkg, "byte") @@ -111,12 +112,11 @@ func InitTypes(defTypeName func(sym *Sym, typ *Type) Object) { // any type (interface) DeferCheckSize() AnyType = defBasic(TFORW, BuiltinPkg, "any") - AnyType.SetUnderlying(NewInterface(NoPkg, []*Field{}, false)) + AnyType.SetUnderlying(NewInterface(BuiltinPkg, []*Field{}, false)) ResumeCheckSize() if base.Flag.G == 0 { ComparableType.Sym().Def = nil - AnyType.Sym().Def = nil } Types[TUNSAFEPTR] = defBasic(TUNSAFEPTR, UnsafePkg, "Pointer")