Skip to content

Commit

Permalink
cl: processPkg check runtimeTypes for generic method
Browse files Browse the repository at this point in the history
  • Loading branch information
visualfc committed Sep 9, 2024
1 parent 74b48ff commit 3bdb921
Show file tree
Hide file tree
Showing 4 changed files with 854 additions and 4 deletions.
8 changes: 4 additions & 4 deletions cl/_testrt/tpabi/out.ll
Original file line number Diff line number Diff line change
Expand Up @@ -152,10 +152,6 @@ _llgo_2: ; preds = %_llgo_0
unreachable
}

declare void @"github.com/goplus/llgo/internal/runtime.init"()

declare ptr @"github.com/goplus/llgo/internal/runtime.Zeroinit"(ptr, i64)

define linkonce void @"main.T[string,int].Info"(%"main.T[string,int]" %0) {
_llgo_0:
%1 = alloca %"main.T[string,int]", align 8
Expand Down Expand Up @@ -192,6 +188,10 @@ _llgo_0:
ret void
}

declare void @"github.com/goplus/llgo/internal/runtime.init"()

declare ptr @"github.com/goplus/llgo/internal/runtime.Zeroinit"(ptr, i64)

define void @"main.init$after"() {
_llgo_0:
%0 = call ptr @"github.com/goplus/llgo/internal/runtime.NewNamed"(i64 25, i64 24, i64 1, i64 2)
Expand Down
37 changes: 37 additions & 0 deletions cl/_testrt/tpmethod/in.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
package main

type Tuple[T any] struct {
v T
}

func (t Tuple[T]) Get() T {
return t.v
}

type Future[T any] interface {
Then(func(T))
}

type future[T any] struct {
fn func(func(T))
}

func (f *future[T]) Then(callback func(T)) {
f.fn(callback)
}

func Async[T any](fn func(func(T))) Future[T] {
return &future[T]{fn: fn}
}

func ReadFile(fileName string) Future[Tuple[error]] {
return Async[Tuple[error]](func(resolve func(Tuple[error])) {
resolve(Tuple[error]{v: nil})
})
}

func main() {
ReadFile("foo.txt").Then(func(v Tuple[error]) {
println(v.Get())
})
}
Loading

0 comments on commit 3bdb921

Please sign in to comment.