diff --git a/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/JavaSyntheticPropertiesScope.kt b/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/JavaSyntheticPropertiesScope.kt index 9885720737c..87b119dd10d 100644 --- a/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/JavaSyntheticPropertiesScope.kt +++ b/compiler/frontend.java/src/org/jetbrains/kotlin/synthetic/JavaSyntheticPropertiesScope.kt @@ -1,5 +1,5 @@ /* - * Copyright 2010-2015 JetBrains s.r.o. + * Copyright 2010-2016 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -120,7 +120,7 @@ class JavaSyntheticPropertiesScope(storageManager: StorageManager, private val l val getMethod = possibleGetMethodNames .flatMap { memberScope.getContributedFunctions(it, NoLookupLocation.FROM_SYNTHETIC_SCOPE) } .singleOrNull { - isGoodGetMethod(it) && it.hasJavaOriginInHierarchy() + it.hasJavaOriginInHierarchy() && isGoodGetMethod(it) } ?: return result(null, possibleGetMethodNames) diff --git a/compiler/testData/diagnostics/tests/inference/regressions/noRecursionOnCallingPureKotlinFunctionAsSyntheticJavaAccessor.kt b/compiler/testData/diagnostics/tests/inference/regressions/noRecursionOnCallingPureKotlinFunctionAsSyntheticJavaAccessor.kt new file mode 100644 index 00000000000..87ffa3dd7e6 --- /dev/null +++ b/compiler/testData/diagnostics/tests/inference/regressions/noRecursionOnCallingPureKotlinFunctionAsSyntheticJavaAccessor.kt @@ -0,0 +1,3 @@ +class B { + fun getA() = a +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/inference/regressions/noRecursionOnCallingPureKotlinFunctionAsSyntheticJavaAccessor.txt b/compiler/testData/diagnostics/tests/inference/regressions/noRecursionOnCallingPureKotlinFunctionAsSyntheticJavaAccessor.txt new file mode 100644 index 00000000000..2327e56c33f --- /dev/null +++ b/compiler/testData/diagnostics/tests/inference/regressions/noRecursionOnCallingPureKotlinFunctionAsSyntheticJavaAccessor.txt @@ -0,0 +1,9 @@ +package + +public final class B { + public constructor B() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public final fun getA(): [ERROR : Error function type] + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/testData/diagnostics/tests/j+k/recursionWithJavaSyntheticProperty.kt b/compiler/testData/diagnostics/tests/j+k/recursionWithJavaSyntheticProperty.kt new file mode 100644 index 00000000000..db64efbde5c --- /dev/null +++ b/compiler/testData/diagnostics/tests/j+k/recursionWithJavaSyntheticProperty.kt @@ -0,0 +1,12 @@ +// FILE: X.java + +public class X { + int getFoo() {return 3;} +} + +// FILE: Usage.kt + +class A : X() { + // TODO: DEBUG_INFO_MISSING_UNRESOLVED indicates a bug here + override fun getFoo() = foo +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/j+k/recursionWithJavaSyntheticProperty.txt b/compiler/testData/diagnostics/tests/j+k/recursionWithJavaSyntheticProperty.txt new file mode 100644 index 00000000000..6b6931497e2 --- /dev/null +++ b/compiler/testData/diagnostics/tests/j+k/recursionWithJavaSyntheticProperty.txt @@ -0,0 +1,17 @@ +package + +public final class A : X { + public constructor A() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + protected open override /*1*/ fun getFoo(): [ERROR : Error function type] + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +public open class X { + public constructor X() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public/*package*/ open fun getFoo(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java index 9a5d55758aa..0572fa5dfe3 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java @@ -9112,6 +9112,12 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/inference/regressions/kt948.kt"); doTest(fileName); } + + @TestMetadata("noRecursionOnCallingPureKotlinFunctionAsSyntheticJavaAccessor.kt") + public void testNoRecursionOnCallingPureKotlinFunctionAsSyntheticJavaAccessor() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/inference/regressions/noRecursionOnCallingPureKotlinFunctionAsSyntheticJavaAccessor.kt"); + doTest(fileName); + } } @TestMetadata("compiler/testData/diagnostics/tests/inference/reportingImprovements") @@ -10287,6 +10293,12 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest { doTest(fileName); } + @TestMetadata("recursionWithJavaSyntheticProperty.kt") + public void testRecursionWithJavaSyntheticProperty() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/j+k/recursionWithJavaSyntheticProperty.kt"); + doTest(fileName); + } + @TestMetadata("recursiveRawUpperBound.kt") public void testRecursiveRawUpperBound() throws Exception { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/j+k/recursiveRawUpperBound.kt");