Get an error "enum switch case label must be the unqualified name" even thought using correct switch case

Viewed 75

I have enum from third party library like this

public enum ErrorCode {
   TIMEOUT,
   UNKNOWN,
   CANCELLED
}

I am using swith case in my code like this

ErrorCode errorCode = result.errorCode; -> from API

switch(errorCode) {
 case TIMEOUT:
   return ...
 case UNKNOWN:
   return ...
 case CANCELLED:
   return ...
}

but when build i got an error like this

error: an enum switch case label must be the unqualified name of an enumeration constant
case CANCELLED:
     ^

Background : CANCELLED is newly added enum from third party on same version of library that i use

illustarion: I used version 1.5.0 enum before is like this

public enum ErrorCode {
   TIMEOUT,
   UNKNOWN
}

then third party update enum in version 1.5.0 become like this

public enum ErrorCode {
   TIMEOUT,
   UNKNOWN,
   CANCELLED
}

I don't know why this happen only in one enum. Can you help me to explain why this issue is happen and how to fix this problem ?

0 Answers
Related