mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-07-26 06:38:42 +00:00
compiler: add support for the go keyword on interface methods
This is a feature that was long missing, but because of the previous refactor, it is now trivial to implement.
This commit is contained in:
committed by
Ron Evans
parent
a4afc3b4b0
commit
9e1b4de999
Vendored
+27
@@ -75,6 +75,8 @@ func main() {
|
||||
|
||||
testGoOnBuiltins()
|
||||
|
||||
testGoOnInterface(Foo(0))
|
||||
|
||||
testCond()
|
||||
|
||||
testIssue1790()
|
||||
@@ -203,6 +205,14 @@ func testCond() {
|
||||
|
||||
var once sync.Once
|
||||
|
||||
func testGoOnInterface(f Itf) {
|
||||
go f.Nowait()
|
||||
time.Sleep(time.Millisecond)
|
||||
go f.Wait()
|
||||
time.Sleep(time.Millisecond * 2)
|
||||
println("done with 'go on interface'")
|
||||
}
|
||||
|
||||
// This tests a fix for issue 1790:
|
||||
// https://github.com/tinygo-org/tinygo/issues/1790
|
||||
func testIssue1790() *int {
|
||||
@@ -210,3 +220,20 @@ func testIssue1790() *int {
|
||||
i := 0
|
||||
return &i
|
||||
}
|
||||
|
||||
type Itf interface {
|
||||
Nowait()
|
||||
Wait()
|
||||
}
|
||||
|
||||
type Foo string
|
||||
|
||||
func (f Foo) Nowait() {
|
||||
println("called: Foo.Nowait")
|
||||
}
|
||||
|
||||
func (f Foo) Wait() {
|
||||
println("called: Foo.Wait")
|
||||
time.Sleep(time.Microsecond)
|
||||
println(" ...waited")
|
||||
}
|
||||
|
||||
Vendored
+4
@@ -20,3 +20,7 @@ acquired mutex from goroutine
|
||||
released mutex from goroutine
|
||||
re-acquired mutex
|
||||
done
|
||||
called: Foo.Nowait
|
||||
called: Foo.Wait
|
||||
...waited
|
||||
done with 'go on interface'
|
||||
|
||||
Reference in New Issue
Block a user