From 2dc6691c1a32a85c8a0edc0060ed37481894dec9 Mon Sep 17 00:00:00 2001 From: Andrey Breslav Date: Fri, 17 Aug 2012 20:39:56 +0400 Subject: [PATCH] DataFlowInfo taken into account when resolving component functions --- .../types/expressions/ExpressionTypingUtils.java | 2 +- .../declarationChecks/DataFlowInfoInMultiDecl.kt | 14 ++++++++++++++ .../jet/checkers/JetDiagnosticsTestGenerated.java | 5 +++++ 3 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 compiler/testData/diagnostics/tests/declarationChecks/DataFlowInfoInMultiDecl.kt diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/ExpressionTypingUtils.java b/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/ExpressionTypingUtils.java index bfcb1c6f286..9952ffb810e 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/ExpressionTypingUtils.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/ExpressionTypingUtils.java @@ -253,7 +253,7 @@ public class ExpressionTypingUtils { @NotNull Name name ) { JetReferenceExpression fake = JetPsiFactory.createSimpleName(context.expressionTypingServices.getProject(), "fake"); - BindingTrace fakeTrace = new BindingTraceContext(); + BindingTrace fakeTrace = TemporaryBindingTrace.create(context.trace); Call call = CallMaker.makeCall(fake, receiver, null, fake, Collections.emptyList()); return context.replaceBindingTrace(fakeTrace).resolveCallWithGivenName(call, fake, name); } diff --git a/compiler/testData/diagnostics/tests/declarationChecks/DataFlowInfoInMultiDecl.kt b/compiler/testData/diagnostics/tests/declarationChecks/DataFlowInfoInMultiDecl.kt new file mode 100644 index 00000000000..074e4c00280 --- /dev/null +++ b/compiler/testData/diagnostics/tests/declarationChecks/DataFlowInfoInMultiDecl.kt @@ -0,0 +1,14 @@ +class A { + fun component1() : Int = 1 + fun component2() : Int = 2 +} + +fun a(aa : A?, b : Any) { + if (aa != null) { + val (a1, b1) = aa; + } + + if (b is A) { + val (a1, b1) = b; + } +} diff --git a/compiler/tests/org/jetbrains/jet/checkers/JetDiagnosticsTestGenerated.java b/compiler/tests/org/jetbrains/jet/checkers/JetDiagnosticsTestGenerated.java index 37aa7febb9b..21f7be5884b 100644 --- a/compiler/tests/org/jetbrains/jet/checkers/JetDiagnosticsTestGenerated.java +++ b/compiler/tests/org/jetbrains/jet/checkers/JetDiagnosticsTestGenerated.java @@ -1053,6 +1053,11 @@ public class JetDiagnosticsTestGenerated extends AbstractDiagnosticsTestWithEage JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.checkers.AbstractDiagnosticsTestWithEagerResolve", new File("compiler/testData/diagnostics/tests/declarationChecks"), "kt", false); } + @TestMetadata("DataFlowInfoInMultiDecl.kt") + public void testDataFlowInfoInMultiDecl() throws Exception { + doTest("compiler/testData/diagnostics/tests/declarationChecks/DataFlowInfoInMultiDecl.kt"); + } + @TestMetadata("kt1141.kt") public void testKt1141() throws Exception { doTest("compiler/testData/diagnostics/tests/declarationChecks/kt1141.kt");