diff --git a/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/sam/SingleAbstractMethodUtils.java b/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/sam/SingleAbstractMethodUtils.java index f9ea9153c7c..5e9b8f937be 100644 --- a/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/sam/SingleAbstractMethodUtils.java +++ b/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/sam/SingleAbstractMethodUtils.java @@ -94,11 +94,17 @@ public class SingleAbstractMethodUtils { JetType returnType = typeParametersSubstitutor.substitute(klass.getDefaultType(), Variance.OUT_VARIANCE); assert returnType != null : "couldn't substitute type: " + returnType + ", substitutor = " + typeParametersSubstitutor; - for (TypeParameterDescriptorImpl typeParameter : traitToFunTypeParameters.values()) { - // TODO copy substituted upper bound - // TODO consider recursive upper bound - typeParameter.addDefaultUpperBound(); - typeParameter.setInitialized(); + for (Map.Entry mapEntry : traitToFunTypeParameters.entrySet()) { + TypeParameterDescriptor traitTypeParameter = mapEntry.getKey(); + TypeParameterDescriptorImpl funTypeParameter = mapEntry.getValue(); + + for (JetType upperBound : traitTypeParameter.getUpperBounds()) { + JetType upperBoundSubstituted = typeParametersSubstitutor.substitute(upperBound, Variance.INVARIANT); + assert upperBoundSubstituted != null : "couldn't substitute type: " + upperBound + ", substitutor = " + typeParametersSubstitutor; + funTypeParameter.addUpperBound(upperBoundSubstituted); + } + + funTypeParameter.setInitialized(); } result.initialize( diff --git a/compiler/testData/loadJava/compiledJava/singleAbstractMethod/GenericInterfaceParameterWithSelfBound.java b/compiler/testData/loadJava/compiledJava/singleAbstractMethod/GenericInterfaceParameterWithSelfBound.java new file mode 100644 index 00000000000..b527d4e2d2a --- /dev/null +++ b/compiler/testData/loadJava/compiledJava/singleAbstractMethod/GenericInterfaceParameterWithSelfBound.java @@ -0,0 +1,7 @@ +package test; + +import java.util.List; + +public interface GenericInterfaceParameterWithSelfBound> { + T method(T t); +} diff --git a/compiler/testData/loadJava/compiledJava/singleAbstractMethod/GenericInterfaceParameterWithSelfBound.txt b/compiler/testData/loadJava/compiledJava/singleAbstractMethod/GenericInterfaceParameterWithSelfBound.txt new file mode 100644 index 00000000000..a136c992d7c --- /dev/null +++ b/compiler/testData/loadJava/compiledJava/singleAbstractMethod/GenericInterfaceParameterWithSelfBound.txt @@ -0,0 +1,7 @@ +package test + +public /*synthesized*/ fun ?> GenericInterfaceParameterWithSelfBound(/*0*/ function : (T?) -> T?) : test.GenericInterfaceParameterWithSelfBound + +public trait GenericInterfaceParameterWithSelfBound?> : java.lang.Object { + public abstract fun method(/*0*/ p0 : T?) : T? +} diff --git a/compiler/testData/loadJava/compiledJava/singleAbstractMethod/GenericInterfaceParametersWithBounds.java b/compiler/testData/loadJava/compiledJava/singleAbstractMethod/GenericInterfaceParametersWithBounds.java new file mode 100644 index 00000000000..73270ef0fbc --- /dev/null +++ b/compiler/testData/loadJava/compiledJava/singleAbstractMethod/GenericInterfaceParametersWithBounds.java @@ -0,0 +1,7 @@ +package test; + +import java.util.List; + +public interface GenericInterfaceParametersWithBounds & Cloneable, B extends List> { + void method(A[] a, B b); +} diff --git a/compiler/testData/loadJava/compiledJava/singleAbstractMethod/GenericInterfaceParametersWithBounds.txt b/compiler/testData/loadJava/compiledJava/singleAbstractMethod/GenericInterfaceParametersWithBounds.txt new file mode 100644 index 00000000000..6b0e3f65043 --- /dev/null +++ b/compiler/testData/loadJava/compiledJava/singleAbstractMethod/GenericInterfaceParametersWithBounds.txt @@ -0,0 +1,7 @@ +package test + +public /*synthesized*/ fun ?> GenericInterfaceParametersWithBounds(/*0*/ function : (jet.Array?, B?) -> jet.Unit) : test.GenericInterfaceParametersWithBounds where A : jet.Comparable?, A : java.lang.Cloneable? + +public trait GenericInterfaceParametersWithBounds?> : java.lang.Object where A : jet.Comparable?, A : java.lang.Cloneable? { + public abstract fun method(/*0*/ p0 : jet.Array?, /*1*/ p1 : B?) : jet.Unit +} diff --git a/compiler/tests/org/jetbrains/jet/jvm/compiler/LoadJavaTestGenerated.java b/compiler/tests/org/jetbrains/jet/jvm/compiler/LoadJavaTestGenerated.java index 15e654443a7..8c3b8a90b6c 100644 --- a/compiler/tests/org/jetbrains/jet/jvm/compiler/LoadJavaTestGenerated.java +++ b/compiler/tests/org/jetbrains/jet/jvm/compiler/LoadJavaTestGenerated.java @@ -1140,6 +1140,16 @@ public class LoadJavaTestGenerated extends AbstractLoadJavaTest { doTestCompiledJava("compiler/testData/loadJava/compiledJava/singleAbstractMethod/FilenameFilter.java"); } + @TestMetadata("GenericInterfaceParameterWithSelfBound.java") + public void testGenericInterfaceParameterWithSelfBound() throws Exception { + doTestCompiledJava("compiler/testData/loadJava/compiledJava/singleAbstractMethod/GenericInterfaceParameterWithSelfBound.java"); + } + + @TestMetadata("GenericInterfaceParametersWithBounds.java") + public void testGenericInterfaceParametersWithBounds() throws Exception { + doTestCompiledJava("compiler/testData/loadJava/compiledJava/singleAbstractMethod/GenericInterfaceParametersWithBounds.java"); + } + @TestMetadata("GenericMethodParameters.java") public void testGenericMethodParameters() throws Exception { doTestCompiledJava("compiler/testData/loadJava/compiledJava/singleAbstractMethod/GenericMethodParameters.java");