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

interp: improve handling of composed interfaces wrappers #1443

Merged
merged 9 commits into from
Aug 25, 2022

Conversation

mvertes
Copy link
Member

@mvertes mvertes commented Aug 23, 2022

This change implements a workaround to better support composed
interfaces in yaegi and let the interpreter define objects which
implement multiple interfaces at once.

We use the existing MapTypes to store what possible composed interface
wrapper could be used for some interfaces. When generating an interface
wrapper, the wrapper with the highest number of implemented methods is
chosen.

This is still an imperfect solution but it improves the accuracy of
interpreter in some critical cases.

This workaround could be removed in future if/when golang/go#15924
is resolved.

Fixes #1425.

This change implements a workaround to better support composed
interfaces in yaegi and let the interpreter to define objects which
impletment multiple interfaces at once.

We use the existing MapTypes to store what possible composed interfaces
wrapper could be used for some interfaces. When generating an interface
wrapper, the wrapper with the highest number of implemented methods is
chosen.

This is still an imperfect solution but it improves the accuracy of
interpreter in some critical cases.

This workaround could be removed in future if/when golang/go#15924
is resolved.

Fixes traefik#1425.
@mvertes mvertes requested a review from mpl August 23, 2022 13:30
@mvertes mvertes added this to the v0.14.x milestone Aug 23, 2022
interp/run.go Outdated Show resolved Hide resolved
interp/use.go Outdated Show resolved Hide resolved
interp/use.go Show resolved Hide resolved
interp/use.go Outdated Show resolved Hide resolved
stdlib/wrapper-composed.go Show resolved Hide resolved
mvertes and others added 5 commits August 25, 2022 10:08
Co-authored-by: mpl <mathieu.lonjaret@gmail.com>
Co-authored-by: mpl <mathieu.lonjaret@gmail.com>
Co-authored-by: mpl <mathieu.lonjaret@gmail.com>
Co-authored-by: mpl <mathieu.lonjaret@gmail.com>
Co-authored-by: mpl <mathieu.lonjaret@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/core area/stdlib bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

stdlib._net_http_ResponseWriter is not seen as an http.Hijacker
3 participants