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

changeset 2543
c6d5efccedc3
parent 2384
327122b01a9e
child 2601
8dcde670aed3
equal deleted inserted replaced
2542:fa6e91185a27 2543:c6d5efccedc3
351 351
352 private Type generateReferenceToTargetConstraint(JCTree tree, UndetVar from, 352 private Type generateReferenceToTargetConstraint(JCTree tree, UndetVar from,
353 Type to, Attr.ResultInfo resultInfo, 353 Type to, Attr.ResultInfo resultInfo,
354 InferenceContext inferenceContext) { 354 InferenceContext inferenceContext) {
355 inferenceContext.solve(List.of(from.qtype), new Warner()); 355 inferenceContext.solve(List.of(from.qtype), new Warner());
356 inferenceContext.notifyChange();
356 Type capturedType = resultInfo.checkContext.inferenceContext() 357 Type capturedType = resultInfo.checkContext.inferenceContext()
357 .cachedCapture(tree, from.inst, false); 358 .cachedCapture(tree, from.inst, false);
358 if (types.isConvertible(capturedType, 359 if (types.isConvertible(capturedType,
359 resultInfo.checkContext.inferenceContext().asUndetVar(to))) { 360 resultInfo.checkContext.inferenceContext().asUndetVar(to))) {
360 //effectively skip additional return-type constraint generation (compatibility) 361 //effectively skip additional return-type constraint generation (compatibility)
447 } 448 }
448 //where 449 //where
449 class ImplicitArgType extends DeferredAttr.DeferredTypeMap { 450 class ImplicitArgType extends DeferredAttr.DeferredTypeMap {
450 451
451 public ImplicitArgType(Symbol msym, Resolve.MethodResolutionPhase phase) { 452 public ImplicitArgType(Symbol msym, Resolve.MethodResolutionPhase phase) {
452 rs.deferredAttr.super(AttrMode.SPECULATIVE, msym, phase); 453 (rs.deferredAttr).super(AttrMode.SPECULATIVE, msym, phase);
453 } 454 }
454 455
455 public Type apply(Type t) { 456 public Type apply(Type t) {
456 t = types.erasure(super.apply(t)); 457 t = types.erasure(super.apply(t));
457 if (t.hasTag(BOT)) 458 if (t.hasTag(BOT))
515 if (!chk.checkValidGenericType(owntype)) { 516 if (!chk.checkValidGenericType(owntype)) {
516 //if the inferred functional interface type is not well-formed, 517 //if the inferred functional interface type is not well-formed,
517 //or if it's not a subtype of the original target, issue an error 518 //or if it's not a subtype of the original target, issue an error
518 checkContext.report(pos, diags.fragment("no.suitable.functional.intf.inst", funcInterface)); 519 checkContext.report(pos, diags.fragment("no.suitable.functional.intf.inst", funcInterface));
519 } 520 }
521 //propagate constraints as per JLS 18.2.1
522 checkContext.compatible(owntype, funcInterface, types.noWarnings);
520 return owntype; 523 return owntype;
521 } 524 }
522 } 525 }
523 // </editor-fold> 526 // </editor-fold>
524 527

mercurial