Hi I have a kotlin warning that I don't understand...
# getting-started
n
Hi I have a kotlin warning that I don't understand. I have an enum type parameter, eg:
Copy code
enum class FileOperationType {
    DOWNLOAD,
    DOWNLOAD_AND_MOVE,
    DOWNLOAD_AND_REMOVE
}
and a function which expects a parameter of that type.
Copy code
fun downloadAllToLocalFolder(
    fileOperation: FileOperation, 
...
In a test I invoke that function:
Copy code
target.downloadAllToLocalFolder(
    FileOperation(DOWNLOAD ...
In this line kotlin issues this warning: Unexpected fileOperation: DOWNLOAD what does it mean?
All enum values are handled in the function. I tried anyway with the other values but the warning remains (obviously changing its target eg unexpected type fileOperation.DOWNLOAD_AND_REMOVE and so on)
s
The type of the enum,
FileOperationType
, doesn't seem to be the same as the type of the function parameter,
FileOperation
. Is that mismatch the cause of the problem?
n
I forgot an important piece. Actually the function parameter is FileOperation which contains FileOperation Type
Copy code
data class FileOperation(
    val type: FileOperationType,
    val hostSourceFolder: FolderName,
    val localDestinationFolder: FolderName,
    val hostDestinationFolder: FolderName? = null
)
The line which calls the function builds a FileOperation instance, the first parameter is the "type":
Copy code
target.downloadAllToLocalFolder(
    FileOperation(DOWNLOAD, "/$remotePath", outputFolderPath),
...
c
Can you try to reproduce the warning on https://play.kotlinlang.org/ ? We definitely don't have enough information here to tell you what's going on
n
Thanks for the suggestion, I am trying to port the code there line by line
with empty function the warning doesn't show up, I will add one line at a time to see which one causes the warning