mirror of
https://github.com/jlengrand/kotlin.git
synced 2026-05-08 00:21:26 +00:00
Generate type-safe barrier in method body
In cases when signature of special bridge is the same as current method, but type is not 'Any?'. Also there is tiny optimization: only null check needed if value parameter type is mapped to Object, but it's not nullable. #KT-9973 Fixed
This commit is contained in:
@@ -6,3 +6,5 @@ abstract class A7 : MutableCollection<Int> {
|
||||
|
||||
// 1 public final bridge contains\(Ljava/lang/Object;\)Z
|
||||
// 1 public final bridge remove\(Ljava/lang/Object;\)Z
|
||||
/* 2 INSTANCEOF: one for 'remove', one for 'contains' type-safe bridges */
|
||||
// 2 INSTANCEOF java/lang/Integer
|
||||
|
||||
@@ -26,3 +26,5 @@ abstract class A6 : java.util.AbstractList<String>() {
|
||||
// 2 public final bridge remove\(Ljava/lang/Object;\)Z
|
||||
// 2 public final bridge indexOf\(Ljava/lang/Object;\)I
|
||||
// 2 public final bridge lastIndexOf\(Ljava/lang/Object;\)I
|
||||
/* 2 INSTANCEOF for each class: one for 'remove', one for 'contains' type-safe bridges */
|
||||
// 8 INSTANCEOF java/lang/String
|
||||
|
||||
@@ -23,3 +23,5 @@ abstract class A2 : MutableCollection<String> {
|
||||
// 1 public final bridge contains\(Ljava/lang/Object;\)Z
|
||||
// 1 public final bridge remove\(Ljava/lang/Object;\)Z
|
||||
// 1 INVOKEVIRTUAL A[0-9]\.contains \(Ljava/lang/String;\)Z
|
||||
/* 2 INSTANCEOF: one for 'remove', one for 'contains' type-safe bridges */
|
||||
// 2 INSTANCEOF
|
||||
|
||||
@@ -22,3 +22,7 @@ abstract class A : I2
|
||||
|
||||
// 1 public final bridge contains\(Ljava/lang/Object;\)Z
|
||||
// 1 public final bridge remove\(Ljava/lang/Object;\)Z
|
||||
/* 2 INSTANCEOF: one for 'remove', one for 'contains' type-safe bridges of A
|
||||
There should be no bridges in interfaces
|
||||
*/
|
||||
// 2 INSTANCEOF java/lang/String
|
||||
|
||||
11
compiler/testData/codegen/bytecodeText/builtinFunctions/genericParameterBridge/notNullAnyMC.kt
vendored
Normal file
11
compiler/testData/codegen/bytecodeText/builtinFunctions/genericParameterBridge/notNullAnyMC.kt
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
abstract class A8 : MutableCollection<Any> {
|
||||
override fun contains(o: Any): Boolean {
|
||||
throw UnsupportedOperationException()
|
||||
}
|
||||
}
|
||||
|
||||
// 1 bridge
|
||||
// 1 public final bridge size
|
||||
// 0 INSTANCEOF
|
||||
/* Only 1 IFNONNULL should be within contains method */
|
||||
// 1 IFNONNULL
|
||||
11
compiler/testData/codegen/bytecodeText/builtinFunctions/genericParameterBridge/notNullParamMC.kt
vendored
Normal file
11
compiler/testData/codegen/bytecodeText/builtinFunctions/genericParameterBridge/notNullParamMC.kt
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
abstract class A<T : Any> : MutableCollection<T> {
|
||||
override fun contains(o: T): Boolean {
|
||||
throw UnsupportedOperationException()
|
||||
}
|
||||
}
|
||||
|
||||
// 1 bridge
|
||||
// 1 public final bridge size
|
||||
// 0 INSTANCEOF
|
||||
/* Only 1 IFNONNULL should be within contains method (because T is not nullable) */
|
||||
// 1 IFNONNULL
|
||||
@@ -6,3 +6,5 @@ abstract class A8 : MutableCollection<Any?> {
|
||||
|
||||
// 1 bridge
|
||||
// 1 public final bridge size
|
||||
// 0 INSTANCEOF
|
||||
// 0 NULL
|
||||
|
||||
Reference in New Issue
Block a user