langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java
changeset 42827 36468b5fa7f4
parent 42822 a84956e7ee4d
child 42828 cce89649f958
equal deleted inserted replaced
42826:563b42fc70ba 42827:36468b5fa7f4
  2649         }
  2649         }
  2650 
  2650 
  2651         private void checkAccessibleTypes(final DiagnosticPosition pos, final Env<AttrContext> env,
  2651         private void checkAccessibleTypes(final DiagnosticPosition pos, final Env<AttrContext> env,
  2652                 final InferenceContext inferenceContext, final List<Type> ts) {
  2652                 final InferenceContext inferenceContext, final List<Type> ts) {
  2653             if (inferenceContext.free(ts)) {
  2653             if (inferenceContext.free(ts)) {
  2654                 inferenceContext.addFreeTypeListener(ts, new FreeTypeListener() {
  2654                 inferenceContext.addFreeTypeListener(ts,
  2655                     @Override
  2655                         solvedContext -> checkAccessibleTypes(pos, env, solvedContext, solvedContext.asInstTypes(ts)));
  2656                     public void typesInferred(InferenceContext inferenceContext) {
       
  2657                         checkAccessibleTypes(pos, env, inferenceContext, inferenceContext.asInstTypes(ts));
       
  2658                     }
       
  2659                 });
       
  2660             } else {
  2656             } else {
  2661                 for (Type t : ts) {
  2657                 for (Type t : ts) {
  2662                     rs.checkAccessibleType(env, t);
  2658                     rs.checkAccessibleType(env, t);
  2663                 }
  2659                 }
  2664             }
  2660             }
  3092      * current inference context.
  3088      * current inference context.
  3093      */
  3089      */
  3094     private void setFunctionalInfo(final Env<AttrContext> env, final JCFunctionalExpression fExpr,
  3090     private void setFunctionalInfo(final Env<AttrContext> env, final JCFunctionalExpression fExpr,
  3095             final Type pt, final Type descriptorType, final Type primaryTarget, final CheckContext checkContext) {
  3091             final Type pt, final Type descriptorType, final Type primaryTarget, final CheckContext checkContext) {
  3096         if (checkContext.inferenceContext().free(descriptorType)) {
  3092         if (checkContext.inferenceContext().free(descriptorType)) {
  3097             checkContext.inferenceContext().addFreeTypeListener(List.of(pt, descriptorType), new FreeTypeListener() {
  3093             checkContext.inferenceContext().addFreeTypeListener(List.of(pt, descriptorType),
  3098                 public void typesInferred(InferenceContext inferenceContext) {
  3094                     inferenceContext -> setFunctionalInfo(env, fExpr, pt, inferenceContext.asInstType(descriptorType),
  3099                     setFunctionalInfo(env, fExpr, pt, inferenceContext.asInstType(descriptorType),
  3095                     inferenceContext.asInstType(primaryTarget), checkContext));
  3100                             inferenceContext.asInstType(primaryTarget), checkContext);
       
  3101                 }
       
  3102             });
       
  3103         } else {
  3096         } else {
  3104             ListBuffer<Type> targets = new ListBuffer<>();
  3097             ListBuffer<Type> targets = new ListBuffer<>();
  3105             if (pt.hasTag(CLASS)) {
  3098             if (pt.hasTag(CLASS)) {
  3106                 if (pt.isCompound()) {
  3099                 if (pt.isCompound()) {
  3107                     targets.append(types.removeWildcards(primaryTarget)); //this goes first
  3100                     targets.append(types.removeWildcards(primaryTarget)); //this goes first
  4572             } else {
  4565             } else {
  4573                 return c.members().anyMatch(anyNonAbstractOrDefaultMethod);
  4566                 return c.members().anyMatch(anyNonAbstractOrDefaultMethod);
  4574             }
  4567             }
  4575         }
  4568         }
  4576 
  4569 
  4577         public static final Filter<Symbol> anyNonAbstractOrDefaultMethod = new Filter<Symbol>() {
  4570         public static final Filter<Symbol> anyNonAbstractOrDefaultMethod = s ->
  4578             @Override
  4571                 s.kind == MTH && (s.flags() & (DEFAULT | ABSTRACT)) != ABSTRACT;
  4579             public boolean accepts(Symbol s) {
       
  4580                 return s.kind == MTH &&
       
  4581                        (s.flags() & (DEFAULT | ABSTRACT)) != ABSTRACT;
       
  4582             }
       
  4583         };
       
  4584 
  4572 
  4585         /** get a diagnostic position for an attribute of Type t, or null if attribute missing */
  4573         /** get a diagnostic position for an attribute of Type t, or null if attribute missing */
  4586         private DiagnosticPosition getDiagnosticPosition(JCClassDecl tree, Type t) {
  4574         private DiagnosticPosition getDiagnosticPosition(JCClassDecl tree, Type t) {
  4587             for(List<JCAnnotation> al = tree.mods.annotations; !al.isEmpty(); al = al.tail) {
  4575             for(List<JCAnnotation> al = tree.mods.annotations; !al.isEmpty(); al = al.tail) {
  4588                 if (types.isSameType(al.head.annotationType.type, t))
  4576                 if (types.isSameType(al.head.annotationType.type, t))