Title: Bug in generated code with @RootContext · Issue #2203 · androidannotations/androidannotations · GitHub
Open Graph Title: Bug in generated code with @RootContext · Issue #2203 · androidannotations/androidannotations
X Title: Bug in generated code with @RootContext · Issue #2203 · androidannotations/androidannotations
Description: Hi, when using a method to inject the Context, and a class which is different than Context is used, the generated code is not correct. I saw this issue while testing #2202 , both annotations have the same bug then. (Note I tested with th...
Open Graph Description: Hi, when using a method to inject the Context, and a class which is different than Context is used, the generated code is not correct. I saw this issue while testing #2202 , both annotations have t...
X Description: Hi, when using a method to inject the Context, and a class which is different than Context is used, the generated code is not correct. I saw this issue while testing #2202 , both annotations have t...
Opengraph URL: https://github.com/androidannotations/androidannotations/issues/2203
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Bug in generated code with @RootContext","articleBody":"Hi, when using a method to inject the Context, and a class which is different than `Context` is used, the generated code is not correct. \r\n\r\nI saw this issue while testing #2202 , both annotations have the same bug then. (Note I tested with the normal \"develop\" branch, to be sure this was not related to the changes on #2202). \r\n\r\n**Annotated code**:\r\n```java\r\n@EBean\r\npublic class MainViewModel {\r\n\r\n @RootContext\r\n void someMethod(Activity anything) {\r\n //Some code\r\n }\r\n\r\n}\r\n```\r\n\r\n**Expected generated code**:\r\n```java\r\n private void init_() {\r\n if (context_ instanceof Activity) {\r\n Activity anything = ((Activity) context_);\r\n someMethod2(anything);\r\n } else {\r\n Log.w(\"MainViewModel_\", ((\"Due to Context class \"+ context_.getClass().getSimpleName())+\", the @RootContext Activity won't be populated\"));\r\n }\r\n }\r\n```\r\n\r\n**Actual generated code**:\r\n```java\r\n private void init_() {\r\n {\r\n Activity anything = null;\r\n someMethod2(anything);\r\n }\r\n if (context_ instanceof Activity) {\r\n anything = ((Activity) context_);\r\n } else {\r\n Log.w(\"MainViewModel_\", ((\"Due to Context class \"+ context_.getClass().getSimpleName())+\", the @RootContext Activity won't be populated\"));\r\n }\r\n }\r\n```\r\n\r\nThe code doesn't compile in general since the field in the \"if (context ...\" block `anything` doens't exist\r\n","author":{"url":"https://github.com/smaugho","@type":"Person","name":"smaugho"},"datePublished":"2019-02-14T23:30:52.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":1},"url":"https://github.com/2203/androidannotations/issues/2203"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:7273c67c-2df8-83b5-1be0-f386a6390a50 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B9DC:240924:17A40D9:2009333:6A62E5DC |
| html-safe-nonce | a36168e5133911314dd773d656e96ad866ce78f1de0ffbb5e50f4be834ef0df7 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCOURDOjI0MDkyNDoxN0E0MEQ5OjIwMDkzMzM6NkE2MkU1REMiLCJ2aXNpdG9yX2lkIjoiODAxMTgyNzk3MTM1ODkwOTkxNyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 8d83414789240974d35701bcb8fe6e6b70758885c090f47a9e89c77855e3c748 |
| hovercard-subject-tag | issue:410539363 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/androidannotations/androidannotations/2203/issue_layout |
| twitter:image | https://opengraph.githubassets.com/60df93d655d80936d05da2e14f290a1d33e7b8e6d69c56c17c2c2a9ff3ffab82/androidannotations/androidannotations/issues/2203 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/60df93d655d80936d05da2e14f290a1d33e7b8e6d69c56c17c2c2a9ff3ffab82/androidannotations/androidannotations/issues/2203 |
| og:image:alt | Hi, when using a method to inject the Context, and a class which is different than Context is used, the generated code is not correct. I saw this issue while testing #2202 , both annotations have t... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | smaugho |
| hostname | github.com |
| expected-hostname | github.com |
| None | df33b1b61ee7b9a0af988199bfc3503c9c1acafb1f1d40e1f140ea7c84f890dd |
| turbo-cache-control | no-preview |
| go-import | github.com/androidannotations/androidannotations git https://github.com/androidannotations/androidannotations.git |
| octolytics-dimension-user_id | 1315313 |
| octolytics-dimension-user_login | androidannotations |
| octolytics-dimension-repository_id | 3116751 |
| octolytics-dimension-repository_nwo | androidannotations/androidannotations |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 3116751 |
| octolytics-dimension-repository_network_root_nwo | androidannotations/androidannotations |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | d41cd1bdb290013455c0ac430fa755621733f5eb |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width