When generating a Java SDK with a property whose type is a Union<Any, something>, the builder methods are not compilable due to Java's erasure of generics at runtime.
public final class EntityStatusArgs extends com.pulumi.resources.ResourceArgs {
@Import(name="error")
private @Nullable Output<Either<Output<Object>,EntityStatusErrorPropertiesArgs>> error;
public static final class Builder {
public Builder error(@Nullable Output<Either<Output<Object>,EntityStatusErrorPropertiesArgs>> error) {
$.error = error;
return this;
}
public Builder error(Either<Output<Object>,EntityStatusErrorPropertiesArgs> error) {
return error(Output.of(error));
}
public Builder error(Output<Object> error) {
return error(Either.ofLeft(error));
}
public Builder error(EntityStatusErrorPropertiesArgs error) {
return error(Either.ofRight(error));
}
}
}
Compiler error
/home/runner/work/pulumi-aws-native/pulumi-aws-native/sdk/java/src/main/java/com/pulumi/awsnative/iottwinmaker/inputs/EntityStatusArgs.java:69: error: name clash: error(Output<Object>) and error(Output<Either<Output<Object>,EntityStatusErrorPropertiesArgs>>) have the same erasure
public Builder error(Output<Object> error) {
When generating a Java SDK with a property whose type is a
Union<Any, something>
, the builder methods are not compilable due to Java's erasure of generics at runtime.This could possibly be addressed in this piece of code: https://github.com/pulumi/pulumi-java/blob/f7468e19e755561d2a8770ebcc0374245c424b29/pkg/codegen/java/gen_program_expressions.go#L536
Schema
Generated code
Compiler error