Thursday, 15 September 2011

inheritance - Scala: "class type required but {trait} with {trait} found" when inheriting from mixin type alias -


I have a very common type nickname defined:

  Package Object Policy Function0 [K]}  

with {type keyGen [K] serializable} but when I try to inherit it:

import Java.security.Key Case Class Fixed Keygen Key Keyword: KeyGen [Key] (Override Def) (): Key = Key} Expand

The Meowen Compiler gave me the following error:

  [error] / ho Me / peng / git / datapassport / core / src / main / scala / com / schedule1 / datapassport / policy / ValueMapping.scala16: class type is required but () = & gt; [ErrOR] ^ [ERROR] / home / peng / git / datapassport / core / src / main / scala: [Error] [key] extension of [key] key [key] / Com /schedule1/datapassport/policy/ValueMapping.scala16: com.schedule1.datapassport.policy.KeyGen [java.security.Key] does not have a manufacturer [Error] Case category Fixed keygen (key: key) Keygen [Key] { 

What's going on here?

T thinks that you are allowed to directly expand a compound type in that way. That is, Function0 [K] is not a class type and it's own, it's a mixed type without the connector, and this is the key to expand something without the constructor, in fact It does not seem that the type nickname does something like this (note the four brackets of the type):

  The case is fixed square (key: key) (function 0 [key] serialable With) override F Apply (): Key = Key}  

We get the same error:

  & lt; Console & gt; 20: Error: Class type is required but () => Fixed the category found with Java.security.Key Serializable Fixed keygen (key: key) (function 0 [key] with serial)   is not a class type. 

But, this definitely works if I remove the brackets without them, Fixed Kigen is expanding without Function0 and serialjob Shaking With it, it is trying to expand a compound type.

To work around it, you only want to use one attribute, instead:

  attribute keygen [k] Function with a serial case class that [ (Key: key) keygen (key) (override DRF): key = key}  

No comments:

Post a Comment