mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
[java] [inference] limit bound promotion per one parameter (IDEA-277612)
GitOrigin-RevId: 0ed133250f1c68c5c14b5e6c5683b03084592e1d
This commit is contained in:
committed by
intellij-monorepo-bot
parent
bd40d80a9a
commit
dea5a38f11
+5
-19
@@ -1,18 +1,4 @@
|
||||
/*
|
||||
* Copyright 2000-2016 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
// Copyright 2000-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.psi.impl.source.resolve.graphInference.constraints;
|
||||
|
||||
import com.intellij.core.JavaPsiBundle;
|
||||
@@ -24,9 +10,7 @@ import com.intellij.psi.util.InheritanceUtil;
|
||||
import com.intellij.psi.util.PsiUtil;
|
||||
import com.intellij.psi.util.TypeConversionUtil;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.*;
|
||||
|
||||
public class StrictSubtypingConstraint implements ConstraintFormula {
|
||||
private PsiType myS;
|
||||
@@ -138,9 +122,11 @@ public class StrictSubtypingConstraint implements ConstraintFormula {
|
||||
}
|
||||
|
||||
PsiSubstitutor substitutor = SResult.getSubstitutor();
|
||||
Map<PsiTypeParameter, PsiType> map = new HashMap<>();
|
||||
for (PsiTypeParameter typeParameter : SClass.getTypeParameters()) {
|
||||
substitutor = substitutor.put(typeParameter, substitutor.substituteWithBoundsPromotion(typeParameter));
|
||||
map.put(typeParameter, substitutor.substituteWithBoundsPromotion(typeParameter));
|
||||
}
|
||||
substitutor = substitutor.putAll(map);
|
||||
|
||||
final PsiSubstitutor tSubstitutor = TResult.getSubstitutor();
|
||||
final PsiSubstitutor sSubstitutor = TypeConversionUtil.getClassSubstitutor(CClass, SClass, substitutor);
|
||||
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
interface Mappable<T> {
|
||||
T map(Mapper mapper);
|
||||
class Foo<B extends Foo.FooBuilder<B, U>, U extends Foo<B, U>> implements Mappable<Foo<B, U>> {
|
||||
static class FooBuilder<B extends FooBuilder<B, U>, U extends Foo<B, U>> {}
|
||||
@Override
|
||||
public Foo<B, U> map(Mapper mapper) { return this; }
|
||||
}
|
||||
|
||||
class Mapper {
|
||||
<E extends Mappable<? extends E>> List<E> map(List<E> in) { return in; }
|
||||
<E extends Mappable<? extends E>> Collection<E> map(Collection<E> in) { return in; }
|
||||
}
|
||||
class Counter implements Mappable<Counter> {
|
||||
private final List<Foo<?, ?>> in;
|
||||
Counter(List<Foo<?, ?>> in) { this.in = in; }
|
||||
@Override
|
||||
public Counter map(Mapper mapper) {
|
||||
return new Counter(mapper.map(in));
|
||||
}
|
||||
}
|
||||
}
|
||||
+2
-15
@@ -1,18 +1,4 @@
|
||||
/*
|
||||
* Copyright 2000-2017 JetBrains s.r.o.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
// Copyright 2000-2021 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
|
||||
package com.intellij.java.codeInsight.daemon.lambda;
|
||||
|
||||
import com.intellij.codeInsight.daemon.LightDaemonAnalyzerTestCase;
|
||||
@@ -207,6 +193,7 @@ public class GraphInferenceHighlightingTest extends LightDaemonAnalyzerTestCase
|
||||
public void testLambdaInConditional() { doTest(); }
|
||||
public void testTopLevelParentNoParameters() { doTest(); }
|
||||
public void testRawTypeOnTheRight() { doTest(); }
|
||||
public void testMutualBoundPromotion() { doTest(); }
|
||||
|
||||
private void doTest() {
|
||||
doTest(false);
|
||||
|
||||
Reference in New Issue
Block a user