src/share/classes/com/sun/tools/javac/comp/Infer.java

changeset 210
1aa81917016a
parent 110
91eea580fbe9
child 229
03bcd66bd8e7
equal deleted inserted replaced
209:9199b9092f73 210:1aa81917016a
152 if (that.inst == null) { 152 if (that.inst == null) {
153 if (that.hibounds.isEmpty()) 153 if (that.hibounds.isEmpty())
154 that.inst = syms.objectType; 154 that.inst = syms.objectType;
155 else if (that.hibounds.tail.isEmpty()) 155 else if (that.hibounds.tail.isEmpty())
156 that.inst = that.hibounds.head; 156 that.inst = that.hibounds.head;
157 else { 157 else
158 for (List<Type> bs = that.hibounds; 158 that.inst = types.glb(that.hibounds);
159 bs.nonEmpty() && that.inst == null; 159 }
160 bs = bs.tail) { 160 if (that.inst == null ||
161 // System.out.println("hibounds = " + that.hibounds);//DEBUG 161 that.inst.isErroneous() ||
162 if (isSubClass(bs.head, that.hibounds)) 162 !types.isSubtypeUnchecked(that.inst, that.hibounds, warn))
163 that.inst = types.fromUnknownFun.apply(bs.head); 163 throw ambiguousNoInstanceException
164 } 164 .setMessage("no.unique.maximal.instance.exists",
165 if (that.inst == null) { 165 that.qtype, that.hibounds);
166 int classCount = 0, interfaceCount = 0;
167 for (Type t : that.hibounds) {
168 if (t.tag == CLASS) {
169 if (t.isInterface())
170 interfaceCount++;
171 else
172 classCount++;
173 }
174 }
175 if ((that.hibounds.size() == classCount + interfaceCount) && classCount == 1)
176 that.inst = types.makeCompoundType(that.hibounds);
177 }
178 if (that.inst == null || !types.isSubtypeUnchecked(that.inst, that.hibounds, warn))
179 throw ambiguousNoInstanceException
180 .setMessage("no.unique.maximal.instance.exists",
181 that.qtype, that.hibounds);
182 }
183 }
184 } 166 }
185 //where 167 //where
186 private boolean isSubClass(Type t, final List<Type> ts) { 168 private boolean isSubClass(Type t, final List<Type> ts) {
187 t = t.baseType(); 169 t = t.baseType();
188 if (t.tag == TYPEVAR) { 170 if (t.tag == TYPEVAR) {

mercurial