Refactoring of JetTypeInfo / BindingContext. Loop data flow analysis corrected.
Now BindingContext includes expression type info instead of jump out possible, data flow info and expression type. getType() was added into BindingContext, getType() and recordType() were added into BindingTrace. JetTypeInfo now includes also jump possible flag and jump point data flow info. Old TypeInfoWithJumpInfo deleted. TypeInfoFactory introduced to create JetTypeInfo instances. A pack of extra tests for break / continue in loops added.
This commit is contained in:
+1
-1
@@ -350,7 +350,7 @@ public final class ExpressionVisitor extends TranslatorVisitor<JsNode> {
|
||||
assert right != null;
|
||||
|
||||
JetType rightType = BindingContextUtils.getNotNull(context.bindingContext(), BindingContext.TYPE, right);
|
||||
JetType leftType = BindingContextUtils.getNotNull(context.bindingContext(), BindingContext.EXPRESSION_TYPE, expression.getLeft());
|
||||
JetType leftType = BindingContextUtils.getNotNullType(context.bindingContext(), expression.getLeft());
|
||||
if (TypeUtils.isNullableType(rightType) || !TypeUtils.isNullableType(leftType)) {
|
||||
return jsExpression.source(expression);
|
||||
}
|
||||
|
||||
+1
-1
@@ -89,7 +89,7 @@ public final class StringTemplateTranslator extends AbstractTranslator {
|
||||
return;
|
||||
}
|
||||
|
||||
JetType type = context().bindingContext().get(BindingContext.EXPRESSION_TYPE, entryExpression);
|
||||
JetType type = context().bindingContext().getType(entryExpression);
|
||||
if (type == null || type.isMarkedNullable()) {
|
||||
append(TopLevelFIF.TO_STRING.apply((JsExpression) null, Collections.singletonList(translatedExpression), context()));
|
||||
}
|
||||
|
||||
+1
-1
@@ -55,7 +55,7 @@ public final class UnaryOperationTranslator {
|
||||
IElementType operationToken = expression.getOperationReference().getReferencedNameElementType();
|
||||
if (operationToken == JetTokens.EXCLEXCL) {
|
||||
JetExpression baseExpression = getBaseExpression(expression);
|
||||
JetType type = BindingContextUtils.getNotNull(context.bindingContext(), BindingContext.EXPRESSION_TYPE, baseExpression);
|
||||
JetType type = BindingContextUtils.getNotNullType(context.bindingContext(), baseExpression);
|
||||
JsExpression translatedExpression = translateAsExpression(baseExpression, context);
|
||||
return type.isMarkedNullable() ? sure(translatedExpression, context) : translatedExpression;
|
||||
}
|
||||
|
||||
@@ -160,7 +160,7 @@ public final class BindingUtils {
|
||||
public static Object getCompileTimeValue(@NotNull BindingContext context, @NotNull JetExpression expression, @NotNull CompileTimeConstant<?> constant) {
|
||||
if (constant != null) {
|
||||
if (constant instanceof IntegerValueTypeConstant) {
|
||||
JetType expectedType = context.get(BindingContext.EXPRESSION_TYPE, expression);
|
||||
JetType expectedType = context.getType(expression);
|
||||
return ((IntegerValueTypeConstant) constant).getValue(expectedType == null ? TypeUtils.NO_EXPECTED_TYPE : expectedType);
|
||||
}
|
||||
return constant.getValue();
|
||||
@@ -210,7 +210,7 @@ public final class BindingUtils {
|
||||
@NotNull
|
||||
public static JetType getTypeForExpression(@NotNull BindingContext context,
|
||||
@NotNull JetExpression expression) {
|
||||
return BindingContextUtils.getNotNull(context, BindingContext.EXPRESSION_TYPE, expression);
|
||||
return BindingContextUtils.getNotNullType(context, expression);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
|
||||
@@ -162,7 +162,7 @@ public final class JsDescriptorUtils {
|
||||
|
||||
@Nullable
|
||||
public static Name getNameIfStandardType(@NotNull JetExpression expression, @NotNull TranslationContext context) {
|
||||
JetType type = context.bindingContext().get(BindingContext.EXPRESSION_TYPE, expression);
|
||||
JetType type = context.bindingContext().getType(expression);
|
||||
return type != null ? DescriptorUtilsPackage.getNameIfStandardType(type) : null;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user