mirror of https://github.com/golang/go.git
go/types: report an error when seeing pointer designation in contracts
Pointer designations were not recognized nor supported. Now we recognize them and report an error until type-checking can handle them. Change-Id: I0deed536aa03c06c3e9ec60a5c2e186e916b970f
This commit is contained in:
parent
e03920500c
commit
f81ad49939
|
|
@ -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?)
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
Loading…
Reference in New Issue