question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Generic type leads to invalid generated code

See original GitHub issue

Here’s an example of type parameterized model:

@JsonSerializable
data class PagedResult<out Data>(val data: List<Data>, val meta: MetaData) {
    @JsonSerializable
    data class MetaData(val total: Int,
                        val count: Int,
                        @Json(name = "per_page")
                        val resultsPerPage: Int,
                        @Json(name = "current_page")
                        val currentPage: Int,
                        @Json(name = "total_pages")
                        val totalPages: Int)
}

The generated code attempts to refer to Data.class which is incorrect since it’s a type parameter.

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
ansmancommented, Dec 23, 2017

This has been fixed and released in beta3

1reaction
ansmancommented, Dec 22, 2017

A PR has been opened in #42

Read more comments on GitHub >

github_iconTop Results From Across the Web

c# - Generic Type InvalidOperationException - Stack Overflow
Your problem is related to covariance & contravariance. In some cases we can have a solution by declaring the view model abstract as ......
Read more >
[BUG] [JAVA] Generic type generates invalid equals body #3808
[BUG] [JAVA] Generic type generates invalid equals body #3808 ... and it generates equals method of this object containing this line.
Read more >
Restrictions on Generics (The Java™ Tutorials > Learning the ...
Because the Java compiler erases all type parameters in generic code, you cannot verify which parameterized type for a generic type is being...
Read more >
Web service error codes (Microsoft Dataverse) - Power Apps
Message: An Invalid type code was specified by the throwing method. 0x80043512 ... Message: The calculation failed due to an overflow error.
Read more >
Bug Patterns - Error Prone
Each bug pattern includes code examples of both positive and negative cases; ... Passing argument to a generic method with an incompatible type....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found