Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
967bd91a6e | ||
|
|
9e15f051b9 |
No files matched your search
@@ -0,0 +1,9 @@
|
|||||||
|
import java.lang.Boolean;
|
||||||
|
import java.lang.System;
|
||||||
|
import java.io.PrintStream;
|
||||||
|
|
||||||
|
public class Bug463 {
|
||||||
|
public static and(Boolean a, Boolean b) { return a & b; } // | and ^ behave the same
|
||||||
|
public static or(Boolean a, Boolean b) { return a | b; }
|
||||||
|
public static xor(Boolean a, Boolean b) { return a ^ b; }
|
||||||
|
}
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
import java.lang.Integer;
|
|
||||||
import java.lang.Object;
|
|
||||||
import java.lang.System;
|
|
||||||
import java.io.PrintStream;
|
|
||||||
|
|
||||||
public class Bug466 {
|
|
||||||
public void p(Object o) { System.out.println(o.toString()); }
|
|
||||||
public run() {
|
|
||||||
var a = 3;
|
|
||||||
p(-(a + 10)); // Java: -13
|
|
||||||
}
|
|
||||||
public static main(args) { new Bug466().run(); }
|
|
||||||
}
|
|
||||||
@@ -57,4 +57,9 @@ public record TargetFunNType(String name, List<TargetType> funNParams, List<Targ
|
|||||||
}
|
}
|
||||||
return Objects.equals(name, otfn.name);
|
return Objects.equals(name, otfn.name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() {
|
||||||
|
return toSignature();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -357,6 +357,17 @@ public class TYPEStmt implements StatementVisitor {
|
|||||||
numericAdditionOrStringConcatenation.add(stringConcat);
|
numericAdditionOrStringConcatenation.add(stringConcat);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (binary.operation.equals(BinaryExpr.Operator.AND) || binary.operation.equals(BinaryExpr.Operator.OR) || binary.operation.equals(BinaryExpr.Operator.XOR)) {
|
||||||
|
// Binary operations defined on boolean
|
||||||
|
if (classNames.contains(bool.getName())) {
|
||||||
|
Constraint<Pair> boolOp = new Constraint<>();
|
||||||
|
boolOp.add(new Pair(binary.lexpr.getType(), bool, PairOperator.EQUALSDOT, loc(binary.getOffset())));
|
||||||
|
boolOp.add(new Pair(binary.rexpr.getType(), bool, PairOperator.EQUALSDOT, loc(binary.getOffset())));
|
||||||
|
boolOp.add(new Pair(bool, binary.getType(), PairOperator.EQUALSDOT, loc(binary.getOffset())));
|
||||||
|
numericAdditionOrStringConcatenation.add(boolOp);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (numericAdditionOrStringConcatenation.isEmpty()) {
|
if (numericAdditionOrStringConcatenation.isEmpty()) {
|
||||||
throw new TypeinferenceException("Kein Typ für " + binary.operation.toString() + " vorhanden", binary.getOffset());
|
throw new TypeinferenceException("Kein Typ für " + binary.operation.toString() + " vorhanden", binary.getOffset());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -50,7 +50,9 @@ public class Logger {
|
|||||||
public static void resetLogs() {
|
public static void resetLogs() {
|
||||||
defaultWriter = null;
|
defaultWriter = null;
|
||||||
try {
|
try {
|
||||||
FileUtils.cleanDirectory(logFolder);
|
FileUtils.cleanDirectory(logFolder);
|
||||||
|
} catch (FileNotFoundException e) {
|
||||||
|
// Ignore
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1808,9 +1808,27 @@ public class TestComplete {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testBug466() throws Exception {
|
public void testBug463() throws Exception {
|
||||||
var classFiles = generateClassFiles(createClassLoader(), "Bug466.jav");
|
var classFiles = generateClassFiles(createClassLoader(), "Bug463.jav");
|
||||||
var clazz = classFiles.get("Bug466");
|
var clazz = classFiles.get("Bug463");
|
||||||
clazz.getDeclaredMethod("main", List.class).invoke(null, List.of());
|
var instance = clazz.getDeclaredConstructor().newInstance();
|
||||||
|
|
||||||
|
var and = clazz.getDeclaredMethod("and", Boolean.class, Boolean.class);
|
||||||
|
assertEquals(true, and.invoke(instance, true, true));
|
||||||
|
assertEquals(false, and.invoke(instance, true, false));
|
||||||
|
assertEquals(false, and.invoke(instance, false, true));
|
||||||
|
assertEquals(false, and.invoke(instance, false, false));
|
||||||
|
|
||||||
|
var or = clazz.getDeclaredMethod("or", Boolean.class, Boolean.class);
|
||||||
|
assertEquals(true, or.invoke(instance, true, true));
|
||||||
|
assertEquals(true, or.invoke(instance, true, false));
|
||||||
|
assertEquals(true, or.invoke(instance, false, true));
|
||||||
|
assertEquals(false, or.invoke(instance, false, false));
|
||||||
|
|
||||||
|
var xor = clazz.getDeclaredMethod("xor", Boolean.class, Boolean.class);
|
||||||
|
assertEquals(false, xor.invoke(instance, true, true));
|
||||||
|
assertEquals(true, xor.invoke(instance, true, false));
|
||||||
|
assertEquals(true, xor.invoke(instance, false, true));
|
||||||
|
assertEquals(false, xor.invoke(instance, false, false));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user