Fix #289
Some checks failed
Build and Test with Maven / Build-and-test-with-Maven (push) Failing after 3m13s

This commit is contained in:
Daniel Holle 2024-03-13 11:21:00 +01:00
parent 26452eb5de
commit 83ae05ea4a
3 changed files with 20 additions and 1 deletions

View File

@ -0,0 +1,11 @@
import java.lang.Object;
import java.lang.Integer;
import java.util.List;
import java.util.ArrayList;
public class TypeCast {
public void main() {
Object a = new ArrayList<Integer>();
ArrayList b = (ArrayList) a;
}
}

View File

@ -102,7 +102,8 @@ public class TYPEStmt implements StatementVisitor {
@Override
public void visit(CastExpr castExpr) {
throw new NotImplementedException();
castExpr.expr.accept(this);
constraintsSet.addUndConstraint(new Pair(castExpr.getType(), castExpr.expr.getType(), PairOperator.SMALLERDOT));
}
@Override

View File

@ -867,6 +867,13 @@ public class TestComplete {
assertEquals(clazzPublic.getDeclaredField("fPrivate").getModifiers(), Modifier.PRIVATE);
}
@Test
public void testTypeCast() throws Exception {
var classFiles = generateClassFiles(new ByteArrayClassLoader(), "TypeCast.jav");
var clazz = classFiles.get("TypeCast");
var instance = clazz.getDeclaredConstructor().newInstance();
}
@Test
public void testBug122() throws Exception {
var classFiles = generateClassFiles(new ByteArrayClassLoader(), "Bug122.jav");