Commit 65cd635c authored by Miklos Magyari's avatar Miklos Magyari
Browse files

OOP: added property default value type checking


Signed-off-by: Miklos Magyari's avatarMiklos Magyari <miklos.magyari@sigmatechnology.se>
parent 92d084f2
...@@ -450,6 +450,13 @@ type class PropertyClass { ...@@ -450,6 +450,13 @@ type class PropertyClass {
return 1; return 1;
} }
} }
// property with default value
private var octetstring os;
var octetstring @property defValProp := 'AB'H { // default value type mismatch
@set => os := value;
@get => os;
};
} }
// raise exception // raise exception
......
...@@ -366,6 +366,13 @@ type class CorrectWithProperty { ...@@ -366,6 +366,13 @@ type class CorrectWithProperty {
} }
} }
} }
// property with default value
private var octetstring os;
var octetstring @property defValProp := 'AB'O {
@set => os := value;
@get => os;
};
} }
/*************************** /***************************
......
...@@ -17,6 +17,7 @@ import org.eclipse.titan.designer.AST.Assignment.Assignment_type; ...@@ -17,6 +17,7 @@ import org.eclipse.titan.designer.AST.Assignment.Assignment_type;
import org.eclipse.titan.designer.AST.FieldSubReference; import org.eclipse.titan.designer.AST.FieldSubReference;
import org.eclipse.titan.designer.AST.IReferenceChain; import org.eclipse.titan.designer.AST.IReferenceChain;
import org.eclipse.titan.designer.AST.IType; import org.eclipse.titan.designer.AST.IType;
import org.eclipse.titan.designer.AST.IValue;
import org.eclipse.titan.designer.AST.Identifier; import org.eclipse.titan.designer.AST.Identifier;
import org.eclipse.titan.designer.AST.Identifier.Identifier_type; import org.eclipse.titan.designer.AST.Identifier.Identifier_type;
import org.eclipse.titan.designer.AST.Location; import org.eclipse.titan.designer.AST.Location;
...@@ -228,9 +229,19 @@ public final class Property_Type extends Type { ...@@ -228,9 +229,19 @@ public final class Property_Type extends Type {
setterStatementBlock.setValueParamList(fpList); setterStatementBlock.setValueParamList(fpList);
setterStatementBlock.check(timestamp); setterStatementBlock.check(timestamp);
} }
if (initValTemplate != null && !hasSetter()) { if (initValTemplate != null) {
initValTemplate.getLocation().reportSemanticError(INITIALVALUEWITHOUTSETTER); if (hasSetter() == false) {
initValTemplate.setIsErroneous(true); initValTemplate.getLocation().reportSemanticError(INITIALVALUEWITHOUTSETTER);
initValTemplate.setIsErroneous(true);
}
initValTemplate.setMyGovernor(myType);
final IValue value = initValTemplate.getValue();
if (value != null) {
value.setMyGovernor(myType);
myType.checkThisValueRef(timestamp, value);
myType.checkThisValue(timestamp, value, null,
new ValueCheckingOptions(Expected_Value_type.EXPECTED_DYNAMIC_VALUE, false, false, true, false, false));
}
} }
} }
......
...@@ -179,7 +179,7 @@ public class OOP_Semantic_tests { ...@@ -179,7 +179,7 @@ public class OOP_Semantic_tests {
private ArrayList<MarkerToCheck> oopNegative_ttcn_initializer() { private ArrayList<MarkerToCheck> oopNegative_ttcn_initializer() {
//oopNegativeSemanticTest.ttcn //oopNegativeSemanticTest.ttcn
ArrayList<MarkerToCheck> markersToCheck = new ArrayList<MarkerToCheck>(100); ArrayList<MarkerToCheck> markersToCheck = new ArrayList<MarkerToCheck>(101);
int lineNum = 33; int lineNum = 33;
markersToCheck.add(new MarkerToCheck("class type expected", lineNum, IMarker.SEVERITY_ERROR)); markersToCheck.add(new MarkerToCheck("class type expected", lineNum, IMarker.SEVERITY_ERROR));
lineNum += 10; lineNum += 10;
...@@ -334,6 +334,8 @@ public class OOP_Semantic_tests { ...@@ -334,6 +334,8 @@ public class OOP_Semantic_tests {
markersToCheck.add(new MarkerToCheck("Property getter cannot be both abstract and final", lineNum, IMarker.SEVERITY_ERROR)); markersToCheck.add(new MarkerToCheck("Property getter cannot be both abstract and final", lineNum, IMarker.SEVERITY_ERROR));
lineNum += 4; lineNum += 4;
markersToCheck.add(new MarkerToCheck("Abstract getter should not have a body", lineNum, IMarker.SEVERITY_ERROR)); markersToCheck.add(new MarkerToCheck("Abstract getter should not have a body", lineNum, IMarker.SEVERITY_ERROR));
lineNum += 7;
markersToCheck.add(new MarkerToCheck("octetstring value was expected", lineNum, IMarker.SEVERITY_ERROR));
lineNum += 17; lineNum += 17;
markersToCheck.add(new MarkerToCheck("Raise statement cannot be used in a finally block", lineNum, IMarker.SEVERITY_ERROR)); markersToCheck.add(new MarkerToCheck("Raise statement cannot be used in a finally block", lineNum, IMarker.SEVERITY_ERROR));
lineNum += 10; lineNum += 10;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment