-
Notifications
You must be signed in to change notification settings - Fork 357
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
interp: improve method resolution for embedded interfaces
The function `getMethodByName()` is now able to look for embedded `valueInterface` field for matching methods in interface struct fields. Fixes #1439 and #1427.
- Loading branch information
Showing
2 changed files
with
49 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package main | ||
|
||
type Transformer interface { | ||
Reset() | ||
} | ||
|
||
type Encoder struct { | ||
Transformer | ||
} | ||
|
||
type nop struct{} | ||
|
||
func (nop) Reset() { println("Reset") } | ||
|
||
func f(e Transformer) { | ||
e.Reset() | ||
} | ||
|
||
func main() { | ||
e := Encoder{Transformer: nop{}} | ||
f(e) | ||
} | ||
|
||
// Output: | ||
// Reset |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters