Skip to content
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1486,12 +1486,6 @@ public Set<InferenceVariable> getSmallestVariableSet(BoundSet bounds, Set<Infere
Map<InferenceVariable,Set<InferenceVariable>> collectDependencies(BoundSet bounds, boolean maySkipSuperBound, boolean[] hasSkippedSuperBound) {
// Implements the definition of dependencies from JLS §18.4:
Map<InferenceVariable,Set<InferenceVariable>> dependsOn = new LinkedHashMap<>();
// "An inference variable α depends on the resolution of itself."
for (InferenceVariable iv : this.inferenceVariables) {
Set<InferenceVariable> selfSet = new LinkedHashSet<>();
selfSet.add(iv);
dependsOn.put(iv, selfSet);
}
for (TypeBound typeBound : bounds.flatten()) {
// "Given a bound of one of the following forms:" (ecj may represent some using :> rather than <:)
// α = T
Expand Down Expand Up @@ -1580,6 +1574,15 @@ Map<InferenceVariable,Set<InferenceVariable>> collectDependencies(BoundSet bound
}
}
} while (hasChange);
// "An inference variable α depends on the resolution of itself."
// https://github.com/eclipse-jdt/eclipse.jdt.core/issues/4846
for (InferenceVariable iv : this.inferenceVariables) {
if (!dependsOn.containsKey(iv)) {
Set<InferenceVariable> selfSet = new LinkedHashSet<>();
selfSet.add(iv);
dependsOn.put(iv, selfSet);
}
}
return dependsOn;
}

Expand Down
2 changes: 1 addition & 1 deletion org.eclipse.jdt.core.tests.compiler/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.jdt.core.tests.compiler;singleton:=true
Bundle-Version: 3.13.1100.qualifier
Bundle-Version: 3.13.1200.qualifier
Bundle-Vendor: %providerName
Bundle-Localization: plugin
Export-Package: org.eclipse.jdt.core.tests.compiler,
Expand Down
2 changes: 1 addition & 1 deletion org.eclipse.jdt.core.tests.compiler/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<relativePath>../tests-pom/</relativePath>
</parent>
<artifactId>org.eclipse.jdt.core.tests.compiler</artifactId>
<version>3.13.1100-SNAPSHOT</version>
<version>3.13.1200-SNAPSHOT</version>
<packaging>eclipse-test-plugin</packaging>

<properties>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10964,4 +10964,56 @@ <X, Y extends One<X>> void foo2(Y y1) {
"The method bar(One<Inner<?>>) in the type Bug is not applicable for the arguments (One<Inner<X>>)\n" +
"----------\n");
}
// https://github.com/eclipse-jdt/eclipse.jdt.core/issues/4846
public void testGH4846() {
if (this.complianceLevel < ClassFileConstants.JDK9) {
return;
}
runConformTest(
new String[] {
"Pairs.java",
"""
import java.util.Map;
import java.util.function.Function;

public class Pairs<T> {

public <V> void addMapEntries(Function<T, Map<String, V>> extractor) {
add(extractor.andThen(Map::entrySet), Map.Entry::getKey, Map.Entry::getValue);
}

public <E> void add(Function<T, Iterable<E>> elementsExtractor, PairExtractor<E> pairExtractor) {
add(elementsExtractor, pairExtractor::getName, pairExtractor::getValue);
}

public <E, V> void add(Function<T, Iterable<E>> elementsExtractor, Function<E, String> nameExtractor,
Function<E, V> valueExtractor) {
}

interface PairExtractor<E> {
<N> N getName(E element);
<V> V getValue(E element);
static <T> PairExtractor<T> of(Function<T, ?> nameExtractor, Function<T, ?> valueExtractor) {
return new PairExtractor<>() {

@Override
@SuppressWarnings("unchecked")
public <N> N getName(T instance) {
return (N) nameExtractor.apply(instance);
}

@Override
@SuppressWarnings("unchecked")
public <V> V getValue(T instance) {
return (V) valueExtractor.apply(instance);
}

};
}
}

}
"""
});
}
}
Loading