Skip to content

Commit

Permalink
修复函数重载的一些错误
Browse files Browse the repository at this point in the history
  • Loading branch information
chai2010 committed Mar 29, 2024
1 parent d961df2 commit 684dd5d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 11 deletions.
18 changes: 8 additions & 10 deletions internal/types/resolver.go
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,7 @@ func (check *Checker) resolveExprOrTypeOrGenericCall(x *operand, e *ast.CallExpr
pname := obj
assert(pname.pkg == check.pkg)
exp := pname.Imported().scope.Lookup(eCall.Sel.Name)
if fnObj, _ := exp.(*Func); ok && len(fnObj.generic) != 0 {
if fnObj, ok := exp.(*Func); ok && len(fnObj.generic) != 0 {
for _, genericFnObj := range fnObj.generic {
if err := check.tryGenericCall(x, genericFnObj, e); err == nil {
eCall.Sel.Name = genericFnObj.name
Expand All @@ -613,15 +613,13 @@ func (check *Checker) resolveExprOrTypeOrGenericCall(x *operand, e *ast.CallExpr

case *Var: // this.Method(arg)
if t, _ := obj.Type().(*Named); t != nil {
if p, _ := t.underlying.(*Pointer); p != nil {
obj, _, _ := lookupFieldOrMethod(p, true, check.pkg, eCall.Sel.Name)
if fnObj, ok := obj.(*Func); ok && len(fnObj.generic) != 0 {
for _, genericFnObj := range fnObj.generic {
if err := check.tryGenericCall(x, genericFnObj, e); err == nil {
eCall.Sel.Name = genericFnObj.name
check.exprOrType(x, e.Fun)
return
}
obj, _, _ := lookupFieldOrMethod(t, true, check.pkg, eCall.Sel.Name)
if fnObj, ok := obj.(*Func); ok && len(fnObj.generic) != 0 {
for _, genericFnObj := range fnObj.generic {
if err := check.tryGenericCall(x, genericFnObj, e); err == nil {
eCall.Sel.Name = genericFnObj.name
check.exprOrType(x, e.Fun)
return
}
}
}
Expand Down
5 changes: 4 additions & 1 deletion waroot/changelog.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
# 版本日志

- (dev)
- 禁止类型别名
- v0.10.0 (2024-03-29)
- 补充基本类型读写胶水
- 修正 I64、U64 不应导出等一些错误
- 实验性引入全局函数和方法的重载功能
- v0.9.2 (2024-03-04) MVP
- 完善 `js/p5` 包, 增加键盘事件处理, 改用凹语言原生绘图
- `wa init` 增加 `-p5` 参数
Expand Down

0 comments on commit 684dd5d

Please sign in to comment.