{"action":"created","issue":{"url":"https://api.github.com/repos/google/j2objc/issues/783","repository_url":"https://api.github.com/repos/google/j2objc","labels_url":"https://api.github.com/repos/google/j2objc/issues/783/labels{/name}","comments_url":"https://api.github.com/repos/google/j2objc/issues/783/comments","events_url":"https://api.github.com/repos/google/j2objc/issues/783/events","html_url":"https://github.com/google/j2objc/issues/783","id":172969873,"number":783,"title":"Enums are broken since 1.0?","user":{"login":"davidganster","id":851282,"avatar_url":"https://avatars.githubusercontent.com/u/851282?v=3","gravatar_id":"","url":"https://api.github.com/users/davidganster","html_url":"https://github.com/davidganster","followers_url":"https://api.github.com/users/davidganster/followers","following_url":"https://api.github.com/users/davidganster/following{/other_user}","gists_url":"https://api.github.com/users/davidganster/gists{/gist_id}","starred_url":"https://api.github.com/users/davidganster/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/davidganster/subscriptions","organizations_url":"https://api.github.com/users/davidganster/orgs","repos_url":"https://api.github.com/users/davidganster/repos","events_url":"https://api.github.com/users/davidganster/events{/privacy}","received_events_url":"https://api.github.com/users/davidganster/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":8,"created_at":"2016-08-24T14:39:29Z","updated_at":"2016-08-31T13:42:36Z","closed_at":null,"body":"In 0.9.8.2.1, the following enum compiled just fine:\r\n\r\n```java\r\npublic class LogLevel {\r\n\r\n    public static final LogLevel DEBUG   = new LogLevel(0);\r\n    public static final LogLevel VERBOSE = new LogLevel(1);\r\n    public static final LogLevel INFO    = new LogLevel(2);\r\n    public static final LogLevel WARN    = new LogLevel(3);\r\n    public static final LogLevel ERROR   = new LogLevel(4);\r\n\r\n    private int level;\r\n    private LogLevel(int level) { this.level = level; }\r\n    public boolean smallerThanOrEqualTo(LogLevel o) {\r\n        return this.level <= o.level;\r\n    }\r\n\r\n}\r\n```\r\n\r\nIt would translate to:\r\n\r\n```objective-c\r\n#ifndef ComPackageName.h\r\n#define ComPackageName.h\r\n\r\n#include \"J2ObjC_header.h\"\r\n\r\n@interface SCLLogLevel : NSObject\r\n\r\n#pragma mark Public\r\n\r\n- (jboolean)smallerThanOrEqualToWithSCLLogLevel:(SCLLogLevel *)o;\r\n\r\n@end\r\n\r\nJ2OBJC_STATIC_INIT(SCLLogLevel)\r\n\r\nFOUNDATION_EXPORT SCLLogLevel *SCLLogLevel_DEBUG__;\r\nJ2OBJC_STATIC_FIELD_GETTER(SCLLogLevel, DEBUG__, SCLLogLevel *)\r\n\r\nFOUNDATION_EXPORT SCLLogLevel *SCLLogLevel_VERBOSE_;\r\nJ2OBJC_STATIC_FIELD_GETTER(SCLLogLevel, VERBOSE_, SCLLogLevel *)\r\n\r\nFOUNDATION_EXPORT SCLLogLevel *SCLLogLevel_INFO_;\r\nJ2OBJC_STATIC_FIELD_GETTER(SCLLogLevel, INFO_, SCLLogLevel *)\r\n\r\nFOUNDATION_EXPORT SCLLogLevel *SCLLogLevel_WARN_;\r\nJ2OBJC_STATIC_FIELD_GETTER(SCLLogLevel, WARN_, SCLLogLevel *)\r\n\r\nFOUNDATION_EXPORT SCLLogLevel *SCLLogLevel_ERROR_;\r\nJ2OBJC_STATIC_FIELD_GETTER(SCLLogLevel, ERROR_, SCLLogLevel *)\r\n\r\nJ2OBJC_TYPE_LITERAL_HEADER(SCLLogLevel)\r\n\r\n@compatibility_alias ComPackagenameLoggingLevel SCLLogLevel;\r\n\r\n#endif // ComPackageName.h\r\n```\r\n\r\nBut, since 1.0 it translates to\r\n\r\n```objective-c\r\n#include \"J2ObjC_header.h\"\r\n\r\n#pragma push_macro(\"ComPackageNameLoggingLogLevel_INCLUDE_ALL\")\r\n#ifdef ComPackageNameLoggingLogLevel_RESTRICT\r\n#define ComPackageNameLoggingLogLevel_INCLUDE_ALL 0\r\n#else\r\n#define ComPackageNameLoggingLogLevel_INCLUDE_ALL 1\r\n#endif\r\n#undef ComPackageNameLoggingLogLevel_RESTRICT\r\n\r\n#if !defined (SCLLogLevel_) && (ComPackageNameLoggingLogLevel_INCLUDE_ALL || defined(SCLLogLevel_INCLUDE))\r\n#define SCLLogLevel_\r\n\r\n@interface SCLLogLevel : NSObject\r\n\r\n#pragma mark Public\r\n\r\n- (jboolean)smallerThanOrEqualToWithSCLLogLevel:(SCLLogLevel *)o;\r\n\r\n@end\r\n\r\nJ2OBJC_STATIC_INIT(SCLLogLevel)\r\n\r\ninline SCLLogLevel *SCLLogLevel_get_DEBUG();\r\n/*! INTERNAL ONLY - Use accessor function from above. */\r\nFOUNDATION_EXPORT SCLLogLevel *SCLLogLevel_DEBUG;\r\nJ2OBJC_STATIC_FIELD_OBJ_FINAL(SCLLogLevel, DEBUG, SCLLogLevel *)\r\n\r\ninline SCLLogLevel *SCLLogLevel_get_VERBOSE();\r\n/*! INTERNAL ONLY - Use accessor function from above. */\r\nFOUNDATION_EXPORT SCLLogLevel *SCLLogLevel_VERBOSE;\r\nJ2OBJC_STATIC_FIELD_OBJ_FINAL(SCLLogLevel, VERBOSE, SCLLogLevel *)\r\n\r\ninline SCLLogLevel *SCLLogLevel_get_INFO();\r\n/*! INTERNAL ONLY - Use accessor function from above. */\r\nFOUNDATION_EXPORT SCLLogLevel *SCLLogLevel_INFO;\r\nJ2OBJC_STATIC_FIELD_OBJ_FINAL(SCLLogLevel, INFO, SCLLogLevel *)\r\n\r\ninline SCLLogLevel *SCLLogLevel_get_WARN();\r\n/*! INTERNAL ONLY - Use accessor function from above. */\r\nFOUNDATION_EXPORT SCLLogLevel *SCLLogLevel_WARN;\r\nJ2OBJC_STATIC_FIELD_OBJ_FINAL(SCLLogLevel, WARN, SCLLogLevel *)\r\n\r\ninline SCLLogLevel *SCLLogLevel_get_ERROR();\r\n/*! INTERNAL ONLY - Use accessor function from above. */\r\nFOUNDATION_EXPORT SCLLogLevel *SCLLogLevel_ERROR;\r\nJ2OBJC_STATIC_FIELD_OBJ_FINAL(SCLLogLevel, ERROR, SCLLogLevel *)\r\n\r\nJ2OBJC_TYPE_LITERAL_HEADER(SCLLogLevel)\r\n\r\n@compatibility_alias ComPackageNameLoggingLogLevel SCLLogLevel;\r\n\r\n#endif\r\n\r\n#pragma pop_macro(\"ComPackageNameLoggingLogLevel_INCLUDE_ALL\")\r\n```\r\n\r\nWhich doesn't compile in Xcode 7.3.1.\r\nThe error message says:\r\n\r\n`Interface type 'SCLLogLevel' cannot be passed by value; did you forget * in 'SCLLogLevel'?`\r\n`Conflicting types for 'J2OBJC_STATIC_FIELD_OBJ_FINAL'`\r\n`Expected ';' after top level declarator`\r\n\r\nand a warning in the same line:\r\n`Type specifier missing, defaults to 'int'`.\r\n\r\nI'm using the j2objc-gradle plugin to do the translation, but I don't think that's the problem, since the translated files themselves seem to be erroneous.\r\n\r\nAny ideas as to what is going wrong here?"},"comment":{"url":"https://api.github.com/repos/google/j2objc/issues/comments/243767688","html_url":"https://github.com/google/j2objc/issues/783#issuecomment-243767688","issue_url":"https://api.github.com/repos/google/j2objc/issues/783","id":243767688,"user":{"login":"kstanger","id":6548109,"avatar_url":"https://avatars.githubusercontent.com/u/6548109?v=3","gravatar_id":"","url":"https://api.github.com/users/kstanger","html_url":"https://github.com/kstanger","followers_url":"https://api.github.com/users/kstanger/followers","following_url":"https://api.github.com/users/kstanger/following{/other_user}","gists_url":"https://api.github.com/users/kstanger/gists{/gist_id}","starred_url":"https://api.github.com/users/kstanger/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kstanger/subscriptions","organizations_url":"https://api.github.com/users/kstanger/orgs","repos_url":"https://api.github.com/users/kstanger/repos","events_url":"https://api.github.com/users/kstanger/events{/privacy}","received_events_url":"https://api.github.com/users/kstanger/received_events","type":"User","site_admin":false},"created_at":"2016-08-31T13:42:36Z","updated_at":"2016-08-31T13:42:36Z","body":"The names of inner types will be appended to the name of the outer type with an underscore delimiter. So in your case your enum type will be called \"MyClass_EnumName\".\r\n\r\nThe preprocessor macros that you're seeing are part of [Segmented Headers](http://j2objc.org/docs/Segmented-Headers.html), which as far as I know are not a problem for Swift bridging, but I could be wrong. They can be disabled with `--no-segmented-headers`"}}
{"actor":{"display_login":"kstanger"}}