diff --git a/pkg/codegen/java/gen_program.go b/pkg/codegen/java/gen_program.go index 7b6ef33f3da..34228f86ef8 100644 --- a/pkg/codegen/java/gen_program.go +++ b/pkg/codegen/java/gen_program.go @@ -1274,9 +1274,9 @@ func (g *generator) genLocalVariable(w io.Writer, localVariable *pcl.LocalVariab g.genIndent(w) if isInvokeCall { g.functionInvokes[variableName] = functionSchema - // TODO: lowerExpression isn't what we expect: function call should extract outputs into .apply(...) calls - // functionDefinitionWithApplies := g.lowerExpression(functionDefinition, localVariable.Definition.Value.Type()) - g.Fgenf(w, "final var %s = %v;\n", variableName, localVariable.Definition.Value) + invokeCall := localVariable.Definition.Value.(*model.FunctionCallExpression) + functionDefinitionWithApplies := g.lowerExpression(invokeCall, invokeCall.Signature.ReturnType) + g.Fgenf(w, "final var %s = %v;\n", variableName, functionDefinitionWithApplies) } else { variable := localVariable.Definition.Value g.Fgenf(w, "final var %s = %v;\n", variableName, g.lowerExpression(variable, variable.Type())) diff --git a/pkg/codegen/java/gen_program_expressions.go b/pkg/codegen/java/gen_program_expressions.go index 6b2190fad0c..1c713adfd1f 100644 --- a/pkg/codegen/java/gen_program_expressions.go +++ b/pkg/codegen/java/gen_program_expressions.go @@ -101,7 +101,7 @@ func (g *generator) GenAnonymousFunctionExpression(w io.Writer, expr *model.Anon return x, nil } - _, diags := model.VisitExpression(expr.Body, modifier, nil) + _, diags := model.VisitExpression(expr.Body, model.IdentityVisitor, modifier) contract.Assertf(len(diags) == 0, "unexpected diagnostics when rewriting parameter name") g.Fgenf(w, "%s", modifiedParamName) g.Fgenf(w, " -> %v", expr.Body) diff --git a/pkg/codegen/testing/test/testdata/aws-fargate-pp/java/aws-fargate.java b/pkg/codegen/testing/test/testdata/aws-fargate-pp/java/aws-fargate.java index b3137b82e95..a3ff05e3710 100644 --- a/pkg/codegen/testing/test/testdata/aws-fargate-pp/java/aws-fargate.java +++ b/pkg/codegen/testing/test/testdata/aws-fargate-pp/java/aws-fargate.java @@ -49,12 +49,12 @@ public static void stack(Context ctx) { .build()); final var subnets = Ec2Functions.getSubnetIds(GetSubnetIdsArgs.builder() - .vpcId(vpc.applyValue(getVpcResult -> getVpcResult.id())) + .vpcId(vpc.id()) .build()); // Create a security group that permits HTTP ingress and unrestricted egress. var webSecurityGroup = new SecurityGroup("webSecurityGroup", SecurityGroupArgs.builder() - .vpcId(vpc.applyValue(getVpcResult -> getVpcResult.id())) + .vpcId(vpc.id()) .egress(SecurityGroupEgressArgs.builder() .protocol("-1") .fromPort(0) @@ -95,7 +95,7 @@ public static void stack(Context ctx) { // Create a load balancer to listen for HTTP traffic on port 80. var webLoadBalancer = new LoadBalancer("webLoadBalancer", LoadBalancerArgs.builder() - .subnets(subnets.applyValue(getSubnetIdsResult -> getSubnetIdsResult.ids())) + .subnets(subnets.ids()) .securityGroups(webSecurityGroup.id()) .build()); @@ -103,7 +103,7 @@ public static void stack(Context ctx) { .port(80) .protocol("HTTP") .targetType("ip") - .vpcId(vpc.applyValue(getVpcResult -> getVpcResult.id())) + .vpcId(vpc.id()) .build()); var webListener = new Listener("webListener", ListenerArgs.builder() @@ -142,7 +142,7 @@ public static void stack(Context ctx) { .taskDefinition(appTask.arn()) .networkConfiguration(ServiceNetworkConfigurationArgs.builder() .assignPublicIp(true) - .subnets(subnets.applyValue(getSubnetIdsResult -> getSubnetIdsResult.ids())) + .subnets(subnets.ids()) .securityGroups(webSecurityGroup.id()) .build()) .loadBalancers(ServiceLoadBalancerArgs.builder() diff --git a/pkg/codegen/testing/test/testdata/aws-s3-folder-pp/java/aws-s3-folder.java b/pkg/codegen/testing/test/testdata/aws-s3-folder-pp/java/aws-s3-folder.java index 2806737ed34..18502058e60 100644 --- a/pkg/codegen/testing/test/testdata/aws-s3-folder-pp/java/aws-s3-folder.java +++ b/pkg/codegen/testing/test/testdata/aws-s3-folder-pp/java/aws-s3-folder.java @@ -10,10 +10,10 @@ import com.pulumi.aws.s3.BucketObjectArgs; import com.pulumi.aws.s3.BucketPolicy; import com.pulumi.aws.s3.BucketPolicyArgs; +import com.pulumi.asset.FileArchive; +import static com.pulumi.codegen.internal.Files.readDir; import static com.pulumi.codegen.internal.Serialization.*; import com.pulumi.codegen.internal.KeyedValue; -import static com.pulumi.codegen.internal.Files.readDir; -import com.pulumi.asset.FileAsset; import java.util.List; import java.util.ArrayList; import java.util.Map; @@ -50,14 +50,14 @@ public static void stack(Context ctx) { // Set the access policy for the bucket so all objects are readable var bucketPolicy = new BucketPolicy("bucketPolicy", BucketPolicyArgs.builder() .bucket(siteBucket.id()) - .policy(siteBucket.id().applyValue(id -> serializeJson( + .policy(siteBucket.id().applyValue(_id -> serializeJson( jsonObject( jsonProperty("Version", "2012-10-17"), jsonProperty("Statement", jsonArray(jsonObject( jsonProperty("Effect", "Allow"), jsonProperty("Principal", "*"), jsonProperty("Action", jsonArray("s3:GetObject")), - jsonProperty("Resource", jsonArray(String.format("arn:aws:s3:::%s/*", id))) + jsonProperty("Resource", jsonArray(String.format("arn:aws:s3:::%s/*", _id))) ))) )))) .build()); diff --git a/pkg/codegen/testing/test/testdata/aws-s3-logging-pp/java/aws-s3-logging.java b/pkg/codegen/testing/test/testdata/aws-s3-logging-pp/java/aws-s3-logging.java index 3ee29c0c28d..06b5f259316 100644 --- a/pkg/codegen/testing/test/testdata/aws-s3-logging-pp/java/aws-s3-logging.java +++ b/pkg/codegen/testing/test/testdata/aws-s3-logging-pp/java/aws-s3-logging.java @@ -34,6 +34,6 @@ public static void stack(Context ctx) { .source(Files.readString(Paths.get("./index.html"))) .build()); - ctx.export("targetBucket", bucket.loggings().applyValue(loggings -> loggings[0].targetBucket())); + ctx.export("targetBucket", bucket.loggings().applyValue(_loggings -> _loggings[0].targetBucket())); } } diff --git a/pkg/codegen/testing/test/testdata/aws-webserver-pp/java/aws-webserver.java b/pkg/codegen/testing/test/testdata/aws-webserver-pp/java/aws-webserver.java index 144bdbbefb6..7f098b053f2 100644 --- a/pkg/codegen/testing/test/testdata/aws-webserver-pp/java/aws-webserver.java +++ b/pkg/codegen/testing/test/testdata/aws-webserver-pp/java/aws-webserver.java @@ -48,7 +48,7 @@ public static void stack(Context ctx) { .tags(Map.of("Name", "web-server-www")) .instanceType("t2.micro") .securityGroups(securityGroup.name()) - .ami(ami.applyValue(getAmiResult -> getAmiResult.id())) + .ami(ami.id()) .userData(""" #!/bin/bash echo "Hello, World!" > index.html diff --git a/pkg/codegen/testing/test/testdata/azure-sa-pp/java/azure-sa.java b/pkg/codegen/testing/test/testdata/azure-sa-pp/java/azure-sa.java index 4bee48076ee..b8d6f0b967a 100644 --- a/pkg/codegen/testing/test/testdata/azure-sa-pp/java/azure-sa.java +++ b/pkg/codegen/testing/test/testdata/azure-sa-pp/java/azure-sa.java @@ -27,7 +27,7 @@ public static void stack(Context ctx) { .name(resourceGroupNameParam) .build()); - final var locationParam = config.get("locationParam").orElse(resourceGroupVar.applyValue(getResourceGroupResult -> getResourceGroupResult.location())); + final var locationParam = config.get("locationParam").orElse(resourceGroupVar.location()); final var storageAccountTierParam = config.get("storageAccountTierParam").orElse("Standard"); final var storageAccountTypeReplicationParam = config.get("storageAccountTypeReplicationParam").orElse("LRS"); var storageAccountResource = new Account("storageAccountResource", AccountArgs.builder() diff --git a/pkg/codegen/testing/test/testdata/output-funcs-aws-pp/java/output-funcs-aws.java b/pkg/codegen/testing/test/testdata/output-funcs-aws-pp/java/output-funcs-aws.java index 5e2b54816be..3e675aef1b9 100644 --- a/pkg/codegen/testing/test/testdata/output-funcs-aws-pp/java/output-funcs-aws.java +++ b/pkg/codegen/testing/test/testdata/output-funcs-aws-pp/java/output-funcs-aws.java @@ -51,7 +51,7 @@ public static void stack(Context ctx) { .egress(false) .protocol("tcp") .ruleAction("allow") - .cidrBlock(privateS3PrefixList.applyValue(getPrefixListResult -> getPrefixListResult).applyValue(privateS3PrefixList -> privateS3PrefixList.applyValue(getPrefixListResult -> getPrefixListResult.cidrBlocks()[0]))) + .cidrBlock(privateS3PrefixList.applyValue(_privateS3PrefixList -> _privateS3PrefixList.cidrBlocks()[0])) .fromPort(443) .toPort(443) .build());