Fixed mapping generic type with multiple bounds from Java to Kotlin.
#KT-3480 fixed
This commit is contained in:
committed by
Zalim Bashorov
parent
e47c84f40f
commit
d3570153ef
@@ -282,7 +282,7 @@ public class JetTypeMapper extends BindingTraceAware {
|
|||||||
|
|
||||||
if (descriptor instanceof TypeParameterDescriptor) {
|
if (descriptor instanceof TypeParameterDescriptor) {
|
||||||
TypeParameterDescriptor typeParameterDescriptor = (TypeParameterDescriptor) descriptor;
|
TypeParameterDescriptor typeParameterDescriptor = (TypeParameterDescriptor) descriptor;
|
||||||
Type type = mapType(typeParameterDescriptor.getUpperBoundsAsType(), kind);
|
Type type = mapType(typeParameterDescriptor.getUpperBounds().iterator().next(), kind);
|
||||||
if (signatureVisitor != null) {
|
if (signatureVisitor != null) {
|
||||||
signatureVisitor.writeTypeVariable(typeParameterDescriptor.getName(), type);
|
signatureVisitor.writeTypeVariable(typeParameterDescriptor.getName(), type);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
import java.util.*;
|
||||||
|
|
||||||
|
public class max {
|
||||||
|
public static <T extends Object & Comparable<? super T>> T max(Collection<? extends T> coll) {
|
||||||
|
return Collections.max(coll);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
fun box(): String {
|
||||||
|
return max.max(java.util.Arrays.asList("AK", "OK", "EK"))!!
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
import java.util.Collection;
|
||||||
|
|
||||||
|
public class unrelatedUpperBounds {
|
||||||
|
public static <T extends CharSequence & java.io.Serializable> T id(T p) {
|
||||||
|
return p;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,3 @@
|
|||||||
|
fun box(): String {
|
||||||
|
return unrelatedUpperBounds.id("OK" as java.lang.String)!! as jet.String
|
||||||
|
}
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
package test;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
|
|
||||||
|
public class Max {
|
||||||
|
public <T extends Object & Comparable<? super T>> T max(Collection<? extends T> coll) {
|
||||||
|
throw new UnsupportedOperationException();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
package test
|
||||||
|
|
||||||
|
public open class Max: Object() {
|
||||||
|
public open fun max<T : Any?>(p0 : Collection<T>?): T? where T : Comparable<T>? {
|
||||||
|
throw UnsupportedOperationException()
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
package test
|
||||||
|
|
||||||
|
public open class Max : java.lang.Object {
|
||||||
|
public constructor Max()
|
||||||
|
public open fun </*0*/ T> max(/*0*/ p0: jet.Collection<T>?): T? where T : jet.Comparable<T>?
|
||||||
|
}
|
||||||
+12
-5
@@ -16,17 +16,14 @@
|
|||||||
|
|
||||||
package org.jetbrains.jet.codegen.generated;
|
package org.jetbrains.jet.codegen.generated;
|
||||||
|
|
||||||
import junit.framework.Assert;
|
|
||||||
import junit.framework.Test;
|
import junit.framework.Test;
|
||||||
import junit.framework.TestSuite;
|
import junit.framework.TestSuite;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.util.regex.Pattern;
|
|
||||||
import org.jetbrains.jet.JetTestUtils;
|
import org.jetbrains.jet.JetTestUtils;
|
||||||
import org.jetbrains.jet.test.InnerTestClasses;
|
import org.jetbrains.jet.test.InnerTestClasses;
|
||||||
import org.jetbrains.jet.test.TestMetadata;
|
import org.jetbrains.jet.test.TestMetadata;
|
||||||
|
|
||||||
import org.jetbrains.jet.codegen.generated.AbstractBlackBoxCodegenTest;
|
import java.io.File;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
/** This class is generated by {@link org.jetbrains.jet.generators.tests.TestsPackage}. DO NOT MODIFY MANUALLY */
|
/** This class is generated by {@link org.jetbrains.jet.generators.tests.TestsPackage}. DO NOT MODIFY MANUALLY */
|
||||||
@SuppressWarnings("all")
|
@SuppressWarnings("all")
|
||||||
@@ -137,6 +134,11 @@ public class BlackBoxWithJavaCodegenTestGenerated extends AbstractBlackBoxCodege
|
|||||||
doTestWithJava("compiler/testData/codegen/boxWithJava/functions/constructor.kt");
|
doTestWithJava("compiler/testData/codegen/boxWithJava/functions/constructor.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("max.kt")
|
||||||
|
public void testMax() throws Exception {
|
||||||
|
doTestWithJava("compiler/testData/codegen/boxWithJava/functions/max.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("referencesStaticInnerClassMethod.kt")
|
@TestMetadata("referencesStaticInnerClassMethod.kt")
|
||||||
public void testReferencesStaticInnerClassMethod() throws Exception {
|
public void testReferencesStaticInnerClassMethod() throws Exception {
|
||||||
doTestWithJava("compiler/testData/codegen/boxWithJava/functions/referencesStaticInnerClassMethod.kt");
|
doTestWithJava("compiler/testData/codegen/boxWithJava/functions/referencesStaticInnerClassMethod.kt");
|
||||||
@@ -147,6 +149,11 @@ public class BlackBoxWithJavaCodegenTestGenerated extends AbstractBlackBoxCodege
|
|||||||
doTestWithJava("compiler/testData/codegen/boxWithJava/functions/referencesStaticInnerClassMethodL2.kt");
|
doTestWithJava("compiler/testData/codegen/boxWithJava/functions/referencesStaticInnerClassMethodL2.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("unrelatedUpperBounds.kt")
|
||||||
|
public void testUnrelatedUpperBounds() throws Exception {
|
||||||
|
doTestWithJava("compiler/testData/codegen/boxWithJava/functions/unrelatedUpperBounds.kt");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("compiler/testData/codegen/boxWithJava/innerClass")
|
@TestMetadata("compiler/testData/codegen/boxWithJava/innerClass")
|
||||||
|
|||||||
@@ -1386,6 +1386,11 @@ public class LoadJavaTestGenerated extends AbstractLoadJavaTest {
|
|||||||
doTestCompiledJavaCompareWithKotlin("compiler/testData/loadJava/compiledJavaCompareWithKotlin/library/LoadIterator.java");
|
doTestCompiledJavaCompareWithKotlin("compiler/testData/loadJava/compiledJavaCompareWithKotlin/library/LoadIterator.java");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("Max.java")
|
||||||
|
public void testMax() throws Exception {
|
||||||
|
doTestCompiledJavaCompareWithKotlin("compiler/testData/loadJava/compiledJavaCompareWithKotlin/library/Max.java");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("compiler/testData/loadJava/compiledJavaCompareWithKotlin/modality")
|
@TestMetadata("compiler/testData/loadJava/compiledJavaCompareWithKotlin/modality")
|
||||||
|
|||||||
+5
@@ -2369,6 +2369,11 @@ public class LazyResolveRecursiveComparingTestGenerated extends AbstractLazyReso
|
|||||||
doTestNotCheckingPrimaryConstructors("compiler/testData/loadJava/compiledJavaCompareWithKotlin/library/LoadIterator.kt");
|
doTestNotCheckingPrimaryConstructors("compiler/testData/loadJava/compiledJavaCompareWithKotlin/library/LoadIterator.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("Max.kt")
|
||||||
|
public void testMax() throws Exception {
|
||||||
|
doTestNotCheckingPrimaryConstructors("compiler/testData/loadJava/compiledJavaCompareWithKotlin/library/Max.kt");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@TestMetadata("compiler/testData/loadJava/compiledJavaCompareWithKotlin/modality")
|
@TestMetadata("compiler/testData/loadJava/compiledJavaCompareWithKotlin/modality")
|
||||||
|
|||||||
@@ -1259,7 +1259,7 @@
|
|||||||
<item name="java.util.Collections T max(java.util.Collection<? extends T>)">
|
<item name="java.util.Collections T max(java.util.Collection<? extends T>)">
|
||||||
<annotation name="org.jetbrains.annotations.NotNull"/>
|
<annotation name="org.jetbrains.annotations.NotNull"/>
|
||||||
<annotation name="jet.runtime.typeinfo.KotlinSignature">
|
<annotation name="jet.runtime.typeinfo.KotlinSignature">
|
||||||
<val name="value" val=""fun <T: Comparable<T>> max(coll : Collection<T>) : T""/>
|
<val name="value" val=""fun <T: Any> max(coll : Collection<T>) : T where T: Comparable<T>""/>
|
||||||
</annotation>
|
</annotation>
|
||||||
</item>
|
</item>
|
||||||
<item name="java.util.Collections T max(java.util.Collection<? extends T>) 0">
|
<item name="java.util.Collections T max(java.util.Collection<? extends T>) 0">
|
||||||
@@ -1281,7 +1281,7 @@
|
|||||||
<item name="java.util.Collections T min(java.util.Collection<? extends T>)">
|
<item name="java.util.Collections T min(java.util.Collection<? extends T>)">
|
||||||
<annotation name="org.jetbrains.annotations.NotNull"/>
|
<annotation name="org.jetbrains.annotations.NotNull"/>
|
||||||
<annotation name="jet.runtime.typeinfo.KotlinSignature">
|
<annotation name="jet.runtime.typeinfo.KotlinSignature">
|
||||||
<val name="value" val=""fun <T: Comparable<T>> min(coll : Collection<T>) : T""/>
|
<val name="value" val=""fun <T: Any> min(coll : Collection<T>) : T where T: Comparable<T>""/>
|
||||||
</annotation>
|
</annotation>
|
||||||
</item>
|
</item>
|
||||||
<item name="java.util.Collections T min(java.util.Collection<? extends T>) 0">
|
<item name="java.util.Collections T min(java.util.Collection<? extends T>) 0">
|
||||||
|
|||||||
Reference in New Issue
Block a user