Lines 504-510
Link Here
|
504 |
/** |
504 |
/** |
505 |
* Internal use only |
505 |
* Internal use only |
506 |
* Given a method, returns null if arguments cannot be converted to parameters. |
506 |
* Given a method, returns null if arguments cannot be converted to parameters. |
507 |
* Will answer a subsituted method in case the method was generic and type inference got triggered; |
507 |
* Will answer a substituted method in case the method was generic and type inference got triggered; |
508 |
* in case the method was originally compatible, then simply answer it back. |
508 |
* in case the method was originally compatible, then simply answer it back. |
509 |
*/ |
509 |
*/ |
510 |
protected final MethodBinding computeCompatibleMethod(MethodBinding method, TypeBinding[] arguments, InvocationSite invocationSite) { |
510 |
protected final MethodBinding computeCompatibleMethod(MethodBinding method, TypeBinding[] arguments, InvocationSite invocationSite) { |
Lines 524-531
Link Here
|
524 |
if (!isVarArgs || argLength < paramLength - 1) |
524 |
if (!isVarArgs || argLength < paramLength - 1) |
525 |
return null; // incompatible |
525 |
return null; // incompatible |
526 |
|
526 |
|
527 |
if (typeVariables != Binding.NO_TYPE_VARIABLES) { // generic method |
527 |
// https://bugs.eclipse.org/bugs/show_bug.cgi?id=330435, inference should kick in only at source 1.5+ |
528 |
boolean compliant14 = compilerOptions().complianceLevel < ClassFileConstants.JDK1_5; |
528 |
if (typeVariables != Binding.NO_TYPE_VARIABLES && compilerOptions().sourceLevel >= ClassFileConstants.JDK1_5) { // generic method |
529 |
TypeBinding[] newArgs = null; |
529 |
TypeBinding[] newArgs = null; |
530 |
for (int i = 0; i < argLength; i++) { |
530 |
for (int i = 0; i < argLength; i++) { |
531 |
TypeBinding param = i < paramLength ? parameters[i] : parameters[paramLength - 1]; |
531 |
TypeBinding param = i < paramLength ? parameters[i] : parameters[paramLength - 1]; |
Lines 535-560
Link Here
|
535 |
System.arraycopy(arguments, 0, newArgs, 0, argLength); |
535 |
System.arraycopy(arguments, 0, newArgs, 0, argLength); |
536 |
} |
536 |
} |
537 |
newArgs[i] = environment().computeBoxingType(arguments[i]); |
537 |
newArgs[i] = environment().computeBoxingType(arguments[i]); |
538 |
} else if (compliant14 && invocationSite instanceof MessageSend |
|
|
539 |
&& param.kind() == Binding.PARAMETERIZED_TYPE && param.erasure().id == TypeIds.T_JavaLangClass |
540 |
&& ((ParameterizedTypeBinding) param).arguments.length == 1 |
541 |
&& ((ParameterizedTypeBinding) param).arguments[0] instanceof TypeVariableBinding |
542 |
&& arguments[i] instanceof BinaryTypeBinding && arguments[i].erasure().id == TypeIds.T_JavaLangClass) { |
543 |
/* https://bugs.eclipse.org/bugs/show_bug.cgi?id=328775. Class literals are special in that |
544 |
they carry (and are the only expressions that can carry) full parameterization information |
545 |
even in 1.4 source code. For inference during method selection/invocation to work properly, |
546 |
resolve class literal expression's type to be a parameterized type if in 1.4 we encounter |
547 |
a method that expects a parameter of the type Class<> |
548 |
*/ |
549 |
if (newArgs == null) { |
550 |
newArgs = new TypeBinding[argLength]; |
551 |
System.arraycopy(arguments, 0, newArgs, 0, argLength); |
552 |
} |
553 |
ClassLiteralAccess classLiteral = (ClassLiteralAccess) ((MessageSend) invocationSite).arguments[i]; |
554 |
// Integer.class --> Class<Integer>, perform boxing of base types (int.class --> Class<Integer>) |
555 |
// BundleWiring.class --> Class<BundleWiring> |
556 |
TypeBinding boxedType = boxing(classLiteral.targetType); |
557 |
newArgs[i] = classLiteral.resolvedType = environment().createParameterizedType(((ParameterizedTypeBinding)param).genericType(), new TypeBinding[]{ boxedType }, null /*not a member*/); |
558 |
} |
538 |
} |
559 |
} |
539 |
} |
560 |
if (newArgs != null) |
540 |
if (newArgs != null) |