Make PropertyMetadataImpl a data class
To allow property delegates to use property metadata as a key in the hash map, and to improve debugging experience
This commit is contained in:
+3
-1
@@ -1076,10 +1076,12 @@ public interface PropertyMetadata {
|
|||||||
public abstract fun <get-name>(): kotlin.String
|
public abstract fun <get-name>(): kotlin.String
|
||||||
}
|
}
|
||||||
|
|
||||||
public final class PropertyMetadataImpl : kotlin.PropertyMetadata {
|
kotlin.data() public final class PropertyMetadataImpl : kotlin.PropertyMetadata {
|
||||||
/*primary*/ public constructor PropertyMetadataImpl(/*0*/ name: kotlin.String)
|
/*primary*/ public constructor PropertyMetadataImpl(/*0*/ name: kotlin.String)
|
||||||
public open override /*1*/ val name: kotlin.String
|
public open override /*1*/ val name: kotlin.String
|
||||||
public open override /*1*/ fun <get-name>(): kotlin.String
|
public open override /*1*/ fun <get-name>(): kotlin.String
|
||||||
|
public final /*synthesized*/ fun component1(): kotlin.String
|
||||||
|
public final /*synthesized*/ fun copy(/*0*/ name: kotlin.String = ...): kotlin.PropertyMetadataImpl
|
||||||
}
|
}
|
||||||
|
|
||||||
public interface Range</*0*/ T : kotlin.Comparable<T>> {
|
public interface Range</*0*/ T : kotlin.Comparable<T>> {
|
||||||
|
|||||||
+36
@@ -0,0 +1,36 @@
|
|||||||
|
import java.util.HashSet
|
||||||
|
|
||||||
|
class A {
|
||||||
|
val foo: String by O
|
||||||
|
val Int.foo: String by O
|
||||||
|
|
||||||
|
fun foo42() = 42.foo
|
||||||
|
}
|
||||||
|
|
||||||
|
val foo: String by O
|
||||||
|
val Int.foo: String by O
|
||||||
|
|
||||||
|
object O {
|
||||||
|
val metadatas = HashSet<PropertyMetadata>()
|
||||||
|
|
||||||
|
fun get(t: Any?, p: PropertyMetadata): String {
|
||||||
|
metadatas.add(p)
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun box(): String {
|
||||||
|
A().foo
|
||||||
|
A().foo42()
|
||||||
|
foo
|
||||||
|
42.foo
|
||||||
|
|
||||||
|
if (O.metadatas.size() != 1)
|
||||||
|
return "Too many different PropertyMetadata instances: ${O.metadatas}"
|
||||||
|
|
||||||
|
val m = O.metadatas.iterator().next()
|
||||||
|
if (m.toString() != "PropertyMetadata(name=foo)")
|
||||||
|
return "Wrong toString(): $m"
|
||||||
|
|
||||||
|
return "OK"
|
||||||
|
}
|
||||||
+6
@@ -2851,6 +2851,12 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("propertyMetadataEqualsHashCodeToString.kt")
|
||||||
|
public void testPropertyMetadataEqualsHashCodeToString() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/box/delegatedProperty/propertyMetadataEqualsHashCodeToString.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("propertyMetadataShouldBeCached.kt")
|
@TestMetadata("propertyMetadataShouldBeCached.kt")
|
||||||
public void testPropertyMetadataShouldBeCached() throws Exception {
|
public void testPropertyMetadataShouldBeCached() throws Exception {
|
||||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/box/delegatedProperty/propertyMetadataShouldBeCached.kt");
|
String fileName = JetTestUtils.navigationMetadata("compiler/testData/codegen/box/delegatedProperty/propertyMetadataShouldBeCached.kt");
|
||||||
|
|||||||
@@ -29,4 +29,6 @@ public interface PropertyMetadata {
|
|||||||
/**
|
/**
|
||||||
* @suppress
|
* @suppress
|
||||||
*/
|
*/
|
||||||
public class PropertyMetadataImpl(override val name: String): PropertyMetadata
|
public data class PropertyMetadataImpl(override val name: String): PropertyMetadata {
|
||||||
|
override fun toString() = "PropertyMetadata(name=$name)"
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user