Search in sources :

Example 1 with MapTypeContext

use of dyvilx.tools.compiler.ast.generic.MapTypeContext in project Dyvil by Dyvil.

the class LambdaExpr method inferReturnType.

public void inferReturnType(IType type, IType valueType) {
    if (this.hasImplicitReturnType()) {
        this.returnType = valueType;
    }
    if ((this.flags & LAMBDA_TYPE_INFERRED) != 0 || type.canExtract(LambdaType.class)) {
        this.type = this.makeType();
        return;
    }
    final ITypeContext tempContext = new MapTypeContext();
    final ParameterList methodParams = this.method.getParameters();
    final int size = Math.min(this.parameters.size(), methodParams.size());
    for (int i = 0; i < size; i++) {
        final IParameter lambdaParam = this.parameters.get(i);
        final IParameter methodParam = methodParams.get(i);
        methodParam.getType().inferTypes(lambdaParam.getType(), tempContext);
    }
    this.method.getType().inferTypes(valueType, tempContext);
    final IType classType = this.method.getEnclosingClass().getThisType();
    this.type = classType.getConcreteType(tempContext);
}
Also used : LambdaType(dyvilx.tools.compiler.ast.type.compound.LambdaType) MapTypeContext(dyvilx.tools.compiler.ast.generic.MapTypeContext) ITypeContext(dyvilx.tools.compiler.ast.generic.ITypeContext) IType(dyvilx.tools.compiler.ast.type.IType)

Aggregations

ITypeContext (dyvilx.tools.compiler.ast.generic.ITypeContext)1 MapTypeContext (dyvilx.tools.compiler.ast.generic.MapTypeContext)1 IType (dyvilx.tools.compiler.ast.type.IType)1 LambdaType (dyvilx.tools.compiler.ast.type.compound.LambdaType)1