Restrict any -> Protocol conversion. Protocol <-> looks at parent. Detect duplicate method definitions for protocols.

This commit is contained in:
Christoffer Lerno
2023-10-08 23:43:02 +02:00
parent 3aa85cf641
commit ebddbfb416
9 changed files with 78 additions and 43 deletions

View 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'
}

View 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();
}