test/tools/javac/lambda/mostSpecific/StructuralMostSpecificTest.java

changeset 2000
4a6acc42c3a1
parent 1520
5c956be64b9e
child 2525
2eb010b6cb22
equal deleted inserted replaced
1999:7993cfab8610 2000:4a6acc42c3a1
195 " #R2 m(#A2 a1) #E2;\n" + 195 " #R2 m(#A2 a1) #E2;\n" +
196 "}\n" + 196 "}\n" +
197 "class Test {\n" + 197 "class Test {\n" +
198 " void m(SAM1 s) { }\n" + 198 " void m(SAM1 s) { }\n" +
199 " void m(SAM2 s) { }\n" + 199 " void m(SAM2 s) { }\n" +
200 " { m(x->{ #LR }); }\n" + 200 " { m((#A1 x)->{ #LR }); }\n" +
201 "}\n"; 201 "}\n";
202 202
203 String source; 203 String source;
204 204
205 public JavaSource() { 205 public JavaSource() {
234 } 234 }
235 235
236 void check() { 236 void check() {
237 checkCount.incrementAndGet(); 237 checkCount.incrementAndGet();
238 238
239 if (ak1 != ak2)
240 return;
241
239 if (!lrk.compatibleWith(rt1) || !lrk.compatibleWith(rt2)) 242 if (!lrk.compatibleWith(rt1) || !lrk.compatibleWith(rt2))
240 return; 243 return;
241 244
242 if (lrk.needsConversion(rt1) != lrk.needsConversion(rt2)) 245 if (lrk.needsConversion(rt1) != lrk.needsConversion(rt2))
243 return; 246 return;
244 247
245 boolean m1MoreSpecific = moreSpecific(rt1, rt2, ek1, ek2, ak1, ak2); 248 boolean m1MoreSpecific = rt1.moreSpecificThan(rt2);
246 boolean m2MoreSpecific = moreSpecific(rt2, rt1, ek2, ek1, ak2, ak1); 249 boolean m2MoreSpecific = rt2.moreSpecificThan(rt1);
247 250
248 boolean ambiguous = (m1MoreSpecific == m2MoreSpecific); 251 boolean ambiguous = (m1MoreSpecific == m2MoreSpecific);
249 252
250 if (ambiguous != diagChecker.ambiguityFound) { 253 if (ambiguous != diagChecker.ambiguityFound) {
251 throw new Error("invalid diagnostics for source:\n" + 254 throw new Error("invalid diagnostics for source:\n" +
264 "\nMost specific found: " + diagChecker.mostSpecificSig + 267 "\nMost specific found: " + diagChecker.mostSpecificSig +
265 "\nm1 more specific: " + m1MoreSpecific + 268 "\nm1 more specific: " + m1MoreSpecific +
266 "\nm2 more specific: " + m2MoreSpecific); 269 "\nm2 more specific: " + m2MoreSpecific);
267 } 270 }
268 } 271 }
269 }
270
271 boolean moreSpecific(RetTypeKind rk1, RetTypeKind rk2, ExceptionKind ek1,
272 ExceptionKind ek2, ArgTypeKind ak1, ArgTypeKind ak2) {
273 if (!rk1.moreSpecificThan(rk2))
274 return false;
275
276 if (ak1 != ak2)
277 return false;
278
279 return true;
280 } 272 }
281 273
282 static class DiagnosticChecker 274 static class DiagnosticChecker
283 implements javax.tools.DiagnosticListener<JavaFileObject> { 275 implements javax.tools.DiagnosticListener<JavaFileObject> {
284 276

mercurial