Skip to main content

Questions tagged [kotlin-inline-class]

From version 1.3+, Kotlin introduces a special kind of class called an inline class, which is declared by placing an 'inline' modifier before the name of the class. They provide a way to wrap a type, thus adding functionality and creating a new type by itself. As opposed to regular wrappers, they will benefit from improved performance. This happens because the data is inlined into its usages, and object instantiation is skipped in the compiled code.

kotlin-inline-class
1 vote
1 answer
67 views

Kotlin interoperability issue with implementing interfaces

I'm working on migrating a web project from Java to Kotlin. During this process I'm faced with compilation issue that can make problems in the future, especially where the existing projects have to ...
Alexandr's user avatar
0 votes
1 answer
39 views

I am not sure how to optimize retrofit with callback in kotlin, or how to remove the callback after its done

I am using callbacks in Kotlin, and I currently have the exact retrofit function returning result in the form of a callback as its used multiple times across different classes,the endpoints are ...
Lingam mohan krishnasen's user avatar
1 vote
1 answer
269 views

How to use kotlin value class from java code?

I have kotlin value class: @JvmInline value class MyValueClass internal constructor(val rawValue: String) { companion object { @JvmName("myTestValueClass") fun String....
testivanivan's user avatar
  • 1,318
1 vote
1 answer
98 views

Kotlin. How to store property in value class?

I'm trying to create value class for storing money. And I need to store private money format. Here is my code: @JvmInline value class Money internal constructor(val rawValue: String) { private ...
testivanivan's user avatar
  • 1,318
2 votes
1 answer
145 views

Force inlining of Kotlin inline-class?

@LukasEder, this question is more Kotlin related, you can probably skip it in favour of the more jOOQ-related continuation in https://github.com/jOOQ/jOOQ/issues/14972 :) So part of a legacy database ...
User1291's user avatar
  • 8,042
1 vote
1 answer
103 views

What is the best use case to understand crossinline

I wanted to understand what is actual use case when we would want to add crossinline keyword to a lambda I have following code where I added crossinline. I understand that crossinline will force any ...
Hack123's user avatar
  • 95
1 vote
1 answer
481 views

Kotlin working with value classes in libraries such as hibernate / jackson

Is there a way to get kotlin value classes (updated inline classes) to work with libraries such as Jackson and Hibernate and have them treat the value class simply as the underlying type? Currently I ...
Vidde's user avatar
  • 31
1 vote
2 answers
2k views

Cannot use 'T' as reified type parameter even I declared that T should be any class inherited by Parcelable

Since I am not yet good in generics I would like to ask: Question: why I cannot inform the function getResult that the return value from bundle.getParcelableCompat<T>(BUNDLE_KEY) would be type ...
deadfish's user avatar
  • 12.2k
1 vote
1 answer
193 views

Kotlin: inline function and shared type

I want to call multiple API calls at once using coroutines. So far I used coroutines only to call single API call which returned result in form off success or error. Its using inline function. But I ...
Martin's user avatar
  • 2,758
0 votes
0 answers
369 views

Is it possible to disable inlining of value classes in Kotlin?

Goal I would like to globally disable inlining of @JvmInline value class classes via a compiler flag or something similar. I would want to do this when running unit tests but not in production. ...
dta's user avatar
  • 654
4 votes
2 answers
2k views

Parcelize value (inline) class in Kotlin

At first glance it seems to be okay to decorate a kotlin value (inline) class like that: @JvmInline @Parcelize value class TestClass(val value: Long) : Parcelable But the build fails reporting: ...
Casaflowa's user avatar
1 vote
0 answers
661 views

Value classes in generics - interoperability with Java/Groovy

I’m struggling with value classes in generics and interoperability with Java or Groovy. Value class are inlined: Inline classes | Kotlin 1 except for generics. Given following value class and ...
Aleksander Ihnatowicz's user avatar
8 votes
1 answer
2k views

Unresolved reference: JvmInline In kotlin playground

This is an exact code snippet of value classes taken from kotlin official website. interface I @JvmInline value class Foo(val i: Int) : I fun asInline(f: Foo) {} fun <T> asGeneric(x: T) {} fun ...
Sourav Kannantha B's user avatar
0 votes
1 answer
490 views

Memory leak: Anonymous class implementing io.reactivex.Observer

I am working on an Android project. Some of my Activities are extending SiteFinderActivity. This class is responsible to validate the current session and pass it down to its children via a few ...
Hesam's user avatar
  • 53.2k
4 votes
2 answers
1k views

Store Kotlin inline class to MongoDB with Spring Data

I'm trying to store a Kotlin's (v1.3.61) inline class to a MongoDB using Spring Data MongoDB (2.2.3-RELEASE), with no luck so far. This is the set up: inline class UserId(@NotBlank val id: String) ...
Jan B.'s user avatar
  • 6,360

15 30 50 per page