Title: AssembleModel unable to analyze Kotlin constructors with not nullable reference parameters · Issue #1336 · UnitTestBot/UTBotJava · GitHub
Open Graph Title: AssembleModel unable to analyze Kotlin constructors with not nullable reference parameters · Issue #1336 · UnitTestBot/UTBotJava
X Title: AssembleModel unable to analyze Kotlin constructors with not nullable reference parameters · Issue #1336 · UnitTestBot/UTBotJava
Description: Description Right now we are unable to properly assemble models if there are not nullable reference parameters in constructor -- such models are instantiated through reflection right now. To Reproduce Launch action on class Sample from b...
Open Graph Description: Description Right now we are unable to properly assemble models if there are not nullable reference parameters in constructor -- such models are instantiated through reflection right now. To Reprod...
X Description: Description Right now we are unable to properly assemble models if there are not nullable reference parameters in constructor -- such models are instantiated through reflection right now. To Reprod...
Opengraph URL: https://github.com/UnitTestBot/UTBotJava/issues/1336
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"AssembleModel unable to analyze Kotlin constructors with not nullable reference parameters","articleBody":"**Description**\r\n\r\nRight now we are unable to properly assemble models if there are not nullable reference parameters in constructor -- such models are instantiated through reflection right now.\r\n\r\n**To Reproduce**\r\n\r\nLaunch action on class `Sample` from below:\r\n\r\n```Kotlin\r\ndata class Point(var x: Int, var y: Int)\r\n\r\nclass Sample(val y: Point) {\r\n fun test(): Int {\r\n if (y.x == 2)\r\n return -1\r\n return 0\r\n }\r\n}\r\n```\r\n\r\n**Expected behavior**\r\n\r\nTests with assembled models are generated.\r\n\r\n**Actual behavior**\r\n\r\nClasses are instantiated through reflection\r\n\r\n**Visual proofs (screenshots, logs, images)**\r\n\r\n~~~Kotlin\r\n@Test\r\nfun testKek1() {\r\n val s = (createInstance(\"nullability.Sample\") as Sample)\r\n val point = (createInstance(\"nullability.Point\") as Point)\r\n point.x = 2\r\n setField(s, \"nullability.Sample\", \"y\", point)\r\n \r\n val actual = kek(s)\r\n \r\n assertEquals(-1, actual)\r\n}\r\n~~~\r\n\r\n**Environment**\r\n\r\nSymbolic execution 100%.\r\n\r\n**Additional context**\r\n\r\nSeems like the problem is that Kotlin compiler adds to constructor of `Sample` instructions like `INVOKESTATIC kotlin/jvm/internal/Intrinsics.checkNotNullParameter (Ljava/lang/Object;Ljava/lang/String;)V`\r\n\r\nThis leads to incorrect behavior of `isAppropriate` and other methods in `ConstructorAnalyzer`\r\n","author":{"url":"https://github.com/volivan239","@type":"Person","name":"volivan239"},"datePublished":"2022-11-09T12:20:38.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":0},"url":"https://github.com/1336/UTBotJava/issues/1336"}
| 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:c123d8ef-58f4-94b8-5536-4c27d958de03 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | BD48:DC185:7631D1:9829A0:698FCF2A |
| html-safe-nonce | e2d4bcae11754db1ea97c29759a90eb8cf4cb6dfd7b06416887ecc232c14bffb |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCRDQ4OkRDMTg1Ojc2MzFEMTo5ODI5QTA6Njk4RkNGMkEiLCJ2aXNpdG9yX2lkIjoiNzQ1Mzc5Njc5OTE1NDczNjkzOCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | b1831932d57b26853bfec69e204f56363af9da2d46a63b8549100777454fc08c |
| hovercard-subject-tag | issue:1441999237 |
| 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/UnitTestBot/UTBotJava/1336/issue_layout |
| twitter:image | https://opengraph.githubassets.com/55ddce1044f9b1edb0c1743e2577cc28705c0a0d6161c4a0930e290d1154f241/UnitTestBot/UTBotJava/issues/1336 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/55ddce1044f9b1edb0c1743e2577cc28705c0a0d6161c4a0930e290d1154f241/UnitTestBot/UTBotJava/issues/1336 |
| og:image:alt | Description Right now we are unable to properly assemble models if there are not nullable reference parameters in constructor -- such models are instantiated through reflection right now. To Reprod... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | volivan239 |
| hostname | github.com |
| expected-hostname | github.com |
| None | 42c603b9d642c4a9065a51770f75e5e27132fef0e858607f5c9cb7e422831a7b |
| turbo-cache-control | no-preview |
| go-import | github.com/UnitTestBot/UTBotJava git https://github.com/UnitTestBot/UTBotJava.git |
| octolytics-dimension-user_id | 87413538 |
| octolytics-dimension-user_login | UnitTestBot |
| octolytics-dimension-repository_id | 480810501 |
| octolytics-dimension-repository_nwo | UnitTestBot/UTBotJava |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 480810501 |
| octolytics-dimension-repository_network_root_nwo | UnitTestBot/UTBotJava |
| 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 | 00bbb8945a3943b287e04c68aff13cb5878ddde7 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width