cloudfoundry-community/bosh-cloudstack-cpi

View on GitHub
go_agent/src/code.google.com/p/go.tools/go/types/testdata/cycles4.src

Summary

Maintainability
Test Coverage
// Copyright 2013 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

// Check that all methods of T are collected before
// determining the result type of m (which embeds
// all methods of T).

type T interface {
    m() interface {T}
    E
}

var _ = T.m(nil).m().e()

type E interface {
    e() int
}

// Check that unresolved forward chains are followed
// (see also comment in resolver.go, checker.typeDecl).

var _ = C.m(nil).m().e()

type A B

type B interface {
    m() interface{C}
    E
}

type C A

// Check that interface type comparison for identity
// does not recur endlessly.

type T1 interface {
    m() interface{T1}
}

type T2 interface {
    m() interface{T2}
}

func _(x T1, y T2) {
    // Checking for assignability of interfaces must check
    // if all methods of x are present in y, and that they
    // have identical signatures. The signatures recur via
    // the result type, which is an interface that embeds
    // a single method m that refers to the very interface
    // that contains it. This requires cycle detection in
    // identity checks for interface types.
    x = y
}

type T3 interface {
    m() interface{T4}
}

type T4 interface {
    m() interface{T3}
}

func _(x T1, y T3) {
    x = y
}