Search in sources :

Example 1 with OBJECT_TYPE

use of org.codehaus.groovy.ast.ClassHelper.OBJECT_TYPE in project groovy by apache.

the class StaticTypesCallSiteWriter method writeListDotProperty.

private void writeListDotProperty(final Expression receiver, final String propertyName, final boolean safe) {
    // for lists, replace list.foo with:
    // def result = new ArrayList(list.size())
    // for (item in list) result.add(item.foo)
    // result
    ClassNode componentType = receiver.getNodeMetaData(StaticCompilationMetadataKeys.COMPONENT_TYPE);
    if (componentType == null) {
        componentType = OBJECT_TYPE;
    }
    CompileStack compileStack = controller.getCompileStack();
    MethodVisitor mv = controller.getMethodVisitor();
    Label exit = new Label();
    if (safe) {
        receiver.visit(controller.getAcg());
        Label doGet = new Label();
        mv.visitJumpInsn(IFNONNULL, doGet);
        controller.getOperandStack().remove(1);
        mv.visitInsn(ACONST_NULL);
        mv.visitJumpInsn(GOTO, exit);
        mv.visitLabel(doGet);
    }
    Variable tmpList = varX("tmpList", ClassHelper.make(ArrayList.class));
    int var = compileStack.defineTemporaryVariable(tmpList, false);
    Variable iterator = varX("iterator", Iterator_TYPE);
    int it = compileStack.defineTemporaryVariable(iterator, false);
    Variable nextVar = varX("next", componentType);
    final int next = compileStack.defineTemporaryVariable(nextVar, false);
    mv.visitTypeInsn(NEW, "java/util/ArrayList");
    mv.visitInsn(DUP);
    receiver.visit(controller.getAcg());
    mv.visitMethodInsn(INVOKEINTERFACE, "java/util/List", "size", "()I", true);
    controller.getOperandStack().remove(1);
    mv.visitMethodInsn(INVOKESPECIAL, "java/util/ArrayList", "<init>", "(I)V", false);
    mv.visitVarInsn(ASTORE, var);
    Label l1 = new Label();
    mv.visitLabel(l1);
    receiver.visit(controller.getAcg());
    mv.visitMethodInsn(INVOKEINTERFACE, "java/util/List", "iterator", "()Ljava/util/Iterator;", true);
    controller.getOperandStack().remove(1);
    mv.visitVarInsn(ASTORE, it);
    Label l2 = new Label();
    mv.visitLabel(l2);
    mv.visitVarInsn(ALOAD, it);
    mv.visitMethodInsn(INVOKEINTERFACE, "java/util/Iterator", "hasNext", "()Z", true);
    Label l3 = new Label();
    mv.visitJumpInsn(IFEQ, l3);
    mv.visitVarInsn(ALOAD, it);
    mv.visitMethodInsn(INVOKEINTERFACE, "java/util/Iterator", "next", "()Ljava/lang/Object;", true);
    mv.visitTypeInsn(CHECKCAST, BytecodeHelper.getClassInternalName(componentType));
    mv.visitVarInsn(ASTORE, next);
    Label l4 = new Label();
    mv.visitLabel(l4);
    mv.visitVarInsn(ALOAD, var);
    PropertyExpression pexp = propX(bytecodeX(componentType, v -> v.visitVarInsn(ALOAD, next)), propertyName);
    pexp.visit(controller.getAcg());
    controller.getOperandStack().box();
    controller.getOperandStack().remove(1);
    mv.visitMethodInsn(INVOKEINTERFACE, "java/util/List", "add", "(Ljava/lang/Object;)Z", true);
    mv.visitInsn(POP);
    Label l5 = new Label();
    mv.visitLabel(l5);
    mv.visitJumpInsn(GOTO, l2);
    mv.visitLabel(l3);
    mv.visitVarInsn(ALOAD, var);
    if (safe) {
        mv.visitLabel(exit);
    }
    controller.getOperandStack().push(ClassHelper.make(ArrayList.class));
    controller.getCompileStack().removeVar(next);
    controller.getCompileStack().removeVar(it);
    controller.getCompileStack().removeVar(var);
}
Also used : ASTORE(org.objectweb.asm.Opcodes.ASTORE) MethodVisitor(org.objectweb.asm.MethodVisitor) GETSTATIC(org.objectweb.asm.Opcodes.GETSTATIC) GeneralUtils.classX(org.codehaus.groovy.ast.tools.GeneralUtils.classX) Number_TYPE(org.codehaus.groovy.ast.ClassHelper.Number_TYPE) ClassHelper.isBigDecimalType(org.codehaus.groovy.ast.ClassHelper.isBigDecimalType) Variable(org.codehaus.groovy.ast.Variable) NEW(org.objectweb.asm.Opcodes.NEW) StaticTypeCheckingSupport.chooseBestMethod(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.chooseBestMethod) INVOKEINTERFACE(org.objectweb.asm.Opcodes.INVOKEINTERFACE) BytecodeHelper(org.codehaus.groovy.classgen.asm.BytecodeHelper) GeneralUtils.nullX(org.codehaus.groovy.ast.tools.GeneralUtils.nullX) Map(java.util.Map) GeneralUtils.propX(org.codehaus.groovy.ast.tools.GeneralUtils.propX) AALOAD(org.objectweb.asm.Opcodes.AALOAD) ClassHelper.isBigIntegerType(org.codehaus.groovy.ast.ClassHelper.isBigIntegerType) BytecodeExpression(org.codehaus.groovy.classgen.BytecodeExpression) PropertyNode(org.codehaus.groovy.ast.PropertyNode) ClassHelper.isWrapperLong(org.codehaus.groovy.ast.ClassHelper.isWrapperLong) VariableExpression(org.codehaus.groovy.ast.expr.VariableExpression) GROOVY_OBJECT_TYPE(org.codehaus.groovy.ast.ClassHelper.GROOVY_OBJECT_TYPE) LIST_TYPE(org.codehaus.groovy.ast.ClassHelper.LIST_TYPE) Collection(java.util.Collection) GeneralUtils.args(org.codehaus.groovy.ast.tools.GeneralUtils.args) BeanUtils.capitalize(org.apache.groovy.util.BeanUtils.capitalize) IFNULL(org.objectweb.asm.Opcodes.IFNULL) MethodCallerMultiAdapter(org.codehaus.groovy.classgen.asm.MethodCallerMultiAdapter) ClassNodeUtils.getField(org.apache.groovy.ast.tools.ClassNodeUtils.getField) ClassHelper.getUnwrapper(org.codehaus.groovy.ast.ClassHelper.getUnwrapper) GeneralUtils.callX(org.codehaus.groovy.ast.tools.GeneralUtils.callX) InnerClassNode(org.codehaus.groovy.ast.InnerClassNode) GETFIELD(org.objectweb.asm.Opcodes.GETFIELD) GroovyBugError(org.codehaus.groovy.GroovyBugError) CallSiteWriter(org.codehaus.groovy.classgen.asm.CallSiteWriter) ExpressionUtils.isThisExpression(org.apache.groovy.ast.tools.ExpressionUtils.isThisExpression) StaticTypeCheckingSupport.findDGMMethodsByNameAndArguments(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.findDGMMethodsByNameAndArguments) DUP(org.objectweb.asm.Opcodes.DUP) CLASS_Type(org.codehaus.groovy.ast.ClassHelper.CLASS_Type) List(java.util.List) StaticTypeCheckingSupport.implementsInterfaceOrIsSubclassOf(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.implementsInterfaceOrIsSubclassOf) CompileStack(org.codehaus.groovy.classgen.asm.CompileStack) OBJECT_TYPE(org.codehaus.groovy.ast.ClassHelper.OBJECT_TYPE) GeneralUtils.bytecodeX(org.codehaus.groovy.ast.tools.GeneralUtils.bytecodeX) ACC_PUBLIC(org.objectweb.asm.Opcodes.ACC_PUBLIC) IFNONNULL(org.objectweb.asm.Opcodes.IFNONNULL) STRING_TYPE(org.codehaus.groovy.ast.ClassHelper.STRING_TYPE) ClassHelper.getWrapper(org.codehaus.groovy.ast.ClassHelper.getWrapper) GOTO(org.objectweb.asm.Opcodes.GOTO) GeneralUtils.constX(org.codehaus.groovy.ast.tools.GeneralUtils.constX) GeneralUtils.isOrImplements(org.codehaus.groovy.ast.tools.GeneralUtils.isOrImplements) PropertyExpression(org.codehaus.groovy.ast.expr.PropertyExpression) ClassHelper.int_TYPE(org.codehaus.groovy.ast.ClassHelper.int_TYPE) ClassHelper.isWrapperInteger(org.codehaus.groovy.ast.ClassHelper.isWrapperInteger) Label(org.objectweb.asm.Label) ACC_STATIC(org.objectweb.asm.Opcodes.ACC_STATIC) ArrayList(java.util.ArrayList) PUTFIELD(org.objectweb.asm.Opcodes.PUTFIELD) IFEQ(org.objectweb.asm.Opcodes.IFEQ) INVOKESTATIC(org.objectweb.asm.Opcodes.INVOKESTATIC) MethodNode(org.codehaus.groovy.ast.MethodNode) ACONST_NULL(org.objectweb.asm.Opcodes.ACONST_NULL) CLOSURE_TYPE(org.codehaus.groovy.ast.ClassHelper.CLOSURE_TYPE) MethodCallExpression(org.codehaus.groovy.ast.expr.MethodCallExpression) GeneralUtils.varX(org.codehaus.groovy.ast.tools.GeneralUtils.varX) Expression(org.codehaus.groovy.ast.expr.Expression) CHECKCAST(org.objectweb.asm.Opcodes.CHECKCAST) POP(org.objectweb.asm.Opcodes.POP) Parameter(org.codehaus.groovy.ast.Parameter) MAP_TYPE(org.codehaus.groovy.ast.ClassHelper.MAP_TYPE) InvokerHelper(org.codehaus.groovy.runtime.InvokerHelper) ClassNode(org.codehaus.groovy.ast.ClassNode) OperandStack(org.codehaus.groovy.classgen.asm.OperandStack) ClassHelper(org.codehaus.groovy.ast.ClassHelper) ClassHelper.isStringType(org.codehaus.groovy.ast.ClassHelper.isStringType) AsmClassGenerator(org.codehaus.groovy.classgen.AsmClassGenerator) ClassHelper.isPrimitiveBoolean(org.codehaus.groovy.ast.ClassHelper.isPrimitiveBoolean) GeneralUtils.castX(org.codehaus.groovy.ast.tools.GeneralUtils.castX) StaticCompilationMetadataKeys(org.codehaus.groovy.transform.sc.StaticCompilationMetadataKeys) StaticTypesMarker(org.codehaus.groovy.transform.stc.StaticTypesMarker) ClassHelper.isGeneratedFunction(org.codehaus.groovy.ast.ClassHelper.isGeneratedFunction) ARRAYLENGTH(org.objectweb.asm.Opcodes.ARRAYLENGTH) StaticTypeCheckingSupport.isClassClassNodeWrappingConcreteType(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.isClassClassNodeWrappingConcreteType) TypeChooser(org.codehaus.groovy.classgen.asm.TypeChooser) GeneralUtils.callThisX(org.codehaus.groovy.ast.tools.GeneralUtils.callThisX) ClassExpression(org.codehaus.groovy.ast.expr.ClassExpression) EmptyStatement(org.codehaus.groovy.ast.stmt.EmptyStatement) ASTNode(org.codehaus.groovy.ast.ASTNode) ClassHelper.isClassType(org.codehaus.groovy.ast.ClassHelper.isClassType) ClassHelper.isPrimitiveType(org.codehaus.groovy.ast.ClassHelper.isPrimitiveType) FieldNode(org.codehaus.groovy.ast.FieldNode) PUTSTATIC(org.objectweb.asm.Opcodes.PUTSTATIC) VariableSlotLoader(org.codehaus.groovy.classgen.asm.VariableSlotLoader) INVOKESPECIAL(org.objectweb.asm.Opcodes.INVOKESPECIAL) Iterator_TYPE(org.codehaus.groovy.ast.ClassHelper.Iterator_TYPE) SyntaxException(org.codehaus.groovy.syntax.SyntaxException) ALOAD(org.objectweb.asm.Opcodes.ALOAD) InnerClassNode(org.codehaus.groovy.ast.InnerClassNode) ClassNode(org.codehaus.groovy.ast.ClassNode) Variable(org.codehaus.groovy.ast.Variable) Label(org.objectweb.asm.Label) ArrayList(java.util.ArrayList) PropertyExpression(org.codehaus.groovy.ast.expr.PropertyExpression) CompileStack(org.codehaus.groovy.classgen.asm.CompileStack) MethodVisitor(org.objectweb.asm.MethodVisitor)

