Skip to content

Commit a348170

Browse files
authored
fix: incorrect code in java-to-kotlin-interop.md (JetBrains#2113)
`unboxBase(boxDerived("s"))` would not compile
1 parent 0855282 commit a348170

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

docs/topics/jvm/java-to-kotlin-interop.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -518,7 +518,7 @@ Box<Derived> boxDerived(Derived value) { ... }
518518
Base unboxBase(Box<Base> box) { ... }
519519
```
520520

521-
The problem is that in Kotlin you can write `unboxBase(boxDerived("s"))` but in Java that would be impossible
521+
The problem is that in Kotlin you can write `unboxBase(boxDerived(Derived()))` but in Java that would be impossible
522522
because in Java the class `Box` is *invariant* in its parameter `T`, and thus `Box<Derived>` is not a subtype of `Box<Base>`.
523523
To make this work in Java, you would have to define `unboxBase` as follows:
524524

0 commit comments

Comments
 (0)