Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug 562551 - content assist not working inside lambda expression #30

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -6524,4 +6524,42 @@ public void testBug564875() throws JavaModelException {
+ "getClass[METHOD_REF]{getClass(), Ljava.lang.Object;, ()Ljava.lang.Class<*>;, null, null, getClass, null, [229, 232], "+(R_DEFAULT+R_PACKAGE_EXPECTED_TYPE+30)+"}\n"
+ "getLastName[METHOD_REF]{getLastName(), LPerson;, ()Ljava.lang.String;, null, null, getLastName, null, [229, 232], "+(R_DEFAULT+R_EXACT_EXPECTED_TYPE+30)+"}", requestor.getResults());
}
public void testBug562551() throws JavaModelException {
this.workingCopies = new ICompilationUnit[1];
this.workingCopies[0] = getWorkingCopy(
"/Completion/src/X.java",
"import java.util.Map;\n"
+ "import java.util.function.Supplier;\n"
+ "public class X {\n"
+ " SingletonSupplier<Map<String, Object>> beansSupplier = SingletonSupplier.of(() -> {\n"
+ " Map<String, Object> beans = new HashMap<>();\n"
+ " beans.cle\n"
+ " return Collections.unmodifiableMap(beans);\n"
+ " });\n"
+ " public static class SingletonSupplier<T> implements Supplier<T> {\n"
+ " @Override\n"
+ " public T get() {\n"
+ " return null;\n"
+ " }\n"
+ " public T obtain() {\n"
+ " T instance = get();\n"
+ " return instance;\n"
+ " }\n"
+ " public static <T> SingletonSupplier<T> of(T instance) {\n"
+ " return null;\n"
+ " }"
+ " public static <T> SingletonSupplier<T> of(Supplier<T> supplier) {\n"
+ " return null;\n"
+ " }\n"
+ " }\n"
+ "}\n");

CompletionTestsRequestor2 requestor = new CompletionTestsRequestor2(true, true, true, false);
requestor.allowAllRequiredProposals();
String str = this.workingCopies[0].getSource();
String completeBehind = "beans.cle";
int cursorLocation = str.lastIndexOf(completeBehind) + completeBehind.length();
this.workingCopies[0].codeComplete(cursorLocation, requestor, this.wcOwner);
assertResults("clear[METHOD_REF]{clear(), Ljava.util.Map<Ljava.lang.String;Ljava.lang.Object;>;, ()V, null, null, clear, null, [215, 218], "+ (R_DEFAULT+R_EXPECTED_TYPE+10)+"}", requestor.getResults());
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2012, 2019 IBM Corporation and others.
* Copyright (c) 2012, 2022 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
Expand Down Expand Up @@ -904,7 +904,7 @@ CompatibilityResult internalIsCompatibleWith(TypeBinding targetType, Scope skope
// copy here is potentially compatible with the target type and has its shape fully computed: i.e value/void compatibility is determined and result expressions have been gathered.
targetType = findGroundTargetType(this.enclosingScope, targetType, targetType, argumentsTypeElided());
MethodBinding sam = targetType.getSingleAbstractMethod(this.enclosingScope, true);
if (sam == null || sam.problemId() == ProblemReasons.NoSuchSingleAbstractMethod) {
if (sam == null || sam.returnType == null || sam.problemId() == ProblemReasons.NoSuchSingleAbstractMethod) {
return CompatibilityResult.INCOMPATIBLE;
}
if (sam.returnType.id == TypeIds.T_void) {
Expand Down Expand Up @@ -970,7 +970,7 @@ private LambdaExpression cachedResolvedCopy(TypeBinding targetType, boolean anyT

if (sam.parameters.length != this.arguments.length)
return null;

this.descriptor = sam;
LambdaExpression copy = null;
if (this.copiesPerTargetType != null) {
copy = this.copiesPerTargetType.get(targetType);
Expand Down