202 } |
202 } |
203 } |
203 } |
204 return true; |
204 return true; |
205 } |
205 } |
206 |
206 |
207 /** Instaniate undetermined type variable to the lub of all its lower bounds. |
207 /** Instantiate undetermined type variable to the lub of all its lower bounds. |
208 * Throw a NoInstanceException if this not possible. |
208 * Throw a NoInstanceException if this not possible. |
209 */ |
209 */ |
210 void minimizeInst(UndetVar that, Warner warn) throws NoInstanceException { |
210 void minimizeInst(UndetVar that, Warner warn) throws NoInstanceException { |
211 if (that.inst == null) { |
211 if (that.inst == null) { |
212 if (that.lobounds.isEmpty()) |
212 if (that.lobounds.isEmpty()) |
214 else if (that.lobounds.tail.isEmpty()) |
214 else if (that.lobounds.tail.isEmpty()) |
215 that.inst = that.lobounds.head.isPrimitive() ? syms.errType : that.lobounds.head; |
215 that.inst = that.lobounds.head.isPrimitive() ? syms.errType : that.lobounds.head; |
216 else { |
216 else { |
217 that.inst = types.lub(that.lobounds); |
217 that.inst = types.lub(that.lobounds); |
218 } |
218 } |
219 if (that.inst == null || that.inst == syms.errType) |
219 if (that.inst == null || that.inst.tag == ERROR) |
220 throw ambiguousNoInstanceException |
220 throw ambiguousNoInstanceException |
221 .setMessage("no.unique.minimal.instance.exists", |
221 .setMessage("no.unique.minimal.instance.exists", |
222 that.qtype, that.lobounds); |
222 that.qtype, that.lobounds); |
223 // VGJ: sort of inlined maximizeInst() below. Adding |
223 // VGJ: sort of inlined maximizeInst() below. Adding |
224 // bounds can cause lobounds that are above hibounds. |
224 // bounds can cause lobounds that are above hibounds. |