2023-12-18 19:13:30 -07:00
|
|
|
// errorcheck
|
2012-01-23 07:19:02 -07:00
|
|
|
|
2016-04-10 15:32:26 -06:00
|
|
|
// Copyright 2012 The Go Authors. All rights reserved.
|
2012-01-23 07:19:02 -07:00
|
|
|
// Use of this source code is governed by a BSD-style
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
|
|
|
// Used to crash compiler in interface type equality check.
|
2017-05-18 15:11:17 -06:00
|
|
|
// (This test used to have problems - see #15596.)
|
2012-01-23 07:19:02 -07:00
|
|
|
|
|
|
|
package p
|
|
|
|
|
2017-05-18 15:11:17 -06:00
|
|
|
// exported interfaces
|
|
|
|
|
2023-12-18 19:13:30 -07:00
|
|
|
type I1 interface { // ERROR "invalid recursive type: anonymous interface refers to itself"
|
2017-05-18 15:11:17 -06:00
|
|
|
F() interface{I1}
|
|
|
|
}
|
|
|
|
|
2023-12-18 19:13:30 -07:00
|
|
|
type I2 interface { // ERROR "invalid recursive type: anonymous interface refers to itself"
|
2017-05-18 15:11:17 -06:00
|
|
|
F() interface{I2}
|
|
|
|
}
|
|
|
|
|
|
|
|
var V1 I1
|
|
|
|
var V2 I2
|
|
|
|
|
|
|
|
func F() bool {
|
|
|
|
return V1 == V2
|
|
|
|
}
|
|
|
|
|
|
|
|
// non-exported interfaces
|
|
|
|
|
2023-12-18 19:13:30 -07:00
|
|
|
type i1 interface { // ERROR "invalid recursive type: anonymous interface refers to itself"
|
2016-05-05 19:03:59 -06:00
|
|
|
F() interface{i1}
|
2012-01-23 07:19:02 -07:00
|
|
|
}
|
|
|
|
|
2023-12-18 19:13:30 -07:00
|
|
|
type i2 interface { // ERROR "invalid recursive type: anonymous interface refers to itself"
|
2016-05-05 19:03:59 -06:00
|
|
|
F() interface{i2}
|
2017-05-18 15:11:17 -06:00
|
|
|
}
|
2012-01-23 07:19:02 -07:00
|
|
|
|
2016-05-05 19:03:59 -06:00
|
|
|
var v1 i1
|
|
|
|
var v2 i2
|
2012-01-23 07:19:02 -07:00
|
|
|
|
|
|
|
func f() bool {
|
|
|
|
return v1 == v2
|
|
|
|
}
|