import (
"cmd/compile/internal/syntax"
+ . "internal/types/errors"
)
// This file implements a check to validate that a Go package doesn't
// TODO(mdempsky): Pivot stack so we report the cycle from the top?
var err error_
+ err.code = InvalidInstanceCycle
obj0 := check.mono.vertices[v].obj
err.errorf(obj0, "instantiation cycle:")
// recordInstance records that the given type parameters were
// instantiated with the corresponding type arguments.
-func (w *monoGraph) recordInstance(pkg *Package, pos syntax.Pos, tparams []*TypeParam, targs []Type, posList []syntax.Pos) {
+func (w *monoGraph) recordInstance(pkg *Package, pos syntax.Pos, tparams []*TypeParam, targs []Type, xlist []syntax.Expr) {
for i, tpar := range tparams {
pos := pos
- if i < len(posList) {
- pos = posList[i]
+ if i < len(xlist) {
+ pos = syntax.StartPos(xlist[i])
}
w.assign(pkg, pos, tpar, targs[i])
}
// type parameters.
var do func(typ Type)
do = func(typ Type) {
- switch typ := typ.(type) {
+ switch typ := _Unalias(typ).(type) {
default:
panic("unexpected type")
// parameters that it's implicitly parameterized by.
for scope := obj.Parent(); scope != root; scope = scope.Parent() {
for _, elem := range scope.elems {
- if elem, ok := elem.(*TypeName); ok && !elem.IsAlias() && elem.Pos().Cmp(obj.Pos()) < 0 {
+ if elem, ok := elem.(*TypeName); ok && !elem.IsAlias() && cmpPos(elem.Pos(), obj.Pos()) < 0 {
if tpar, ok := elem.Type().(*TypeParam); ok {
if idx < 0 {
idx = len(w.vertices)