KT-4341 No resolved call for right-hand side of equals expression
#KT-4341 Fixed
This commit is contained in:
@@ -367,7 +367,8 @@ public class CandidateResolver {
|
||||
CallCandidateResolutionContext<? extends CallableDescriptor> contextForArgument = storedContextForArgument
|
||||
.replaceContextDependency(INDEPENDENT).replaceBindingTrace(context.trace).replaceExpectedType(expectedType);
|
||||
JetType type;
|
||||
if (contextForArgument.candidateCall.hasIncompleteTypeParameters()) {
|
||||
if (contextForArgument.candidateCall.hasIncompleteTypeParameters()
|
||||
&& !contextForArgument.candidateCall.isCompleted()) { //e.g. 'equals' argument
|
||||
type = completeTypeInferenceDependentOnExpectedTypeForCall(contextForArgument, true);
|
||||
}
|
||||
else {
|
||||
|
||||
+5
-4
@@ -883,10 +883,12 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
|
||||
dataFlowInfo = leftTypeInfo.getDataFlowInfo();
|
||||
ExpressionTypingContext contextWithDataFlow = context.replaceDataFlowInfo(dataFlowInfo);
|
||||
|
||||
JetTypeInfo rightTypeInfo = facade.getTypeInfo(right, contextWithDataFlow);
|
||||
dataFlowInfo = rightTypeInfo.getDataFlowInfo();
|
||||
|
||||
TemporaryBindingTrace traceInterpretingRightAsNullableAny = TemporaryBindingTrace.create(
|
||||
context.trace, "trace to resolve 'equals(Any?)' interpreting as of type Any? an expression:" + right);
|
||||
context.trace, "trace to resolve 'equals(Any?)' interpreting as of type Any? an expression:", right);
|
||||
traceInterpretingRightAsNullableAny.record(EXPRESSION_TYPE, right, KotlinBuiltIns.getInstance().getNullableAnyType());
|
||||
traceInterpretingRightAsNullableAny.record(PROCESSED, right);
|
||||
|
||||
Call call = CallMaker.makeCallWithExpressions(operationSign, receiver, null, operationSign, Collections.singletonList(right));
|
||||
ExpressionTypingContext newContext = context.replaceBindingTrace(traceInterpretingRightAsNullableAny);
|
||||
@@ -897,7 +899,7 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
|
||||
@Override
|
||||
public boolean accept(@Nullable WritableSlice<?, ?> slice, Object key) {
|
||||
// the type of the right expression isn't 'Any?' actually
|
||||
if (key == right && (slice == EXPRESSION_TYPE || slice == PROCESSED)) return false;
|
||||
if (key == right && slice == EXPRESSION_TYPE) return false;
|
||||
|
||||
// a hack due to KT-678
|
||||
// without this line an autocast is reported on the receiver (if it was previously checked for not-null)
|
||||
@@ -907,7 +909,6 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
|
||||
return true;
|
||||
}
|
||||
}, true);
|
||||
dataFlowInfo = facade.getTypeInfo(right, contextWithDataFlow).getDataFlowInfo();
|
||||
|
||||
if (resolutionResults.isSuccess()) {
|
||||
FunctionDescriptor equals = resolutionResults.getResultingCall().getResultingDescriptor();
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
//KT-4341 No resolved call for right-hand side of equals expression
|
||||
package g
|
||||
|
||||
inline fun <T, U, V> inlineFunWithInvoke(s: (p: T) -> U) {
|
||||
<!USAGE_IS_NOT_INLINABLE!>s<!> == <!USAGE_IS_NOT_INLINABLE!>s<!> //resolved call for right-hand side 's' not traced
|
||||
}
|
||||
@@ -4039,7 +4039,7 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest {
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/diagnostics/tests/inline")
|
||||
@InnerTestClasses({Inline.BinaryExpressions.class, Inline.NonPublicMember.class, Inline.UnaryExpressions.class})
|
||||
@InnerTestClasses({Inline.BinaryExpressions.class, Inline.NonPublicMember.class, Inline.Regressions.class, Inline.UnaryExpressions.class})
|
||||
public static class Inline extends AbstractJetDiagnosticsTest {
|
||||
public void testAllFilesPresentInInline() throws Exception {
|
||||
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage", new File("compiler/testData/diagnostics/tests/inline"), Pattern.compile("^(.+)\\.kt$"), true);
|
||||
@@ -4236,6 +4236,19 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest {
|
||||
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/diagnostics/tests/inline/regressions")
|
||||
public static class Regressions extends AbstractJetDiagnosticsTest {
|
||||
public void testAllFilesPresentInRegressions() throws Exception {
|
||||
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage", new File("compiler/testData/diagnostics/tests/inline/regressions"), Pattern.compile("^(.+)\\.kt$"), true);
|
||||
}
|
||||
|
||||
@TestMetadata("kt4341.kt")
|
||||
public void testKt4341() throws Exception {
|
||||
doTest("compiler/testData/diagnostics/tests/inline/regressions/kt4341.kt");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/diagnostics/tests/inline/unaryExpressions")
|
||||
public static class UnaryExpressions extends AbstractJetDiagnosticsTest {
|
||||
public void testAllFilesPresentInUnaryExpressions() throws Exception {
|
||||
@@ -4259,6 +4272,7 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest {
|
||||
suite.addTestSuite(Inline.class);
|
||||
suite.addTestSuite(BinaryExpressions.class);
|
||||
suite.addTestSuite(NonPublicMember.class);
|
||||
suite.addTestSuite(Regressions.class);
|
||||
suite.addTestSuite(UnaryExpressions.class);
|
||||
return suite;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user