-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
checker: add test for interface embedding and interface with erroneou…
…s implementation (test related to vlang#21030) (vlang#21033)
- Loading branch information
Showing
2 changed files
with
32 additions
and
0 deletions.
There are no files selected for viewing
9 changes: 9 additions & 0 deletions
9
...ker/tests/struct_init_with_iface_embed_iface_with_incorrect_method_impl_ref_field_err.out
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,9 @@ | ||
vlib/v/checker/tests/struct_init_with_iface_embed_iface_with_incorrect_method_impl_ref_field_err.vv:21:3: error: `&Stream` incorrectly implements method `read` of interface `Refresher`: expected return type `!int` | ||
19 | s := &Stream{} | ||
20 | _ := &Server{ | ||
21 | refresher: s | ||
| ~~~~~~~~~~~~ | ||
22 | } | ||
23 | } | ||
Details: main.Refresher has `fn read(x main.Refresher, buf []u8) !int` | ||
main.Stream has `fn read(a main.Stream, buf []u8)` |
23 changes: 23 additions & 0 deletions
23
...cker/tests/struct_init_with_iface_embed_iface_with_incorrect_method_impl_ref_field_err.vv
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,23 @@ | ||
interface Refresher { | ||
Reader | ||
} | ||
|
||
interface Reader { | ||
read(buf []u8) !int | ||
} | ||
|
||
struct Server { | ||
refresher Refresher | ||
} | ||
|
||
struct Stream {} | ||
|
||
// Implementation is missing the return type. | ||
fn (a Stream) read(buf []u8) {} | ||
|
||
fn test_struct_init_with_interface_field() { | ||
s := &Stream{} | ||
_ := &Server{ | ||
refresher: s | ||
} | ||
} |