Add compatibility warning for SAM conversions on Kotlin functions

This commit is contained in:
Mikhail Zarechenskiy
2020-05-29 14:15:35 +03:00
parent 080d8fa127
commit 01de789c76
15 changed files with 467 additions and 2 deletions
@@ -7959,6 +7959,11 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirOldFronte
runTest("compiler/testData/diagnostics/tests/funInterface/genericSubstitutionForFunInterface.kt");
}
@TestMetadata("noCompatibilityResolveForFunInterfaces.kt")
public void testNoCompatibilityResolveForFunInterfaces() throws Exception {
runTest("compiler/testData/diagnostics/tests/funInterface/noCompatibilityResolveForFunInterfaces.kt");
}
@TestMetadata("resolveFunInterfaceWithoutMainMethod.kt")
public void testResolveFunInterfaceWithoutMainMethod() throws Exception {
runTest("compiler/testData/diagnostics/tests/funInterface/resolveFunInterfaceWithoutMainMethod.kt");
@@ -13611,6 +13616,11 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirOldFronte
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/j+k/sam"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
}
@TestMetadata("compatibilityResolveToOuterScopeForKotlinFunctions.kt")
public void testCompatibilityResolveToOuterScopeForKotlinFunctions() throws Exception {
runTest("compiler/testData/diagnostics/tests/j+k/sam/compatibilityResolveToOuterScopeForKotlinFunctions.kt");
}
@TestMetadata("enhancedSamConstructor.kt")
public void testEnhancedSamConstructor() throws Exception {
runTest("compiler/testData/diagnostics/tests/j+k/sam/enhancedSamConstructor.kt");
@@ -38,4 +38,7 @@ object JavaBasedSamConversionOracle : SamConversionOracle {
val descriptor = samType.constructor.declarationDescriptor
return descriptor is ClassDescriptor && (descriptor.isFun || descriptor is JavaClassDescriptor)
}
override fun isJavaApplicableCandidate(candidate: CallableDescriptor): Boolean =
shouldRunSamConversionForFunction(candidate)
}
@@ -22,4 +22,7 @@ class JvmSamConversionOracle(
override fun isPossibleSamType(samType: KotlinType): Boolean =
JavaBasedSamConversionOracle.isPossibleSamType(samType)
override fun isJavaApplicableCandidate(candidate: CallableDescriptor): Boolean =
JavaBasedSamConversionOracle.shouldRunSamConversionForFunction(candidate)
}
@@ -11,6 +11,7 @@ import org.jetbrains.kotlin.config.LanguageFeature
import org.jetbrains.kotlin.descriptors.ClassDescriptor
import org.jetbrains.kotlin.descriptors.ParameterDescriptor
import org.jetbrains.kotlin.incremental.record
import org.jetbrains.kotlin.resolve.calls.inference.model.LowerPriorityToPreserveCompatibility
import org.jetbrains.kotlin.resolve.calls.model.*
import org.jetbrains.kotlin.resolve.sam.SAM_LOOKUP_NAME
import org.jetbrains.kotlin.resolve.sam.getFunctionTypeForPossibleSamType
@@ -86,6 +87,10 @@ object SamTypeConversions : ParameterTypeConversion {
SamConversionDescription(convertedTypeByOriginal, convertedTypeByCandidate!!)
)
if (needCompatibilityResolve(candidate, expectedParameterType)) {
candidate.addDiagnostic(LowerPriorityToPreserveCompatibility)
}
val samDescriptor = originalExpectedType.constructor.declarationDescriptor
if (samDescriptor is ClassDescriptor) {
callComponents.lookupTracker.record(candidate.scopeTower.location, samDescriptor, SAM_LOOKUP_NAME)
@@ -93,4 +98,13 @@ object SamTypeConversions : ParameterTypeConversion {
return convertedTypeByCandidate
}
private fun needCompatibilityResolve(candidate: KotlinResolutionCandidate, typeToConvert: UnwrappedType): Boolean {
// fun interfaces is a new feature with a new modifier, so no compatibility resolve is needed
val descriptor = typeToConvert.constructor.declarationDescriptor
if (descriptor is ClassDescriptor && descriptor.isFun) return false
// now conversions for Kotlin candidates are possible, so we have to perform compatibility resolve
return !candidate.callComponents.samConversionOracle.isJavaApplicableCandidate(candidate.resolvedCall.candidateDescriptor)
}
}
@@ -19,8 +19,7 @@ package org.jetbrains.kotlin.resolve.calls.inference.model
import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor
import org.jetbrains.kotlin.resolve.calls.model.*
import org.jetbrains.kotlin.resolve.calls.tower.ResolutionCandidateApplicability
import org.jetbrains.kotlin.resolve.calls.tower.ResolutionCandidateApplicability.INAPPLICABLE
import org.jetbrains.kotlin.resolve.calls.tower.ResolutionCandidateApplicability.INAPPLICABLE_WRONG_RECEIVER
import org.jetbrains.kotlin.resolve.calls.tower.ResolutionCandidateApplicability.*
import org.jetbrains.kotlin.resolve.scopes.receivers.DetailedReceiver
import org.jetbrains.kotlin.types.KotlinType
import org.jetbrains.kotlin.types.model.KotlinTypeMarker
@@ -123,3 +122,5 @@ class ConstrainingTypeIsError(
val constraintType: KotlinTypeMarker,
val position: IncorporationConstraintPosition
) : ConstraintSystemCallDiagnostic(INAPPLICABLE)
object LowerPriorityToPreserveCompatibility : ConstraintSystemCallDiagnostic(RESOLVED_NEED_PRESERVE_COMPATIBILITY)
@@ -86,6 +86,7 @@ fun getResultApplicability(diagnostics: Collection<KotlinCallDiagnostic>) =
enum class ResolutionCandidateApplicability {
RESOLVED, // call success or has uncompleted inference or in other words possible successful candidate
RESOLVED_WITH_ERROR, // call has error, but it is still successful from resolution perspective
RESOLVED_NEED_PRESERVE_COMPATIBILITY, // call resolved successfully, but using new features that changes resolve
RESOLVED_LOW_PRIORITY,
CONVENTION_ERROR, // missing infix, operator etc
MAY_THROW_RUNTIME_ERROR, // unsafe call or unstable smart cast
@@ -120,6 +121,7 @@ class UsedSmartCastForDispatchReceiver(val smartCastType: KotlinType) : Resoluti
object ErrorDescriptorDiagnostic : ResolutionDiagnostic(RESOLVED) // todo discuss and change to INAPPLICABLE
object LowPriorityDescriptorDiagnostic : ResolutionDiagnostic(RESOLVED_LOW_PRIORITY)
object DynamicDescriptorDiagnostic : ResolutionDiagnostic(RESOLVED_LOW_PRIORITY)
object ResolvedUsingNewFeatures : ResolutionDiagnostic(RESOLVED_NEED_PRESERVE_COMPATIBILITY)
object UnstableSmartCastDiagnostic : ResolutionDiagnostic(RESOLVED_WITH_ERROR)
object HiddenExtensionRelatedToDynamicTypes : ResolutionDiagnostic(HIDDEN)
object HiddenDescriptor : ResolutionDiagnostic(HIDDEN)
@@ -0,0 +1,65 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_EXPRESSION
fun interface KRunnable {
fun invoke()
}
object Test1 {
fun foo(x: Any) {}
fun foo(f: () -> Unit) {}
object Scope {
fun foo(r: KRunnable) {}
fun test(f: () -> Unit) {
<!DEBUG_INFO_CALL("fqName: Test1.Scope.foo; typeCall: function")!>foo(f)<!>
}
}
}
object Test2 {
fun foo(f: () -> String) {}
object Scope {
fun foo(r: KRunnable) {}
fun test(f: () -> Unit) {
<!DEBUG_INFO_CALL("fqName: Test2.Scope.foo; typeCall: function")!>foo(f)<!>
}
}
}
object Test3 {
fun foo(i: Int, r: KRunnable): Int = 0
fun foo(n: Number, f: () -> Unit): String = ""
fun test(f: () -> Unit) {
val result = foo(1, f)
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Int")!>result<!>
}
}
object Test4 {
fun foo(i: Int, r: KRunnable): Int = 0
fun foo(n: Number, f: () -> Unit): String = ""
fun bar() {}
fun test() {
val result = foo(1, ::bar)
result
}
}
object Test5 {
fun foo(x: Any) {}
fun foo(f: () -> Unit) {}
object Scope {
fun foo(r: KRunnable) {}
fun test() {
foo { }
}
}
}
@@ -0,0 +1,65 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_EXPRESSION
fun interface KRunnable {
fun invoke()
}
object Test1 {
fun foo(x: Any) {}
fun foo(f: () -> Unit) {}
object Scope {
fun foo(r: KRunnable) {}
fun test(f: () -> Unit) {
<!DEBUG_INFO_CALL("fqName: Test1.Scope.foo; typeCall: function")!>foo(f)<!>
}
}
}
object Test2 {
fun foo(f: () -> String) {}
object Scope {
fun foo(r: KRunnable) {}
fun test(f: () -> Unit) {
<!DEBUG_INFO_CALL("fqName: Test2.Scope.foo; typeCall: function")!>foo(f)<!>
}
}
}
object Test3 {
fun foo(i: Int, r: KRunnable): Int = 0
fun foo(n: Number, f: () -> Unit): String = ""
fun test(f: () -> Unit) {
val result = foo(1, f)
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Int")!>result<!>
}
}
object Test4 {
fun foo(i: Int, r: KRunnable): Int = 0
fun foo(n: Number, f: () -> Unit): String = ""
fun bar() {}
fun test() {
val result = foo(1, ::bar)
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Int")!>result<!>
}
}
object Test5 {
fun foo(x: Any) {}
fun foo(f: () -> Unit) {}
object Scope {
fun foo(r: KRunnable) {}
fun test() {
<!DEBUG_INFO_CALL("fqName: Test5.Scope.foo; typeCall: function")!>foo { }<!>
}
}
}
@@ -0,0 +1,82 @@
package
public fun interface KRunnable {
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public abstract fun invoke(): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public object Test1 {
private constructor Test1()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public final fun foo(/*0*/ f: () -> kotlin.Unit): kotlin.Unit
public final fun foo(/*0*/ x: kotlin.Any): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
public object Scope {
private constructor Scope()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public final fun foo(/*0*/ r: KRunnable): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public final fun test(/*0*/ f: () -> kotlin.Unit): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
}
public object Test2 {
private constructor Test2()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public final fun foo(/*0*/ f: () -> kotlin.String): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
public object Scope {
private constructor Scope()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public final fun foo(/*0*/ r: KRunnable): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public final fun test(/*0*/ f: () -> kotlin.Unit): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
}
public object Test3 {
private constructor Test3()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public final fun foo(/*0*/ i: kotlin.Int, /*1*/ r: KRunnable): kotlin.Int
public final fun foo(/*0*/ n: kotlin.Number, /*1*/ f: () -> kotlin.Unit): kotlin.String
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public final fun test(/*0*/ f: () -> kotlin.Unit): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public object Test4 {
private constructor Test4()
public final fun bar(): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public final fun foo(/*0*/ i: kotlin.Int, /*1*/ r: KRunnable): kotlin.Int
public final fun foo(/*0*/ n: kotlin.Number, /*1*/ f: () -> kotlin.Unit): kotlin.String
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public final fun test(): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public object Test5 {
private constructor Test5()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public final fun foo(/*0*/ f: () -> kotlin.Unit): kotlin.Unit
public final fun foo(/*0*/ x: kotlin.Any): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
public object Scope {
private constructor Scope()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public final fun foo(/*0*/ r: KRunnable): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public final fun test(): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
}
@@ -0,0 +1,61 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_EXPRESSION
object Test1 {
fun foo(x: Any) {}
fun foo(f: () -> Unit) {}
object Scope {
fun foo(r: Runnable) {}
fun test(f: () -> Unit) {
<!DEBUG_INFO_CALL("fqName: Test1.foo; typeCall: function")!>foo(f)<!>
}
}
}
object Test2 {
fun foo(f: () -> String) {}
object Scope {
fun foo(r: Runnable) {}
fun test(f: () -> Unit) {
<!DEBUG_INFO_CALL("fqName: Test2.Scope.foo; typeCall: function")!>foo(f)<!>
}
}
}
object Test3 {
fun foo(i: Int, r: Runnable): Int = 0
fun foo(n: Number, f: () -> Unit): String = ""
fun test(f: () -> Unit) {
val result = foo(1, f)
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String")!>result<!>
}
}
object Test4 {
fun foo(i: Int, r: Runnable): Int = 0
fun foo(n: Number, f: () -> Unit): String = ""
fun bar() {}
fun test() {
val result = foo(1, ::bar)
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String")!>result<!>
}
}
object Test5 {
fun foo(x: Any) {}
fun foo(f: () -> Unit) {}
object Scope {
fun foo(r: Runnable) {}
fun test() {
<!DEBUG_INFO_CALL("fqName: Test5.foo; typeCall: function")!>foo { }<!>
}
}
}
@@ -0,0 +1,61 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_EXPRESSION
object Test1 {
fun foo(x: Any) {}
fun foo(f: () -> Unit) {}
object Scope {
fun foo(r: Runnable) {}
fun test(f: () -> Unit) {
<!DEBUG_INFO_CALL("fqName: Test1.foo; typeCall: function")!>foo(f)<!>
}
}
}
object Test2 {
fun foo(f: () -> String) {}
object Scope {
fun foo(r: Runnable) {}
fun test(f: () -> Unit) {
<!DEBUG_INFO_CALL("fqName: Test2.Scope.foo; typeCall: function")!>foo(f)<!>
}
}
}
object Test3 {
fun foo(i: Int, r: Runnable): Int = 0
fun foo(n: Number, f: () -> Unit): String = ""
fun test(f: () -> Unit) {
val result = foo(1, f)
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String")!>result<!>
}
}
object Test4 {
fun foo(i: Int, r: Runnable): Int = 0
fun foo(n: Number, f: () -> Unit): String = ""
fun bar() {}
fun test() {
val result = foo(1, ::bar)
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.String")!>result<!>
}
}
object Test5 {
fun foo(x: Any) {}
fun foo(f: () -> Unit) {}
object Scope {
fun foo(r: Runnable) {}
fun test() {
<!DEBUG_INFO_CALL("fqName: Test5.foo; typeCall: function")!>foo { }<!>
}
}
}
@@ -0,0 +1,75 @@
package
public object Test1 {
private constructor Test1()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public final fun foo(/*0*/ f: () -> kotlin.Unit): kotlin.Unit
public final fun foo(/*0*/ x: kotlin.Any): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
public object Scope {
private constructor Scope()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public final fun foo(/*0*/ r: java.lang.Runnable): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public final fun test(/*0*/ f: () -> kotlin.Unit): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
}
public object Test2 {
private constructor Test2()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public final fun foo(/*0*/ f: () -> kotlin.String): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
public object Scope {
private constructor Scope()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public final fun foo(/*0*/ r: java.lang.Runnable): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public final fun test(/*0*/ f: () -> kotlin.Unit): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
}
public object Test3 {
private constructor Test3()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public final fun foo(/*0*/ i: kotlin.Int, /*1*/ r: java.lang.Runnable): kotlin.Int
public final fun foo(/*0*/ n: kotlin.Number, /*1*/ f: () -> kotlin.Unit): kotlin.String
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public final fun test(/*0*/ f: () -> kotlin.Unit): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public object Test4 {
private constructor Test4()
public final fun bar(): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public final fun foo(/*0*/ i: kotlin.Int, /*1*/ r: java.lang.Runnable): kotlin.Int
public final fun foo(/*0*/ n: kotlin.Number, /*1*/ f: () -> kotlin.Unit): kotlin.String
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public final fun test(): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public object Test5 {
private constructor Test5()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public final fun foo(/*0*/ f: () -> kotlin.Unit): kotlin.Unit
public final fun foo(/*0*/ x: kotlin.Any): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
public object Scope {
private constructor Scope()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public final fun foo(/*0*/ r: java.lang.Runnable): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public final fun test(): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
}
@@ -7966,6 +7966,11 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTestWithFirVali
runTest("compiler/testData/diagnostics/tests/funInterface/genericSubstitutionForFunInterface.kt");
}
@TestMetadata("noCompatibilityResolveForFunInterfaces.kt")
public void testNoCompatibilityResolveForFunInterfaces() throws Exception {
runTest("compiler/testData/diagnostics/tests/funInterface/noCompatibilityResolveForFunInterfaces.kt");
}
@TestMetadata("resolveFunInterfaceWithoutMainMethod.kt")
public void testResolveFunInterfaceWithoutMainMethod() throws Exception {
runTest("compiler/testData/diagnostics/tests/funInterface/resolveFunInterfaceWithoutMainMethod.kt");
@@ -13618,6 +13623,11 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTestWithFirVali
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/j+k/sam"), Pattern.compile("^(.*)\\.kts?$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
}
@TestMetadata("compatibilityResolveToOuterScopeForKotlinFunctions.kt")
public void testCompatibilityResolveToOuterScopeForKotlinFunctions() throws Exception {
runTest("compiler/testData/diagnostics/tests/j+k/sam/compatibilityResolveToOuterScopeForKotlinFunctions.kt");
}
@TestMetadata("enhancedSamConstructor.kt")
public void testEnhancedSamConstructor() throws Exception {
runTest("compiler/testData/diagnostics/tests/j+k/sam/enhancedSamConstructor.kt");
@@ -7961,6 +7961,11 @@ public class DiagnosticsUsingJavacTestGenerated extends AbstractDiagnosticsUsing
runTest("compiler/testData/diagnostics/tests/funInterface/genericSubstitutionForFunInterface.kt");
}
@TestMetadata("noCompatibilityResolveForFunInterfaces.kt")
public void testNoCompatibilityResolveForFunInterfaces() throws Exception {
runTest("compiler/testData/diagnostics/tests/funInterface/noCompatibilityResolveForFunInterfaces.kt");
}
@TestMetadata("resolveFunInterfaceWithoutMainMethod.kt")
public void testResolveFunInterfaceWithoutMainMethod() throws Exception {
runTest("compiler/testData/diagnostics/tests/funInterface/resolveFunInterfaceWithoutMainMethod.kt");
@@ -13613,6 +13618,11 @@ public class DiagnosticsUsingJavacTestGenerated extends AbstractDiagnosticsUsing
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/testData/diagnostics/tests/j+k/sam"), Pattern.compile("^(.+)\\.kt$"), Pattern.compile("^(.+)\\.fir\\.kts?$"), true);
}
@TestMetadata("compatibilityResolveToOuterScopeForKotlinFunctions.kt")
public void testCompatibilityResolveToOuterScopeForKotlinFunctions() throws Exception {
runTest("compiler/testData/diagnostics/tests/j+k/sam/compatibilityResolveToOuterScopeForKotlinFunctions.kt");
}
@TestMetadata("enhancedSamConstructor.kt")
public void testEnhancedSamConstructor() throws Exception {
runTest("compiler/testData/diagnostics/tests/j+k/sam/enhancedSamConstructor.kt");
@@ -14,6 +14,7 @@ import org.jetbrains.kotlin.types.KotlinType
interface SamConversionOracle {
fun shouldRunSamConversionForFunction(candidate: CallableDescriptor): Boolean
fun isPossibleSamType(samType: KotlinType): Boolean
fun isJavaApplicableCandidate(candidate: CallableDescriptor): Boolean
}
class SamConversionOracleDefault : SamConversionOracle {
@@ -23,4 +24,6 @@ class SamConversionOracleDefault : SamConversionOracle {
val descriptor = samType.constructor.declarationDescriptor
return descriptor is ClassDescriptor && descriptor.isFun
}
override fun isJavaApplicableCandidate(candidate: CallableDescriptor): Boolean = false
}