diff --git a/go/gccgoimporter/parser.go b/go/gccgoimporter/parser.go index 5bd1858fb3..d20a967313 100644 --- a/go/gccgoimporter/parser.go +++ b/go/gccgoimporter/parser.go @@ -659,8 +659,8 @@ func lookupBuiltinType(typ int) types.Type { gccgoBuiltinCOMPLEX64: types.Typ[types.Complex64], gccgoBuiltinCOMPLEX128: types.Typ[types.Complex128], gccgoBuiltinERROR: types.Universe.Lookup("error").Type(), - gccgoBuiltinBYTE: types.Typ[types.Byte], - gccgoBuiltinRUNE: types.Typ[types.Rune], + gccgoBuiltinBYTE: types.Universe.Lookup("byte").Type(), + gccgoBuiltinRUNE: types.Universe.Lookup("rune").Type(), }[typ] } diff --git a/go/importer/predefined.go b/go/importer/predefined.go index a4db56886c..b23dfcb4c2 100644 --- a/go/importer/predefined.go +++ b/go/importer/predefined.go @@ -76,8 +76,9 @@ var predeclared = []types.Type{ types.Typ[types.UnsafePointer], // aliases - types.UniverseByte, - types.UniverseRune, + types.Universe.Lookup("byte").Type(), + types.Universe.Lookup("rune").Type(), + // error types.Universe.Lookup("error").Type(), } diff --git a/go/types/builtins.go b/go/types/builtins.go index 3da49b92ce..f45f930a42 100644 --- a/go/types/builtins.go +++ b/go/types/builtins.go @@ -96,7 +96,7 @@ func (check *Checker) builtin(x *operand, call *ast.CallExpr, id builtinId) (_ b // spec: "As a special case, append also accepts a first argument assignable // to type []byte with a second argument of string type followed by ... . // This form appends the bytes of the string. - if nargs == 2 && call.Ellipsis.IsValid() && x.assignableTo(check.conf, NewSlice(UniverseByte)) { + if nargs == 2 && call.Ellipsis.IsValid() && x.assignableTo(check.conf, NewSlice(universeByte)) { arg(x, 1) if x.mode == invalid { return @@ -289,7 +289,7 @@ func (check *Checker) builtin(x *operand, call *ast.CallExpr, id builtinId) (_ b switch t := y.typ.Underlying().(type) { case *Basic: if isString(y.typ) { - src = UniverseByte + src = universeByte } case *Slice: src = t.elem diff --git a/go/types/expr.go b/go/types/expr.go index 78b14e07e7..6efc7b4309 100644 --- a/go/types/expr.go +++ b/go/types/expr.go @@ -1183,7 +1183,7 @@ func (check *Checker) exprInternal(x *operand, e ast.Expr, hint Type) exprKind { // (not a constant) even if the string and the // index are constant x.mode = value - x.typ = UniverseByte // use 'byte' name + x.typ = universeByte // use 'byte' name } case *Array: diff --git a/go/types/predicates.go b/go/types/predicates.go index b5c39d9d16..993c6d290b 100644 --- a/go/types/predicates.go +++ b/go/types/predicates.go @@ -296,7 +296,7 @@ func defaultType(typ Type) Type { case UntypedInt: return Typ[Int] case UntypedRune: - return UniverseRune // use 'rune' name + return universeRune // use 'rune' name case UntypedFloat: return Typ[Float64] case UntypedComplex: diff --git a/go/types/stmt.go b/go/types/stmt.go index 0aafb30efb..eeb2c31730 100644 --- a/go/types/stmt.go +++ b/go/types/stmt.go @@ -629,7 +629,7 @@ func (check *Checker) stmt(ctxt stmtContext, s ast.Stmt) { case *Basic: if isString(typ) { key = Typ[Int] - val = UniverseRune // use 'rune' name + val = universeRune // use 'rune' name } case *Array: key = Typ[Int] diff --git a/go/types/universe.go b/go/types/universe.go index 472c6bef1a..12a34ef853 100644 --- a/go/types/universe.go +++ b/go/types/universe.go @@ -2,7 +2,7 @@ // Use of this source code is governed by a BSD-style // license that can be found in the LICENSE file. -// This file implements the universe and unsafe package scopes. +// This file sets up the universe scope and the unsafe package. package types @@ -17,11 +17,11 @@ var ( Universe *Scope Unsafe *Package universeIota *Const - UniverseByte *Basic // uint8 alias, but has name "byte" - UniverseRune *Basic // int32 alias, but has name "rune" + universeByte *Basic // uint8 alias, but has name "byte" + universeRune *Basic // int32 alias, but has name "rune" ) -var Typ = [...]*Basic{ +var Typ = []*Basic{ Invalid: {Invalid, 0, "invalid type"}, Bool: {Bool, IsBoolean, "bool"}, @@ -187,8 +187,8 @@ func init() { defPredeclaredFuncs() universeIota = Universe.Lookup("iota").(*Const) - UniverseByte = Universe.Lookup("byte").(*TypeName).typ.(*Basic) - UniverseRune = Universe.Lookup("rune").(*TypeName).typ.(*Basic) + universeByte = Universe.Lookup("byte").(*TypeName).typ.(*Basic) + universeRune = Universe.Lookup("rune").(*TypeName).typ.(*Basic) } // Objects with names containing blanks are internal and not entered into