mirror of
https://github.com/tiennm99/lombok.git
synced 2026-10-14 22:17:41 +00:00
Fix for issue 401: test(), Object.test(), and super.test() were all allowed in eclipse for @ExtensionMethod, resulting in VerifyErrors in the emitted class files.
This commit is contained in:
1 parent
d1539a3ec2
commit
afcb211e47
2 files changed
+21
-6
No files matched your search
@@ -48,8 +48,10 @@ import org.eclipse.jdt.internal.compiler.ast.MessageSend;
|
||||
import org.eclipse.jdt.internal.compiler.ast.NameReference;
|
||||
import org.eclipse.jdt.internal.compiler.ast.QualifiedNameReference;
|
||||
import org.eclipse.jdt.internal.compiler.ast.SingleNameReference;
|
||||
import org.eclipse.jdt.internal.compiler.ast.SuperReference;
|
||||
import org.eclipse.jdt.internal.compiler.ast.ThisReference;
|
||||
import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration;
|
||||
import org.eclipse.jdt.internal.compiler.lookup.Binding;
|
||||
import org.eclipse.jdt.internal.compiler.lookup.BlockScope;
|
||||
import org.eclipse.jdt.internal.compiler.lookup.CompilationUnitScope;
|
||||
import org.eclipse.jdt.internal.compiler.lookup.MethodBinding;
|
||||
@@ -201,7 +203,16 @@ public class PatchExtensionMethod {
|
||||
}
|
||||
}
|
||||
|
||||
for (Extension extension : extensions) {
|
||||
boolean skip = false;
|
||||
|
||||
if (methodCall.receiver instanceof ThisReference && (((ThisReference)methodCall.receiver).bits & ASTNode.IsImplicitThis) != 0) skip = true;
|
||||
if (methodCall.receiver instanceof SuperReference) skip = true;
|
||||
if (methodCall.receiver instanceof NameReference) {
|
||||
Binding binding = ((NameReference)methodCall.receiver).binding;
|
||||
if (binding instanceof TypeBinding) skip = true;
|
||||
}
|
||||
|
||||
if (!skip) for (Extension extension : extensions) {
|
||||
if (!extension.suppressBaseMethods && !(methodCall.binding instanceof ProblemMethodBinding)) continue;
|
||||
for (MethodBinding extensionMethod : extension.extensionMethods) {
|
||||
if (!Arrays.equals(methodCall.selector, extensionMethod.selector)) continue;
|
||||
|
||||
@@ -45,7 +45,7 @@ import org.eclipse.jdt.internal.compiler.ast.ASTNode;
|
||||
import org.eclipse.jdt.internal.compiler.ast.Annotation;
|
||||
import org.eclipse.jdt.internal.compiler.ast.FieldReference;
|
||||
import org.eclipse.jdt.internal.compiler.ast.NameReference;
|
||||
import org.eclipse.jdt.internal.compiler.ast.SingleNameReference;
|
||||
import org.eclipse.jdt.internal.compiler.ast.SuperReference;
|
||||
import org.eclipse.jdt.internal.compiler.ast.TypeDeclaration;
|
||||
import org.eclipse.jdt.internal.compiler.lookup.Binding;
|
||||
import org.eclipse.jdt.internal.compiler.lookup.ClassScope;
|
||||
@@ -103,14 +103,18 @@ public class PatchExtensionMethodCompletionProposal {
|
||||
if (node == null) return null;
|
||||
if (!(node instanceof CompletionOnQualifiedNameReference) && !(node instanceof CompletionOnSingleNameReference) && !(node instanceof CompletionOnMemberAccess)) return null;
|
||||
|
||||
// Never offer on 'super.<autocomplete>'.
|
||||
if (node instanceof FieldReference && ((FieldReference)node).receiver instanceof SuperReference) return null;
|
||||
|
||||
if (node instanceof NameReference) {
|
||||
Binding binding = ((NameReference) node).binding;
|
||||
if ((node instanceof SingleNameReference) && (((SingleNameReference) node).token.length == 0)) {
|
||||
// Unremark next block to allow a 'blank' autocomplete to list any extensions that apply to the current scope, but make sure we're not in a static context first, which this doesn't do.
|
||||
// Lacking good use cases, and having this particular concept be a little tricky on javac, means for now we don't support extension methods like this. this.X() will be fine, though.
|
||||
|
||||
/* if ((node instanceof SingleNameReference) && (((SingleNameReference) node).token.length == 0)) {
|
||||
firstParameterType = decl.binding;
|
||||
} else if (binding instanceof VariableBinding) {
|
||||
} else */if (binding instanceof VariableBinding) {
|
||||
firstParameterType = ((VariableBinding) binding).type;
|
||||
} else if (binding instanceof TypeBinding) {
|
||||
firstParameterType = (TypeBinding) binding;
|
||||
}
|
||||
} else if (node instanceof FieldReference) {
|
||||
firstParameterType = ((FieldReference) node).actualReceiverType;
|
||||
|
||||
Reference in new issue
Block a user