Do not fail when delegating to an (unsupported) dynamic type on the JVM
This commit is contained in:
@@ -25,7 +25,7 @@ import org.jetbrains.jet.utils.keysToMapExceptNulls
|
|||||||
import org.jetbrains.jet.lang.resolve.DescriptorUtils
|
import org.jetbrains.jet.lang.resolve.DescriptorUtils
|
||||||
import org.jetbrains.jet.lang.resolve.MemberComparator
|
import org.jetbrains.jet.lang.resolve.MemberComparator
|
||||||
import java.util.Comparator
|
import java.util.Comparator
|
||||||
import org.jetbrains.jet.lang.resolve.scopes.JetScope
|
import org.jetbrains.jet.lang.types.isDynamic
|
||||||
|
|
||||||
public object CodegenUtilKt {
|
public object CodegenUtilKt {
|
||||||
|
|
||||||
@@ -39,6 +39,7 @@ public object CodegenUtilKt {
|
|||||||
toTrait: ClassDescriptor,
|
toTrait: ClassDescriptor,
|
||||||
delegateExpressionType: JetType? = null
|
delegateExpressionType: JetType? = null
|
||||||
): Map<CallableMemberDescriptor, CallableDescriptor> {
|
): Map<CallableMemberDescriptor, CallableDescriptor> {
|
||||||
|
if (delegateExpressionType?.isDynamic() ?: false) return mapOf();
|
||||||
|
|
||||||
return descriptor.getDefaultType().getMemberScope().getDescriptors().stream()
|
return descriptor.getDefaultType().getMemberScope().getDescriptors().stream()
|
||||||
.filterIsInstance(javaClass<CallableMemberDescriptor>())
|
.filterIsInstance(javaClass<CallableMemberDescriptor>())
|
||||||
|
|||||||
@@ -0,0 +1,5 @@
|
|||||||
|
trait Tr {
|
||||||
|
fun foo()
|
||||||
|
}
|
||||||
|
|
||||||
|
class C(d: <!UNSUPPORTED!>dynamic<!>) : Tr by d
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
package
|
||||||
|
|
||||||
|
internal final class C : Tr {
|
||||||
|
public constructor C(/*0*/ d: dynamic)
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
internal open override /*1*/ /*delegation*/ fun foo(): kotlin.Unit
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
}
|
||||||
|
|
||||||
|
internal trait Tr {
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
internal abstract fun foo(): kotlin.Unit
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
}
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
trait Tr {
|
||||||
|
fun foo()
|
||||||
|
}
|
||||||
|
|
||||||
|
class C(d: dynamic) : Tr by d
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
package
|
||||||
|
|
||||||
|
internal final class C : Tr {
|
||||||
|
public constructor C(/*0*/ d: dynamic)
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
internal open override /*1*/ /*delegation*/ fun foo(): kotlin.Unit
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
}
|
||||||
|
|
||||||
|
internal trait Tr {
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
internal abstract fun foo(): kotlin.Unit
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
}
|
||||||
@@ -3716,6 +3716,12 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest {
|
|||||||
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/diagnostics/tests/dynamicTypes"), Pattern.compile("^(.+)\\.kt$"), true);
|
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/diagnostics/tests/dynamicTypes"), Pattern.compile("^(.+)\\.kt$"), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("delegationBy.kt")
|
||||||
|
public void testDelegationBy() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/dynamicTypes/delegationBy.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("unsupported.kt")
|
@TestMetadata("unsupported.kt")
|
||||||
public void testUnsupported() throws Exception {
|
public void testUnsupported() throws Exception {
|
||||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/dynamicTypes/unsupported.kt");
|
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/dynamicTypes/unsupported.kt");
|
||||||
|
|||||||
@@ -75,6 +75,12 @@ public class JetDiagnosticsTestWithJsStdLibGenerated extends AbstractJetDiagnost
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("delegationBy.kt")
|
||||||
|
public void testDelegationBy() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithJsStdLib/dynamicTypes/delegationBy.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("dynamicCalls.kt")
|
@TestMetadata("dynamicCalls.kt")
|
||||||
public void testDynamicCalls() throws Exception {
|
public void testDynamicCalls() throws Exception {
|
||||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithJsStdLib/dynamicTypes/dynamicCalls.kt");
|
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/testsWithJsStdLib/dynamicTypes/dynamicCalls.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user