Search in sources :

Example 1 with DoubleColonLHS

use of org.jetbrains.kotlin.types.expressions.DoubleColonLHS in project kotlin by JetBrains.

the class ExpressionCodegen method visitClassLiteralExpression.

@Override
public StackValue visitClassLiteralExpression(@NotNull KtClassLiteralExpression expression, StackValue data) {
    KtExpression receiverExpression = expression.getReceiverExpression();
    assert receiverExpression != null : "Class literal expression should have a left-hand side";
    DoubleColonLHS lhs = bindingContext.get(DOUBLE_COLON_LHS, receiverExpression);
    assert lhs != null : "Class literal expression should have LHS resolved";
    return generateClassLiteralReference(lhs, receiverExpression, /* wrapIntoKClass = */
    true);
}
Also used : DoubleColonLHS(org.jetbrains.kotlin.types.expressions.DoubleColonLHS)

Example 2 with DoubleColonLHS

use of org.jetbrains.kotlin.types.expressions.DoubleColonLHS in project kotlin by JetBrains.

the class ExpressionVisitor method visitClassLiteralExpression.

@Override
public JsNode visitClassLiteralExpression(@NotNull KtClassLiteralExpression expression, TranslationContext context) {
    KtExpression receiverExpression = expression.getReceiverExpression();
    assert receiverExpression != null : "Class literal expression should have a left-hand side";
    DoubleColonLHS lhs = context.bindingContext().get(DOUBLE_COLON_LHS, receiverExpression);
    assert lhs != null : "Class literal expression should have LHS resolved";
    if (lhs instanceof DoubleColonLHS.Expression && !((DoubleColonLHS.Expression) lhs).isObjectQualifier()) {
        JsExpression receiver = translateAsExpression(receiverExpression, context);
        KotlinType type = context.bindingContext().getType(receiverExpression);
        if (type != null && KotlinBuiltIns.isChar(type)) {
            receiver = JsAstUtils.charToBoxedChar(receiver);
        }
        return new JsInvocation(context.namer().kotlin(GET_KCLASS_FROM_EXPRESSION), receiver);
    }
    return new JsInvocation(context.namer().kotlin(GET_KCLASS), UtilsKt.getReferenceToJsClass(lhs.getType(), context));
}
Also used : Translation.translateAsExpression(org.jetbrains.kotlin.js.translate.general.Translation.translateAsExpression) ExpressionTypingUtils.isFunctionExpression(org.jetbrains.kotlin.types.expressions.ExpressionTypingUtils.isFunctionExpression) DoubleColonLHS(org.jetbrains.kotlin.types.expressions.DoubleColonLHS) KotlinType(org.jetbrains.kotlin.types.KotlinType)

Aggregations

DoubleColonLHS (org.jetbrains.kotlin.types.expressions.DoubleColonLHS)2 Translation.translateAsExpression (org.jetbrains.kotlin.js.translate.general.Translation.translateAsExpression)1 KotlinType (org.jetbrains.kotlin.types.KotlinType)1 ExpressionTypingUtils.isFunctionExpression (org.jetbrains.kotlin.types.expressions.ExpressionTypingUtils.isFunctionExpression)1