Don't allow classes to be defined with same name as their container (direct)
parent
9b84fc3428
commit
2c54333259
|
@ -33,16 +33,16 @@ public final class TypeChecker
|
||||||
|
|
||||||
|
|
||||||
/* Test getEntity on Module */
|
/* Test getEntity on Module */
|
||||||
gprintln("getEntity: myModule.x: "~to!(string)(getEntity(modulle, "myModule.x")));
|
// gprintln("getEntity: myModule.x: "~to!(string)(getEntity(modulle, "myModule.x")));
|
||||||
gprintln("getEntity: x: "~to!(string)(getEntity(modulle, "x")));
|
// gprintln("getEntity: x: "~to!(string)(getEntity(modulle, "x")));
|
||||||
|
|
||||||
/* Test getEntity on Class */
|
// /* Test getEntity on Class */
|
||||||
Container clazzEntity = cast(Container)getEntity(modulle, "clazz1");
|
// Container clazzEntity = cast(Container)getEntity(modulle, "clazz1");
|
||||||
gprintln("getEntity: clazz1.k: "~to!(string)(getEntity(clazzEntity, "clazz1.k")));
|
// gprintln("getEntity: clazz1.k: "~to!(string)(getEntity(clazzEntity, "clazz1.k")));
|
||||||
gprintln("getEntity: k: "~to!(string)(getEntity(clazzEntity, "k")));
|
// gprintln("getEntity: k: "~to!(string)(getEntity(clazzEntity, "k")));
|
||||||
clazzEntity = cast(Container)getEntity(modulle, "myModule.clazz1");
|
// clazzEntity = cast(Container)getEntity(modulle, "myModule.clazz1");
|
||||||
gprintln("getEntity: clazz1.k: "~to!(string)(getEntity(clazzEntity, "clazz1.k")));
|
// gprintln("getEntity: clazz1.k: "~to!(string)(getEntity(clazzEntity, "clazz1.k")));
|
||||||
gprintln("getEntity: k: "~to!(string)(getEntity(clazzEntity, "myModule.clazz1.k")));
|
// gprintln("getEntity: k: "~to!(string)(getEntity(clazzEntity, "myModule.clazz1.k")));
|
||||||
|
|
||||||
//process();
|
//process();
|
||||||
beginCheck();
|
beginCheck();
|
||||||
|
@ -307,23 +307,25 @@ public final class TypeChecker
|
||||||
*
|
*
|
||||||
* TODO: This will meet inner clazz1 first, we need to do another check
|
* TODO: This will meet inner clazz1 first, we need to do another check
|
||||||
*/
|
*/
|
||||||
|
gprintln("ddddsffsad");
|
||||||
if(resolveUp(c, clazz.getName()) != clazz)
|
if(resolveUp(c, clazz.getName()) != clazz)
|
||||||
{
|
{
|
||||||
Parser.expect("Error defining class with same name in same container: ClassTried: "~clazz.getName()~", Container: "~c.getName());
|
Parser.expect("Error defining class with same name in same container: ClassTried: "~clazz.getName()~", Container: "~c.getName());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
gprintln("dshfgjhdsj");
|
||||||
/* Get the current container's parent container */
|
/* Get the current container's parent container */
|
||||||
Container parentContainer = c.parentOf();
|
Container parentContainer = c.parentOf();
|
||||||
|
|
||||||
/* If c (container is Module) then it has no Parent */
|
/* Don't allow a class to be named after it's container */
|
||||||
if(!parentContainer)
|
// if(!parentContainer)
|
||||||
{
|
// {
|
||||||
if(cmp(c.getName(), clazz.getName()) == 0)
|
if(cmp(c.getName(), clazz.getName()) == 0)
|
||||||
{
|
{
|
||||||
Parser.expect("Cannot use name of module, in use");
|
Parser.expect("Class cannot be defined with same name as containing entity");
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
// }
|
||||||
|
|
||||||
/* TODO: We allow shaddowing so below is disabled */
|
/* TODO: We allow shaddowing so below is disabled */
|
||||||
/* TODO: We should however use the below for dot-less resolution */
|
/* TODO: We should however use the below for dot-less resolution */
|
||||||
|
@ -401,6 +403,7 @@ public final class TypeChecker
|
||||||
//gprintln("Processing at path/level: "~path, DebugType.WARNING);
|
//gprintln("Processing at path/level: "~path, DebugType.WARNING);
|
||||||
|
|
||||||
/* First we define types (so classes) */
|
/* First we define types (so classes) */
|
||||||
|
gprintln("dd");
|
||||||
checkClasses(c);
|
checkClasses(c);
|
||||||
|
|
||||||
Statement[] statements = c.getStatements();
|
Statement[] statements = c.getStatements();
|
||||||
|
|
|
@ -47,7 +47,7 @@ public class clazz1
|
||||||
|
|
||||||
public class clazz3
|
public class clazz3
|
||||||
{
|
{
|
||||||
class bruh2
|
class clazz1
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue