Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cl: processPkg check runtimeTypes for generic method #782

Merged
merged 2 commits into from
Sep 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading