Lines 50-56
Link Here
|
50 |
public long nameSourcePosition ; //(start<<32)+end |
50 |
public long nameSourcePosition ; //(start<<32)+end |
51 |
|
51 |
|
52 |
public TypeBinding actualReceiverType; |
52 |
public TypeBinding actualReceiverType; |
53 |
public TypeBinding receiverGenericCast; // extra reference type cast to perform on generic receiver |
|
|
54 |
public TypeBinding valueCast; // extra reference type cast to perform on method returned value |
53 |
public TypeBinding valueCast; // extra reference type cast to perform on method returned value |
55 |
public TypeReference[] typeArguments; |
54 |
public TypeReference[] typeArguments; |
56 |
public TypeBinding[] genericTypeArguments; |
55 |
public TypeBinding[] genericTypeArguments; |
Lines 123-134
Link Here
|
123 |
* @param valueRequired boolean |
122 |
* @param valueRequired boolean |
124 |
*/ |
123 |
*/ |
125 |
public void generateCode(BlockScope currentScope, CodeStream codeStream, boolean valueRequired) { |
124 |
public void generateCode(BlockScope currentScope, CodeStream codeStream, boolean valueRequired) { |
126 |
|
|
|
127 |
int pc = codeStream.position; |
125 |
int pc = codeStream.position; |
128 |
|
|
|
129 |
// generate receiver/enclosing instance access |
126 |
// generate receiver/enclosing instance access |
130 |
MethodBinding codegenBinding = this.binding.original(); |
127 |
MethodBinding codegenBinding = this.binding.original(); |
131 |
boolean isStatic = codegenBinding.isStatic(); |
128 |
boolean isStatic = codegenBinding.isStatic(); |
|
|
129 |
TypeBinding codeGenReceiverType = this.actualReceiverType; |
132 |
if (isStatic) { |
130 |
if (isStatic) { |
133 |
this.receiver.generateCode(currentScope, codeStream, false); |
131 |
this.receiver.generateCode(currentScope, codeStream, false); |
134 |
codeStream.recordPositionsFrom(pc, this.sourceStart); |
132 |
codeStream.recordPositionsFrom(pc, this.sourceStart); |
Lines 139-155
Link Here
|
139 |
codeStream.generateOuterAccess(path, this, targetType, currentScope); |
137 |
codeStream.generateOuterAccess(path, this, targetType, currentScope); |
140 |
} else { |
138 |
} else { |
141 |
this.receiver.generateCode(currentScope, codeStream, true); |
139 |
this.receiver.generateCode(currentScope, codeStream, true); |
142 |
if (this.receiverGenericCast != null) |
|
|
143 |
codeStream.checkcast(this.receiverGenericCast); |
144 |
codeStream.recordPositionsFrom(pc, this.sourceStart); |
140 |
codeStream.recordPositionsFrom(pc, this.sourceStart); |
145 |
|
|
|
146 |
} |
141 |
} |
147 |
// generate arguments |
142 |
// generate arguments |
148 |
generateArguments(this.binding, this.arguments, currentScope, codeStream); |
143 |
generateArguments(this.binding, this.arguments, currentScope, codeStream); |
149 |
|
144 |
|
150 |
// actual message invocation |
145 |
// actual message invocation |
151 |
if (this.syntheticAccessor == null){ |
146 |
if (this.syntheticAccessor == null){ |
152 |
TypeBinding constantPoolDeclaringClass = CodeStream.getConstantPoolDeclaringClass(currentScope, codegenBinding, this.actualReceiverType, this.receiver.isImplicitThis(), this.receiverGenericCast != null); |
147 |
TypeBinding constantPoolDeclaringClass = CodeStream.getConstantPoolDeclaringClass(currentScope, codegenBinding, codeGenReceiverType, this.receiver.isImplicitThis()); |
153 |
if (isStatic){ |
148 |
if (isStatic){ |
154 |
codeStream.invoke(Opcodes.OPC_invokestatic, codegenBinding, constantPoolDeclaringClass); |
149 |
codeStream.invoke(Opcodes.OPC_invokestatic, codegenBinding, constantPoolDeclaringClass); |
155 |
} else if( (this.receiver.isSuper()) || codegenBinding.isPrivate()){ |
150 |
} else if( (this.receiver.isSuper()) || codegenBinding.isPrivate()){ |
Lines 443-448
Link Here
|
443 |
if ((this.binding.tagBits & TagBits.HasMissingType) != 0) { |
438 |
if ((this.binding.tagBits & TagBits.HasMissingType) != 0) { |
444 |
scope.problemReporter().missingTypeInMethod(this, this.binding); |
439 |
scope.problemReporter().missingTypeInMethod(this, this.binding); |
445 |
} |
440 |
} |
|
|
441 |
// compute generic cast if necessary |
442 |
TypeBinding upperBound = this.actualReceiverType.getReceiverTypeErasure(this.binding.declaringClass); |
443 |
if (upperBound != null && upperBound != this.actualReceiverType.erasure()) { |
444 |
this.actualReceiverType = upperBound; // handle indirect inheritance thru variable secondary bound |
445 |
} |
446 |
final CompilerOptions compilerOptions = scope.compilerOptions(); |
446 |
final CompilerOptions compilerOptions = scope.compilerOptions(); |
447 |
if (!this.binding.isStatic()) { |
447 |
if (!this.binding.isStatic()) { |
448 |
// the "receiver" must not be a type |
448 |
// the "receiver" must not be a type |
Lines 455-467
Link Here
|
455 |
} |
455 |
} |
456 |
} else { |
456 |
} else { |
457 |
this.receiver.computeConversion(scope, this.actualReceiverType, this.actualReceiverType); |
457 |
this.receiver.computeConversion(scope, this.actualReceiverType, this.actualReceiverType); |
458 |
// compute generic cast if necessary |
|
|
459 |
TypeBinding receiverErasure = this.actualReceiverType.erasure(); |
460 |
if (receiverErasure instanceof ReferenceBinding) { |
461 |
if (receiverErasure.findSuperTypeOriginatingFrom(this.binding.declaringClass) == null) { |
462 |
this.receiverGenericCast = this.binding.declaringClass; // handle indirect inheritance thru variable secondary bound |
463 |
} |
464 |
} |
465 |
} |
458 |
} |
466 |
} else { |
459 |
} else { |
467 |
// static message invoked through receiver? legal but unoptimal (optional warning). |
460 |
// static message invoked through receiver? legal but unoptimal (optional warning). |
Lines 507-515
Link Here
|
507 |
if (this.typeArguments != null && this.binding.original().typeVariables == Binding.NO_TYPE_VARIABLES) { |
500 |
if (this.typeArguments != null && this.binding.original().typeVariables == Binding.NO_TYPE_VARIABLES) { |
508 |
scope.problemReporter().unnecessaryTypeArgumentsForMethodInvocation(this.binding, this.genericTypeArguments, this.typeArguments); |
501 |
scope.problemReporter().unnecessaryTypeArgumentsForMethodInvocation(this.binding, this.genericTypeArguments, this.typeArguments); |
509 |
} |
502 |
} |
510 |
return (this.resolvedType.tagBits & TagBits.HasMissingType) == 0 |
503 |
return (this.resolvedType.tagBits & TagBits.HasMissingType) == 0 ? this.resolvedType : null; |
511 |
? this.resolvedType |
|
|
512 |
: null; |
513 |
} |
504 |
} |
514 |
|
505 |
|
515 |
public void setActualReceiverType(ReferenceBinding receiverType) { |
506 |
public void setActualReceiverType(ReferenceBinding receiverType) { |