'As' function for constants

This commit is contained in:
Natalia Ukhorskaya
2013-12-17 12:52:18 +04:00
parent b4ad149e77
commit 7a9d822070
9 changed files with 136 additions and 14 deletions
@@ -153,7 +153,7 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
TypeResolutionContext typeResolutionContext = new TypeResolutionContext(context.scope, context.trace, true, allowBareTypes);
PossiblyBareType possiblyBareTarget = context.expressionTypingServices.getTypeResolver().resolvePossiblyBareType(typeResolutionContext, right);
if (isTypeFlexible(left) || operationType == JetTokens.COLON) {
if (operationType == JetTokens.COLON) {
// We do not allow bare types on static assertions, because static assertions provide an expected type for their argument,
// thus causing a circularity in type dependencies
assert !possiblyBareTarget.isBare() : "Bare types should not be allowed for static assertions, because argument inference makes no sense there";
@@ -132,15 +132,6 @@ public class ExpressionTypingUtils {
}
}
public static boolean isTypeFlexible(@Nullable JetExpression expression) {
if (expression == null) return false;
return TokenSet.create(
JetNodeTypes.INTEGER_CONSTANT,
JetNodeTypes.FLOAT_CONSTANT
).contains(expression.getNode().getElementType());
}
private static boolean isCapturedInInline(
@NotNull BindingContext context,
@NotNull DeclarationDescriptor scopeContainer,