Example 2 with OBJECT_TYPE

use of org.codehaus.groovy.ast.ClassHelper.OBJECT_TYPE in project groovy by apache.

the class StaticTypeCheckingSupport method evaluateExpression.

/**
 * A helper method that can be used to evaluate expressions as found in annotation
 * parameters. For example, it will evaluate a constant, be it referenced directly as
 * an integer or as a reference to a field.
 * <p>
 * If this method throws an exception, then the expression cannot be evaluated on its own.
 *
 * @param expr   the expression to be evaluated
 * @param config the compiler configuration
 * @return the result of the expression
 */
public static Object evaluateExpression(final Expression expr, final CompilerConfiguration config) {
    Expression ce = expr instanceof CastExpression ? ((CastExpression) expr).getExpression() : expr;
    if (ce instanceof ConstantExpression) {
        if (expr.getType().equals(ce.getType()))
            return ((ConstantExpression) ce).getValue();
    } else if (ce instanceof ListExpression) {
        if (expr.getType().isArray() && expr.getType().getComponentType().equals(STRING_TYPE))
            return ((ListExpression) ce).getExpressions().stream().map(e -> evaluateExpression(e, config)).toArray(String[]::new);
    }
    String className = "Expression$" + UUID.randomUUID().toString().replace('-', '$');
    ClassNode simpleClass = new ClassNode(className, Opcodes.ACC_PUBLIC, OBJECT_TYPE);
    addGeneratedMethod(simpleClass, "eval", Opcodes.ACC_PUBLIC + Opcodes.ACC_STATIC, OBJECT_TYPE, Parameter.EMPTY_ARRAY, ClassNode.EMPTY_ARRAY, new ReturnStatement(expr));
    // adjust configuration so class can be inspected by this JVM
    CompilerConfiguration cc = new CompilerConfiguration(config);
    // unlikely to be required by expression
    cc.setPreviewFeatures(false);
    cc.setTargetBytecode(CompilerConfiguration.DEFAULT.getTargetBytecode());
    CompilationUnit cu = new CompilationUnit(cc);
    try {
        cu.addClassNode(simpleClass);
        cu.compile(Phases.CLASS_GENERATION);
        List<GroovyClass> classes = cu.getClasses();
        Class<?> aClass = cu.getClassLoader().defineClass(className, classes.get(0).getBytes());
        try {
            return aClass.getMethod("eval").invoke(null);
        } catch (ReflectiveOperationException e) {
            throw new GroovyBugError(e);
        }
    } finally {
        closeQuietly(cu.getClassLoader());
    }
}
Also used : Arrays(java.util.Arrays) BigInteger_TYPE(org.codehaus.groovy.ast.ClassHelper.BigInteger_TYPE) DEPRECATED_TYPE(org.codehaus.groovy.ast.ClassHelper.DEPRECATED_TYPE) COMPARE_GREATER_THAN(org.codehaus.groovy.syntax.Types.COMPARE_GREATER_THAN) GSTRING_TYPE(org.codehaus.groovy.ast.ClassHelper.GSTRING_TYPE) WideningCategories.isFloatingCategory(org.codehaus.groovy.ast.tools.WideningCategories.isFloatingCategory) Character_TYPE(org.codehaus.groovy.ast.ClassHelper.Character_TYPE) ClassHelper.make(org.codehaus.groovy.ast.ClassHelper.make) POWER_EQUAL(org.codehaus.groovy.syntax.Types.POWER_EQUAL) Matcher(java.util.regex.Matcher) INTDIV_EQUAL(org.codehaus.groovy.syntax.Types.INTDIV_EQUAL) Map(java.util.Map) COMPARE_GREATER_THAN_EQUAL(org.codehaus.groovy.syntax.Types.COMPARE_GREATER_THAN_EQUAL) VOID_TYPE(org.codehaus.groovy.ast.ClassHelper.VOID_TYPE) ClassHelper.isBigIntegerType(org.codehaus.groovy.ast.ClassHelper.isBigIntegerType) Traits(org.codehaus.groovy.transform.trait.Traits) ClassHelper.char_TYPE(org.codehaus.groovy.ast.ClassHelper.char_TYPE) COMPARE_TO(org.codehaus.groovy.syntax.Types.COMPARE_TO) COLLECTION_TYPE(org.codehaus.groovy.ast.ClassHelper.COLLECTION_TYPE) BITWISE_AND(org.codehaus.groovy.syntax.Types.BITWISE_AND) VariableExpression(org.codehaus.groovy.ast.expr.VariableExpression) PLUS(org.codehaus.groovy.syntax.Types.PLUS) ArgumentListExpression(org.codehaus.groovy.ast.expr.ArgumentListExpression) Set(java.util.Set) LOGICAL_AND(org.codehaus.groovy.syntax.Types.LOGICAL_AND) ClassHelper.getUnwrapper(org.codehaus.groovy.ast.ClassHelper.getUnwrapper) RIGHT_SHIFT_EQUAL(org.codehaus.groovy.syntax.Types.RIGHT_SHIFT_EQUAL) CLASS_Type(org.codehaus.groovy.ast.ClassHelper.CLASS_Type) COMPARE_NOT_EQUAL(org.codehaus.groovy.syntax.Types.COMPARE_NOT_EQUAL) OBJECT_TYPE(org.codehaus.groovy.ast.ClassHelper.OBJECT_TYPE) ClassHelper.makeWithoutCaching(org.codehaus.groovy.ast.ClassHelper.makeWithoutCaching) ClassHelper.byte_TYPE(org.codehaus.groovy.ast.ClassHelper.byte_TYPE) ClassNodeUtils.samePackageName(org.apache.groovy.ast.tools.ClassNodeUtils.samePackageName) STRING_TYPE(org.codehaus.groovy.ast.ClassHelper.STRING_TYPE) ClassHelper.long_TYPE(org.codehaus.groovy.ast.ClassHelper.long_TYPE) RIGHT_SHIFT_UNSIGNED(org.codehaus.groovy.syntax.Types.RIGHT_SHIFT_UNSIGNED) LEFT_SQUARE_BRACKET(org.codehaus.groovy.syntax.Types.LEFT_SQUARE_BRACKET) CastExpression(org.codehaus.groovy.ast.expr.CastExpression) ClassHelper.getWrapper(org.codehaus.groovy.ast.ClassHelper.getWrapper) PLUS_EQUAL(org.codehaus.groovy.syntax.Types.PLUS_EQUAL) RIGHT_SHIFT(org.codehaus.groovy.syntax.Types.RIGHT_SHIFT) DefaultGroovyMethods.asBoolean(org.codehaus.groovy.runtime.DefaultGroovyMethods.asBoolean) COMPARE_NOT_IN(org.codehaus.groovy.syntax.Types.COMPARE_NOT_IN) COMPARE_EQUAL(org.codehaus.groovy.syntax.Types.COMPARE_EQUAL) INTDIV(org.codehaus.groovy.syntax.Types.INTDIV) DIVIDE_EQUAL(org.codehaus.groovy.syntax.Types.DIVIDE_EQUAL) MINUS(org.codehaus.groovy.syntax.Types.MINUS) TreeSet(java.util.TreeSet) MOD_EQUAL(org.codehaus.groovy.syntax.Types.MOD_EQUAL) ArrayList(java.util.ArrayList) LinkedHashMap(java.util.LinkedHashMap) BITWISE_OR_EQUAL(org.codehaus.groovy.syntax.Types.BITWISE_OR_EQUAL) LOGICAL_OR(org.codehaus.groovy.syntax.Types.LOGICAL_OR) DefaultGroovyMethodsSupport.closeQuietly(org.codehaus.groovy.runtime.DefaultGroovyMethodsSupport.closeQuietly) COMPARE_IDENTICAL(org.codehaus.groovy.syntax.Types.COMPARE_IDENTICAL) MethodNode(org.codehaus.groovy.ast.MethodNode) BITWISE_AND_EQUAL(org.codehaus.groovy.syntax.Types.BITWISE_AND_EQUAL) Expression(org.codehaus.groovy.ast.expr.Expression) ExpressionUtils.isNullConstant(org.apache.groovy.ast.tools.ExpressionUtils.isNullConstant) ClassHelper.short_TYPE(org.codehaus.groovy.ast.ClassHelper.short_TYPE) KEYWORD_IN(org.codehaus.groovy.syntax.Types.KEYWORD_IN) LinkedHashSet(java.util.LinkedHashSet) Opcodes(org.objectweb.asm.Opcodes) Parameter(org.codehaus.groovy.ast.Parameter) POWER(org.codehaus.groovy.syntax.Types.POWER) ClassNode(org.codehaus.groovy.ast.ClassNode) ClassHelper.isStringType(org.codehaus.groovy.ast.ClassHelper.isStringType) ClassHelper.float_TYPE(org.codehaus.groovy.ast.ClassHelper.float_TYPE) GenericsType(org.codehaus.groovy.ast.GenericsType) ClassHelper.isPrimitiveBoolean(org.codehaus.groovy.ast.ClassHelper.isPrimitiveBoolean) ReturnStatement(org.codehaus.groovy.ast.stmt.ReturnStatement) CompilerConfiguration(org.codehaus.groovy.control.CompilerConfiguration) Phases(org.codehaus.groovy.control.Phases) ClassHelper.isClassType(org.codehaus.groovy.ast.ClassHelper.isClassType) ClassHelper.isPrimitiveType(org.codehaus.groovy.ast.ClassHelper.isPrimitiveType) ClassHelper.double_TYPE(org.codehaus.groovy.ast.ClassHelper.double_TYPE) ClassHelper.isGroovyObjectType(org.codehaus.groovy.ast.ClassHelper.isGroovyObjectType) Float_TYPE(org.codehaus.groovy.ast.ClassHelper.Float_TYPE) MetaClassRegistryImpl(org.codehaus.groovy.runtime.metaclass.MetaClassRegistryImpl) WideningCategories.isNumberCategory(org.codehaus.groovy.ast.tools.WideningCategories.isNumberCategory) ListExpression(org.codehaus.groovy.ast.expr.ListExpression) ClassHelper.isWrapperBoolean(org.codehaus.groovy.ast.ClassHelper.isWrapperBoolean) KEYWORD_INSTANCEOF(org.codehaus.groovy.syntax.Types.KEYWORD_INSTANCEOF) MapExpression(org.codehaus.groovy.ast.expr.MapExpression) ClassHelper.isGStringType(org.codehaus.groovy.ast.ClassHelper.isGStringType) GenericsTypeName(org.codehaus.groovy.ast.GenericsType.GenericsTypeName) ConstantExpression(org.codehaus.groovy.ast.expr.ConstantExpression) Long_TYPE(org.codehaus.groovy.ast.ClassHelper.Long_TYPE) LEFT_SHIFT_EQUAL(org.codehaus.groovy.syntax.Types.LEFT_SHIFT_EQUAL) Number_TYPE(org.codehaus.groovy.ast.ClassHelper.Number_TYPE) ClassHelper.findSAM(org.codehaus.groovy.ast.ClassHelper.findSAM) Enum_Type(org.codehaus.groovy.ast.ClassHelper.Enum_Type) ClassHelper.isBigDecimalType(org.codehaus.groovy.ast.ClassHelper.isBigDecimalType) Variable(org.codehaus.groovy.ast.Variable) ClassHelper.isSAMType(org.codehaus.groovy.ast.ClassHelper.isSAMType) MULTIPLY_EQUAL(org.codehaus.groovy.syntax.Types.MULTIPLY_EQUAL) GeneralUtils(org.codehaus.groovy.ast.tools.GeneralUtils) MULTIPLY(org.codehaus.groovy.syntax.Types.MULTIPLY) MATCH_REGEX(org.codehaus.groovy.syntax.Types.MATCH_REGEX) Integer_TYPE(org.codehaus.groovy.ast.ClassHelper.Integer_TYPE) ClassHelper.void_WRAPPER_TYPE(org.codehaus.groovy.ast.ClassHelper.void_WRAPPER_TYPE) ArrayExpression(org.codehaus.groovy.ast.expr.ArrayExpression) Collection(java.util.Collection) BITWISE_XOR(org.codehaus.groovy.syntax.Types.BITWISE_XOR) Types(org.codehaus.groovy.syntax.Types) LEFT_SHIFT(org.codehaus.groovy.syntax.Types.LEFT_SHIFT) UUID(java.util.UUID) RIGHT_SHIFT_UNSIGNED_EQUAL(org.codehaus.groovy.syntax.Types.RIGHT_SHIFT_UNSIGNED_EQUAL) InnerClassNode(org.codehaus.groovy.ast.InnerClassNode) Short_TYPE(org.codehaus.groovy.ast.ClassHelper.Short_TYPE) GroovyBugError(org.codehaus.groovy.GroovyBugError) List(java.util.List) BinaryExpression(org.codehaus.groovy.ast.expr.BinaryExpression) Optional(java.util.Optional) Double_TYPE(org.codehaus.groovy.ast.ClassHelper.Double_TYPE) BITWISE_XOR_EQUAL(org.codehaus.groovy.syntax.Types.BITWISE_XOR_EQUAL) ClassHelper.int_TYPE(org.codehaus.groovy.ast.ClassHelper.int_TYPE) WideningCategories.lowestUpperBound(org.codehaus.groovy.ast.tools.WideningCategories.lowestUpperBound) HashMap(java.util.HashMap) DIVIDE(org.codehaus.groovy.syntax.Types.DIVIDE) Maps(org.apache.groovy.util.Maps) HashSet(java.util.HashSet) ClassHelper.isNumberType(org.codehaus.groovy.ast.ClassHelper.isNumberType) CompilationUnit(org.codehaus.groovy.control.CompilationUnit) CLOSURE_TYPE(org.codehaus.groovy.ast.ClassHelper.CLOSURE_TYPE) ClassHelper.boolean_TYPE(org.codehaus.groovy.ast.ClassHelper.boolean_TYPE) WideningCategories.isBigIntCategory(org.codehaus.groovy.ast.tools.WideningCategories.isBigIntCategory) ClassNodeUtils.addGeneratedMethod(org.apache.groovy.ast.tools.ClassNodeUtils.addGeneratedMethod) LinkedList(java.util.LinkedList) Byte_TYPE(org.codehaus.groovy.ast.ClassHelper.Byte_TYPE) Iterator(java.util.Iterator) COMPARE_NOT_INSTANCEOF(org.codehaus.groovy.syntax.Types.COMPARE_NOT_INSTANCEOF) ParameterUtils(org.codehaus.groovy.ast.tools.ParameterUtils) GroovyClass(org.codehaus.groovy.tools.GroovyClass) GenericsUtils.makeClassSafe0(org.codehaus.groovy.ast.tools.GenericsUtils.makeClassSafe0) COMPARE_NOT_IDENTICAL(org.codehaus.groovy.syntax.Types.COMPARE_NOT_IDENTICAL) ClosureExpression(org.codehaus.groovy.ast.expr.ClosureExpression) GenericsUtils(org.codehaus.groovy.ast.tools.GenericsUtils) MINUS_EQUAL(org.codehaus.groovy.syntax.Types.MINUS_EQUAL) StringJoiner(java.util.StringJoiner) WideningCategories(org.codehaus.groovy.ast.tools.WideningCategories) MOD(org.codehaus.groovy.syntax.Types.MOD) BaseStream(java.util.stream.BaseStream) COMPARE_LESS_THAN(org.codehaus.groovy.syntax.Types.COMPARE_LESS_THAN) COMPARE_LESS_THAN_EQUAL(org.codehaus.groovy.syntax.Types.COMPARE_LESS_THAN_EQUAL) Comparator(java.util.Comparator) ConstructorNode(org.codehaus.groovy.ast.ConstructorNode) Collections(java.util.Collections) ClassHelper.isObjectType(org.codehaus.groovy.ast.ClassHelper.isObjectType) BITWISE_OR(org.codehaus.groovy.syntax.Types.BITWISE_OR) CompilationUnit(org.codehaus.groovy.control.CompilationUnit) ClassNode(org.codehaus.groovy.ast.ClassNode) InnerClassNode(org.codehaus.groovy.ast.InnerClassNode) GroovyClass(org.codehaus.groovy.tools.GroovyClass) ConstantExpression(org.codehaus.groovy.ast.expr.ConstantExpression) ArgumentListExpression(org.codehaus.groovy.ast.expr.ArgumentListExpression) ListExpression(org.codehaus.groovy.ast.expr.ListExpression) GroovyBugError(org.codehaus.groovy.GroovyBugError) VariableExpression(org.codehaus.groovy.ast.expr.VariableExpression) ArgumentListExpression(org.codehaus.groovy.ast.expr.ArgumentListExpression) CastExpression(org.codehaus.groovy.ast.expr.CastExpression) Expression(org.codehaus.groovy.ast.expr.Expression) ListExpression(org.codehaus.groovy.ast.expr.ListExpression) MapExpression(org.codehaus.groovy.ast.expr.MapExpression) ConstantExpression(org.codehaus.groovy.ast.expr.ConstantExpression) ArrayExpression(org.codehaus.groovy.ast.expr.ArrayExpression) BinaryExpression(org.codehaus.groovy.ast.expr.BinaryExpression) ClosureExpression(org.codehaus.groovy.ast.expr.ClosureExpression) ReturnStatement(org.codehaus.groovy.ast.stmt.ReturnStatement) CompilerConfiguration(org.codehaus.groovy.control.CompilerConfiguration) CastExpression(org.codehaus.groovy.ast.expr.CastExpression)

