Generate generic signatures for special bridges

#KT-12408 Fixed Target versions 1.1.4
This commit is contained in:
Dmitry Petrov
2017-05-30 11:35:58 +03:00
parent 48a60e6f39
commit fd00a6fbe8
10 changed files with 193 additions and 30 deletions
@@ -1126,8 +1126,12 @@ public class FunctionCodegen {
boolean isSpecialOrDelegationToSuper = isSpecialBridge || isStubDeclarationWithDelegationToSuper;
int flags = ACC_PUBLIC | ACC_BRIDGE | (!isSpecialOrDelegationToSuper ? ACC_SYNTHETIC : 0) | (isSpecialBridge ? ACC_FINAL : 0); // TODO.
MethodVisitor mv =
v.newMethod(JvmDeclarationOriginKt.Bridge(descriptor, origin), flags, bridge.getName(), bridge.getDescriptor(), null, null);
String bridgeSignature =
isSpecialBridge ? typeMapper.mapSignatureWithGeneric(descriptor, OwnerKind.IMPLEMENTATION).getGenericsSignature()
: null;
MethodVisitor mv = v.newMethod(JvmDeclarationOriginKt.Bridge(descriptor, origin), flags,
bridge.getName(), bridge.getDescriptor(), bridgeSignature, null);
if (!state.getClassBuilderMode().generateBodies) return;
mv.visitCode();
@@ -1,3 +0,0 @@
// WITH_SIGNATURES
class MyMap<K, V> : MutableMap<K, V> by HashMap<K, V>()
@@ -1,21 +0,0 @@
@kotlin.Metadata
public final class<<K:Ljava/lang/Object;V:Ljava/lang/Object;>Ljava/lang/Object;Ljava/util/Map<TK;TV;>;Lkotlin/jvm/internal/markers/KMutableMap;> MyMap {
public @org.jetbrains.annotations.NotNull <()Ljava/util/Collection<TV;>;> method getValues(): java.util.Collection
public @org.jetbrains.annotations.NotNull <()Ljava/util/Set<Ljava/util/Map$Entry<TK;TV;>;>;> method getEntries(): java.util.Set
public @org.jetbrains.annotations.NotNull <()Ljava/util/Set<TK;>;> method getKeys(): java.util.Set
public @org.jetbrains.annotations.Nullable <(Ljava/lang/Object;)TV;> method get(p0: java.lang.Object): java.lang.Object
public @org.jetbrains.annotations.Nullable <(Ljava/lang/Object;)TV;> method remove(p0: java.lang.Object): java.lang.Object
public <(Ljava/util/Map<+TK;+TV;>;)V> method putAll(@org.jetbrains.annotations.NotNull p0: java.util.Map): void
public @org.jetbrains.annotations.Nullable <(TK;TV;)TV;> method put(p0: java.lang.Object, p1: java.lang.Object): java.lang.Object
public <null> method <init>(): void
public <null> method clear(): void
public <null> method containsKey(p0: java.lang.Object): boolean
public <null> method containsValue(p0: java.lang.Object): boolean
public final <null> method entrySet(): java.util.Set
public <null> method getSize(): int
public <null> method isEmpty(): boolean
public final <null> method keySet(): java.util.Set
public final <null> method size(): int
public final <null> method values(): java.util.Collection
private synthetic final field <null> $$delegate_0: java.util.HashMap
}
@@ -0,0 +1,5 @@
// WITH_SIGNATURES
class GenericMap<K, V> : MutableMap<K, V> by HashMap<K, V>()
abstract class AbstractGenericMap<K, V> : MutableMap<K, V> by HashMap<K, V>()
@@ -0,0 +1,43 @@
@kotlin.Metadata
public abstract class<<K:Ljava/lang/Object;V:Ljava/lang/Object;>Ljava/lang/Object;Ljava/util/Map<TK;TV;>;Lkotlin/jvm/internal/markers/KMutableMap;> AbstractGenericMap {
public @org.jetbrains.annotations.NotNull <()Ljava/util/Collection<TV;>;> method getValues(): java.util.Collection
public final <()Ljava/util/Collection<TV;>;> method values(): java.util.Collection
public final <()Ljava/util/Set<Ljava/util/Map$Entry<TK;TV;>;>;> method entrySet(): java.util.Set
public @org.jetbrains.annotations.NotNull <()Ljava/util/Set<Ljava/util/Map$Entry<TK;TV;>;>;> method getEntries(): java.util.Set
public @org.jetbrains.annotations.NotNull <()Ljava/util/Set<TK;>;> method getKeys(): java.util.Set
public final <()Ljava/util/Set<TK;>;> method keySet(): java.util.Set
public @org.jetbrains.annotations.Nullable <(Ljava/lang/Object;)TV;> method get(p0: java.lang.Object): java.lang.Object
public @org.jetbrains.annotations.Nullable <(Ljava/lang/Object;)TV;> method remove(p0: java.lang.Object): java.lang.Object
public <(Ljava/util/Map<+TK;+TV;>;)V> method putAll(@org.jetbrains.annotations.NotNull p0: java.util.Map): void
public @org.jetbrains.annotations.Nullable <(TK;TV;)TV;> method put(p0: java.lang.Object, p1: java.lang.Object): java.lang.Object
public <null> method <init>(): void
public <null> method clear(): void
public <null> method containsKey(p0: java.lang.Object): boolean
public <null> method containsValue(p0: java.lang.Object): boolean
public <null> method getSize(): int
public <null> method isEmpty(): boolean
public final <null> method size(): int
private synthetic final field <null> $$delegate_0: java.util.HashMap
}
@kotlin.Metadata
public final class<<K:Ljava/lang/Object;V:Ljava/lang/Object;>Ljava/lang/Object;Ljava/util/Map<TK;TV;>;Lkotlin/jvm/internal/markers/KMutableMap;> GenericMap {
public @org.jetbrains.annotations.NotNull <()Ljava/util/Collection<TV;>;> method getValues(): java.util.Collection
public final <()Ljava/util/Collection<TV;>;> method values(): java.util.Collection
public final <()Ljava/util/Set<Ljava/util/Map$Entry<TK;TV;>;>;> method entrySet(): java.util.Set
public @org.jetbrains.annotations.NotNull <()Ljava/util/Set<Ljava/util/Map$Entry<TK;TV;>;>;> method getEntries(): java.util.Set
public @org.jetbrains.annotations.NotNull <()Ljava/util/Set<TK;>;> method getKeys(): java.util.Set
public final <()Ljava/util/Set<TK;>;> method keySet(): java.util.Set
public @org.jetbrains.annotations.Nullable <(Ljava/lang/Object;)TV;> method get(p0: java.lang.Object): java.lang.Object
public @org.jetbrains.annotations.Nullable <(Ljava/lang/Object;)TV;> method remove(p0: java.lang.Object): java.lang.Object
public <(Ljava/util/Map<+TK;+TV;>;)V> method putAll(@org.jetbrains.annotations.NotNull p0: java.util.Map): void
public @org.jetbrains.annotations.Nullable <(TK;TV;)TV;> method put(p0: java.lang.Object, p1: java.lang.Object): java.lang.Object
public <null> method <init>(): void
public <null> method clear(): void
public <null> method containsKey(p0: java.lang.Object): boolean
public <null> method containsValue(p0: java.lang.Object): boolean
public <null> method getSize(): int
public <null> method isEmpty(): boolean
public final <null> method size(): int
private synthetic final field <null> $$delegate_0: java.util.HashMap
}
@@ -0,0 +1,5 @@
// WITH_SIGNATURES
class StringStringMap : MutableMap<String, String> by HashMap<String, String>()
abstract class AbstractStringStringMap : MutableMap<String, String> by HashMap<String, String>()
@@ -0,0 +1,53 @@
@kotlin.Metadata
public abstract class<Ljava/lang/Object;Ljava/util/Map<Ljava/lang/String;Ljava/lang/String;>;Lkotlin/jvm/internal/markers/KMutableMap;> AbstractStringStringMap {
public @org.jetbrains.annotations.NotNull <()Ljava/util/Collection<Ljava/lang/String;>;> method getValues(): java.util.Collection
public final <()Ljava/util/Collection<Ljava/lang/String;>;> method values(): java.util.Collection
public @org.jetbrains.annotations.NotNull <()Ljava/util/Set<Ljava/lang/String;>;> method getKeys(): java.util.Set
public final <()Ljava/util/Set<Ljava/lang/String;>;> method keySet(): java.util.Set
public final <()Ljava/util/Set<Ljava/util/Map$Entry<Ljava/lang/String;Ljava/lang/String;>;>;> method entrySet(): java.util.Set
public @org.jetbrains.annotations.NotNull <()Ljava/util/Set<Ljava/util/Map$Entry<Ljava/lang/String;Ljava/lang/String;>;>;> method getEntries(): java.util.Set
public <(Ljava/util/Map<+Ljava/lang/String;+Ljava/lang/String;>;)V> method putAll(@org.jetbrains.annotations.NotNull p0: java.util.Map): void
public <null> method <init>(): void
public <null> method clear(): void
public <null> method containsKey(@org.jetbrains.annotations.NotNull p0: java.lang.String): boolean
public final <null> method containsKey(p0: java.lang.Object): boolean
public <null> method containsValue(@org.jetbrains.annotations.NotNull p0: java.lang.String): boolean
public final <null> method containsValue(p0: java.lang.Object): boolean
public @org.jetbrains.annotations.Nullable <null> method get(@org.jetbrains.annotations.NotNull p0: java.lang.String): java.lang.String
public final <null> method get(p0: java.lang.Object): java.lang.Object
public <null> method getSize(): int
public <null> method isEmpty(): boolean
public @org.jetbrains.annotations.Nullable <null> method put(@org.jetbrains.annotations.NotNull p0: java.lang.String, @org.jetbrains.annotations.NotNull p1: java.lang.String): java.lang.String
public synthetic <null> method put(p0: java.lang.Object, p1: java.lang.Object): java.lang.Object
public @org.jetbrains.annotations.Nullable <null> method remove(@org.jetbrains.annotations.NotNull p0: java.lang.String): java.lang.String
public final <null> method remove(p0: java.lang.Object): java.lang.Object
public final <null> method size(): int
private synthetic final field <null> $$delegate_0: java.util.HashMap
}
@kotlin.Metadata
public final class<Ljava/lang/Object;Ljava/util/Map<Ljava/lang/String;Ljava/lang/String;>;Lkotlin/jvm/internal/markers/KMutableMap;> StringStringMap {
public @org.jetbrains.annotations.NotNull <()Ljava/util/Collection<Ljava/lang/String;>;> method getValues(): java.util.Collection
public final <()Ljava/util/Collection<Ljava/lang/String;>;> method values(): java.util.Collection
public @org.jetbrains.annotations.NotNull <()Ljava/util/Set<Ljava/lang/String;>;> method getKeys(): java.util.Set
public final <()Ljava/util/Set<Ljava/lang/String;>;> method keySet(): java.util.Set
public final <()Ljava/util/Set<Ljava/util/Map$Entry<Ljava/lang/String;Ljava/lang/String;>;>;> method entrySet(): java.util.Set
public @org.jetbrains.annotations.NotNull <()Ljava/util/Set<Ljava/util/Map$Entry<Ljava/lang/String;Ljava/lang/String;>;>;> method getEntries(): java.util.Set
public <(Ljava/util/Map<+Ljava/lang/String;+Ljava/lang/String;>;)V> method putAll(@org.jetbrains.annotations.NotNull p0: java.util.Map): void
public <null> method <init>(): void
public <null> method clear(): void
public <null> method containsKey(@org.jetbrains.annotations.NotNull p0: java.lang.String): boolean
public final <null> method containsKey(p0: java.lang.Object): boolean
public <null> method containsValue(@org.jetbrains.annotations.NotNull p0: java.lang.String): boolean
public final <null> method containsValue(p0: java.lang.Object): boolean
public @org.jetbrains.annotations.Nullable <null> method get(@org.jetbrains.annotations.NotNull p0: java.lang.String): java.lang.String
public final <null> method get(p0: java.lang.Object): java.lang.Object
public <null> method getSize(): int
public <null> method isEmpty(): boolean
public @org.jetbrains.annotations.Nullable <null> method put(@org.jetbrains.annotations.NotNull p0: java.lang.String, @org.jetbrains.annotations.NotNull p1: java.lang.String): java.lang.String
public synthetic <null> method put(p0: java.lang.Object, p1: java.lang.Object): java.lang.Object
public @org.jetbrains.annotations.Nullable <null> method remove(@org.jetbrains.annotations.NotNull p0: java.lang.String): java.lang.String
public final <null> method remove(p0: java.lang.Object): java.lang.Object
public final <null> method size(): int
private synthetic final field <null> $$delegate_0: java.util.HashMap
}
@@ -0,0 +1,5 @@
// WITH_SIGNATURES
class StringMap<V> : MutableMap<String, V> by HashMap<String, V>()
abstract class AbstractStringMap<V> : MutableMap<String, V> by HashMap<String, V>()
@@ -0,0 +1,51 @@
@kotlin.Metadata
public abstract class<<V:Ljava/lang/Object;>Ljava/lang/Object;Ljava/util/Map<Ljava/lang/String;TV;>;Lkotlin/jvm/internal/markers/KMutableMap;> AbstractStringMap {
public @org.jetbrains.annotations.NotNull <()Ljava/util/Collection<TV;>;> method getValues(): java.util.Collection
public final <()Ljava/util/Collection<TV;>;> method values(): java.util.Collection
public @org.jetbrains.annotations.NotNull <()Ljava/util/Set<Ljava/lang/String;>;> method getKeys(): java.util.Set
public final <()Ljava/util/Set<Ljava/lang/String;>;> method keySet(): java.util.Set
public final <()Ljava/util/Set<Ljava/util/Map$Entry<Ljava/lang/String;TV;>;>;> method entrySet(): java.util.Set
public @org.jetbrains.annotations.NotNull <()Ljava/util/Set<Ljava/util/Map$Entry<Ljava/lang/String;TV;>;>;> method getEntries(): java.util.Set
public @org.jetbrains.annotations.Nullable <(Ljava/lang/Object;)TV;> method get(@org.jetbrains.annotations.NotNull p0: java.lang.String): java.lang.Object
public final <(Ljava/lang/Object;)TV;> method get(p0: java.lang.Object): java.lang.Object
public @org.jetbrains.annotations.Nullable <(Ljava/lang/Object;)TV;> method remove(@org.jetbrains.annotations.NotNull p0: java.lang.String): java.lang.Object
public final <(Ljava/lang/Object;)TV;> method remove(p0: java.lang.Object): java.lang.Object
public @org.jetbrains.annotations.Nullable <(Ljava/lang/String;TV;)TV;> method put(@org.jetbrains.annotations.NotNull p0: java.lang.String, p1: java.lang.Object): java.lang.Object
public <(Ljava/util/Map<+Ljava/lang/String;+TV;>;)V> method putAll(@org.jetbrains.annotations.NotNull p0: java.util.Map): void
public <null> method <init>(): void
public <null> method clear(): void
public <null> method containsKey(@org.jetbrains.annotations.NotNull p0: java.lang.String): boolean
public final <null> method containsKey(p0: java.lang.Object): boolean
public <null> method containsValue(p0: java.lang.Object): boolean
public <null> method getSize(): int
public <null> method isEmpty(): boolean
public synthetic <null> method put(p0: java.lang.Object, p1: java.lang.Object): java.lang.Object
public final <null> method size(): int
private synthetic final field <null> $$delegate_0: java.util.HashMap
}
@kotlin.Metadata
public final class<<V:Ljava/lang/Object;>Ljava/lang/Object;Ljava/util/Map<Ljava/lang/String;TV;>;Lkotlin/jvm/internal/markers/KMutableMap;> StringMap {
public @org.jetbrains.annotations.NotNull <()Ljava/util/Collection<TV;>;> method getValues(): java.util.Collection
public final <()Ljava/util/Collection<TV;>;> method values(): java.util.Collection
public @org.jetbrains.annotations.NotNull <()Ljava/util/Set<Ljava/lang/String;>;> method getKeys(): java.util.Set
public final <()Ljava/util/Set<Ljava/lang/String;>;> method keySet(): java.util.Set
public final <()Ljava/util/Set<Ljava/util/Map$Entry<Ljava/lang/String;TV;>;>;> method entrySet(): java.util.Set
public @org.jetbrains.annotations.NotNull <()Ljava/util/Set<Ljava/util/Map$Entry<Ljava/lang/String;TV;>;>;> method getEntries(): java.util.Set
public @org.jetbrains.annotations.Nullable <(Ljava/lang/Object;)TV;> method get(@org.jetbrains.annotations.NotNull p0: java.lang.String): java.lang.Object
public final <(Ljava/lang/Object;)TV;> method get(p0: java.lang.Object): java.lang.Object
public @org.jetbrains.annotations.Nullable <(Ljava/lang/Object;)TV;> method remove(@org.jetbrains.annotations.NotNull p0: java.lang.String): java.lang.Object
public final <(Ljava/lang/Object;)TV;> method remove(p0: java.lang.Object): java.lang.Object
public @org.jetbrains.annotations.Nullable <(Ljava/lang/String;TV;)TV;> method put(@org.jetbrains.annotations.NotNull p0: java.lang.String, p1: java.lang.Object): java.lang.Object
public <(Ljava/util/Map<+Ljava/lang/String;+TV;>;)V> method putAll(@org.jetbrains.annotations.NotNull p0: java.util.Map): void
public <null> method <init>(): void
public <null> method clear(): void
public <null> method containsKey(@org.jetbrains.annotations.NotNull p0: java.lang.String): boolean
public final <null> method containsKey(p0: java.lang.Object): boolean
public <null> method containsValue(p0: java.lang.Object): boolean
public <null> method getSize(): int
public <null> method isEmpty(): boolean
public synthetic <null> method put(p0: java.lang.Object, p1: java.lang.Object): java.lang.Object
public final <null> method size(): int
private synthetic final field <null> $$delegate_0: java.util.HashMap
}
@@ -242,10 +242,31 @@ public class BytecodeListingTestGenerated extends AbstractBytecodeListingTest {
doTest(fileName);
}
@TestMetadata("signatureForSpecialBridge.kt")
public void testSignatureForSpecialBridge() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/bytecodeListing/specialBridges/signatureForSpecialBridge.kt");
doTest(fileName);
@TestMetadata("compiler/testData/codegen/bytecodeListing/specialBridges/signatures")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class Signatures extends AbstractBytecodeListingTest {
public void testAllFilesPresentInSignatures() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/codegen/bytecodeListing/specialBridges/signatures"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
}
@TestMetadata("genericClass.kt")
public void testGenericClass() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/bytecodeListing/specialBridges/signatures/genericClass.kt");
doTest(fileName);
}
@TestMetadata("nonGenericClass.kt")
public void testNonGenericClass() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/bytecodeListing/specialBridges/signatures/nonGenericClass.kt");
doTest(fileName);
}
@TestMetadata("partiallySpecializedClass.kt")
public void testPartiallySpecializedClass() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/bytecodeListing/specialBridges/signatures/partiallySpecializedClass.kt");
doTest(fileName);
}
}
}
}