Commit 4187b216 authored by Miklos Magyari's avatar Miklos Magyari
Browse files

OOP: abstract properties should have a body


Signed-off-by: Miklos Magyari's avatarMiklos Magyari <miklos.magyari@sigmatechnology.se>
parent 60ef0ac4
......@@ -457,6 +457,9 @@ type class PropertyClass {
@set => os := value;
@get => os;
};
// invalid: abstract property without a body
var @abstract integer @property abstractNoBody;
}
// raise exception
......@@ -469,7 +472,7 @@ function f_with_exception(integer pl_int) return integer exception(integer) {
} catch (integer e) {
log("Catch block");
} finally {
log("Finally block");
log("Finally block");
raise integer:0; // invalid, raise cannot be used in a finally block
}
......
......@@ -56,7 +56,8 @@ public final class Property_Type extends Type {
private static final String MODIFIERFINALABSTRACT = "Property {0} cannot be both abstract and final";
private static final String ABSTRACTWITHBODY = "Abstract {0} should not have a body";
private static final String ABSTRACTWITHOUTBODY = "Abstract properties shall contain a property body";
private static final String GETTER = "getter";
private static final String SETTER = "setter";
......@@ -218,6 +219,10 @@ public final class Property_Type extends Type {
}
checkModifiers();
if (isAbstract && !hasBody) {
getLocation().reportSemanticError(ABSTRACTWITHOUTBODY);
}
if (getterStatementBlock != null) {
getterStatementBlock.check(timestamp);
......
......@@ -181,7 +181,7 @@ public class OOP_Semantic_tests {
private ArrayList<MarkerToCheck> oopNegative_ttcn_initializer() {
//oopNegativeSemanticTest.ttcn
ArrayList<MarkerToCheck> markersToCheck = new ArrayList<MarkerToCheck>(106);
ArrayList<MarkerToCheck> markersToCheck = new ArrayList<MarkerToCheck>(107);
int lineNum = 33;
markersToCheck.add(new MarkerToCheck("class type expected", lineNum, IMarker.SEVERITY_ERROR));
lineNum += 10;
......@@ -338,7 +338,9 @@ public class OOP_Semantic_tests {
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 += 6;
markersToCheck.add(new MarkerToCheck("Abstract properties shall contain a property body", lineNum, IMarker.SEVERITY_ERROR));
lineNum += 14;
markersToCheck.add(new MarkerToCheck("Raise statement cannot be used in a finally block", lineNum, IMarker.SEVERITY_ERROR));
lineNum += 4;
markersToCheck.add(new MarkerToCheck("The prototype of method `toString is not identical to that of the method inherited from the object class", lineNum, IMarker.SEVERITY_ERROR));
......@@ -361,7 +363,7 @@ public class OOP_Semantic_tests {
markersToCheck.add(new MarkerToCheck("Private member is inaccessible due to its protection level", lineNum, IMarker.SEVERITY_ERROR));
lineNum += 2;
markersToCheck.add(new MarkerToCheck("Character string value was expected", lineNum, IMarker.SEVERITY_ERROR));
markersToCheck.add(new MarkerToCheck("Too few parameters: 12 was expected instead of 10", lineNum, IMarker.SEVERITY_ERROR));
markersToCheck.add(new MarkerToCheck("Too few parameters: 13 was expected instead of 10", lineNum, IMarker.SEVERITY_ERROR));
lineNum += 3;
markersToCheck.add(new MarkerToCheck("Cannot assign a value to a property without a setter", lineNum, IMarker.SEVERITY_ERROR));
lineNum += 3;
......
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