From 2fdebc02033626aeb27effd9cce84649fb82ef59 Mon Sep 17 00:00:00 2001 From: NoName11234 <47484268+NoName11234@users.noreply.github.com> Date: Wed, 15 May 2024 15:45:07 +0200 Subject: [PATCH] implemented scalark2test --- src/test/java/UnifyTest.java | 598 ++++++++++++++++++++++++++++++++++- 1 file changed, 597 insertions(+), 1 deletion(-) diff --git a/src/test/java/UnifyTest.java b/src/test/java/UnifyTest.java index 6f75a89..4f7d453 100644 --- a/src/test/java/UnifyTest.java +++ b/src/test/java/UnifyTest.java @@ -81,5 +81,601 @@ public class UnifyTest { Set> solution = unifyAlgo.unify(undConstraints, oderConstraints, finiteClosure, new NullWriter(), false, urm, tasks); System.out.println(solution.size()); //System.out.println(solution); - }} + } + + @Test + public void basicMatrixTest(){ + UnifyType type1; + UnifyType type2; + Set undConstraints = new HashSet<>(); + + //und-constraints + //Matrix <. ret + type1 = new ReferenceType("Matrix"); + type2 = new PlaceholderType("ret"); + undConstraints.add(new UnifyPair(type1, type2, PairOperator.SMALLERDOT)); + //Integer <. i + type1 = new ReferenceType("Integer"); + type2 = new PlaceholderType("i"); + undConstraints.add(new UnifyPair(type1, type2, PairOperator.SMALLERDOT)); + //Matrix <. Vector + type1 = new ReferenceType("Matrix"); + type2 = new ReferenceType("Vector", new TypeParams(new PlaceholderType("x"))); + undConstraints.add(new UnifyPair(type1, type2, PairOperator.SMALLERDOT)); + //x? <. v1 + type1 = new PlaceholderType("x"); + type2 = new PlaceholderType("v1"); + undConstraints.add(new UnifyPair(type1, type2, PairOperator.SMALLERDOT)); + //i <. Integer + type1 = new PlaceholderType("i"); + type2 = new ReferenceType("Integer"); + undConstraints.add(new UnifyPair(type1, type2, PairOperator.SMALLERDOT)); + //Vector <. v2 + type1 = new ReferenceType("Vector", new TypeParams(new ReferenceType("Integer"))); + type2 = new PlaceholderType("v2"); + undConstraints.add(new UnifyPair(type1, type2, PairOperator.SMALLERDOT)); + //v1 <. Vector + type1 = new PlaceholderType("v1"); + type2 = new ReferenceType("Vector", new TypeParams(new PlaceholderType("y"))); + undConstraints.add(new UnifyPair(type1, type2, PairOperator.SMALLERDOT)); + //m <. Vector + type1 = new PlaceholderType("m"); + type2 = new ReferenceType("Vector", new TypeParams(new PlaceholderType("z"))); + undConstraints.add(new UnifyPair(type1, type2, PairOperator.SMALLERDOT)); + //z? <. zr + type1 = new PlaceholderType("z"); + type2 = new PlaceholderType("zr"); + undConstraints.add(new UnifyPair(type1, type2, PairOperator.SMALLERDOT)); + //zr <. Vector + type1 = new PlaceholderType("zr"); + type2 = new ReferenceType("Vector", new TypeParams(new PlaceholderType("z2"))); + undConstraints.add(new UnifyPair(type1, type2, PairOperator.SMALLERDOT)); + //z2? <. z2r + type1 = new PlaceholderType("z2"); + type2 = new PlaceholderType("z2r"); + undConstraints.add(new UnifyPair(type1, type2, PairOperator.SMALLERDOT)); + //z2r <. Integer + type1 = new PlaceholderType("z2r"); + type2 = new ReferenceType("Integer"); + undConstraints.add(new UnifyPair(type1, type2, PairOperator.SMALLERDOT)); + //v1 <. Vector + type1 = new PlaceholderType("v1"); + type2 = new ReferenceType("Vector", new TypeParams(new PlaceholderType("y2"))); + undConstraints.add(new UnifyPair(type1, type2, PairOperator.SMALLERDOT)); + //y2? <. y2r + type1 = new PlaceholderType("y2"); + type2 = new PlaceholderType("y2r"); + undConstraints.add(new UnifyPair(type1, type2, PairOperator.SMALLERDOT)); + //y2r <. Integer + type1 = new PlaceholderType("y2r"); + type2 = new ReferenceType("Integer"); + undConstraints.add(new UnifyPair(type1, type2, PairOperator.SMALLERDOT)); + //v2 <. Vector + type1 = new PlaceholderType("v2"); + type2 = new ReferenceType("Vector", new TypeParams(new PlaceholderType("x3"))); + undConstraints.add(new UnifyPair(type1, type2, PairOperator.SMALLERDOT)); + //x3? <. x3r + type1 = new PlaceholderType("x3"); + type2 = new PlaceholderType("x3r"); + undConstraints.add(new UnifyPair(type1, type2, PairOperator.SMALLERDOT)); + //Integer <. x3r + type1 = new ReferenceType("Integer"); + type2 = new PlaceholderType("x3r"); + undConstraints.add(new UnifyPair(type1, type2, PairOperator.SMALLERDOT)); + //ret <. Vector + type1 = new PlaceholderType("ret"); + type2 = new ReferenceType("Vector", new TypeParams(new PlaceholderType("x2"))); + undConstraints.add(new UnifyPair(type1, type2, PairOperator.SMALLERDOT)); + //x2? <. x2r + type1 = new PlaceholderType("x2"); + type2 = new PlaceholderType("x2r"); + undConstraints.add(new UnifyPair(type1, type2, PairOperator.SMALLERDOT)); + //v2 <. x2r + type1 = new PlaceholderType("v2"); + type2 = new PlaceholderType("x2r"); + undConstraints.add(new UnifyPair(type1, type2, PairOperator.SMALLERDOT)); + + //oder-constraints + List>> oderConstraints = new ArrayList<>(); + + //FiniteClosure + Set constraints = new HashSet<>(); + //Matrix extends Vector> + type1 = new ReferenceType("Matrix"); + type2 = new ReferenceType("Vector", new TypeParams(new ReferenceType("Vector", new TypeParams(new ReferenceType("Integer"))))); + constraints.add(new UnifyPair(type1, type2, PairOperator.SMALLER)); + //Vector extends Object + type1 = new ReferenceType("Vector", new TypeParams(new ReferenceType("X"))); + type2 = new ReferenceType("Object"); + constraints.add(new UnifyPair(type1, type2, PairOperator.SMALLER)); + //Integer extends Object + type1 = new ReferenceType("Integer"); + type2 = new ReferenceType("Object"); + constraints.add(new UnifyPair(type1, type2, PairOperator.SMALLER)); + FiniteClosure finiteClosure = new FiniteClosure(constraints, new NullWriter()); + + TypeUnify unifyAlgo = new TypeUnify(); + ConstraintSet< Pair> cons = new ConstraintSet<>(); + UnifyResultModel urm = new UnifyResultModel(cons, finiteClosure); + UnifyTaskModel tasks = new UnifyTaskModel(); + Set> solution = unifyAlgo.unify(undConstraints, oderConstraints, finiteClosure, new NullWriter(), false, urm, tasks); + System.out.println(solution.size()); + } + + @Test + public void scalark2(){ + UnifyType type1; + UnifyType type2; + + //und-constraints + Set undConstraints = new HashSet<>(); + //H =. Scalar + type1 = new PlaceholderType("H"); + type2 = new ReferenceType("Scalar"); + undConstraints.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + //E >> oderConstraints = new ArrayList<>(); + Set> constraints = new HashSet<>(); + Constraint constraint = new Constraint<>(); + + //set #1 + //D =. java.lang.Float + type1 = new PlaceholderType("D"); + type2 = new ReferenceType("java.lang.Boolean"); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + constraints.add(constraint); + //D =. java.lang.Integer + constraint = new Constraint<>(); + type1 = new PlaceholderType("D"); + type2 = new ReferenceType("java.lang.Integer"); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + constraints.add(constraint); + oderConstraints.add(constraints); + + //set #2 + constraints = new HashSet<>(); + //F =. java.lang.Integer + constraint = new Constraint<>(); + type1 = new PlaceholderType("F"); + type2 = new ReferenceType("java.lang.Integer"); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + constraints.add(constraint); + //F =. java.lang.Float + constraint = new Constraint<>(); + type1 = new PlaceholderType("F"); + type2 = new ReferenceType("java.lang.Float"); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + constraints.add(constraint); + oderConstraints.add(constraints); + + //set #3 + constraints = new HashSet<>(); + //H =. ? extends Scalar + constraint = new Constraint<>(); + type1 = new PlaceholderType("H"); + type2 = new ExtendsType(new ReferenceType("Scalar")); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + //java.lang.Integer =. J + type1 = new ReferenceType("java.lang.Integer"); + type2 = new PlaceholderType("J"); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + constraints.add(constraint); + //H =. Vector + constraint = new Constraint<>(); + type1 = new PlaceholderType("H"); + type2 = new ReferenceType("Vector", new TypeParams(new PlaceholderType("AJP"))); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + //java.lang.Integer =. J + type1 = new ReferenceType("java.lang.Integer"); + type2 = new PlaceholderType("J"); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + constraints.add(constraint); + //H =. ? extends Vector + constraint = new Constraint<>(); + type1 = new PlaceholderType("H"); + type2 = new ExtendsType(new ReferenceType("Vector", new TypeParams(new PlaceholderType("AJP")))); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + //java.lang.Integer =. J + type1 = new ReferenceType("java.lang.Integer"); + type2 = new PlaceholderType("J"); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + constraints.add(constraint); + //H =. Scalar + constraint = new Constraint<>(); + type1 = new PlaceholderType("H"); + type2 = new ReferenceType("Scalar"); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + //java.lang.Integer =. J + type1 = new ReferenceType("java.lang.Integer"); + type2 = new PlaceholderType("J"); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + constraints.add(constraint); + oderConstraints.add(constraints); + + //set #4 + constraints = new HashSet<>(); + //java.lang.Integer =. O + constraint = new Constraint<>(); + type1 = new ReferenceType("java.lang.Integer"); + type2 = new PlaceholderType("O"); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + //L =. Scalar + type1 = new PlaceholderType("L"); + type2 = new ReferenceType("Scalar"); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + //E <. java.lang.Integer + type1 = new PlaceholderType("E"); + type2 = new ReferenceType("java.lang.Integer"); + constraint.add(new UnifyPair(type1, type2, PairOperator.SMALLERDOT)); + constraints.add(constraint); + //E <. java.lang.Integer + constraint = new Constraint<>(); + type1 = new PlaceholderType("E"); + type2 = new ReferenceType("java.lang.Integer"); + constraint.add(new UnifyPair(type1, type2, PairOperator.SMALLERDOT)); + //L =. ? extends Vector + type1 = new PlaceholderType("L"); + type2 = new ExtendsType(new ReferenceType("Vector", new TypeParams(new PlaceholderType("AJQ")))); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + //AJQ =. O + type1 = new PlaceholderType("AJQ"); + type2 = new PlaceholderType("O"); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + constraints.add(constraint); + //java.lang.Integer =. O + constraint = new Constraint<>(); + type1 = new ReferenceType("java.lang.Integer"); + type2 = new PlaceholderType("O"); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + //E <. java.lang.Integer + type1 = new PlaceholderType("E"); + type2 = new ReferenceType("java.lang.Integer"); + constraint.add(new UnifyPair(type1, type2, PairOperator.SMALLERDOT)); + //L =. ? extends Scalar + type1 = new PlaceholderType("L"); + type2 = new ExtendsType(new ReferenceType("Scalar")); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + constraints.add(constraint); + //L =. Vector + constraint = new Constraint<>(); + type1 = new PlaceholderType("L"); + type2 = new ReferenceType("Vector", new TypeParams(new PlaceholderType("AJQ"))); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + //E <. java.lang.Integer + type1 = new PlaceholderType("E"); + type2 = new ReferenceType("java.lang.Integer"); + constraint.add(new UnifyPair(type1, type2, PairOperator.SMALLERDOT)); + //AJQ =. O + type1 = new PlaceholderType("AJQ"); + type2 = new PlaceholderType("O"); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + constraints.add(constraint); + oderConstraints.add(constraints); + + //set #5 + constraints = new HashSet<>(); + //AJR =. S + constraint = new Constraint<>(); + type1 = new PlaceholderType("AJR"); + type2 = new PlaceholderType("S"); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + //E <. java.lang.Integer + type1 = new PlaceholderType("E"); + type2 = new ReferenceType("java.lang.Integer"); + constraint.add(new UnifyPair(type1, type2, PairOperator.SMALLERDOT)); + //B =. Vector + type1 = new PlaceholderType("B"); + type2 = new ReferenceType("Vector", new TypeParams(new PlaceholderType("AJR"))); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + constraints.add(constraint); + //java.lang.Integer =. S + constraint = new Constraint<>(); + type1 = new ReferenceType("java.lang.Integer"); + type2 = new PlaceholderType("S"); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + //E <. java.lang.Integer + type1 = new PlaceholderType("E"); + type2 = new ReferenceType("java.lang.Integer"); + constraint.add(new UnifyPair(type1, type2, PairOperator.SMALLERDOT)); + //B =. Scalar + type1 = new PlaceholderType("B"); + type2 = new ReferenceType("Scalar"); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + constraints.add(constraint); + //java.lang.Integer =. S + constraint = new Constraint<>(); + type1 = new ReferenceType("java.lang.Integer"); + type2 = new PlaceholderType("S"); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + //B =. ? extends Scalar + type1 = new PlaceholderType("B"); + type2 = new ExtendsType(new ReferenceType("Scalar")); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + //E <. java.lang.Integer + type1 = new PlaceholderType("E"); + type2 = new ReferenceType("java.lang.Integer"); + constraint.add(new UnifyPair(type1, type2, PairOperator.SMALLERDOT)); + constraints.add(constraint); + //AJR =. S + constraint = new Constraint<>(); + type1 = new PlaceholderType("AJR"); + type2 = new PlaceholderType("S"); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + //B =. ? extends Vector + type1 = new PlaceholderType("B"); + type2 = new ExtendsType(new ReferenceType("Vector", new TypeParams(new PlaceholderType("AJR")))); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + //E <. java.lang.Integer + type1 = new PlaceholderType("E"); + type2 = new ReferenceType("java.lang.Integer"); + constraint.add(new UnifyPair(type1, type2, PairOperator.SMALLERDOT)); + constraints.add(constraint); + oderConstraints.add(constraints); + + //set #6 + constraints = new HashSet<>(); + //O <. java.lang.Float + constraint = new Constraint<>(); + type1 = new PlaceholderType("O"); + type2 = new ReferenceType("java.lang.Float"); + constraint.add(new UnifyPair(type1, type2, PairOperator.SMALLERDOT)); + //java.lang.Float =. U + type1 = new ReferenceType("java.lang.Float"); + type2 = new PlaceholderType("U"); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + //S <. java.lang.Float + type1 = new PlaceholderType("S"); + type2 = new ReferenceType("java.lang.Float"); + constraint.add(new UnifyPair(type1, type2, PairOperator.SMALLERDOT)); + constraints.add(constraint); + //java.lang.Integer =. U + constraint = new Constraint<>(); + type1 = new ReferenceType("java.lang.Integer"); + type2 = new PlaceholderType("U"); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + //S <. java.lang.Integer + type1 = new PlaceholderType("S"); + type2 = new ReferenceType("java.lang.Integer"); + constraint.add(new UnifyPair(type1, type2, PairOperator.SMALLERDOT)); + //O <. java.lang.Integer + type1 = new PlaceholderType("O"); + type2 = new ReferenceType("java.lang.Integer"); + constraint.add(new UnifyPair(type1, type2, PairOperator.SMALLERDOT)); + constraints.add(constraint); + oderConstraints.add(constraints); + + //set #7 + constraints = new HashSet<>(); + //java.lang.Integer =. V + constraint = new Constraint<>(); + type1 = new ReferenceType("java.lang.Integer"); + type2 = new PlaceholderType("V"); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + //U <. java.lang.Integer + type1 = new PlaceholderType("U"); + type2 = new ReferenceType("java.lang.Integer"); + constraint.add(new UnifyPair(type1, type2, PairOperator.SMALLERDOT)); + //C <. java.lang.Integer + type1 = new PlaceholderType("C"); + type2 = new ReferenceType("java.lang.Integer"); + constraint.add(new UnifyPair(type1, type2, PairOperator.SMALLERDOT)); + constraints.add(constraint); + //java.lang.Float =. V + constraint = new Constraint<>(); + type1 = new ReferenceType("java.lang.Float"); + type2 = new PlaceholderType("V"); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + //U <. java.lang.Float + type1 = new PlaceholderType("U"); + type2 = new ReferenceType("java.lang.Float"); + constraint.add(new UnifyPair(type1, type2, PairOperator.SMALLERDOT)); + //C <. java.lang.Float + type1 = new PlaceholderType("C"); + type2 = new ReferenceType("java.lang.Float"); + constraint.add(new UnifyPair(type1, type2, PairOperator.SMALLERDOT)); + constraints.add(constraint); + oderConstraints.add(constraints); + + //set #8 + constraints = new HashSet<>(); + //W =. java.lang.Float + constraint = new Constraint<>(); + type1 = new PlaceholderType("W"); + type2 = new ReferenceType("java.lang.Float"); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + constraints.add(constraint); + //W =. java.lang.Integer + constraint = new Constraint<>(); + type1 = new PlaceholderType("W"); + type2 = new ReferenceType("java.lang.Integer"); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + constraints.add(constraint); + oderConstraints.add(constraints); + + //set #9 + constraints = new HashSet<>(); + //W <. java.lang.Integer + constraint = new Constraint<>(); + type1 = new PlaceholderType("W"); + type2 = new ReferenceType("java.lang.Integer"); + constraint.add(new UnifyPair(type1, type2, PairOperator.SMALLERDOT)); + //E <. java.lang.Integer + type1 = new PlaceholderType("E"); + type2 = new ReferenceType("java.lang.Integer"); + constraint.add(new UnifyPair(type1, type2, PairOperator.SMALLERDOT)); + //java.lang.Integer =. X + type1 = new ReferenceType("java.lang.Integer"); + type2 = new PlaceholderType("X"); + constraints.add(constraint); + //java.lang.Float =. X + constraint = new Constraint<>(); + type1 = new ReferenceType("java.lang.Float"); + type2 = new PlaceholderType("X"); + constraint.add(new UnifyPair(type1, type2, PairOperator.EQUALSDOT)); + //E <. java.lang.Float + type1 = new PlaceholderType("E"); + type2 = new ReferenceType("java.lang.Float"); + constraint.add(new UnifyPair(type1, type2, PairOperator.SMALLERDOT)); + //W <. java.lang.Float + type1 = new PlaceholderType("W"); + type2 = new ReferenceType("java.lang.Float"); + constraint.add(new UnifyPair(type1, type2, PairOperator.SMALLERDOT)); + constraints.add(constraint); + oderConstraints.add(constraints); + + + //FiniteClosure + Set fcConstraints = new HashSet<>(); + //java.lang.Number < java.lang.Object + type1 = new ReferenceType("java.lang.Number"); + type2 = new ReferenceType("java.lang.Object"); + fcConstraints.add(new UnifyPair(type1, type2, PairOperator.SMALLER)); + //java.lang.Number < java.io.Serializable + type1 = new ReferenceType("java.lang.Number"); + type2 = new ReferenceType("java.io.Serializable"); + fcConstraints.add(new UnifyPair(type1, type2, PairOperator.SMALLER)); + //java.lang.Float < java.lang.Number + type1 = new ReferenceType("java.lang.Float"); + type2 = new ReferenceType("java.lang.Number"); + fcConstraints.add(new UnifyPair(type1, type2, PairOperator.SMALLER)); + //java.lang.Integer < java.lang.Number + type1 = new ReferenceType("java.lang.Integer"); + type2 = new ReferenceType("java.lang.Number"); + fcConstraints.add(new UnifyPair(type1, type2, PairOperator.SMALLER)); + //java.lang.Integer < java.lang.Object + type1 = new ReferenceType("java.lang.Integer"); + type2 = new ReferenceType("java.lang.Object"); + fcConstraints.add(new UnifyPair(type1, type2, PairOperator.SMALLER)); + //java.lang.Integer < java.lang.constant.Constable + type1 = new ReferenceType("java.lang.Integer"); + type2 = new ReferenceType("java.lang.constant.Constable"); + fcConstraints.add(new UnifyPair(type1, type2, PairOperator.SMALLER)); + //java.lang.Integer < java.io.Serializable + type1 = new ReferenceType("java.lang.Integer"); + type2 = new ReferenceType("java.io.Serializable"); + fcConstraints.add(new UnifyPair(type1, type2, PairOperator.SMALLER)); + //java.lang.Integer < java.lang.constant.ConstantDesc + type1 = new ReferenceType("java.lang.Integer"); + type2 = new ReferenceType("java.lang.constant.ConstantDesc"); + fcConstraints.add(new UnifyPair(type1, type2, PairOperator.SMALLER)); + //java.lang.Integer < java.lang.Comparable + type1 = new ReferenceType("java.lang.Integer"); + type2 = new ReferenceType("java.lang.Comparable", new TypeParams(new ReferenceType("java.lang.Integer"))); + fcConstraints.add(new UnifyPair(type1, type2, PairOperator.SMALLER)); + //java.lang.Float < java.lang.Object + type1 = new ReferenceType("java.lang.Float"); + type2 = new ReferenceType("java.lang.Object"); + fcConstraints.add(new UnifyPair(type1, type2, PairOperator.SMALLER)); + //java.lang.Float < java.lang.constant.Constable + type1 = new ReferenceType("java.lang.Float"); + type2 = new ReferenceType("java.lang.constant.Constable"); + fcConstraints.add(new UnifyPair(type1, type2, PairOperator.SMALLER)); + //java.lang.Float < java.io.Serializable + type1 = new ReferenceType("java.lang.Float"); + type2 = new ReferenceType("java.io.Serializable"); + fcConstraints.add(new UnifyPair(type1, type2, PairOperator.SMALLER)); + //java.lang.Float < java.lang.Comparable + type1 = new ReferenceType("java.lang.Integer"); + type2 = new ReferenceType("java.lang.Comparable", new TypeParams(new ReferenceType("java.lang.Float"))); + fcConstraints.add(new UnifyPair(type1, type2, PairOperator.SMALLER)); + //java.lang.Float < java.lang.constant.ConstantDesc + type1 = new ReferenceType("java.lang.Float"); + type2 = new ReferenceType("java.lang.constant.ConstantDesc"); + fcConstraints.add(new UnifyPair(type1, type2, PairOperator.SMALLER)); + //Scalar < java.lang.Object + type1 = new ReferenceType("Scalar", new TypeParams(new PlaceholderType("EYW"))); + type2 = new ReferenceType("java.lang.Object"); + fcConstraints.add(new UnifyPair(type1, type2, PairOperator.SMALLER)); + //Scalar < Vector + type1 = new ReferenceType("Scalar", new TypeParams(new PlaceholderType("EYW"))); + type2 = new ReferenceType("Vector", new TypeParams(new ReferenceType("java.lang.Integer"))); + fcConstraints.add(new UnifyPair(type1, type2, PairOperator.SMALLER)); + //java.lang.Comparable < java.lang.Object + type1 = new ReferenceType("java.lang.Comparable", new TypeParams(new ReferenceType("java.lang.Float"))); + type2 = new ReferenceType("java.lang.Object"); + fcConstraints.add(new UnifyPair(type1, type2, PairOperator.SMALLER)); + //Vector < java.lang.Object + type1 = new ReferenceType("Vector", new TypeParams(new ReferenceType("java.lang.Integer"))); + type2 = new ReferenceType("java.lang.Object"); + fcConstraints.add(new UnifyPair(type1, type2, PairOperator.SMALLER)); + //Scalar < Vector + type1 = new ReferenceType("Scalar"); + type2 = new ReferenceType("Vector", new TypeParams(new ReferenceType("java.lang.Integer"))); + fcConstraints.add(new UnifyPair(type1, type2, PairOperator.SMALLER)); + //java.lang.constant.ConstantDesc < java.lang.Object + type1 = new ReferenceType("java.lang.constant.ConstantDesc"); + type2 = new ReferenceType("java.lang.Object"); + fcConstraints.add(new UnifyPair(type1, type2, PairOperator.SMALLER)); + //Scalar < java.lang.Object + type1 = new ReferenceType("Scalar"); + type2 = new ReferenceType("java.lang.Object"); + fcConstraints.add(new UnifyPair(type1, type2, PairOperator.SMALLER)); + //java.lang.constant.Constable < java.lang.Object + type1 = new ReferenceType("java.lang.constant.Constable"); + type2 = new ReferenceType("java.lang.Object"); + fcConstraints.add(new UnifyPair(type1, type2, PairOperator.SMALLER)); + //Vector < java.lang.Object + type1 = new ReferenceType("Vector", new TypeParams(new PlaceholderType("EWV"))); + type2 = new ReferenceType("java.lang.Object"); + fcConstraints.add(new UnifyPair(type1, type2, PairOperator.SMALLER)); + //java.io.Serializable < java.lang.Object + type1 = new ReferenceType("java.io.Serializable"); + type2 = new ReferenceType("java.lang.Object"); + fcConstraints.add(new UnifyPair(type1, type2, PairOperator.SMALLER)); + //java.lang.Comparable < java.lang.Object + type1 = new ReferenceType("java.lang.Comparable", new TypeParams(new ReferenceType("java.lang.Integer"))); + type2 = new ReferenceType("java.lang.Object"); + fcConstraints.add(new UnifyPair(type1, type2, PairOperator.SMALLER)); + + FiniteClosure finiteClosure = new FiniteClosure(fcConstraints, new NullWriter()); + TypeUnify unifyAlgo = new TypeUnify(); + ConstraintSet< Pair> cons = new ConstraintSet<>(); + UnifyResultModel urm = new UnifyResultModel(cons, finiteClosure); + UnifyTaskModel tasks = new UnifyTaskModel(); + Set> solution = unifyAlgo.unify(undConstraints, oderConstraints, finiteClosure, new NullWriter(), false, urm, tasks); + System.out.println(solution); + System.out.println(solution.size()); + } +}