diff --git a/src/main/java/de/tla2b/types/PairType.java b/src/main/java/de/tla2b/types/PairType.java index 316d36b820d8ea9f8eff27b10edb932ba997feff..14a787ffff92aa95be089696361d97c8d4e59466 100644 --- a/src/main/java/de/tla2b/types/PairType.java +++ b/src/main/java/de/tla2b/types/PairType.java @@ -1,6 +1,5 @@ package de.tla2b.types; - import de.be4.classicalb.core.parser.node.AMultOrCartExpression; import de.be4.classicalb.core.parser.node.PExpression; import de.tla2b.exceptions.UnificationException; @@ -107,33 +106,22 @@ public class PairType extends AbstractHasFollowers { @Override public PairType cloneTLAType() { - return new PairType(this.first.cloneTLAType(), - this.second.cloneTLAType()); + return new PairType(this.first.cloneTLAType(), this.second.cloneTLAType()); } @Override public boolean contains(TLAType o) { - return first.equals(o) || first.contains(o) || second.equals(o) - || second.contains(o); + return first.equals(o) || first.contains(o) || second.equals(o) || second.contains(o); } @Override public String toString() { - String res = first + "*"; - if (second instanceof PairType) { - res += "(" + second + ")"; - } else - res += second; - return res; - + return first + "*" + (second instanceof PairType ? "(" + second + ")" : second); } @Override public PExpression getBNode() { - AMultOrCartExpression card = new AMultOrCartExpression(); - card.setLeft(first.getBNode()); - card.setRight(second.getBNode()); - return card; + return new AMultOrCartExpression(first.getBNode(), second.getBNode()); } public void apply(TypeVisitorInterface visitor) { diff --git a/src/main/java/de/tla2b/types/StringType.java b/src/main/java/de/tla2b/types/StringType.java index e88d0ed9a87c68c49f3e0aa47a8ed6dcf861854c..e4af60b65715a8dae451205c838d932758d370b9 100644 --- a/src/main/java/de/tla2b/types/StringType.java +++ b/src/main/java/de/tla2b/types/StringType.java @@ -25,7 +25,6 @@ public class StringType extends TLAType { return o.compare(this); } else return false; - } @Override @@ -38,22 +37,15 @@ public class StringType extends TLAType { if (!this.compare(o)) { throw new UnificationException(); } - if (o.getKind() == STRING) { - return this; - } else if (o instanceof UntypedType) { + if (o instanceof UntypedType) { ((UntypedType) o).setFollowersTo(this); ((UntypedType) o).deleteFollowers(); - return this; } else if (o instanceof FunctionType) { // function - if (o instanceof AbstractHasFollowers) { - ((AbstractHasFollowers) o).setFollowersTo(this); - ((AbstractHasFollowers) o).deleteFollowers(); - } - return this; - } else { - throw new UnificationException(); + ((FunctionType) o).setFollowersTo(this); + ((FunctionType) o).deleteFollowers(); } + return this; } @Override diff --git a/src/main/java/de/tla2b/types/StructOrFunctionType.java b/src/main/java/de/tla2b/types/StructOrFunctionType.java index 56af36ef5e805000e09c0baf2202ab1b961c5512..d32b8f871834291ac00f1ac27b87b3ca89c4b3bd 100644 --- a/src/main/java/de/tla2b/types/StructOrFunctionType.java +++ b/src/main/java/de/tla2b/types/StructOrFunctionType.java @@ -155,8 +155,7 @@ public class StructOrFunctionType extends AbstractHasFollowers { this.types.put(field, type); } } - TLAType res = testRecord(); - return res; + return testRecord(); } return this; } diff --git a/src/main/java/de/tla2b/types/StructType.java b/src/main/java/de/tla2b/types/StructType.java index 833651edc7550fb90891ca564ee1b6a59380ce2c..18137a9de73741b1a9e271cceb14c5d6b3ffdc93 100644 --- a/src/main/java/de/tla2b/types/StructType.java +++ b/src/main/java/de/tla2b/types/StructType.java @@ -104,8 +104,8 @@ public class StructType extends AbstractHasFollowers { if (o instanceof StructType) { StructType otherStruct = (StructType) o; - boolean extendStruct = false; + boolean extendStruct; if (this.incompleteStruct && otherStruct.incompleteStruct) { extendStruct = false; } else if (this.incompleteStruct) {