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

ast, checker, cgen: fix interface embeded methods call(fix #16496) #19936

Merged
merged 1 commit into from
Nov 19, 2023

Conversation

shove70
Copy link
Contributor

@shove70 shove70 commented Nov 19, 2023

  1. Fixed Build error: tcc: error: undefined symbol 'color__Color_cprintln', tcc: error: undefined symbol 'color__Brush_cprintln' #16496
  2. Add tests.
interface Foo {
    a_method()
}

fn (f Foo) foo_method() int {
    return 0
}

interface Bar {
    Foo
}

fn (b Bar) bar_method() int {
    return b.foo_method()
}

struct Derived {}

fn (d &Derived) a_method() {
}

fn main() {
    bar := Bar(Derived{})
    println(bar.bar_method())
}

outputs:

0

This problem occurs when calls the method of the embedded interface in the interface method, because the transformation mechanism of the interface embedded method is currently missing. This PR implements the same mechanism in the interface by calling the method of the embedded struct from the struct

Copy link
Member

@spytheman spytheman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Excellent work.

@spytheman spytheman merged commit 09c65a7 into vlang:master Nov 19, 2023
54 checks passed
@shove70 shove70 deleted the interface_methods branch November 19, 2023 16:33
@RGBCube
Copy link
Contributor

RGBCube commented Nov 19, 2023

Thanks for this fix! I can start working on my coloring library once again...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
3 participants