@Override public void visitLambda(JCLambda that) { if (that.paramKind == ParameterKind.EXPLICIT) { //if lambda is explicit, we can save info in the corresponding argument type processArg(that, () -> { JCLambda speculativeLambda = deferredAttr.attribSpeculativeLambda(that, env, attr.methodAttrInfo); return new ExplicitLambdaType(that, env, speculativeLambda); }); } else { //otherwise just use a deferred type setResult(that, deferredAttr.new DeferredType(that, env)); } }
@Override @DefinedBy(Api.COMPILER_TREE) public JCTree visitLambdaExpression(LambdaExpressionTree node, Void _unused) { JCLambda oldLambda = (JCLambda)node; JCLambda newLambda = (JCLambda)super.visitLambdaExpression(node, _unused); if (oldLambda.paramKind == ParameterKind.IMPLICIT) { //reset implicit lambda parameters (whose type might have been set during attr) newLambda.paramKind = ParameterKind.IMPLICIT; newLambda.params.forEach(p -> p.vartype = null); } return newLambda; }
public List<JCVariableDecl> inlineParams(Inliner inliner) throws CouldNotResolveImportException { if (parameterKind() == ParameterKind.EXPLICIT) { return List.convert(JCVariableDecl.class, inliner.inlineList(getParameters())); } ListBuffer<JCVariableDecl> params = new ListBuffer<>(); for (UVariableDecl param : getParameters()) { params.add(param.inlineImplicitType(inliner)); } return params.toList(); }
public static ULambda create( ParameterKind parameterKind, Iterable<UVariableDecl> parameters, UTree<?> body) { return new AutoValue_ULambda(parameterKind, ImmutableList.copyOf(parameters), body); }
abstract ParameterKind parameterKind();