From: bdemsky Date: Tue, 7 Nov 2006 06:43:36 +0000 (+0000) Subject: Make people write casts... X-Git-Tag: preEdgeChange~753 X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=e5e73222c4bc1ca9f1ddb8b3e70b01e74f8f6282;p=IRC.git Make people write casts... --- diff --git a/Robust/src/IR/Tree/SemanticCheck.java b/Robust/src/IR/Tree/SemanticCheck.java index 7dcb5eb1..0feb9d0e 100644 --- a/Robust/src/IR/Tree/SemanticCheck.java +++ b/Robust/src/IR/Tree/SemanticCheck.java @@ -659,6 +659,9 @@ public class SemanticCheck { if (bestmd==null) throw new Error("No method found for :"+min.printNode(0)); min.setMethod(bestmd); + + if ((td!=null)&&(min.getType()!=null)&&!typeutil.isSuperorType(td, min.getType())) + throw new Error(min.getType()+ " is not equal to or a subclass of "+td); /* Check whether we need to set this parameter to implied this */ if (!bestmd.isStatic()) { if (min.getExpression()==null) { diff --git a/Robust/src/Tests/Inventory.java b/Robust/src/Tests/Inventory.java index cf4938e2..8f06c0f1 100644 --- a/Robust/src/Tests/Inventory.java +++ b/Robust/src/Tests/Inventory.java @@ -24,7 +24,7 @@ public class Inventory { if (map.containsKey(name) == false) { map.put(name, newitem); } else { - ItemInfo i = map.get(name); + ItemInfo i = (ItemInfo) map.get(name); i.quantity += quantity; i.price = price; map.put(name, i); @@ -38,7 +38,7 @@ public class Inventory { System.printString("Error - Item does not exist"); return -1; } else { - ItemInfo i = map.get(name); + ItemInfo i = (ItemInfo) map.get(name); if (i.quantity == 0) { System.printString("Error - Item unavailable"); return -1; @@ -63,7 +63,7 @@ public class Inventory { while (i.hasNext() == true) { Object o = i.next(); String name = o.toString(); - ItemInfo oo = j.next(); + ItemInfo oo = (ItemInfo) j.next(); sb.append(name); sb.append(" "); Integer q = new Integer(oo.quantity);