Given java classes "abstract Credentials" and deriving "EmailPassword"/"OAuth" classes.
and interface CredentialsStorage, with appropriate implementations EmailPasswordStorage and OAuthStorage
I need to create some sort of an array with triples: storage, valid credentials, invalid credentials)
So I started with this:
type T <: Credentials
type S <: CredentialsStorage[T]
private var testData: Array[(S, T, T)] = Array(
(emailStorage, validEmailPasswd, new EmailPasswordCredentials("1", "2")),
(oAuthStorage, validAuthToken, new OAuthCredentials("invalid auth token", OAuthService.FACEBOOK))
)
however this doesn't compile
error: type mismatch;
found : storage.EmailPasswordStorage[credentials.EmailPassword]
required: CredentialsStorageTest.this.S
(emailStorage, validEmailPasswd, new EmailPasswordCredentials("1", "2")),
how do I fix this problem and what is the correct definition of dependent/existential types here?
UPD I solved the problem with definition of tuple type itself:
type T[A] = (CredentialsStorage[A],A,A)
val testData : Array[T[_ <: Credentials]] = ...
type T <: Credentials
defines an abstract type. You haven't defined what T
is in this instance. Try including type T = credentials.EmailPassword
and type S = storage.EmailPasswordStorage[T]
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.