annotate 'getArrayExpression' with @Nullable @IfNotParsed
from EA
This commit is contained in:
@@ -61,25 +61,24 @@ public class JetArrayAccessExpression extends JetReferenceExpression {
|
||||
return visitor.visitArrayAccessExpression(this, data);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Nullable @IfNotParsed
|
||||
public JetExpression getArrayExpression() {
|
||||
JetExpression baseExpression = findChildByClass(JetExpression.class);
|
||||
assert baseExpression != null;
|
||||
return baseExpression;
|
||||
return findChildByClass(JetExpression.class);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public List<JetExpression> getIndexExpressions() {
|
||||
PsiElement container = getIndicesNode();
|
||||
if (container == null) return Collections.emptyList();
|
||||
return PsiTreeUtil.getChildrenOfTypeAsList(container, JetExpression.class);
|
||||
return PsiTreeUtil.getChildrenOfTypeAsList(getIndicesNode(), JetExpression.class);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public JetContainerNode getIndicesNode() {
|
||||
return (JetContainerNode) findChildByType(JetNodeTypes.INDICES);
|
||||
JetContainerNode indicesNode = (JetContainerNode) findChildByType(JetNodeTypes.INDICES);
|
||||
assert indicesNode != null : "Can't be null because of parser";
|
||||
return indicesNode;
|
||||
}
|
||||
|
||||
|
||||
@NotNull
|
||||
public List<TextRange> getBracketRanges() {
|
||||
PsiElement lBracket = getIndicesNode().findChildByType(JetTokens.LBRACKET);
|
||||
PsiElement rBracket = getIndicesNode().findChildByType(JetTokens.RBRACKET);
|
||||
|
||||
+11
-5
@@ -719,14 +719,17 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
|
||||
return !context.dataFlowInfo.getNullability(dataFlowValue).canBeNull();
|
||||
}
|
||||
|
||||
public static void checkLValue(BindingTrace trace, JetExpression expression) {
|
||||
public static void checkLValue(@NotNull BindingTrace trace, @NotNull JetExpression expression) {
|
||||
checkLValue(trace, expression, false);
|
||||
}
|
||||
|
||||
private static void checkLValue(BindingTrace trace, JetExpression expressionWithParenthesis, boolean canBeThis) {
|
||||
private static void checkLValue(@NotNull BindingTrace trace, @NotNull JetExpression expressionWithParenthesis, boolean canBeThis) {
|
||||
JetExpression expression = JetPsiUtil.deparenthesizeWithNoTypeResolution(expressionWithParenthesis);
|
||||
if (expression instanceof JetArrayAccessExpression) {
|
||||
checkLValue(trace, ((JetArrayAccessExpression) expression).getArrayExpression(), true);
|
||||
JetExpression arrayExpression = ((JetArrayAccessExpression) expression).getArrayExpression();
|
||||
if (arrayExpression != null) {
|
||||
checkLValue(trace, arrayExpression, true);
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (canBeThis && expression instanceof JetThisExpression) return;
|
||||
@@ -1112,13 +1115,16 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
|
||||
@NotNull ExpressionTypingContext oldContext,
|
||||
@NotNull BindingTrace traceForResolveResult,
|
||||
boolean isGet) {
|
||||
JetTypeInfo arrayTypeInfo = facade.getTypeInfo(arrayAccessExpression.getArrayExpression(), oldContext);
|
||||
JetExpression arrayExpression = arrayAccessExpression.getArrayExpression();
|
||||
if (arrayExpression == null) return JetTypeInfo.create(null, oldContext.dataFlowInfo);
|
||||
|
||||
JetTypeInfo arrayTypeInfo = facade.getTypeInfo(arrayExpression, oldContext);
|
||||
JetType arrayType = arrayTypeInfo.getType();
|
||||
if (arrayType == null) return arrayTypeInfo;
|
||||
|
||||
DataFlowInfo dataFlowInfo = arrayTypeInfo.getDataFlowInfo();
|
||||
ExpressionTypingContext context = oldContext.replaceDataFlowInfo(dataFlowInfo);
|
||||
ExpressionReceiver receiver = new ExpressionReceiver(arrayAccessExpression.getArrayExpression(), arrayType);
|
||||
ExpressionReceiver receiver = new ExpressionReceiver(arrayExpression, arrayType);
|
||||
if (!isGet) assert rightHandSide != null;
|
||||
|
||||
OverloadResolutionResults<FunctionDescriptor> functionResults = context.resolveCallWithGivenName(
|
||||
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
package bar
|
||||
|
||||
fun main(args : Array<String>) {
|
||||
<!DEBUG_INFO_MISSING_UNRESOLVED!><!NO_CLASS_OBJECT!>String<!>[<!SYNTAX!><!>]<!> <!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>names<!> <!DEBUG_INFO_MISSING_UNRESOLVED!><!SYNTAX!>=<!> ["ads"]<!>
|
||||
}
|
||||
|
||||
|
||||
@@ -1982,6 +1982,11 @@ public class JetDiagnosticsTestGenerated extends AbstractDiagnosticsTestWithEage
|
||||
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.GenerateTests", new File("compiler/testData/diagnostics/tests/incompleteCode/diagnosticWithSyntaxError"), Pattern.compile("^(.+)\\.kt$"), true);
|
||||
}
|
||||
|
||||
@TestMetadata("arrayExpression.kt")
|
||||
public void testArrayExpression() throws Exception {
|
||||
doTest("compiler/testData/diagnostics/tests/incompleteCode/diagnosticWithSyntaxError/arrayExpression.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("checkBackingFieldException.kt")
|
||||
public void testCheckBackingFieldException() throws Exception {
|
||||
doTest("compiler/testData/diagnostics/tests/incompleteCode/diagnosticWithSyntaxError/checkBackingFieldException.kt");
|
||||
|
||||
+4
-1
@@ -20,6 +20,7 @@ import com.google.common.collect.Lists;
|
||||
import com.google.dart.compiler.backend.js.ast.JsExpression;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.lang.psi.JetArrayAccessExpression;
|
||||
import org.jetbrains.jet.lang.psi.JetExpression;
|
||||
import org.jetbrains.k2js.translate.context.TranslationContext;
|
||||
import org.jetbrains.k2js.translate.general.AbstractTranslator;
|
||||
import org.jetbrains.k2js.translate.general.Translation;
|
||||
@@ -88,7 +89,9 @@ public class ArrayAccessTranslator extends AbstractTranslator implements AccessT
|
||||
|
||||
@NotNull
|
||||
protected JsExpression translateArrayExpression() {
|
||||
return Translation.translateAsExpression(expression.getArrayExpression(), context());
|
||||
JetExpression arrayExpression = expression.getArrayExpression();
|
||||
assert arrayExpression != null : "Code with parsing errors shouldn't be translated";
|
||||
return Translation.translateAsExpression(arrayExpression, context());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
Reference in New Issue
Block a user