Example 3 with OBJECT_TYPE

use of org.codehaus.groovy.ast.ClassHelper.OBJECT_TYPE in project groovy by apache.

the class StaticTypeCheckingVisitor method findMethodsWithGenerated.

/**
 * Returns methods defined for the specified receiver and adds "non-existing"
 * methods that will be generated afterwards by the compiler; for example if
 * a method is using default values and the class node isn't compiled yet.
 *
 * @param receiver the receiver where to find methods
 * @param name     the name of the methods to return
 * @return the methods that are defined on the receiver completed with stubs for future methods
 */
protected List<MethodNode> findMethodsWithGenerated(final ClassNode receiver, final String name) {
    if (receiver.isArray()) {
        if (name.equals("clone")) {
            // GROOVY-10319: array clone -- <https://docs.oracle.com/javase/specs/jls/se8/html/jls-10.html#jls-10.7>
            MethodNode clone = new MethodNode("clone", Opcodes.ACC_PUBLIC, OBJECT_TYPE, Parameter.EMPTY_ARRAY, ClassNode.EMPTY_ARRAY, null);
            // retain Object for declaringClass and returnType
            clone.setDeclaringClass(OBJECT_TYPE);
            clone.setNodeMetaData(INFERRED_RETURN_TYPE, receiver);
            return Collections.singletonList(clone);
        } else {
            return OBJECT_TYPE.getMethods(name);
        }
    }
    List<MethodNode> methods = receiver.getMethods(name);
    if (receiver.isAbstract()) {
        collectAllInterfaceMethodsByName(receiver, name, methods);
    } else {
        // GROOVY-9890: always search for default methods
        List<MethodNode> interfaceMethods = new ArrayList<>();
        collectAllInterfaceMethodsByName(receiver, name, interfaceMethods);
        interfaceMethods.stream().filter(mn -> mn.isDefault() || (mn.isPublic() && !mn.isStatic() && !mn.isAbstract() && Traits.isTrait(mn.getDeclaringClass()))).forEach(methods::add);
    }
    if (receiver.isInterface()) {
        methods.addAll(OBJECT_TYPE.getMethods(name));
    }
    if (methods.isEmpty() || receiver.isResolved()) {
        return methods;
    }
    return addGeneratedMethods(receiver, methods);
}
Also used : BigInteger_TYPE(org.codehaus.groovy.ast.ClassHelper.BigInteger_TYPE) Enumeration(java.util.Enumeration) StaticTypeCheckingSupport.applyGenericsContext(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.applyGenericsContext) StaticTypeCheckingSupport.filterMethodsByVisibility(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.filterMethodsByVisibility) Character_TYPE(org.codehaus.groovy.ast.ClassHelper.Character_TYPE) LinkedHashSet_TYPE(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.LinkedHashSet_TYPE) InvocationWriter(org.codehaus.groovy.classgen.asm.InvocationWriter) StaticTypeCheckingSupport.chooseBestMethod(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.chooseBestMethod) StaticTypeCheckingSupport.fullyResolve(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.fullyResolve) Map(java.util.Map) GeneralUtils.propX(org.codehaus.groovy.ast.tools.GeneralUtils.propX) StaticTypeCheckingSupport.prettyPrintTypeName(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.prettyPrintTypeName) VOID_TYPE(org.codehaus.groovy.ast.ClassHelper.VOID_TYPE) PropertyNode(org.codehaus.groovy.ast.PropertyNode) COMPARE_TO(org.codehaus.groovy.syntax.Types.COMPARE_TO) UnaryMinusExpression(org.codehaus.groovy.ast.expr.UnaryMinusExpression) ClosureListExpression(org.codehaus.groovy.ast.expr.ClosureListExpression) PV_FIELDS_MUTATION(org.codehaus.groovy.transform.stc.StaticTypesMarker.PV_FIELDS_MUTATION) ClassHelper.isPrimitiveLong(org.codehaus.groovy.ast.ClassHelper.isPrimitiveLong) ArgumentListExpression(org.codehaus.groovy.ast.expr.ArgumentListExpression) StaticTypeCheckingSupport.findDGMMethodsForClassNode(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.findDGMMethodsForClassNode) MethodReferenceExpression(org.codehaus.groovy.ast.expr.MethodReferenceExpression) TernaryExpression(org.codehaus.groovy.ast.expr.TernaryExpression) OBJECT_TYPE(org.codehaus.groovy.ast.ClassHelper.OBJECT_TYPE) ClassHelper.byte_TYPE(org.codehaus.groovy.ast.ClassHelper.byte_TYPE) GeneralUtils.elvisX(org.codehaus.groovy.ast.tools.GeneralUtils.elvisX) STRING_TYPE(org.codehaus.groovy.ast.ClassHelper.STRING_TYPE) BeanUtils.decapitalize(org.apache.groovy.util.BeanUtils.decapitalize) ClassHelper.getWrapper(org.codehaus.groovy.ast.ClassHelper.getWrapper) COMPARE_NOT_IN(org.codehaus.groovy.syntax.Types.COMPARE_NOT_IN) StaticTypeCheckingSupport.isOperationInGroup(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.isOperationInGroup) COMPARE_EQUAL(org.codehaus.groovy.syntax.Types.COMPARE_EQUAL) GeneralUtils.isOrImplements(org.codehaus.groovy.ast.tools.GeneralUtils.isOrImplements) ClassHelper.isPrimitiveDouble(org.codehaus.groovy.ast.ClassHelper.isPrimitiveDouble) PropertyExpression(org.codehaus.groovy.ast.expr.PropertyExpression) ClassHelper.isWrapperInteger(org.codehaus.groovy.ast.ClassHelper.isWrapperInteger) DIVIDE_EQUAL(org.codehaus.groovy.syntax.Types.DIVIDE_EQUAL) StaticTypeCheckingSupport.getOperationName(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.getOperationName) IMPLICIT_RECEIVER(org.codehaus.groovy.transform.stc.StaticTypesMarker.IMPLICIT_RECEIVER) StaticTypeCheckingSupport.resolveClassNodeGenerics(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.resolveClassNodeGenerics) ClassHelper.isPrimitiveShort(org.codehaus.groovy.ast.ClassHelper.isPrimitiveShort) ClosureUtils.getParametersSafe(org.codehaus.groovy.ast.tools.ClosureUtils.getParametersSafe) ClassHelper.isWrapperDouble(org.codehaus.groovy.ast.ClassHelper.isWrapperDouble) Matcher_TYPE(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.Matcher_TYPE) LinkedHashMap(java.util.LinkedHashMap) PrefixExpression(org.codehaus.groovy.ast.expr.PrefixExpression) SystemUtil(org.apache.groovy.util.SystemUtil) ExpressionStatement(org.codehaus.groovy.ast.stmt.ExpressionStatement) PostfixExpression(org.codehaus.groovy.ast.expr.PostfixExpression) Expression(org.codehaus.groovy.ast.expr.Expression) ClassHelper.short_TYPE(org.codehaus.groovy.ast.ClassHelper.short_TYPE) StaticTypeCheckingSupport.isPowerOperator(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.isPowerOperator) Opcodes(org.objectweb.asm.Opcodes) UnaryPlusExpression(org.codehaus.groovy.ast.expr.UnaryPlusExpression) SourceUnit(org.codehaus.groovy.control.SourceUnit) ClassNode(org.codehaus.groovy.ast.ClassNode) ClassHelper.isStringType(org.codehaus.groovy.ast.ClassHelper.isStringType) ClassHelper.float_TYPE(org.codehaus.groovy.ast.ClassHelper.float_TYPE) ClassHelper.isPrimitiveInt(org.codehaus.groovy.ast.ClassHelper.isPrimitiveInt) GenericsType(org.codehaus.groovy.ast.GenericsType) ClassHelper.isPrimitiveBoolean(org.codehaus.groovy.ast.ClassHelper.isPrimitiveBoolean) GeneralUtils.castX(org.codehaus.groovy.ast.tools.GeneralUtils.castX) ReturnStatement(org.codehaus.groovy.ast.stmt.ReturnStatement) AnnotationConstantExpression(org.codehaus.groovy.ast.expr.AnnotationConstantExpression) UNKNOWN_PARAMETER_TYPE(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.UNKNOWN_PARAMETER_TYPE) AtomicLong(java.util.concurrent.atomic.AtomicLong) DYNAMIC_RESOLUTION(org.codehaus.groovy.transform.stc.StaticTypesMarker.DYNAMIC_RESOLUTION) BitwiseNegationExpression(org.codehaus.groovy.ast.expr.BitwiseNegationExpression) ClassHelper.isFunctionalInterface(org.codehaus.groovy.ast.ClassHelper.isFunctionalInterface) Float_TYPE(org.codehaus.groovy.ast.ClassHelper.Float_TYPE) CONSTRUCTED_LAMBDA_EXPRESSION(org.codehaus.groovy.transform.stc.StaticTypesMarker.CONSTRUCTED_LAMBDA_EXPRESSION) MapExpression(org.codehaus.groovy.ast.expr.MapExpression) ClassHelper.isGStringType(org.codehaus.groovy.ast.ClassHelper.isGStringType) GenericsTypeName(org.codehaus.groovy.ast.GenericsType.GenericsTypeName) AnnotatedNode(org.codehaus.groovy.ast.AnnotatedNode) ConstantExpression(org.codehaus.groovy.ast.expr.ConstantExpression) Long_TYPE(org.codehaus.groovy.ast.ClassHelper.Long_TYPE) StaticTypeCheckingSupport.extractGenericsParameterMapOfThis(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.extractGenericsParameterMapOfThis) StaticTypesTransformation(org.codehaus.groovy.transform.StaticTypesTransformation) GeneralUtils.getGetterName(org.codehaus.groovy.ast.tools.GeneralUtils.getGetterName) StaticTypeCheckingSupport.getCombinedBoundType(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.getCombinedBoundType) Number_TYPE(org.codehaus.groovy.ast.ClassHelper.Number_TYPE) MethodCall(org.codehaus.groovy.ast.expr.MethodCall) ClassHelper.isBigDecimalType(org.codehaus.groovy.ast.ClassHelper.isBigDecimalType) Collectors.toMap(java.util.stream.Collectors.toMap) StaticTypeCheckingSupport.evaluateExpression(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.evaluateExpression) INFERRED_TYPE(org.codehaus.groovy.transform.stc.StaticTypesMarker.INFERRED_TYPE) ForStatement(org.codehaus.groovy.ast.stmt.ForStatement) PV_FIELDS_ACCESS(org.codehaus.groovy.transform.stc.StaticTypesMarker.PV_FIELDS_ACCESS) StaticTypeCheckingSupport.findSetters(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.findSetters) Collection(java.util.Collection) DefaultGroovyMethods(org.codehaus.groovy.runtime.DefaultGroovyMethods) Collectors(java.util.stream.Collectors) NotExpression(org.codehaus.groovy.ast.expr.NotExpression) InnerClassNode(org.codehaus.groovy.ast.InnerClassNode) Short_TYPE(org.codehaus.groovy.ast.ClassHelper.Short_TYPE) Objects(java.util.Objects) StaticTypeCheckingSupport.findDGMMethodsByNameAndArguments(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.findDGMMethodsByNameAndArguments) IfStatement(org.codehaus.groovy.ast.stmt.IfStatement) FieldExpression(org.codehaus.groovy.ast.expr.FieldExpression) StaticTypeCheckingSupport.isBitOperator(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.isBitOperator) ClosureUtils.hasImplicitParameter(org.codehaus.groovy.ast.tools.ClosureUtils.hasImplicitParameter) StaticTypeCheckingSupport.isWildcardLeftHandSide(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.isWildcardLeftHandSide) BigDecimal_TYPE(org.codehaus.groovy.ast.ClassHelper.BigDecimal_TYPE) ClassHelper.isPrimitiveByte(org.codehaus.groovy.ast.ClassHelper.isPrimitiveByte) StaticTypeCheckingSupport.getCombinedGenericsType(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.getCombinedGenericsType) WideningCategories.isIntCategory(org.codehaus.groovy.ast.tools.WideningCategories.isIntCategory) DynamicVariable(org.codehaus.groovy.ast.DynamicVariable) Double_TYPE(org.codehaus.groovy.ast.ClassHelper.Double_TYPE) IntStream(java.util.stream.IntStream) StaticTypeCheckingSupport.isAssignableTo(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.isAssignableTo) ClosureSignatureHint(groovy.transform.stc.ClosureSignatureHint) AnnotationNode(org.codehaus.groovy.ast.AnnotationNode) StaticTypeCheckingSupport.isBeingCompiled(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.isBeingCompiled) StaticTypeCheckingSupport.typeCheckMethodsWithGenerics(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.typeCheckMethodsWithGenerics) DIVIDE(org.codehaus.groovy.syntax.Types.DIVIDE) Function(java.util.function.Function) ASSIGN(org.codehaus.groovy.syntax.Types.ASSIGN) HashSet(java.util.HashSet) ClassHelper.isNumberType(org.codehaus.groovy.ast.ClassHelper.isNumberType) BiPredicate(java.util.function.BiPredicate) ELVIS_EQUAL(org.codehaus.groovy.syntax.Types.ELVIS_EQUAL) NUMBER_OPS(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.NUMBER_OPS) Tuple2(groovy.lang.Tuple2) ClassHelper.boolean_TYPE(org.codehaus.groovy.ast.ClassHelper.boolean_TYPE) PV_METHODS_ACCESS(org.codehaus.groovy.transform.stc.StaticTypesMarker.PV_METHODS_ACCESS) ClassCodeVisitorSupport(org.codehaus.groovy.ast.ClassCodeVisitorSupport) StaticTypeCheckingSupport.checkPossibleLossOfPrecision(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.checkPossibleLossOfPrecision) GeneralUtils.varX(org.codehaus.groovy.ast.tools.GeneralUtils.varX) EmptyExpression(org.codehaus.groovy.ast.expr.EmptyExpression) LinkedList(java.util.LinkedList) StaticTypeCheckingSupport.typeCheckMethodArgumentWithGenerics(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.typeCheckMethodArgumentWithGenerics) ConstructorCallExpression(org.codehaus.groovy.ast.expr.ConstructorCallExpression) COMPARE_NOT_INSTANCEOF(org.codehaus.groovy.syntax.Types.COMPARE_NOT_INSTANCEOF) ClassHelper(org.codehaus.groovy.ast.ClassHelper) DECLARATION_INFERRED_TYPE(org.codehaus.groovy.transform.stc.StaticTypesMarker.DECLARATION_INFERRED_TYPE) SET_TYPE(org.codehaus.groovy.ast.ClassHelper.SET_TYPE) StaticTypeCheckingSupport.isArrayOp(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.isArrayOp) ClassExpression(org.codehaus.groovy.ast.expr.ClassExpression) ASTNode(org.codehaus.groovy.ast.ASTNode) TupleExpression(org.codehaus.groovy.ast.expr.TupleExpression) GeneralUtils.binX(org.codehaus.groovy.ast.tools.GeneralUtils.binX) TryCatchStatement(org.codehaus.groovy.ast.stmt.TryCatchStatement) GenericsUtils(org.codehaus.groovy.ast.tools.GenericsUtils) StringJoiner(java.util.StringJoiner) MethodPointerExpression(org.codehaus.groovy.ast.expr.MethodPointerExpression) StaticTypeCheckingSupport.allParametersAndArgumentsMatchWithDefaultParams(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.allParametersAndArgumentsMatchWithDefaultParams) ClassHelper.isWrapperCharacter(org.codehaus.groovy.ast.ClassHelper.isWrapperCharacter) ConstructorNode(org.codehaus.groovy.ast.ConstructorNode) MapEntryExpression(org.codehaus.groovy.ast.expr.MapEntryExpression) ClassHelper.isObjectType(org.codehaus.groovy.ast.ClassHelper.isObjectType) Arrays(java.util.Arrays) INFERRED_RETURN_TYPE(org.codehaus.groovy.transform.stc.StaticTypesMarker.INFERRED_RETURN_TYPE) StaticTypeCheckingSupport.checkCompatibleAssignmentTypes(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.checkCompatibleAssignmentTypes) Closure(groovy.lang.Closure) StaticTypeCheckingSupport.getGenericsWithoutArray(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.getGenericsWithoutArray) WideningCategories.isFloatingCategory(org.codehaus.groovy.ast.tools.WideningCategories.isFloatingCategory) StaticTypeCheckingSupport.isTraitSelf(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.isTraitSelf) RANGE_TYPE(org.codehaus.groovy.ast.ClassHelper.RANGE_TYPE) ClosureParams(groovy.transform.stc.ClosureParams) CLOSURE_ARGUMENTS(org.codehaus.groovy.transform.stc.StaticTypesMarker.CLOSURE_ARGUMENTS) INTDIV_EQUAL(org.codehaus.groovy.syntax.Types.INTDIV_EQUAL) StaticTypeCheckingSupport.extractGenericsConnections(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.extractGenericsConnections) CaseStatement(org.codehaus.groovy.ast.stmt.CaseStatement) ClassHelper.isBigIntegerType(org.codehaus.groovy.ast.ClassHelper.isBigIntegerType) Traits(org.codehaus.groovy.transform.trait.Traits) ClassHelper.char_TYPE(org.codehaus.groovy.ast.ClassHelper.char_TYPE) MINUS_MINUS(org.codehaus.groovy.syntax.Types.MINUS_MINUS) VariableExpression(org.codehaus.groovy.ast.expr.VariableExpression) EnumMap(java.util.EnumMap) LIST_TYPE(org.codehaus.groovy.ast.ClassHelper.LIST_TYPE) TypeCheckingMode(groovy.transform.TypeCheckingMode) BeanUtils.capitalize(org.apache.groovy.util.BeanUtils.capitalize) PATTERN_TYPE(org.codehaus.groovy.ast.ClassHelper.PATTERN_TYPE) NamedParams(groovy.transform.NamedParams) Set(java.util.Set) Token(org.codehaus.groovy.syntax.Token) ClassHelper.isPrimitiveVoid(org.codehaus.groovy.ast.ClassHelper.isPrimitiveVoid) ClassHelper.getUnwrapper(org.codehaus.groovy.ast.ClassHelper.getUnwrapper) GeneralUtils.callX(org.codehaus.groovy.ast.tools.GeneralUtils.callX) InvocationTargetException(java.lang.reflect.InvocationTargetException) WideningCategories.isFloat(org.codehaus.groovy.ast.tools.WideningCategories.isFloat) STREAM_TYPE(org.codehaus.groovy.ast.ClassHelper.STREAM_TYPE) CLASS_Type(org.codehaus.groovy.ast.ClassHelper.CLASS_Type) StaticTypeCheckingSupport.toMethodParametersString(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.toMethodParametersString) ClassHelper.isWrapperByte(org.codehaus.groovy.ast.ClassHelper.isWrapperByte) COMPARE_NOT_EQUAL(org.codehaus.groovy.syntax.Types.COMPARE_NOT_EQUAL) StaticTypeCheckingSupport.implementsInterfaceOrIsSubclassOf(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.implementsInterfaceOrIsSubclassOf) ClassHelper.getNextSuperClass(org.codehaus.groovy.ast.ClassHelper.getNextSuperClass) ClassHelper.isWrapperFloat(org.codehaus.groovy.ast.ClassHelper.isWrapperFloat) ClassHelper.dynamicType(org.codehaus.groovy.ast.ClassHelper.dynamicType) ClassHelper.long_TYPE(org.codehaus.groovy.ast.ClassHelper.long_TYPE) LinkedHashMap_TYPE(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.LinkedHashMap_TYPE) StaticTypeCheckingSupport.isBoolIntrinsicOp(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.isBoolIntrinsicOp) CastExpression(org.codehaus.groovy.ast.expr.CastExpression) StaticTypeCheckingSupport.boundUnboundedWildcards(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.boundUnboundedWildcards) ReturnAdder(org.codehaus.groovy.classgen.ReturnAdder) INTDIV(org.codehaus.groovy.syntax.Types.INTDIV) StaticMethodCallExpression(org.codehaus.groovy.ast.expr.StaticMethodCallExpression) LambdaExpression(org.codehaus.groovy.ast.expr.LambdaExpression) TYPE(org.codehaus.groovy.transform.stc.StaticTypesMarker.TYPE) GeneralUtils.thisPropX(org.codehaus.groovy.ast.tools.GeneralUtils.thisPropX) StaticTypeCheckingSupport.missesGenericsTypes(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.missesGenericsTypes) MOD_EQUAL(org.codehaus.groovy.syntax.Types.MOD_EQUAL) WhileStatement(org.codehaus.groovy.ast.stmt.WhileStatement) ArrayList(java.util.ArrayList) ClosureUtils.getResolveStrategyName(org.codehaus.groovy.ast.tools.ClosureUtils.getResolveStrategyName) MethodNode(org.codehaus.groovy.ast.MethodNode) WideningCategories.isBigDecCategory(org.codehaus.groovy.ast.tools.WideningCategories.isBigDecCategory) ClassHelper.isPrimitiveFloat(org.codehaus.groovy.ast.ClassHelper.isPrimitiveFloat) KEYWORD_IN(org.codehaus.groovy.syntax.Types.KEYWORD_IN) LinkedHashSet(java.util.LinkedHashSet) Parameter(org.codehaus.groovy.ast.Parameter) MAP_TYPE(org.codehaus.groovy.ast.ClassHelper.MAP_TYPE) WideningCategories.isDoubleCategory(org.codehaus.groovy.ast.tools.WideningCategories.isDoubleCategory) EmptyStatement(org.codehaus.groovy.ast.stmt.EmptyStatement) ClassHelper.isClassType(org.codehaus.groovy.ast.ClassHelper.isClassType) ClassHelper.isPrimitiveType(org.codehaus.groovy.ast.ClassHelper.isPrimitiveType) ClassHelper.double_TYPE(org.codehaus.groovy.ast.ClassHelper.double_TYPE) ClassHelper.isPrimitiveChar(org.codehaus.groovy.ast.ClassHelper.isPrimitiveChar) WideningCategories.isLongCategory(org.codehaus.groovy.ast.tools.WideningCategories.isLongCategory) DIRECT_METHOD_CALL_TARGET(org.codehaus.groovy.transform.stc.StaticTypesMarker.DIRECT_METHOD_CALL_TARGET) WideningCategories.isNumberCategory(org.codehaus.groovy.ast.tools.WideningCategories.isNumberCategory) PLUS_PLUS(org.codehaus.groovy.syntax.Types.PLUS_PLUS) ListExpression(org.codehaus.groovy.ast.expr.ListExpression) KEYWORD_INSTANCEOF(org.codehaus.groovy.syntax.Types.KEYWORD_INSTANCEOF) StaticTypeCheckingSupport.isAssignment(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.isAssignment) GeneralUtils.getSetterName(org.codehaus.groovy.ast.tools.GeneralUtils.getSetterName) DELEGATION_METADATA(org.codehaus.groovy.transform.stc.StaticTypesMarker.DELEGATION_METADATA) StaticTypeCheckingSupport.lastArgMatchesVarg(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.lastArgMatchesVarg) StaticTypeCheckingSupport.isGStringOrGStringStringLUB(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.isGStringOrGStringStringLUB) ClassHelper.findSAM(org.codehaus.groovy.ast.ClassHelper.findSAM) RangeExpression(org.codehaus.groovy.ast.expr.RangeExpression) ResolveVisitor(org.codehaus.groovy.control.ResolveVisitor) Variable(org.codehaus.groovy.ast.Variable) ClassHelper.isSAMType(org.codehaus.groovy.ast.ClassHelper.isSAMType) FIND_REGEX(org.codehaus.groovy.syntax.Types.FIND_REGEX) StaticTypeCheckingSupport.prettyPrintType(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.prettyPrintType) GeneralUtils(org.codehaus.groovy.ast.tools.GeneralUtils) WideningCategories.isDouble(org.codehaus.groovy.ast.tools.WideningCategories.isDouble) Integer_TYPE(org.codehaus.groovy.ast.ClassHelper.Integer_TYPE) DelegatesTo(groovy.lang.DelegatesTo) SpreadExpression(org.codehaus.groovy.ast.expr.SpreadExpression) SUPER_MOP_METHOD_REQUIRED(org.codehaus.groovy.transform.stc.StaticTypesMarker.SUPER_MOP_METHOD_REQUIRED) ClassHelper.isWrapperLong(org.codehaus.groovy.ast.ClassHelper.isWrapperLong) ArrayExpression(org.codehaus.groovy.ast.expr.ArrayExpression) GROOVY_OBJECT_TYPE(org.codehaus.groovy.ast.ClassHelper.GROOVY_OBJECT_TYPE) GeneralUtils.args(org.codehaus.groovy.ast.tools.GeneralUtils.args) CatchStatement(org.codehaus.groovy.ast.stmt.CatchStatement) GroovyBugError(org.codehaus.groovy.GroovyBugError) READONLY_PROPERTY(org.codehaus.groovy.transform.stc.StaticTypesMarker.READONLY_PROPERTY) List(java.util.List) TypeChecked(groovy.transform.TypeChecked) BinaryExpression(org.codehaus.groovy.ast.expr.BinaryExpression) BlockStatement(org.codehaus.groovy.ast.stmt.BlockStatement) Modifier(java.lang.reflect.Modifier) Optional(java.util.Optional) Statement(org.codehaus.groovy.ast.stmt.Statement) ClassHelper.isWrapperShort(org.codehaus.groovy.ast.ClassHelper.isWrapperShort) GeneralUtils.constX(org.codehaus.groovy.ast.tools.GeneralUtils.constX) ClassHelper.int_TYPE(org.codehaus.groovy.ast.ClassHelper.int_TYPE) CodeVisitorSupport(org.codehaus.groovy.ast.CodeVisitorSupport) ElvisOperatorExpression(org.codehaus.groovy.ast.expr.ElvisOperatorExpression) Collection_TYPE(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.Collection_TYPE) StaticTypeCheckingSupport.findTargetVariable(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.findTargetVariable) WideningCategories.lowestUpperBound(org.codehaus.groovy.ast.tools.WideningCategories.lowestUpperBound) HashMap(java.util.HashMap) ClassHelper.isDynamicTyped(org.codehaus.groovy.ast.ClassHelper.isDynamicTyped) TokenUtil(org.codehaus.groovy.syntax.TokenUtil) AtomicReference(java.util.concurrent.atomic.AtomicReference) StaticTypeCheckingSupport.isVargs(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.isVargs) CompilationUnit(org.codehaus.groovy.control.CompilationUnit) CLOSURE_TYPE(org.codehaus.groovy.ast.ClassHelper.CLOSURE_TYPE) WideningCategories.isBigIntCategory(org.codehaus.groovy.ast.tools.WideningCategories.isBigIntCategory) MethodCallExpression(org.codehaus.groovy.ast.expr.MethodCallExpression) StaticTypeCheckingSupport.isCompareToBoolean(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.isCompareToBoolean) StaticTypeCheckingSupport.isParameterizedWithString(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.isParameterizedWithString) Byte_TYPE(org.codehaus.groovy.ast.ClassHelper.Byte_TYPE) ErrorCollector(org.codehaus.groovy.control.ErrorCollector) Iterator(java.util.Iterator) IntRange(groovy.lang.IntRange) ClosureSignatureConflictResolver(groovy.transform.stc.ClosureSignatureConflictResolver) GenericsUtils.makeClassSafe0(org.codehaus.groovy.ast.tools.GenericsUtils.makeClassSafe0) StaticTypeCheckingSupport.isUsingGenericsOrIsArrayUsingGenerics(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.isUsingGenericsOrIsArrayUsingGenerics) DeclarationExpression(org.codehaus.groovy.ast.expr.DeclarationExpression) StaticTypeCheckingSupport.isClassClassNodeWrappingConcreteType(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.isClassClassNodeWrappingConcreteType) StaticTypeCheckingSupport.isParameterizedWithGStringOrGStringString(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.isParameterizedWithGStringOrGStringString) NamedParam(groovy.transform.NamedParam) ClosureExpression(org.codehaus.groovy.ast.expr.ClosureExpression) StaticTypeCheckingSupport.applyGenericsConnections(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.applyGenericsConnections) StaticTypeCheckingSupport.fullyResolveType(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.fullyResolveType) SwitchStatement(org.codehaus.groovy.ast.stmt.SwitchStatement) StaticTypeCheckingSupport.isShiftOperation(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.isShiftOperation) FieldNode(org.codehaus.groovy.ast.FieldNode) AttributeExpression(org.codehaus.groovy.ast.expr.AttributeExpression) WideningCategories(org.codehaus.groovy.ast.tools.WideningCategories) AUTOCLOSEABLE_TYPE(org.codehaus.groovy.ast.ClassHelper.AUTOCLOSEABLE_TYPE) EQUAL(org.codehaus.groovy.syntax.Types.EQUAL) MOD(org.codehaus.groovy.syntax.Types.MOD) Collections(java.util.Collections) Iterator_TYPE(org.codehaus.groovy.ast.ClassHelper.Iterator_TYPE) ArrayList_TYPE(org.codehaus.groovy.transform.stc.StaticTypeCheckingSupport.ArrayList_TYPE) MethodNode(org.codehaus.groovy.ast.MethodNode) ArrayList(java.util.ArrayList)

Aggregations

ArrayList (java.util.ArrayList)3 Collection (java.util.Collection)3 List (java.util.List)3 Map (java.util.Map)3 Arrays (java.util.Arrays)2 Collections (java.util.Collections)2 HashMap (java.util.HashMap)2 HashSet (java.util.HashSet)2 Iterator (java.util.Iterator)2 LinkedHashMap (java.util.LinkedHashMap)2 LinkedHashSet (java.util.LinkedHashSet)2 LinkedList (java.util.LinkedList)2 Optional (java.util.Optional)2 Set (java.util.Set)2 StringJoiner (java.util.StringJoiner)2 GroovyBugError (org.codehaus.groovy.GroovyBugError)2 CLASS_Type (org.codehaus.groovy.ast.ClassHelper.CLASS_Type)2 CLOSURE_TYPE (org.codehaus.groovy.ast.ClassHelper.CLOSURE_TYPE)2 Number_TYPE (org.codehaus.groovy.ast.ClassHelper.Number_TYPE)2 OBJECT_TYPE (org.codehaus.groovy.ast.ClassHelper.OBJECT_TYPE)2