File tree Expand file tree Collapse file tree 1 file changed +27
-1
lines changed Expand file tree Collapse file tree 1 file changed +27
-1
lines changed Original file line number Diff line number Diff line change @@ -586,7 +586,7 @@ fun emptyList(): List<Nothing> = listOf()
586
586
// List emptyList() { ... }
587
587
```
588
588
589
- ### Inline value classes
589
+ ## Inline value classes
590
590
591
591
<primary-label ref =" experimental-general " />
592
592
@@ -639,3 +639,29 @@ MyInt output = ExampleKt.timesTwoBoxed(input);
639
639
640
640
To apply this behavior to all inline value classes and the functions that use them within a module, compile it with the ` -Xjvm-expose-boxed ` option.
641
641
Compiling with this option has the same effect as if every declaration in the module has the ` @JvmExposeBoxed ` annotation.
642
+
643
+ ### Inherited functions
644
+
645
+ The ` @JvmExposeBoxed ` annotation doesn't automatically generate boxed representations for inherited functions.
646
+
647
+ To generate the necessary representation for an inherited function, override it in the implementing or extending class:
648
+
649
+ ``` kotlin
650
+ interface IdTransformer {
651
+ fun transformId (rawId : UInt ): UInt = rawId
652
+ }
653
+
654
+ // Doesn't generate a boxed representation for the transformId() function
655
+ @OptIn(ExperimentalStdlibApi ::class )
656
+ @JvmExposeBoxed
657
+ class LightweightTransformer : IdTransformer
658
+
659
+ // Generates a boxed representation for the transformId() function
660
+ @OptIn(ExperimentalStdlibApi ::class )
661
+ @JvmExposeBoxed
662
+ class DefaultTransformer : IdTransformer {
663
+ override fun transformId (rawId : UInt ): UInt = super .transformId(rawId)
664
+ }
665
+ ```
666
+
667
+ To learn how inheritance works in Kotlin and how to call superclass implementations using the ` super ` keyword, see [ Inheritance] ( inheritance.md#calling-the-superclass-implementation ) .
You can’t perform that action at this time.
0 commit comments