Type arguments [org.testcontainers.containers.PostgreSQLContainer[_]] do not conform to class PostgreSQLContainer's type parameter bounds [SELF <: org.testcontainers.containers.PostgreSQLContainer[SELF]]

I am trying to use library testcontainers which has following contract
PostgreSQLContainer<SELF extends PostgreSQLContainer<SELF>> [0]. I am not sure how to create a new instance for that because when creating with

val postgresql = new PostgreSQLContainer[_]("postgres:9.6.2")

the compiler complains

class type required but org.testcontainers.containers.PostgreSQLContainer[_] found

And if creating with

val postgresql = new PostgreSQLContainer[PostgreSQLContainer[_]]("postgres:9.6.2").withUsername("test").withPassword("test") 

the compiler throws error

type arguments [org.testcontainers.containers.PostgreSQLContainer[_]] do not conform to class PostgreSQLContainer's type parameter bounds [SELF <: org.testcontainers.containers.PostgreSQLContainer[SELF]]

And if creating with statement

val postgresql = new PostgreSQLContainer("postgres:9.6.2").withUsername("test").withPassword("test")

error value withPassword is not a member of Nothing is thrown.

I can new instance with just val postgresql = new PostgreSQLContainer("postgres:9.6.2"), but that’s not what I want because I want to change username and password.

What is the right way to instantiate this class in scala way?

Thanks

  1. https://github.com/testcontainers/testcontainers-java/blob/master/modules/postgresql/src/main/java/org/testcontainers/containers/PostgreSQLContainer.java

What about this?

class SPostgreSQLContainer(v: String) extends PostgreSQLContainer[SPostgreSQLContainer](v)

new SPostgreSQLContainer("postgres:9.6.2").withUsername("test").withPassword("test")

If that doesn’t work for some reason, I see that they have a scala library which specifically says:

testcontainers-java is awesome and yes, you can use it in scala projects as is but there are some problems initializing containers due to DockerComposeContainer<SELF extends DockerComposeContainer<SELF>>