mirror of
https://github.com/golang/go
synced 2024-11-24 17:20:12 -07:00
go/types, types2: alias type declarations may refer to constraint types
Fixes #51616. Change-Id: I388a6d91d9bfe5410b5eb32e1606257ec668d618 Reviewed-on: https://go-review.googlesource.com/c/go/+/392715 Trust: Robert Griesemer <gri@golang.org> Reviewed-by: Robert Findley <rfindley@google.com>
This commit is contained in:
parent
63c7614fd0
commit
3ebb1720d9
@ -502,7 +502,7 @@ func (check *Checker) typeDecl(obj *TypeName, tdecl *syntax.TypeDecl, def *Named
|
|||||||
}
|
}
|
||||||
|
|
||||||
check.brokenAlias(obj)
|
check.brokenAlias(obj)
|
||||||
rhs = check.varType(tdecl.Type)
|
rhs = check.typ(tdecl.Type)
|
||||||
check.validAlias(obj, rhs)
|
check.validAlias(obj, rhs)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
19
src/cmd/compile/internal/types2/testdata/fixedbugs/issue51616.go2
vendored
Normal file
19
src/cmd/compile/internal/types2/testdata/fixedbugs/issue51616.go2
vendored
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
// Copyright 2022 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
package p
|
||||||
|
|
||||||
|
type (
|
||||||
|
C[T any] interface{~int; M() T}
|
||||||
|
|
||||||
|
_ C[bool]
|
||||||
|
_ comparable
|
||||||
|
_ interface {~[]byte | ~string}
|
||||||
|
|
||||||
|
// Alias type declarations may refer to "constraint" types
|
||||||
|
// like ordinary type declarations.
|
||||||
|
_ = C[bool]
|
||||||
|
_ = comparable
|
||||||
|
_ = interface {~[]byte | ~string}
|
||||||
|
)
|
@ -559,7 +559,7 @@ func (check *Checker) typeDecl(obj *TypeName, tdecl *ast.TypeSpec, def *Named) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
check.brokenAlias(obj)
|
check.brokenAlias(obj)
|
||||||
rhs = check.varType(tdecl.Type)
|
rhs = check.typ(tdecl.Type)
|
||||||
check.validAlias(obj, rhs)
|
check.validAlias(obj, rhs)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
19
src/go/types/testdata/fixedbugs/issue51616.go2
vendored
Normal file
19
src/go/types/testdata/fixedbugs/issue51616.go2
vendored
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
// Copyright 2022 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
package p
|
||||||
|
|
||||||
|
type (
|
||||||
|
C[T any] interface{~int; M() T}
|
||||||
|
|
||||||
|
_ C[bool]
|
||||||
|
_ comparable
|
||||||
|
_ interface {~[]byte | ~string}
|
||||||
|
|
||||||
|
// Alias type declarations may refer to "constraint" types
|
||||||
|
// like ordinary type declarations.
|
||||||
|
_ = C[bool]
|
||||||
|
_ = comparable
|
||||||
|
_ = interface {~[]byte | ~string}
|
||||||
|
)
|
Loading…
Reference in New Issue
Block a user