diff --git a/src/go/types/NOTES b/src/go/types/NOTES index 9f8ef96d10..b68c2cc650 100644 --- a/src/go/types/NOTES +++ b/src/go/types/NOTES @@ -4,6 +4,8 @@ so we have a better track record. I only switched to this file in Nov 2019, henc ---------------------------------------------------------------------------------------------------- TODO +- implement type-checking for type parameters with pointer designation in contracts +- figure out how to translate methods with pointer designation into interface bounds - review use of Contract.TParams field - it seems like it's only needed for length checks? - review handling of fields of instantiated generic types (do we need to make them non-parameterized, similar to what we did for the embedded interfaces created by contract embedding?) diff --git a/src/go/types/contracts.go b/src/go/types/contracts.go index 1dae945e76..e20ce1d1e0 100644 --- a/src/go/types/contracts.go +++ b/src/go/types/contracts.go @@ -33,6 +33,9 @@ func (check *Checker) contractDecl(obj *Contract, cdecl *ast.ContractSpec) { // collect constraints for _, c := range cdecl.Constraints { + if c.Star.IsValid() { + check.errorf(c.Star, "pointer designation for type parameters not yet supported (* is ignored)") + } if c.Param != nil { // If a type name is present, it must be one of the contract's type parameters. pos := c.Param.Pos() diff --git a/src/go/types/testdata/tmp.go2 b/src/go/types/testdata/tmp.go2 index fdcef50337..3f2775edb0 100644 --- a/src/go/types/testdata/tmp.go2 +++ b/src/go/types/testdata/tmp.go2 @@ -4,6 +4,15 @@ package p +// TODO(gri) this should work +contract C(T) { + T m() +} + +func _(type T C)(x *T) { + x.m /* ERROR no field or method m */ () +} + /* func f(type T)(T) diff --git a/src/go/types/testdata/todos.go2 b/src/go/types/testdata/todos.go2 index 8739b0997b..8bad5efb2f 100644 --- a/src/go/types/testdata/todos.go2 +++ b/src/go/types/testdata/todos.go2 @@ -8,6 +8,11 @@ package p +// Pointer designation for type parameters is not yet supported. +contract _C(T) { + * /* ERROR not yet supported */ T m() +} + // indexing on generic types containing type parameters in their type list // is not yet supported func _(type T interface { type T })(x T) {