提交 c3854c93 编写于 作者: A Andrey Breslav

Negations supported

上级 49b60c3a
......@@ -3,7 +3,7 @@ package org.jetbrains.jet.lang.psi;
import com.intellij.lang.ASTNode;
import com.intellij.psi.PsiElement;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.jet.JetNodeTypes;
import org.jetbrains.annotations.Nullable;
/**
* @author max
......@@ -18,13 +18,12 @@ public class JetPrefixExpression extends JetUnaryExpression {
visitor.visitPrefixExpression(this);
}
@NotNull
@Nullable @IfNotParsed
public JetExpression getBaseExpression() {
PsiElement expression = getOperationSign().getNextSibling();
while (expression != null && false == expression instanceof JetExpression) {
expression = expression.getNextSibling();
}
assert expression != null;
return (JetExpression) expression;
}
}
......@@ -2,6 +2,7 @@ package org.jetbrains.jet.lang.psi;
import com.intellij.lang.ASTNode;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.jet.JetNodeTypes;
/**
......@@ -12,7 +13,6 @@ public abstract class JetUnaryExpression extends JetExpression {
super(node);
}
@NotNull
public abstract JetExpression getBaseExpression();
@NotNull
......
......@@ -1403,6 +1403,25 @@ public class JetTypeInferrer {
}
}
}
@Override
public void visitUnaryExpression(JetUnaryExpression expression) {
IElementType operationTokenType = expression.getOperationSign().getReferencedNameElementType();
if (operationTokenType == JetTokens.EXCL) {
JetExpression baseExpression = expression.getBaseExpression();
if (baseExpression != null) {
result[0] = extractDataFlowInfoFromCondition(baseExpression, !conditionValue);
}
}
}
@Override
public void visitParenthesizedExpression(JetParenthesizedExpression expression) {
JetExpression body = expression.getExpression();
if (body != null) {
body.accept(this);
}
}
});
return result[0];
}
......
......@@ -214,3 +214,44 @@ fun f6(s : String?) {
} while (s == null)
s.get(0)
}
fun f7(s : String?, t : String?) {
s?.get(0)
if (!(s == null)) {
s.get(0)
}
s?.get(0)
if (!(s != null)) {
s?.get(0)
}
else {
s.get(0)
}
s?.get(0)
if (!!(s != null)) {
s.get(0)
}
else {
s?.get(0)
}
s?.get(0)
t?.get(0)
if (!(s == null || t == null)) {
s.get(0)
t.get(0)
}
else {
s?.get(0)
t?.get(0)
}
s?.get(0)
t?.get(0)
if (!(s == null && s == null)) {
s.get(0)
t?.get(0)
}
else {
s?.get(0)
t?.get(0)
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册