src/share/classes/com/sun/tools/javac/code/Types.java

changeset 1510
7873d37f5b37
parent 1497
7aa2025bbb7b
child 1521
71f35e4b93a5
equal deleted inserted replaced
1509:1985e35e97b2 1510:7873d37f5b37
352 352
353 public Symbol getSymbol() { 353 public Symbol getSymbol() {
354 return descSym; 354 return descSym;
355 } 355 }
356 356
357 public Type getType(Type origin) { 357 public Type getType(Type site) {
358 return memberType(origin, descSym); 358 if (capture(site) != site) {
359 Type formalInterface = site.tsym.type;
360 ListBuffer<Type> typeargs = ListBuffer.lb();
361 List<Type> actualTypeargs = site.getTypeArguments();
362 //simply replace the wildcards with its bound
363 for (Type t : formalInterface.getTypeArguments()) {
364 if (actualTypeargs.head.hasTag(WILDCARD)) {
365 WildcardType wt = (WildcardType)actualTypeargs.head;
366 typeargs.append(wt.type);
367 } else {
368 typeargs.append(actualTypeargs.head);
369 }
370 actualTypeargs = actualTypeargs.tail;
371 }
372 site = subst(formalInterface, formalInterface.getTypeArguments(), typeargs.toList());
373 if (!chk.checkValidGenericType(site)) {
374 //if the inferred functional interface type is not well-formed,
375 //or if it's not a subtype of the original target, issue an error
376 throw failure(diags.fragment("no.suitable.functional.intf.inst", site));
377 }
378 }
379 return memberType(site, descSym);
359 } 380 }
360 } 381 }
361 382
362 class Entry { 383 class Entry {
363 final FunctionDescriptor cachedDescRes; 384 final FunctionDescriptor cachedDescRes;
546 * Is given type a functional interface? 567 * Is given type a functional interface?
547 */ 568 */
548 public boolean isFunctionalInterface(TypeSymbol tsym) { 569 public boolean isFunctionalInterface(TypeSymbol tsym) {
549 try { 570 try {
550 findDescriptorSymbol(tsym); 571 findDescriptorSymbol(tsym);
572 return true;
573 } catch (FunctionDescriptorLookupError ex) {
574 return false;
575 }
576 }
577
578 public boolean isFunctionalInterface(Type site) {
579 try {
580 findDescriptorType(site);
551 return true; 581 return true;
552 } catch (FunctionDescriptorLookupError ex) { 582 } catch (FunctionDescriptorLookupError ex) {
553 return false; 583 return false;
554 } 584 }
555 } 585 }

mercurial