diff --git a/src/main/java/de/maishai/typedast/typedclass/TypedAssignment.java b/src/main/java/de/maishai/typedast/typedclass/TypedAssignment.java index 404ad8d..c662b60 100644 --- a/src/main/java/de/maishai/typedast/typedclass/TypedAssignment.java +++ b/src/main/java/de/maishai/typedast/typedclass/TypedAssignment.java @@ -70,7 +70,7 @@ public class TypedAssignment implements TypedStatement { if (currentMethod.isLocalVariableInMethod(name)) { return currentMethod.getLocalVariableType(name); } else if (currentClass.isThereField(name)) { - return currentClass.getFieldType(name); + throw new RuntimeException("Field Variable "+ name + " should be used with `thisĀ“"); } else { throw new RuntimeException("Variable " + name + " not declared in method"); } @@ -80,7 +80,7 @@ public class TypedAssignment implements TypedStatement { if (currentConstructor.isLocalVariableInConstructor(name)) { return currentConstructor.getLocalVariableType(name); } else if (currentClass.isThereField(name)) { - return currentClass.getFieldType(name); + throw new RuntimeException("Field Variable "+ name+ " should be used with `thisĀ“"); } else { throw new RuntimeException("Variable " + name + " not declared in constructor"); } diff --git a/src/main/java/de/maishai/typedast/typedclass/TypedLocalVariable.java b/src/main/java/de/maishai/typedast/typedclass/TypedLocalVariable.java index ad73cbf..639dcff 100644 --- a/src/main/java/de/maishai/typedast/typedclass/TypedLocalVariable.java +++ b/src/main/java/de/maishai/typedast/typedclass/TypedLocalVariable.java @@ -32,14 +32,12 @@ public final class TypedLocalVariable implements TypedNode { if (typedProgram.getCurrentClass().getCurrentMethod().isLocalVariableInMethod(name)) { throw new RuntimeException("Variable " + name + " already declared"); } - typedProgram.getCurrentClass().getCurrentMethod().getLocalVariables().add(this); return type; } if (!typedProgram.getCurrentClass().isCurrentMethodPresent() && typedProgram.getCurrentClass().isCurrentConstructorPresent()) { if (typedProgram.getCurrentClass().getCurrentConstructor().isLocalVariableInConstructor(name)) { throw new RuntimeException("Variable " + name + " already declared"); } - typedProgram.getCurrentClass().getCurrentConstructor().getLocalVariables().add(this); return type; } throw new RuntimeException("not found method or constructor in class");