mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
Restrict any -> Protocol conversion. Protocol <-> looks at parent. Detect duplicate method definitions for protocols.
This commit is contained in:
22
test/test_suite/dynamic/any_cast.c3
Normal file
22
test/test_suite/dynamic/any_cast.c3
Normal file
@@ -0,0 +1,22 @@
|
||||
module test;
|
||||
|
||||
protocol Abc : Def
|
||||
{}
|
||||
|
||||
protocol Def
|
||||
{}
|
||||
|
||||
fn void! test()
|
||||
{
|
||||
any* x;
|
||||
Abc* d = x; // #error: cannot implicitly be converted to 'Abc*'
|
||||
}
|
||||
|
||||
|
||||
fn void! test2()
|
||||
{
|
||||
Abc* x;
|
||||
any* d = x;
|
||||
Def* e = x;
|
||||
x = e; // #error: is not a parent protocol of 'Def'
|
||||
}
|
||||
12
test/test_suite/dynamic/duplicate_definition.c3
Normal file
12
test/test_suite/dynamic/duplicate_definition.c3
Normal file
@@ -0,0 +1,12 @@
|
||||
module test;
|
||||
|
||||
protocol Abc
|
||||
{
|
||||
fn void abc();
|
||||
fn void abc(); // #error: Duplicate definition
|
||||
}
|
||||
fn void! main()
|
||||
{
|
||||
Abc* g;
|
||||
g.abc();
|
||||
}
|
||||
Reference in New Issue
Block a user