aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/cmd/compile/internal/types2/builtins.go2
-rw-r--r--src/cmd/compile/internal/types2/decl.go12
-rw-r--r--src/cmd/compile/internal/types2/lookup.go2
-rw-r--r--src/cmd/compile/internal/types2/subst.go17
-rw-r--r--src/cmd/compile/internal/types2/type.go5
-rw-r--r--src/cmd/compile/internal/types2/typestring.go3
-rw-r--r--src/cmd/compile/internal/types2/typexpr.go4
7 files changed, 9 insertions, 36 deletions
diff --git a/src/cmd/compile/internal/types2/builtins.go b/src/cmd/compile/internal/types2/builtins.go
index c1706fd873..6ad84f4354 100644
--- a/src/cmd/compile/internal/types2/builtins.go
+++ b/src/cmd/compile/internal/types2/builtins.go
@@ -727,7 +727,7 @@ func (check *Checker) applyTypeFunc(f func(Type) Type, x Type) Type {
// construct a suitable new type parameter
tpar := NewTypeName(nopos, nil /* = Universe pkg */, "<type parameter>", nil)
- ptyp := check.NewTypeParam(tp.ptr, tpar, 0, &emptyInterface) // assigns type to tpar as a side-effect
+ ptyp := check.NewTypeParam(tpar, 0, &emptyInterface) // assigns type to tpar as a side-effect
tsum := NewSum(rtypes)
ptyp.bound = &Interface{types: tsum, allMethods: markComplete, allTypes: tsum}
diff --git a/src/cmd/compile/internal/types2/decl.go b/src/cmd/compile/internal/types2/decl.go
index ef8dc7a245..ff37d85c6f 100644
--- a/src/cmd/compile/internal/types2/decl.go
+++ b/src/cmd/compile/internal/types2/decl.go
@@ -734,15 +734,9 @@ func (check *Checker) collectTypeParams(list []*syntax.Field) (tparams []*TypeNa
}
func (check *Checker) declareTypeParam(tparams []*TypeName, name *syntax.Name) []*TypeName {
- var ptr bool
- nstr := name.Value
- if len(nstr) > 0 && nstr[0] == '*' {
- ptr = true
- nstr = nstr[1:]
- }
- tpar := NewTypeName(name.Pos(), check.pkg, nstr, nil)
- check.NewTypeParam(ptr, tpar, len(tparams), &emptyInterface) // assigns type to tpar as a side-effect
- check.declare(check.scope, name, tpar, check.scope.pos) // TODO(gri) check scope position
+ tpar := NewTypeName(name.Pos(), check.pkg, name.Value, nil)
+ check.NewTypeParam(tpar, len(tparams), &emptyInterface) // assigns type to tpar as a side-effect
+ check.declare(check.scope, name, tpar, check.scope.pos) // TODO(gri) check scope position
tparams = append(tparams, tpar)
if check.conf.Trace {
diff --git a/src/cmd/compile/internal/types2/lookup.go b/src/cmd/compile/internal/types2/lookup.go
index 277212c568..e1e7b5814d 100644
--- a/src/cmd/compile/internal/types2/lookup.go
+++ b/src/cmd/compile/internal/types2/lookup.go
@@ -222,7 +222,7 @@ func (check *Checker) rawLookupFieldOrMethod(T Type, addressable bool, pkg *Pack
// is shorthand for (&x).m()".
if f, _ := obj.(*Func); f != nil {
// determine if method has a pointer receiver
- hasPtrRecv := tpar == nil && ptrRecv(f) || tpar != nil && tpar.ptr
+ hasPtrRecv := tpar == nil && ptrRecv(f)
if hasPtrRecv && !indirect && !addressable {
return nil, nil, true // pointer/addressable receiver required
}
diff --git a/src/cmd/compile/internal/types2/subst.go b/src/cmd/compile/internal/types2/subst.go
index 27c907de10..e64e24a8a1 100644
--- a/src/cmd/compile/internal/types2/subst.go
+++ b/src/cmd/compile/internal/types2/subst.go
@@ -143,27 +143,14 @@ func (check *Checker) instantiate(pos syntax.Pos, typ Type, targs []Type, poslis
// - check only if we have methods
check.completeInterface(nopos, iface)
if len(iface.allMethods) > 0 {
- // If the type argument is a type parameter itself, its pointer designation
- // must match the pointer designation of the callee's type parameter.
// If the type argument is a pointer to a type parameter, the type argument's
// method set is empty.
// TODO(gri) is this what we want? (spec question)
- if tparg := targ.TypeParam(); tparg != nil {
- if tparg.ptr != tpar.ptr {
- check.errorf(pos, "pointer designation mismatch")
- break
- }
- } else if base, isPtr := deref(targ); isPtr && base.TypeParam() != nil {
+ if base, isPtr := deref(targ); isPtr && base.TypeParam() != nil {
check.errorf(pos, "%s has no methods", targ)
break
}
- // If a type parameter is marked as a pointer type, the type bound applies
- // to a pointer of the type argument.
- actual := targ
- if tpar.ptr {
- actual = NewPointer(targ)
- }
- if m, wrong := check.missingMethod(actual, iface, true); m != nil {
+ if m, wrong := check.missingMethod(targ, iface, true); m != nil {
// TODO(gri) needs to print updated name to avoid major confusion in error message!
// (print warning for now)
// check.softErrorf(pos, "%s does not satisfy %s (warning: name not updated) = %s (missing method %s)", targ, tpar.bound, iface, m)
diff --git a/src/cmd/compile/internal/types2/type.go b/src/cmd/compile/internal/types2/type.go
index c26d243f3c..1bfde41159 100644
--- a/src/cmd/compile/internal/types2/type.go
+++ b/src/cmd/compile/internal/types2/type.go
@@ -832,7 +832,6 @@ func (t *Named) AddMethod(m *Func) {
type TypeParam struct {
check *Checker // for lazy type bound completion
id uint64 // unique id
- ptr bool // pointer designation
obj *TypeName // corresponding type name
index int // parameter index
bound Type // *Named or *Interface; underlying type is always *Interface
@@ -840,9 +839,9 @@ type TypeParam struct {
}
// NewTypeParam returns a new TypeParam.
-func (check *Checker) NewTypeParam(ptr bool, obj *TypeName, index int, bound Type) *TypeParam {
+func (check *Checker) NewTypeParam(obj *TypeName, index int, bound Type) *TypeParam {
assert(bound != nil)
- typ := &TypeParam{check: check, id: check.nextId, ptr: ptr, obj: obj, index: index, bound: bound}
+ typ := &TypeParam{check: check, id: check.nextId, obj: obj, index: index, bound: bound}
check.nextId++
if obj.typ == nil {
obj.typ = typ
diff --git a/src/cmd/compile/internal/types2/typestring.go b/src/cmd/compile/internal/types2/typestring.go
index 98021797a1..6b6d7ad2be 100644
--- a/src/cmd/compile/internal/types2/typestring.go
+++ b/src/cmd/compile/internal/types2/typestring.go
@@ -350,9 +350,6 @@ func writeTParamList(buf *bytes.Buffer, list []*TypeName, qf Qualifier, visited
prev = b
if t, _ := p.typ.(*TypeParam); t != nil {
- if t.ptr {
- buf.WriteByte('*')
- }
writeType(buf, t, qf, visited)
} else {
buf.WriteString(p.name)
diff --git a/src/cmd/compile/internal/types2/typexpr.go b/src/cmd/compile/internal/types2/typexpr.go
index 0edd7731fa..1adf967859 100644
--- a/src/cmd/compile/internal/types2/typexpr.go
+++ b/src/cmd/compile/internal/types2/typexpr.go
@@ -307,12 +307,8 @@ func (check *Checker) funcType(sig *Signature, recvPar *syntax.Field, tparams []
// - only do this if we have the right number (otherwise an error is reported elsewhere)
if len(sig.rparams) == len(recvTParams) {
// We have a list of *TypeNames but we need a list of Types.
- // While creating this list, also update type parameter pointer designation
- // for each (*TypeParam) list entry, by copying the information from the
- // receiver base type's type parameters.
list := make([]Type, len(sig.rparams))
for i, t := range sig.rparams {
- t.typ.(*TypeParam).ptr = recvTParams[i].typ.(*TypeParam).ptr
list[i] = t.typ
}
for i, tname := range sig.rparams {