Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions java/src/com/google/template/soy/jbcsrc/ExpressionCompiler.java
Original file line number Diff line number Diff line change
Expand Up @@ -1615,7 +1615,7 @@ private SoyExpression visitFieldAccess(SoyExpression baseExpr, FieldAccessNode n
if (sourceMethod != null) {
Optional<Extern> externApi = ExternAdaptors.asExtern(sourceMethod, args);
if (externApi.isPresent()) {
return callExtern(externApi.get(), args);
return callExtern(externApi.get(), args, node.getType());
}
return sourceFunctionCompiler.compile(node, sourceMethod, args, parameters, detacher);
}
Expand Down Expand Up @@ -1771,7 +1771,7 @@ var record = (RecordLiteralNode) node.getChild(1);
visitAllParams(node, ImmutableList.<SoyExpression>builder().add(baseExpr));
Optional<Extern> externApi = ExternAdaptors.asExtern(sourceMethod, args);
if (externApi.isPresent()) {
return callExtern(externApi.get(), args);
return callExtern(externApi.get(), args, node.getType());
}
return sourceFunctionCompiler.compile(node, sourceMethod, args, parameters, detacher);
}
Expand Down Expand Up @@ -2023,13 +2023,14 @@ SoyExpression visitPluginFunction(FunctionNode node) {
return callExtern(
ExternAdaptors.asExtern(
(SoyJavaExternFunction) fn, args, node.getType(), node.getAllowedParamTypes()),
args);
args,
node.getType());
} else if (fn instanceof SoyJavaSourceFunction) {
ImmutableList<SoyExpression> args = visitAllParams(node);
return sourceFunctionCompiler.compile(
node, (SoyJavaSourceFunction) fn, args, parameters, detacher);
} else if (fn instanceof Extern) {
return callExtern((Extern) fn, visitAllParams(node));
return callExtern((Extern) fn, visitAllParams(node), node.getType());
} else if (fn == FunctionNode.FUNCTION_POINTER) {
FunctionType functionType = node.getNameExpr().getType().asType(FunctionType.class);
SoyRuntimeType soyReturnType = ExternCompiler.getRuntimeType(functionType.getReturnType());
Expand Down Expand Up @@ -2107,7 +2108,8 @@ private ImmutableList<SoyExpression> visitAllParams(
return builder.build();
}

private SoyExpression callExtern(Extern extern, List<SoyExpression> params) {
private SoyExpression callExtern(
Extern extern, List<SoyExpression> params, SoyType resolvedReturnType) {
SourceLogicalPath path = extern.getPath();
JavaImpl javaImpl = extern.getJavaImpl();
boolean hasJavaImpl = javaImpl != null || extern.hasAutoImpl();
Expand All @@ -2125,7 +2127,7 @@ private SoyExpression callExtern(Extern extern, List<SoyExpression> params) {
linkStatically = hasJavaImpl && owningFile.getSoyFileKind() == SoyFileKind.SRC;
}
FunctionType functionType = extern.getSignature();
SoyRuntimeType soyReturnType = ExternCompiler.getRuntimeType(functionType.getReturnType());
SoyRuntimeType soyReturnType = ExternCompiler.getRuntimeType(resolvedReturnType);
boolean requiresRenderContext = !linkStatically || requiresRenderContext(extern);

if (extern.isJavaAsync()) {
Expand Down Expand Up @@ -2199,7 +2201,7 @@ private SoyExpression callExtern(Extern extern, List<SoyExpression> params) {
externCall =
ExternCompiler.adaptReturnType(
getTypeInfoForJavaImpl(javaImpl.returnType().className()).type(),
functionType.getReturnType(),
resolvedReturnType,
externCall);
// Allow ExternSourceFunction to return a boxed value.
if (isDefinitelyAssignableFrom(SOY_VALUE_TYPE, externCall.resultType())) {
Expand Down
Loading