Skip to content

Commit 993e805

Browse files
committed
repairing the check of inner class constructor calls and updating test cases
1 parent fe0954a commit 993e805

File tree

3 files changed

+34
-4
lines changed

3 files changed

+34
-4
lines changed

key.core/src/main/java/de/uka/ilkd/key/proof/init/FinalFieldCodeValidator.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import de.uka.ilkd.key.java.abstraction.ClassType;
1212
import de.uka.ilkd.key.java.abstraction.KeYJavaType;
1313
import de.uka.ilkd.key.java.abstraction.Type;
14+
import de.uka.ilkd.key.java.declaration.ClassDeclaration;
1415
import de.uka.ilkd.key.java.expression.Assignment;
1516
import de.uka.ilkd.key.java.expression.operator.New;
1617
import de.uka.ilkd.key.java.reference.*;
@@ -171,7 +172,7 @@ private void validateNew(New _new) {
171172

172173
TypeReference typeRef = _new.getTypeReference();
173174
Type type = typeRef.getKeYJavaType().getJavaType();
174-
if (type instanceof ClassType classType && !classType.isStatic()) {
175+
if (type instanceof ClassDeclaration classType && classType.isInnerClass() && !classType.isStatic()) {
175176
// This also disallows things like "a.new B()" which would not like this. However,
176177
// KeY cannot deal with this anyway, so we can do the easy check here.
177178
throw new FinalViolationException(

key.core/src/test/java/de/uka/ilkd/key/proof/runallproofs/RunAllProofsTestUnit.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ public TestResult runTest(JunitXmlWriter xml) throws Exception {
121121

122122
boolean success = true;
123123
StringBuilder message = new StringBuilder("group " + testName + ":\n");
124+
StringBuilder summary = new StringBuilder("Summary of test results:\n");
124125
for (int i = 0; i < testResults.size(); i++) {
125126
var start = System.currentTimeMillis();
126127
TestFile file = testFiles.get(i);
@@ -133,7 +134,12 @@ public TestResult runTest(JunitXmlWriter xml) throws Exception {
133134
!testResult.success() ? "error" : "", testResult.message(), "", time / 1000.0);
134135
success &= testResult.success();
135136
message.append(testResult.message()).append("\n");
137+
summary.append(String.format(" %s (%s): %s%n",
138+
file.getKeYFile().getName(),
139+
file.getTestProperty(),
140+
testResult.success() ? "success" : "FAILURE"));
136141
}
142+
message.insert(0, summary);
137143
return new TestResult(message.toString(), success);
138144
}
139145

key.core/src/test/resources/de/uka/ilkd/key/nparser/taclets.old.txt

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
# This files contains representation of taclets, which are accepted and revised.
2-
# Date: Fri Dec 13 23:01:56 CET 2024
2+
# Date: Mon Mar 03 18:42:58 CET 2025
33

44
== abortJavaCardTransactionAPI (abortJavaCardTransactionAPI) =========================================
55
abortJavaCardTransactionAPI {
@@ -1906,7 +1906,7 @@ assignment_read_static_attribute {
19061906
\sameUpdateLevel\varcond(\hasSort(#sv (program StaticVariable), G), \not \final(#sv (program StaticVariable)))
19071907
\replacewith(update-application(elem-update(#v0 (program Variable))(G::select(heap,null,#memberPVToField(#sv))),#allmodal(post)))
19081908
\heuristics(simplify_prog_subset, simplify_prog)
1909-
Choices: programRules:Java}
1909+
Choices: (programRules:Java & finalFields:immutable)}
19101910
-----------------------------------------------------
19111911
== assignment_read_static_attribute_final (assignment_read_static_attribute_final) =========================================
19121912
assignment_read_static_attribute_final {
@@ -1916,7 +1916,7 @@ assignment_read_static_attribute_final {
19161916
\sameUpdateLevel\varcond(\hasSort(#sv (program StaticVariable), G), \final(#sv (program StaticVariable)))
19171917
\replacewith(update-application(elem-update(#v0 (program Variable))(G::final(null,#memberPVToField(#sv))),#allmodal(post)))
19181918
\heuristics(simplify_prog_subset, simplify_prog)
1919-
Choices: programRules:Java}
1919+
Choices: (programRules:Java & finalFields:immutable)}
19201920
-----------------------------------------------------
19211921
== assignment_read_static_attribute_with_variable_prefix (assignment) =========================================
19221922
assignment_read_static_attribute_with_variable_prefix {
@@ -7278,6 +7278,13 @@ equal_literals {
72787278
\heuristics(simplify_literals)
72797279
Choices: true}
72807280
-----------------------------------------------------
7281+
== equalityOfSingleton (equalityOfSingleton) =========================================
7282+
equalityOfSingleton {
7283+
\find(equals(singleton(o1,f1),singleton(o2,f2)))
7284+
\replacewith(and(equals(o1,o2),equals(f1,f2)))
7285+
\heuristics(simplify)
7286+
Choices: programRules:Java}
7287+
-----------------------------------------------------
72817288
== equalityToElementOf (equalityToElementOf) =========================================
72827289
equalityToElementOf {
72837290
\find(equals(s,s2))
@@ -15150,6 +15157,14 @@ reference_type_cast {
1515015157
\heuristics(simplify_prog)
1515115158
Choices: (programRules:Java & runtimeExceptions:ban)}
1515215159
-----------------------------------------------------
15160+
== referencedObjectIsCreatedRighFinalEQ (referencedObjectIsCreatedRighFinalEQ) =========================================
15161+
referencedObjectIsCreatedRighFinalEQ {
15162+
\assumes ([equals(deltaObject::final(o,f),EQ)]==>[equals(EQ,null)])
15163+
\find(==>equals(boolean::select(h,EQ,java.lang.Object::<created>),TRUE))
15164+
\add []==>[or(equals(boolean::select(h,o,java.lang.Object::<created>),TRUE),equals(o,null))]
15165+
\heuristics(concrete)
15166+
Choices: programRules:Java}
15167+
-----------------------------------------------------
1515315168
== referencedObjectIsCreatedRight (referencedObjectIsCreatedRight) =========================================
1515415169
referencedObjectIsCreatedRight {
1515515170
\assumes ([]==>[equals(deltaObject::select(h,o,f),null)])
@@ -15166,6 +15181,14 @@ referencedObjectIsCreatedRightEQ {
1516615181
\heuristics(concrete)
1516715182
Choices: programRules:Java}
1516815183
-----------------------------------------------------
15184+
== referencedObjectIsCreatedRightFinal (referencedObjectIsCreatedRightFinal) =========================================
15185+
referencedObjectIsCreatedRightFinal {
15186+
\assumes ([]==>[equals(deltaObject::final(o,f),null)])
15187+
\find(==>equals(boolean::select(h,deltaObject::final(o,f),java.lang.Object::<created>),TRUE))
15188+
\replacewith([]==>[or(equals(boolean::select(h,o,java.lang.Object::<created>),TRUE),equals(o,null))])
15189+
\heuristics(simplify_enlarging)
15190+
Choices: programRules:Java}
15191+
-----------------------------------------------------
1516915192
== regExAxiom (regExAxiom) =========================================
1517015193
regExAxiom {
1517115194
\find(match(regEx(stringAsPattern),string))

0 commit comments

Comments
 (0)