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 99f4a71bd24..190b1b05701 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 @@ -58,19 +58,7 @@ public class SingleAbstractMethodUtils { } @Nullable - public static SimpleType getFunctionTypeForSamInterface( - @NotNull JavaClassDescriptor clazz, - @Nullable SamConversionResolver samResolver - ) { - if (samResolver == null) { - return clazz.getDefaultFunctionTypeForSamInterface(); - } - - return samResolver.resolveFunctionTypeIfSamInterface(clazz); - } - - @Nullable - public static KotlinType getFunctionTypeForSamType(@NotNull KotlinType samType, @Nullable SamConversionResolver samResolver) { + public static KotlinType getFunctionTypeForSamType(@NotNull KotlinType samType, @NotNull SamConversionResolver samResolver) { UnwrappedType unwrappedType = samType.unwrap(); if (unwrappedType instanceof FlexibleType) { SimpleType lower = getFunctionTypeForSamType(((FlexibleType) unwrappedType).getLowerBound(), samResolver); @@ -86,13 +74,13 @@ public class SingleAbstractMethodUtils { } @Nullable - private static SimpleType getFunctionTypeForSamType(@NotNull SimpleType samType, @Nullable SamConversionResolver samResolver) { + private static SimpleType getFunctionTypeForSamType(@NotNull SimpleType samType, @NotNull SamConversionResolver samResolver) { // e.g. samType == Comparator? ClassifierDescriptor classifier = samType.getConstructor().getDeclarationDescriptor(); if (classifier instanceof JavaClassDescriptor) { // Function2 - SimpleType functionTypeDefault = getFunctionTypeForSamInterface((JavaClassDescriptor) classifier, samResolver); + SimpleType functionTypeDefault = samResolver.resolveFunctionTypeIfSamInterface((JavaClassDescriptor) classifier); if (functionTypeDefault != null) { SimpleType noProjectionsSamType = SingleAbstractMethodUtilsKt.nonProjectionParametrization(samType); @@ -236,7 +224,7 @@ public class SingleAbstractMethodUtils { } public static boolean isSamType(@NotNull KotlinType type) { - return getFunctionTypeForSamType(type, null) != null; + return getFunctionTypeForSamType(type, SamConversionResolver.JavaBasedSamConversionResolver.INSTANCE) != null; } public static boolean isSamAdapterNecessary(@NotNull FunctionDescriptor fun) { diff --git a/core/descriptors.jvm/src/org/jetbrains/kotlin/load/java/components/SamConversionResolver.kt b/core/descriptors.jvm/src/org/jetbrains/kotlin/load/java/components/SamConversionResolver.kt index ccb97c0ec79..a69469f3c4c 100644 --- a/core/descriptors.jvm/src/org/jetbrains/kotlin/load/java/components/SamConversionResolver.kt +++ b/core/descriptors.jvm/src/org/jetbrains/kotlin/load/java/components/SamConversionResolver.kt @@ -17,7 +17,6 @@ package org.jetbrains.kotlin.load.java.components import org.jetbrains.kotlin.container.DefaultImplementation -import org.jetbrains.kotlin.container.PlatformExtensionsClashResolver import org.jetbrains.kotlin.container.PlatformSpecificExtension import org.jetbrains.kotlin.load.java.descriptors.JavaClassDescriptor import org.jetbrains.kotlin.types.SimpleType @@ -28,5 +27,11 @@ interface SamConversionResolver : PlatformSpecificExtension