diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/ClosureCodegen.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/ClosureCodegen.java index e48457f66f8..95da1862900 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/ClosureCodegen.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/ClosureCodegen.java @@ -203,7 +203,7 @@ public class ClosureCodegen extends MemberCodegen { erasedInterfaceFunction = getErasedInvokeFunction(funDescriptor); } else { - erasedInterfaceFunction = samType.getAbstractMethod().getOriginal(); + erasedInterfaceFunction = samType.getOriginalAbstractMethod(); } generateBridge( diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/SamType.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/SamType.java index 6214f1f70d8..c86e0cd53d1 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/SamType.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/SamType.java @@ -54,8 +54,8 @@ public class SamType { } @NotNull - public SimpleFunctionDescriptor getAbstractMethod() { - return (SimpleFunctionDescriptor) SingleAbstractMethodUtils.getAbstractMembers(type).get(0); + public SimpleFunctionDescriptor getOriginalAbstractMethod() { + return (SimpleFunctionDescriptor) SingleAbstractMethodUtils.getAbstractMembers(getJavaClassDescriptor()).get(0); } @Override diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/SamWrapperCodegen.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/SamWrapperCodegen.java index 3b591f2200d..e3731cd284c 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/SamWrapperCodegen.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/SamWrapperCodegen.java @@ -88,7 +88,7 @@ public class SamWrapperCodegen { /* isExternal = */ false ); // e.g. compare(T, T) - SimpleFunctionDescriptor erasedInterfaceFunction = samType.getAbstractMethod().getOriginal().copy( + SimpleFunctionDescriptor erasedInterfaceFunction = samType.getOriginalAbstractMethod().copy( classDescriptor, Modality.FINAL, Visibilities.PUBLIC, @@ -167,7 +167,7 @@ public class SamWrapperCodegen { // generate sam bridges // TODO: erasedInterfaceFunction is actually not an interface function, but function in generated class - SimpleFunctionDescriptor originalInterfaceErased = samType.getAbstractMethod().getOriginal(); + SimpleFunctionDescriptor originalInterfaceErased = samType.getOriginalAbstractMethod(); SimpleFunctionDescriptorImpl descriptorForBridges = SimpleFunctionDescriptorImpl .create(erasedInterfaceFunction.getContainingDeclaration(), erasedInterfaceFunction.getAnnotations(), originalInterfaceErased.getName(), CallableMemberDescriptor.Kind.DECLARATION, erasedInterfaceFunction.getSource()); diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/state/KotlinTypeMapper.java b/compiler/backend/src/org/jetbrains/kotlin/codegen/state/KotlinTypeMapper.java index 37c29cb85bb..8b3b4fe6c86 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/state/KotlinTypeMapper.java +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/state/KotlinTypeMapper.java @@ -899,7 +899,7 @@ public class KotlinTypeMapper { if (expression instanceof KtLambdaExpression) { SamType samType = bindingContext.get(SAM_VALUE, (KtExpression) expression); if (samType != null) { - return samType.getAbstractMethod().getName().asString(); + return samType.getOriginalAbstractMethod().getName().asString(); } } } diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/sam/SingleAbstractMethodUtils.java b/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/sam/SingleAbstractMethodUtils.java index 1e0342a69d6..26d5bb8ef55 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/sam/SingleAbstractMethodUtils.java +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/load/java/sam/SingleAbstractMethodUtils.java @@ -47,9 +47,9 @@ public class SingleAbstractMethodUtils { } @NotNull - public static List getAbstractMembers(@NotNull KotlinType type) { + public static List getAbstractMembers(@NotNull ClassDescriptor classDescriptor) { List abstractMembers = new ArrayList<>(); - for (DeclarationDescriptor member : DescriptorUtils.getAllDescriptors(type.getMemberScope())) { + for (DeclarationDescriptor member : DescriptorUtils.getAllDescriptors(classDescriptor.getUnsubstitutedMemberScope())) { if (member instanceof CallableMemberDescriptor && ((CallableMemberDescriptor) member).getModality() == Modality.ABSTRACT) { abstractMembers.add((CallableMemberDescriptor) member); } @@ -154,7 +154,7 @@ public class SingleAbstractMethodUtils { if (klass.isDefinitelyNotSamInterface()) return null; - List abstractMembers = getAbstractMembers(klass.getDefaultType()); + List abstractMembers = getAbstractMembers(klass); if (abstractMembers.size() == 1) { CallableMemberDescriptor member = abstractMembers.get(0); if (member instanceof SimpleFunctionDescriptor) {