diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/cfg/PseudocodeVariableDataCollector.kt b/compiler/frontend/src/org/jetbrains/jet/lang/cfg/PseudocodeVariableDataCollector.kt index 232c71e6da5..dead27ae36f 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/cfg/PseudocodeVariableDataCollector.kt +++ b/compiler/frontend/src/org/jetbrains/jet/lang/cfg/PseudocodeVariableDataCollector.kt @@ -79,11 +79,13 @@ public class PseudocodeVariableDataCollector( if (instruction is VariableDeclarationInstruction) { val variableDeclarationElement = instruction.getVariableDeclarationElement() val descriptor = bindingContext.get(BindingContext.DECLARATION_TO_DESCRIPTOR, variableDeclarationElement) - assert(descriptor is VariableDescriptor, - "Variable descriptor should correspond to the instruction for ${instruction.getElement().getText()}.\n" + - "Descriptor : $descriptor") - lexicalScopeVariableInfo.registerVariableDeclaredInScope( - descriptor as VariableDescriptor, instruction.getLexicalScope()) + if (descriptor != null) { + assert(descriptor is VariableDescriptor, + "Variable descriptor should correspond to the instruction for ${instruction.getElement().getText()}.\n" + + "Descriptor : $descriptor") + lexicalScopeVariableInfo.registerVariableDeclaredInScope( + descriptor as VariableDescriptor, instruction.getLexicalScope()) + } } }) return lexicalScopeVariableInfo diff --git a/compiler/testData/diagnostics/tests/incompleteCode/variableDeclarationInSelector.kt b/compiler/testData/diagnostics/tests/incompleteCode/variableDeclarationInSelector.kt new file mode 100644 index 00000000000..08756b791e8 --- /dev/null +++ b/compiler/testData/diagnostics/tests/incompleteCode/variableDeclarationInSelector.kt @@ -0,0 +1,4 @@ +fun foo(s: String) { + s. + val b = 42 +} \ No newline at end of file diff --git a/compiler/tests/org/jetbrains/jet/checkers/JetDiagnosticsTestGenerated.java b/compiler/tests/org/jetbrains/jet/checkers/JetDiagnosticsTestGenerated.java index 2a61d65a9a4..75a3ed7d6a8 100644 --- a/compiler/tests/org/jetbrains/jet/checkers/JetDiagnosticsTestGenerated.java +++ b/compiler/tests/org/jetbrains/jet/checkers/JetDiagnosticsTestGenerated.java @@ -3416,6 +3416,11 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest { doTest("compiler/testData/diagnostics/tests/incompleteCode/typeParameterOnLhsOfDot.kt"); } + @TestMetadata("variableDeclarationInSelector.kt") + public void testVariableDeclarationInSelector() throws Exception { + doTest("compiler/testData/diagnostics/tests/incompleteCode/variableDeclarationInSelector.kt"); + } + @TestMetadata("compiler/testData/diagnostics/tests/incompleteCode/diagnosticWithSyntaxError") public static class DiagnosticWithSyntaxError extends AbstractJetDiagnosticsTest { public void testAllFilesPresentInDiagnosticWithSyntaxError() throws Exception {