Add three regression test cases for cross-package interface private method calls: 1. _cmptest/issue1370_gotypes/ - Tests go/types.Object interface with Scope.Insert() which calls the private setParent() method 2. _cmptest/issue1370_goast/ - Tests go/ast.Expr interface conversion with ast.Ident which has a private exprNode() method 3. _cmptest/issue1370_geometry/ - Tests custom geometry.Shape interface with private methods (validate, setID) across package boundaries These tests verify the fix in ssa/abitype.go correctly sets the interface metadata's PkgPath to the interface definition package instead of the compilation package, preventing segmentation faults when calling private methods. Generated with [codeagent](https://github.com/qbox/codeagent) Co-authored-by: luoliwoshang <51194195+luoliwoshang@users.noreply.github.com>
33 lines
561 B
Go
33 lines
561 B
Go
package main
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"github.com/goplus/llgo/_cmptest/issue1370_geometry/geometry"
|
|
)
|
|
|
|
func main() {
|
|
rect := geometry.NewRectangle(5.0, 3.0)
|
|
|
|
err := geometry.RegisterShape(rect, 42)
|
|
if err != nil {
|
|
println("FAIL: RegisterShape returned error")
|
|
return
|
|
}
|
|
|
|
if rect.GetID() != 42 {
|
|
println("FAIL: ID not set correctly")
|
|
return
|
|
}
|
|
|
|
area := rect.Area()
|
|
fmt.Printf("Area: %.1f\n", area)
|
|
|
|
if area != 15.0 {
|
|
println("FAIL: Area calculation incorrect")
|
|
return
|
|
}
|
|
|
|
println("SUCCESS: Custom interface with private methods works correctly")
|
|
}
|