From e3b1639edf67e1891895aee0ae44a7ffd3c020e0 Mon Sep 17 00:00:00 2001 From: Andrey Breslav Date: Tue, 8 Jul 2014 21:41:48 +0400 Subject: [PATCH] KT-5425 Kotlin plugin crashes when project uses RxJava 17.0 or older #KT-5425 Fixed --- .../tests/j+k/samInConstructorWithGenerics.kt | 21 +++++++++++++++++++ .../checkers/JetDiagnosticsTestGenerated.java | 5 +++++ .../descriptor/JavaConstructorDescriptor.java | 2 +- .../impl/ConstructorDescriptorImpl.java | 2 +- 4 files changed, 28 insertions(+), 2 deletions(-) create mode 100644 compiler/testData/diagnostics/tests/j+k/samInConstructorWithGenerics.kt diff --git a/compiler/testData/diagnostics/tests/j+k/samInConstructorWithGenerics.kt b/compiler/testData/diagnostics/tests/j+k/samInConstructorWithGenerics.kt new file mode 100644 index 00000000000..705eb1bc5d1 --- /dev/null +++ b/compiler/testData/diagnostics/tests/j+k/samInConstructorWithGenerics.kt @@ -0,0 +1,21 @@ +// FILE: j/OnSubscribe.java +package j; + +public interface OnSubscribe { + void f(); +} + +// FILE: j/Observable.java +package j; + +public class Observable { + + protected Observable(OnSubscribe f) { + } +} + +// FILE: Kotlin.kt + +import j.* + +class K : Observable({}) \ No newline at end of file diff --git a/compiler/tests/org/jetbrains/jet/checkers/JetDiagnosticsTestGenerated.java b/compiler/tests/org/jetbrains/jet/checkers/JetDiagnosticsTestGenerated.java index e5764ae6cb6..ee289e33482 100644 --- a/compiler/tests/org/jetbrains/jet/checkers/JetDiagnosticsTestGenerated.java +++ b/compiler/tests/org/jetbrains/jet/checkers/JetDiagnosticsTestGenerated.java @@ -5151,6 +5151,11 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest { doTest("compiler/testData/diagnostics/tests/j+k/recursiveRawUpperBound.kt"); } + @TestMetadata("samInConstructorWithGenerics.kt") + public void testSamInConstructorWithGenerics() throws Exception { + doTest("compiler/testData/diagnostics/tests/j+k/samInConstructorWithGenerics.kt"); + } + @TestMetadata("Simple.kt") public void testSimple() throws Exception { doTest("compiler/testData/diagnostics/tests/j+k/Simple.kt"); diff --git a/core/descriptor.loader.java/src/org/jetbrains/jet/lang/resolve/java/descriptor/JavaConstructorDescriptor.java b/core/descriptor.loader.java/src/org/jetbrains/jet/lang/resolve/java/descriptor/JavaConstructorDescriptor.java index 63d9b224817..a1229be2501 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/jet/lang/resolve/java/descriptor/JavaConstructorDescriptor.java +++ b/core/descriptor.loader.java/src/org/jetbrains/jet/lang/resolve/java/descriptor/JavaConstructorDescriptor.java @@ -74,7 +74,7 @@ public class JavaConstructorDescriptor extends ConstructorDescriptorImpl impleme @Nullable FunctionDescriptor original, @NotNull Kind kind ) { - if (kind != Kind.DECLARATION) { + if (kind != Kind.DECLARATION && kind != Kind.SYNTHESIZED) { throw new IllegalStateException("Attempt at creating a constructor that is not a declaration: \n" + "copy from: " + this + "\n" + "newOwner: " + newOwner + "\n" + diff --git a/core/descriptors/src/org/jetbrains/jet/lang/descriptors/impl/ConstructorDescriptorImpl.java b/core/descriptors/src/org/jetbrains/jet/lang/descriptors/impl/ConstructorDescriptorImpl.java index cd2c63fb2c9..65273140162 100644 --- a/core/descriptors/src/org/jetbrains/jet/lang/descriptors/impl/ConstructorDescriptorImpl.java +++ b/core/descriptors/src/org/jetbrains/jet/lang/descriptors/impl/ConstructorDescriptorImpl.java @@ -112,7 +112,7 @@ public class ConstructorDescriptorImpl extends FunctionDescriptorImpl implements @Nullable FunctionDescriptor original, @NotNull Kind kind ) { - if (kind != Kind.DECLARATION) { + if (kind != Kind.DECLARATION && kind != Kind.SYNTHESIZED) { throw new IllegalStateException("Attempt at creating a constructor that is not a declaration: \n" + "copy from: " + this + "\n" + "newOwner: " + newOwner + "\n" +