Package com.strobel.reflection

Examples of com.strobel.reflection.Type


        validateArgumentCount(method, nodeKind, arguments.size(), parameterTypes);

        T[] newArgs = null;

        for (int i = 0, n = parameterTypes.size(); i < n; i++) {
            final Type parameterType = parameterTypes.get(i);
            final T arg = validateOneArgument(method, nodeKind, arguments.get(i), parameterType);

            if (arg != arguments.get(i)) {
                if (newArgs == null) {
                    newArgs = arguments.toArray();
View Full Code Here


        final T arg,
        final Type parameterType) {

        verifyCanRead(arg, "arguments");

        final Type argType = arg.getType();

        if (!parameterType.isAssignableFrom(argType)) {
            switch (nodeKind) {
                case New:
                    throw Error.expressionTypeDoesNotMatchConstructorParameter(argType, parameterType);
View Full Code Here

                final ParameterExpression pex = parameters.get(i);
                final ParameterInfo pi = methodParameters.get(i);

                verifyCanRead(pex, "parameters");

                final Type pType = pi.getParameterType();

                if (!TypeUtils.areEquivalent(pex.getType(), pType)) {
                    if (!pType.isGenericParameter() || !pType.isAssignableFrom(pex.getType())) {
                        throw Error.parameterExpressionNotValidForDelegate(pex.getType(), pType);
                    }
                }

                if (set.contains(pex)) {
                    throw Error.duplicateVariable(pex);
                }

                set.add(pex);
            }
        }
        else if (parameters.size() > 0) {
            throw Error.incorrectNumberOfLambdaDeclarationParameters();
        }

        final Type returnType = method.getReturnType();

        if (returnType != PrimitiveTypes.Void &&
            !TypeUtils.areEquivalent(returnType, body.getType())) {
            if (/*!returnType.isGenericParameter() ||*/ !returnType.isAssignableFrom(body.getType())) {
                throw Error.expressionTypeDoesNotMatchReturn(body.getType(), returnType);
            }
        }
    }
View Full Code Here

                }
            }
        }
        else {
            //Body of every catch must have the same type of body of try.
            final Type tryType = tryBody.getType();
            for (int i = 0, n = handlers.size(); i < n; i++) {
                final Expression catchBody = handlers.get(i).getBody();
                if (catchBody == null || !TypeUtils.areEquivalent(catchBody.getType(), tryType)) {
                    throw Error.bodyOfCatchMustHaveSameTypeAsBodyOfTry();
                }
View Full Code Here

            return false;
        }

        for (int i = 0, n = arguments.size(); i < n; i++) {
            final Expression argument = arguments.get(i);
            final Type argumentType = argument.getType();
            final Type parameterType = parameters.get(i).getParameterType();

            if (!TypeUtils.areReferenceAssignable(parameterType, argumentType) &&
                !(TypeUtils.isSameOrSubType(Type.of(LambdaExpression.class), parameterType) &&
                  parameterType.isAssignableFrom(argument.getType()))) {

                return false;
            }
        }
        return true;
View Full Code Here

        return leftType;
    }

    private static Type validateCoalesceArgumentTypes(final Type left, final Type right) {
        final Type leftStripped = TypeUtils.getUnderlyingPrimitive(left);

        if (left.isPrimitive()) {
            throw Error.coalesceUsedOnNonNullableType();
        }
        else if (TypeUtils.isAutoUnboxed(left) && TypeUtils.hasReferenceConversion(right, leftStripped)) {
View Full Code Here

        }

        final Expression left = b.getLeft();
        final Expression right = b.getRight();

        final Type leftType = left.getType();
        final Type rightType = right.getType();

        if (nodeType.isEqualityOperator() &&
            (b.getType() == PrimitiveTypes.Boolean || b.getType() == Types.Boolean)) {

            emitExpression(getEqualityOperand(left));
View Full Code Here

        final Type resultType) {

        final boolean leftIsBoxed = TypeUtils.isAutoUnboxed(leftType);
        final boolean rightIsBoxed = TypeUtils.isAutoUnboxed(rightType);

        Type finalLeftType = leftType;
        Type finalRightType = rightType;

        if (leftIsBoxed) {
            finalLeftType = unboxLeftBinaryOperand(leftType, rightType);
        }
View Full Code Here

        final Type resultType) {

        final boolean leftIsBoxed = TypeUtils.isAutoUnboxed(leftType);
        final boolean rightIsBoxed = TypeUtils.isAutoUnboxed(rightType);

        Type finalLeftType = leftType;
        Type finalRightType = rightType;

        if (leftIsBoxed) {
            finalLeftType = unboxLeftBinaryOperand(leftType, rightType);
        }
View Full Code Here

            TypeUtils.getUnderlyingPrimitiveOrSelf(resultType)
        );
    }

    private Type unboxRightBinaryOperand(final Type rightType) {
        final Type finalRightType = TypeUtils.getUnderlyingPrimitive(rightType);
        generator.emitUnbox(finalRightType);
        return finalRightType;
    }
View Full Code Here

TOP

Related Classes of com.strobel.reflection.Type

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.