Skip to content

Commit

Permalink
fix test for go1.17
Browse files Browse the repository at this point in the history
  • Loading branch information
xhd2015 committed Apr 6, 2024
1 parent 0a5cae8 commit 6d0b957
Show file tree
Hide file tree
Showing 9 changed files with 37 additions and 21 deletions.
6 changes: 3 additions & 3 deletions cmd/xgo/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ package main

import "fmt"

const VERSION = "1.0.18"
const REVISION = "86b60236af7fe7147b90073421f57187fbf6990a+1"
const NUMBER = 165
const VERSION = "1.0.19"
const REVISION = "7b94c97a1b438510f46aa86fca2b626396b9d2e1+1"
const NUMBER = 166

func getRevision() string {
revSuffix := ""
Expand Down
2 changes: 1 addition & 1 deletion patch/ctxt/skip_pkg_go1.19_and_below.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//go:build go1.17 && !go1.20
// +build go1.17,!go1.20

package ctx
package ctxt

import (
"strings"
Expand Down
16 changes: 16 additions & 0 deletions patch/syntax/call_expr_go1.17_18_19.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
//go:build !go1.20
// +build !go1.20

package syntax

import "cmd/compile/internal/syntax"

func (ctx *BlockContext) traverseCallExpr(node *syntax.CallExpr, globaleNames map[string]*DeclInfo, imports map[string]string) *syntax.CallExpr {
if node == nil {
return nil
}
for i, arg := range node.ArgList {
node.ArgList[i] = ctx.traverseExpr(arg, globaleNames, imports)
}
return node
}
10 changes: 10 additions & 0 deletions patch/syntax/call_expr_go1.20.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
//go:build go1.20
// +build go1.20

package syntax

import "cmd/compile/internal/syntax"

func (ctx *BlockContext) traverseCallExpr(node syntax.Expr, globaleNames map[string]*DeclInfo, imports map[string]string) syntax.Expr {
return ctx.traverseExpr(node, globaleNames, imports)
}
12 changes: 1 addition & 11 deletions patch/syntax/vars.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,16 +46,6 @@ func collectVarDecls(declKind DeclKind, names []*syntax.Name, typ syntax.Expr) [
return decls
}

type vis struct {
}

var _ syntax.Visitor = (*vis)(nil)

// Visit implements syntax.Visitor.
func (c *vis) Visit(node syntax.Node) (w syntax.Visitor) {
return nil
}

func trapVariables(pkgPath string, fileList []*syntax.File, funcDelcs []*DeclInfo) {
names := make(map[string]*DeclInfo, len(funcDelcs))
varNames := make(map[string]bool)
Expand Down Expand Up @@ -198,7 +188,7 @@ func (ctx *BlockContext) traverseStmt(node syntax.Stmt, globaleNames map[string]
return ctx.traverseBlockStmt(node, globaleNames, imports)
case *syntax.CallStmt:
// defer, go
node.Call = ctx.traverseExpr(node.Call, globaleNames, imports)
node.Call = ctx.traverseCallExpr(node.Call, globaleNames, imports)
return node
case *syntax.IfStmt:
node.Init = ctx.traverseSimpleStmt(node.Init, globaleNames, imports)
Expand Down
6 changes: 3 additions & 3 deletions runtime/core/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import (
"os"
)

const VERSION = "1.0.18"
const REVISION = "86b60236af7fe7147b90073421f57187fbf6990a+1"
const NUMBER = 165
const VERSION = "1.0.19"
const REVISION = "7b94c97a1b438510f46aa86fca2b626396b9d2e1+1"
const NUMBER = 166

// these fields will be filled by compiler
const XGO_VERSION = ""
Expand Down
2 changes: 1 addition & 1 deletion runtime/functab/functab.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func InfoFunc(fn interface{}) *core.FuncInfo {
func InfoVar(addr interface{}) *core.FuncInfo {
ensureMapping()
v := reflect.ValueOf(addr)
if v.Kind() != reflect.Pointer {
if v.Kind() != reflect.Ptr {
panic(fmt.Errorf("given type is not a pointer: %T", addr))
}
ptr := v.Pointer()
Expand Down
2 changes: 1 addition & 1 deletion runtime/mock/patch.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func Patch(fn interface{}, replacer interface{}) func() {
if fnType != reflect.TypeOf(replacer) {
panic(fmt.Errorf("replacer should have type: %T, actual: %T", fn, replacer))
}
} else if fnKind == reflect.Pointer {
} else if fnKind == reflect.Ptr {
replacerType := reflect.TypeOf(replacer)
wantType := reflect.FuncOf(nil, []reflect.Type{fnType.Elem()}, false)
var targetTypeStr string
Expand Down
2 changes: 1 addition & 1 deletion support/goinfo/mod.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func ResolveMainModule(dir string, args []string) (string, error) {

return modPath, nil

// // has quailified name: not starting with ./ or ../
// // has qualified name: not starting with ./ or ../
// var qualifieldNames []string
// for _, arg := range args {
// if !isRelative(arg) {
Expand Down

0 comments on commit 6d0b957

Please sign in to comment.