diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tower/NewResolutionOldInference.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tower/NewResolutionOldInference.kt index 32f69d3ddce..1a1421379df 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tower/NewResolutionOldInference.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/tower/NewResolutionOldInference.kt @@ -19,6 +19,7 @@ package org.jetbrains.kotlin.resolve.calls.tower import org.jetbrains.kotlin.config.LanguageFeature import org.jetbrains.kotlin.config.LanguageVersionSettings import org.jetbrains.kotlin.descriptors.* +import org.jetbrains.kotlin.descriptors.synthetic.SyntheticMemberDescriptor import org.jetbrains.kotlin.diagnostics.Errors import org.jetbrains.kotlin.incremental.components.LookupLocation import org.jetbrains.kotlin.name.Name @@ -596,6 +597,8 @@ internal fun reportResolvedUsingDeprecatedVisibility( val descriptorToLookup: DeclarationDescriptor = when (candidateDescriptor) { is ClassConstructorDescriptor -> candidateDescriptor.containingDeclaration is FakeCallableDescriptorForObject -> candidateDescriptor.classDescriptor + is SyntheticMemberDescriptor<*> -> candidateDescriptor.baseDescriptorForSynthetic + is PropertyDescriptor, is FunctionDescriptor -> candidateDescriptor else -> error( "Unexpected candidate descriptor of resolved call with " + "ResolvedUsingDeprecatedVisibility-diagnostic: $candidateDescriptor\n" + diff --git a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/tower/TowerLevels.kt b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/tower/TowerLevels.kt index f1881355eed..2819218ad2a 100644 --- a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/tower/TowerLevels.kt +++ b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/tower/TowerLevels.kt @@ -222,13 +222,20 @@ internal open class ScopeBasedTowerLevel protected constructor( private val resolutionScope: ResolutionScope ) : AbstractScopeTowerLevel(scopeTower) { + val deprecationDiagnosticOfThisScope: ResolutionDiagnostic? = + if (resolutionScope is DeprecatedLexicalScope) ResolvedUsingDeprecatedVisibility(resolutionScope, location) else null + internal constructor(scopeTower: ImplicitScopeTower, lexicalScope: LexicalScope) : this(scopeTower, lexicalScope as ResolutionScope) override fun getVariables( name: Name, extensionReceiver: ReceiverValueWithSmartCastInfo? ): Collection = resolutionScope.getContributedVariables(name, location).map { - createCandidateDescriptor(it, dispatchReceiver = null) + createCandidateDescriptor( + it, + dispatchReceiver = null, + specialError = deprecationDiagnosticOfThisScope + ) } override fun getObjects( @@ -249,8 +256,13 @@ internal open class ScopeBasedTowerLevel protected constructor( ): Collection { val result: ArrayList = ArrayList() - resolutionScope.getContributedFunctionsAndConstructors(name, location, scopeTower.syntheticScopes) - .mapTo(result) { createCandidateDescriptor(it, dispatchReceiver = null) } + resolutionScope.getContributedFunctionsAndConstructors(name, location, scopeTower.syntheticScopes).mapTo(result) { + createCandidateDescriptor( + it, + dispatchReceiver = null, + specialError = deprecationDiagnosticOfThisScope + ) + } // Add constructors of deprecated classifier with an additional diagnostic val descriptorWithDeprecation = resolutionScope.getContributedClassifierIncludeDeprecated(name, location) diff --git a/compiler/resolution/src/org/jetbrains/kotlin/resolve/scopes/utils/ScopeUtils.kt b/compiler/resolution/src/org/jetbrains/kotlin/resolve/scopes/utils/ScopeUtils.kt index 84f995a6ce5..c05f16effd0 100644 --- a/compiler/resolution/src/org/jetbrains/kotlin/resolve/scopes/utils/ScopeUtils.kt +++ b/compiler/resolution/src/org/jetbrains/kotlin/resolve/scopes/utils/ScopeUtils.kt @@ -17,6 +17,7 @@ package org.jetbrains.kotlin.resolve.scopes.utils import org.jetbrains.kotlin.descriptors.* +import org.jetbrains.kotlin.descriptors.synthetic.SyntheticMemberDescriptor import org.jetbrains.kotlin.incremental.components.LookupLocation import org.jetbrains.kotlin.incremental.components.NoLookupLocation import org.jetbrains.kotlin.name.Name @@ -91,8 +92,20 @@ fun DeclarationDescriptor.canBeResolvedWithoutDeprecation( location: LookupLocation ): Boolean { for (scope in scopeForResolution.parentsWithSelf) { - val (descriptorFromCurrentScope, isDeprecated) = scope.getContributedClassifierIncludeDeprecated(name, location) ?: continue - if (descriptorFromCurrentScope == this && !isDeprecated) return true + val hasNonDeprecatedSuitableCandidate = when (this) { + // Looking for classifier: fair check via special method in ResolutionScope + is ClassifierDescriptor -> scope.getContributedClassifierIncludeDeprecated(name, location) + ?.let { it.descriptor == this && !it.isDeprecated } + + // Looking for member: heuristically check only one case, when another descriptor visible through explicit import + is VariableDescriptor -> (scope as? ImportingScope)?.getContributedVariables(name, location)?.any { it == this } + + is FunctionDescriptor -> (scope as? ImportingScope)?.getContributedFunctions(name, location)?.any { it == this } + + else -> null + } + + if (hasNonDeprecatedSuitableCandidate == true) return true } return false diff --git a/compiler/testData/diagnostics/tests/objects/kt21515/staticsFromJavaNew.kt b/compiler/testData/diagnostics/tests/objects/kt21515/staticsFromJavaNew.kt new file mode 100644 index 00000000000..d1602310a97 --- /dev/null +++ b/compiler/testData/diagnostics/tests/objects/kt21515/staticsFromJavaNew.kt @@ -0,0 +1,48 @@ +// !LANGUAGE: +ProhibitVisibilityOfNestedClassifiersFromSupertypesOfCompanion +// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE + +// FILE: test/Java.java +package test; + +public class Java { + public static void method() { } + public static int property = 42; + public static class Classifier { } + public static void syntheticSam(Runnable r) { } + + public static int getStaticSyntheticProperty() { return 42; } + public static int setStaticSyntheticProperty(int x) { return 42; } + + public int getInstanceSyntheticProperty() { return 42; } + public int setInstanceSyntheticProperty(int x) { return 42; } +} + +// FILE: Kotlin.kt +package test + +open class Base { + companion object : Java() { + + } +} + +class Derived : Base() { + fun test(javaStaticInTypePosition: Classifier) { + method() + property + Classifier() + syntheticSam { } + + // Instance members shouldn't be affected, but we check them, just in case + val y = instanceSyntheticProperty + instanceSyntheticProperty = 43 + + // Note that statics actually aren't converted into synthetic property in Kotlin + val x = syntheticProperty + syntheticProperty = 42 + } + + class JavaStaticInSupertypeList : Classifier() { + + } +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/objects/kt21515/staticsFromJavaNew.txt b/compiler/testData/diagnostics/tests/objects/kt21515/staticsFromJavaNew.txt new file mode 100644 index 00000000000..df6243ef39a --- /dev/null +++ b/compiler/testData/diagnostics/tests/objects/kt21515/staticsFromJavaNew.txt @@ -0,0 +1,58 @@ +package + +package test { + + public open class Base { + public constructor Base() + 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 open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + + public companion object Companion : test.Java { + private constructor Companion() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun getInstanceSyntheticProperty(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun setInstanceSyntheticProperty(/*0*/ x: kotlin.Int): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } + } + + public final class Derived : test.Base { + public constructor Derived() + 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 final fun test(/*0*/ javaStaticInTypePosition: [ERROR : Classifier]): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + + public final class JavaStaticInSupertypeList { + public constructor JavaStaticInSupertypeList() + 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 open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } + } + + public open class Java { + public constructor Java() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open fun getInstanceSyntheticProperty(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open fun setInstanceSyntheticProperty(/*0*/ x: kotlin.Int): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + + public open class Classifier { + public constructor Classifier() + 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 open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } + + // Static members + public final var property: kotlin.Int + public open fun getStaticSyntheticProperty(): kotlin.Int + public open fun method(): kotlin.Unit + public open fun setStaticSyntheticProperty(/*0*/ x: kotlin.Int): kotlin.Int + public open fun syntheticSam(/*0*/ r: java.lang.Runnable!): kotlin.Unit + } +} diff --git a/compiler/testData/diagnostics/tests/objects/kt21515/staticsFromJavaOld.kt b/compiler/testData/diagnostics/tests/objects/kt21515/staticsFromJavaOld.kt new file mode 100644 index 00000000000..5331d6f75e5 --- /dev/null +++ b/compiler/testData/diagnostics/tests/objects/kt21515/staticsFromJavaOld.kt @@ -0,0 +1,48 @@ +// !LANGUAGE: -ProhibitVisibilityOfNestedClassifiersFromSupertypesOfCompanion +// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE + +// FILE: test/Java.java +package test; + +public class Java { + public static void method() { } + public static int property = 42; + public static class Classifier { } + public static void syntheticSam(Runnable r) { } + + public static int getStaticSyntheticProperty() { return 42; } + public static int setStaticSyntheticProperty(int x) { return 42; } + + public int getInstanceSyntheticProperty() { return 42; } + public int setInstanceSyntheticProperty(int x) { return 42; } +} + +// FILE: Kotlin.kt +package test + +open class Base { + companion object : Java() { + + } +} + +class Derived : Base() { + fun test(javaStaticInTypePosition: Classifier) { + method() + property + Classifier() + syntheticSam { } + + // Instance members shouldn't be affected, but we check them, just in case + val y = instanceSyntheticProperty + instanceSyntheticProperty = 43 + + // Note that statics actually aren't converted into synthetic property in Kotlin + val x = syntheticProperty + syntheticProperty = 42 + } + + class JavaStaticInSupertypeList : Classifier() { + + } +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/objects/kt21515/staticsFromJavaOld.txt b/compiler/testData/diagnostics/tests/objects/kt21515/staticsFromJavaOld.txt new file mode 100644 index 00000000000..a4241b83e8a --- /dev/null +++ b/compiler/testData/diagnostics/tests/objects/kt21515/staticsFromJavaOld.txt @@ -0,0 +1,58 @@ +package + +package test { + + public open class Base { + public constructor Base() + 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 open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + + public companion object Companion : test.Java { + private constructor Companion() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun getInstanceSyntheticProperty(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun setInstanceSyntheticProperty(/*0*/ x: kotlin.Int): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } + } + + public final class Derived : test.Base { + public constructor Derived() + 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 final fun test(/*0*/ javaStaticInTypePosition: test.Java.Classifier): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + + public final class JavaStaticInSupertypeList : test.Java.Classifier { + public constructor JavaStaticInSupertypeList() + 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 open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } + } + + public open class Java { + public constructor Java() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open fun getInstanceSyntheticProperty(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open fun setInstanceSyntheticProperty(/*0*/ x: kotlin.Int): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + + public open class Classifier { + public constructor Classifier() + 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 open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } + + // Static members + public final var property: kotlin.Int + public open fun getStaticSyntheticProperty(): kotlin.Int + public open fun method(): kotlin.Unit + public open fun setStaticSyntheticProperty(/*0*/ x: kotlin.Int): kotlin.Int + public open fun syntheticSam(/*0*/ r: java.lang.Runnable!): kotlin.Unit + } +} diff --git a/compiler/testData/diagnostics/tests/objects/kt21515/staticsFromJavaWithQualificationNew.kt b/compiler/testData/diagnostics/tests/objects/kt21515/staticsFromJavaWithQualificationNew.kt new file mode 100644 index 00000000000..ca2d5e72a55 --- /dev/null +++ b/compiler/testData/diagnostics/tests/objects/kt21515/staticsFromJavaWithQualificationNew.kt @@ -0,0 +1,53 @@ +// !LANGUAGE: +ProhibitVisibilityOfNestedClassifiersFromSupertypesOfCompanion +// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE + +// FILE: test/Java.java +package test; + +public class Java { + public static void method() { } + public static int property = 42; + public static class Classifier { } + public static void syntheticSam(Runnable r) { } + + public static int getStaticSyntheticProperty() { return 42; } + public static int setStaticSyntheticProperty(int x) { return 42; } + + public int getInstanceSyntheticProperty() { return 42; } + public int setInstanceSyntheticProperty(int x) { return 42; } +} + +// FILE: Kotlin.kt +package test + +import test.Java.method +import test.Java.Classifier +import test.Java.property +import test.Java.syntheticSam + +open class Base { + companion object : Java() { + + } +} + +class Derived : Base() { + fun test(javaStaticInTypePosition: Classifier) { + method() + property + Classifier() + syntheticSam { } + + // Instance members shouldn't be affected, but we check them, just in case + val y = instanceSyntheticProperty + instanceSyntheticProperty = 43 + + // Note that statics actually aren't converted into synthetic property in Kotlin + val x = syntheticProperty + syntheticProperty = 42 + } + + class JavaStaticInSupertypeList : Classifier() { + + } +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/objects/kt21515/staticsFromJavaWithQualificationNew.txt b/compiler/testData/diagnostics/tests/objects/kt21515/staticsFromJavaWithQualificationNew.txt new file mode 100644 index 00000000000..a4241b83e8a --- /dev/null +++ b/compiler/testData/diagnostics/tests/objects/kt21515/staticsFromJavaWithQualificationNew.txt @@ -0,0 +1,58 @@ +package + +package test { + + public open class Base { + public constructor Base() + 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 open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + + public companion object Companion : test.Java { + private constructor Companion() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun getInstanceSyntheticProperty(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun setInstanceSyntheticProperty(/*0*/ x: kotlin.Int): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } + } + + public final class Derived : test.Base { + public constructor Derived() + 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 final fun test(/*0*/ javaStaticInTypePosition: test.Java.Classifier): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + + public final class JavaStaticInSupertypeList : test.Java.Classifier { + public constructor JavaStaticInSupertypeList() + 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 open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } + } + + public open class Java { + public constructor Java() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open fun getInstanceSyntheticProperty(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open fun setInstanceSyntheticProperty(/*0*/ x: kotlin.Int): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + + public open class Classifier { + public constructor Classifier() + 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 open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } + + // Static members + public final var property: kotlin.Int + public open fun getStaticSyntheticProperty(): kotlin.Int + public open fun method(): kotlin.Unit + public open fun setStaticSyntheticProperty(/*0*/ x: kotlin.Int): kotlin.Int + public open fun syntheticSam(/*0*/ r: java.lang.Runnable!): kotlin.Unit + } +} diff --git a/compiler/testData/diagnostics/tests/objects/kt21515/staticsFromJavaWithQualificationOld.kt b/compiler/testData/diagnostics/tests/objects/kt21515/staticsFromJavaWithQualificationOld.kt new file mode 100644 index 00000000000..0d15c35222d --- /dev/null +++ b/compiler/testData/diagnostics/tests/objects/kt21515/staticsFromJavaWithQualificationOld.kt @@ -0,0 +1,53 @@ +// !LANGUAGE: -ProhibitVisibilityOfNestedClassifiersFromSupertypesOfCompanion +// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE + +// FILE: test/Java.java +package test; + +public class Java { + public static void method() { } + public static int property = 42; + public static class Classifier { } + public static void syntheticSam(Runnable r) { } + + public static int getStaticSyntheticProperty() { return 42; } + public static int setStaticSyntheticProperty(int x) { return 42; } + + public int getInstanceSyntheticProperty() { return 42; } + public int setInstanceSyntheticProperty(int x) { return 42; } +} + +// FILE: Kotlin.kt +package test + +import test.Java.method +import test.Java.Classifier +import test.Java.property +import test.Java.syntheticSam + +open class Base { + companion object : Java() { + + } +} + +class Derived : Base() { + fun test(javaStaticInTypePosition: Classifier) { + method() + property + Classifier() + syntheticSam { } + + // Instance members shouldn't be affected, but we check them, just in case + val y = instanceSyntheticProperty + instanceSyntheticProperty = 43 + + // Note that statics actually aren't converted into synthetic property in Kotlin + val x = syntheticProperty + syntheticProperty = 42 + } + + class JavaStaticInSupertypeList : Classifier() { + + } +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/objects/kt21515/staticsFromJavaWithQualificationOld.txt b/compiler/testData/diagnostics/tests/objects/kt21515/staticsFromJavaWithQualificationOld.txt new file mode 100644 index 00000000000..a4241b83e8a --- /dev/null +++ b/compiler/testData/diagnostics/tests/objects/kt21515/staticsFromJavaWithQualificationOld.txt @@ -0,0 +1,58 @@ +package + +package test { + + public open class Base { + public constructor Base() + 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 open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + + public companion object Companion : test.Java { + private constructor Companion() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun getInstanceSyntheticProperty(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun setInstanceSyntheticProperty(/*0*/ x: kotlin.Int): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } + } + + public final class Derived : test.Base { + public constructor Derived() + 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 final fun test(/*0*/ javaStaticInTypePosition: test.Java.Classifier): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + + public final class JavaStaticInSupertypeList : test.Java.Classifier { + public constructor JavaStaticInSupertypeList() + 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 open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } + } + + public open class Java { + public constructor Java() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open fun getInstanceSyntheticProperty(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open fun setInstanceSyntheticProperty(/*0*/ x: kotlin.Int): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + + public open class Classifier { + public constructor Classifier() + 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 open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } + + // Static members + public final var property: kotlin.Int + public open fun getStaticSyntheticProperty(): kotlin.Int + public open fun method(): kotlin.Unit + public open fun setStaticSyntheticProperty(/*0*/ x: kotlin.Int): kotlin.Int + public open fun syntheticSam(/*0*/ r: java.lang.Runnable!): kotlin.Unit + } +} diff --git a/compiler/testData/diagnostics/tests/scopes/inheritance/statics/companionObject/accessToStaticMembersOfParentClassJKJ.kt b/compiler/testData/diagnostics/tests/scopes/inheritance/statics/companionObject/accessToStaticMembersOfParentClassJKJ_after.kt similarity index 67% rename from compiler/testData/diagnostics/tests/scopes/inheritance/statics/companionObject/accessToStaticMembersOfParentClassJKJ.kt rename to compiler/testData/diagnostics/tests/scopes/inheritance/statics/companionObject/accessToStaticMembersOfParentClassJKJ_after.kt index 45298fbeceb..4f1de885bcf 100644 --- a/compiler/testData/diagnostics/tests/scopes/inheritance/statics/companionObject/accessToStaticMembersOfParentClassJKJ.kt +++ b/compiler/testData/diagnostics/tests/scopes/inheritance/statics/companionObject/accessToStaticMembersOfParentClassJKJ_after.kt @@ -1,3 +1,4 @@ +// !LANGUAGE: +ProhibitVisibilityOfNestedClassifiersFromSupertypesOfCompanion // FILE: J.java public class J { public static void foo() {} @@ -17,20 +18,20 @@ open class A { class B : J2() { init { - foo() + foo() bar() boo() } fun test2() { - foo() + foo() bar() boo() } object O { fun test() { - foo() + foo() bar() boo() } @@ -38,13 +39,13 @@ class B : J2() { companion object { init { - foo() + foo() bar() boo() } fun test() { - foo() + foo() bar() boo() } diff --git a/compiler/testData/diagnostics/tests/scopes/inheritance/statics/companionObject/accessToStaticMembersOfParentClassJKJ.txt b/compiler/testData/diagnostics/tests/scopes/inheritance/statics/companionObject/accessToStaticMembersOfParentClassJKJ_after.txt similarity index 100% rename from compiler/testData/diagnostics/tests/scopes/inheritance/statics/companionObject/accessToStaticMembersOfParentClassJKJ.txt rename to compiler/testData/diagnostics/tests/scopes/inheritance/statics/companionObject/accessToStaticMembersOfParentClassJKJ_after.txt diff --git a/compiler/testData/diagnostics/tests/scopes/inheritance/statics/companionObject/accessToStaticMembersOfParentClassJKJ_before.kt b/compiler/testData/diagnostics/tests/scopes/inheritance/statics/companionObject/accessToStaticMembersOfParentClassJKJ_before.kt new file mode 100644 index 00000000000..24cd81e05a7 --- /dev/null +++ b/compiler/testData/diagnostics/tests/scopes/inheritance/statics/companionObject/accessToStaticMembersOfParentClassJKJ_before.kt @@ -0,0 +1,55 @@ +// !LANGUAGE: -ProhibitVisibilityOfNestedClassifiersFromSupertypesOfCompanion +// FILE: J.java +public class J { + public static void foo() {} +} + +// FILE: J2.java +public class J2 extends A { + public static void boo() {} +} + +// FILE: test.kt +open class A { + companion object : J() { + fun bar() {} + } +} + +class B : J2() { + init { + foo() + bar() + boo() + } + + fun test2() { + foo() + bar() + boo() + } + + object O { + fun test() { + foo() + bar() + boo() + } + } + + companion object { + init { + foo() + bar() + boo() + } + + fun test() { + foo() + bar() + boo() + } + + fun bar() {} + } +} diff --git a/compiler/testData/diagnostics/tests/scopes/inheritance/statics/companionObject/accessToStaticMembersOfParentClassJKJ_before.txt b/compiler/testData/diagnostics/tests/scopes/inheritance/statics/companionObject/accessToStaticMembersOfParentClassJKJ_before.txt new file mode 100644 index 00000000000..45693567c18 --- /dev/null +++ b/compiler/testData/diagnostics/tests/scopes/inheritance/statics/companionObject/accessToStaticMembersOfParentClassJKJ_before.txt @@ -0,0 +1,61 @@ +package + +public open class A { + public constructor A() + 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 open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + + public companion object Companion : J { + private constructor Companion() + public final fun bar(): kotlin.Unit + 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 open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } +} + +public final class B : J2 { + public constructor B() + 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 final fun test2(): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + + public companion object Companion { + private constructor Companion() + public final fun bar(): kotlin.Unit + 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 final fun test(): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } + + public object O { + private constructor O() + 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 final fun test(): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } +} + +public open class J { + public constructor J() + 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 open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + + // Static members + public open fun foo(): kotlin.Unit +} + +public open class J2 : A { + public constructor J2() + 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 open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + + // Static members + public open fun boo(): kotlin.Unit +} diff --git a/compiler/testData/diagnostics/tests/scopes/inheritance/statics/companionObject/accessToStaticMembersOfParentClass.kt b/compiler/testData/diagnostics/tests/scopes/inheritance/statics/companionObject/accessToStaticMembersOfParentClass_after.kt similarity index 61% rename from compiler/testData/diagnostics/tests/scopes/inheritance/statics/companionObject/accessToStaticMembersOfParentClass.kt rename to compiler/testData/diagnostics/tests/scopes/inheritance/statics/companionObject/accessToStaticMembersOfParentClass_after.kt index d0d719c9955..aa556c2c09a 100644 --- a/compiler/testData/diagnostics/tests/scopes/inheritance/statics/companionObject/accessToStaticMembersOfParentClass.kt +++ b/compiler/testData/diagnostics/tests/scopes/inheritance/statics/companionObject/accessToStaticMembersOfParentClass_after.kt @@ -1,3 +1,4 @@ +// !LANGUAGE: +ProhibitVisibilityOfNestedClassifiersFromSupertypesOfCompanion // FILE: J.java public class J { public static void foo() {} @@ -12,30 +13,30 @@ open class A { class B : A() { init { - foo() + foo() bar() } fun test2() { - foo() + foo() bar() } object O { fun test() { - foo() + foo() bar() } } companion object { init { - foo() + foo() bar() } fun test() { - foo() + foo() bar() } diff --git a/compiler/testData/diagnostics/tests/scopes/inheritance/statics/companionObject/accessToStaticMembersOfParentClass.txt b/compiler/testData/diagnostics/tests/scopes/inheritance/statics/companionObject/accessToStaticMembersOfParentClass_after.txt similarity index 100% rename from compiler/testData/diagnostics/tests/scopes/inheritance/statics/companionObject/accessToStaticMembersOfParentClass.txt rename to compiler/testData/diagnostics/tests/scopes/inheritance/statics/companionObject/accessToStaticMembersOfParentClass_after.txt diff --git a/compiler/testData/diagnostics/tests/scopes/inheritance/statics/companionObject/accessToStaticMembersOfParentClass_before.kt b/compiler/testData/diagnostics/tests/scopes/inheritance/statics/companionObject/accessToStaticMembersOfParentClass_before.kt new file mode 100644 index 00000000000..b0ae1b726b9 --- /dev/null +++ b/compiler/testData/diagnostics/tests/scopes/inheritance/statics/companionObject/accessToStaticMembersOfParentClass_before.kt @@ -0,0 +1,46 @@ +// !LANGUAGE: -ProhibitVisibilityOfNestedClassifiersFromSupertypesOfCompanion +// FILE: J.java +public class J { + public static void foo() {} +} + +// FILE: test.kt +open class A { + companion object : J() { + fun bar() {} + } +} + +class B : A() { + init { + foo() + bar() + } + + fun test2() { + foo() + bar() + } + + object O { + fun test() { + foo() + bar() + } + } + + companion object { + init { + foo() + bar() + } + + fun test() { + foo() + bar() + } + + fun bar() {} + } +} + diff --git a/compiler/testData/diagnostics/tests/scopes/inheritance/statics/companionObject/accessToStaticMembersOfParentClass_before.txt b/compiler/testData/diagnostics/tests/scopes/inheritance/statics/companionObject/accessToStaticMembersOfParentClass_before.txt new file mode 100644 index 00000000000..f108a572ecc --- /dev/null +++ b/compiler/testData/diagnostics/tests/scopes/inheritance/statics/companionObject/accessToStaticMembersOfParentClass_before.txt @@ -0,0 +1,51 @@ +package + +public open class A { + public constructor A() + 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 open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + + public companion object Companion : J { + private constructor Companion() + public final fun bar(): kotlin.Unit + 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 open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } +} + +public final class B : A { + public constructor B() + 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 final fun test2(): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + + public companion object Companion { + private constructor Companion() + public final fun bar(): kotlin.Unit + 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 final fun test(): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } + + public object O { + private constructor O() + 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 final fun test(): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } +} + +public open class J { + public constructor J() + 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 open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + + // Static members + public open fun foo(): kotlin.Unit +} diff --git a/compiler/testData/diagnostics/tests/scopes/inheritance/statics/companionObject/inheritFromContainingClass.kt b/compiler/testData/diagnostics/tests/scopes/inheritance/statics/companionObject/inheritFromContainingClass_after.kt similarity index 93% rename from compiler/testData/diagnostics/tests/scopes/inheritance/statics/companionObject/inheritFromContainingClass.kt rename to compiler/testData/diagnostics/tests/scopes/inheritance/statics/companionObject/inheritFromContainingClass_after.kt index 1bf3e1f87f9..52b535bcf50 100644 --- a/compiler/testData/diagnostics/tests/scopes/inheritance/statics/companionObject/inheritFromContainingClass.kt +++ b/compiler/testData/diagnostics/tests/scopes/inheritance/statics/companionObject/inheritFromContainingClass_after.kt @@ -1,3 +1,4 @@ +// !LANGUAGE: +ProhibitVisibilityOfNestedClassifiersFromSupertypesOfCompanion // !WITH_NEW_INFERENCE // !DIAGNOSTICS: -UNUSED_VARIABLE diff --git a/compiler/testData/diagnostics/tests/scopes/inheritance/statics/companionObject/inheritFromContainingClass.txt b/compiler/testData/diagnostics/tests/scopes/inheritance/statics/companionObject/inheritFromContainingClass_after.txt similarity index 100% rename from compiler/testData/diagnostics/tests/scopes/inheritance/statics/companionObject/inheritFromContainingClass.txt rename to compiler/testData/diagnostics/tests/scopes/inheritance/statics/companionObject/inheritFromContainingClass_after.txt diff --git a/compiler/testData/diagnostics/tests/scopes/inheritance/statics/companionObject/inheritFromContainingClass_before.kt b/compiler/testData/diagnostics/tests/scopes/inheritance/statics/companionObject/inheritFromContainingClass_before.kt new file mode 100644 index 00000000000..c14253fe0de --- /dev/null +++ b/compiler/testData/diagnostics/tests/scopes/inheritance/statics/companionObject/inheritFromContainingClass_before.kt @@ -0,0 +1,54 @@ +// !LANGUAGE: -ProhibitVisibilityOfNestedClassifiersFromSupertypesOfCompanion +// !WITH_NEW_INFERENCE +// !DIAGNOSTICS: -UNUSED_VARIABLE + +// FILE: J.java +public class J { + public static void foo() {} +} + +// FILE: test.kt +open class A : J() { + init { + foo() + bar() + val a: Int = baz() + val b: T = baz() + } + + fun test1() { + foo() + bar() + val a: Int = baz() + val b: T = baz() + } + + fun baz(): T = null!! + + object O { + fun test() { + foo() + bar() + val a: Int = baz() + val b: T = baz() + } + } + + companion object : A() { + init { + foo() + bar() + val a: Int = baz() + val b: T = baz() + } + + fun test() { + foo() + bar() + val a: Int = baz() + val b: T = baz() + } + + fun bar() {} + } +} diff --git a/compiler/testData/diagnostics/tests/scopes/inheritance/statics/companionObject/inheritFromContainingClass_before.txt b/compiler/testData/diagnostics/tests/scopes/inheritance/statics/companionObject/inheritFromContainingClass_before.txt new file mode 100644 index 00000000000..de4dfcfebe0 --- /dev/null +++ b/compiler/testData/diagnostics/tests/scopes/inheritance/statics/companionObject/inheritFromContainingClass_before.txt @@ -0,0 +1,39 @@ +package + +public open class A : J { + public constructor A() + public final fun baz(): T + 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 final fun test1(): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + + public companion object Companion : A { + private constructor Companion() + public final fun bar(): kotlin.Unit + public final override /*1*/ /*fake_override*/ fun baz(): kotlin.Int + 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 final fun test(): kotlin.Unit + public final override /*1*/ /*fake_override*/ fun test1(): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } + + public object O { + private constructor O() + 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 final fun test(): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } +} + +public open class J { + public constructor J() + 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 open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + + // Static members + public open fun foo(): kotlin.Unit +} diff --git a/compiler/testData/diagnostics/tests/scopes/inheritance/statics/companionObject/inheritFromJavaAfterKotlin.kt b/compiler/testData/diagnostics/tests/scopes/inheritance/statics/companionObject/inheritFromJavaAfterKotlin_after.kt similarity index 72% rename from compiler/testData/diagnostics/tests/scopes/inheritance/statics/companionObject/inheritFromJavaAfterKotlin.kt rename to compiler/testData/diagnostics/tests/scopes/inheritance/statics/companionObject/inheritFromJavaAfterKotlin_after.kt index 88d7872255e..77ea21a9bbf 100644 --- a/compiler/testData/diagnostics/tests/scopes/inheritance/statics/companionObject/inheritFromJavaAfterKotlin.kt +++ b/compiler/testData/diagnostics/tests/scopes/inheritance/statics/companionObject/inheritFromJavaAfterKotlin_after.kt @@ -1,3 +1,4 @@ +// !LANGUAGE: +ProhibitVisibilityOfNestedClassifiersFromSupertypesOfCompanion // FILE: J.java public class J { public static void foo() {} @@ -11,20 +12,20 @@ open class B : J() { class A { init { - foo() + foo() bar() baz() } fun test1() { - foo() + foo() bar() baz() } object O { fun test() { - foo() + foo() bar() baz() } diff --git a/compiler/testData/diagnostics/tests/scopes/inheritance/statics/companionObject/inheritFromJavaAfterKotlin.txt b/compiler/testData/diagnostics/tests/scopes/inheritance/statics/companionObject/inheritFromJavaAfterKotlin_after.txt similarity index 100% rename from compiler/testData/diagnostics/tests/scopes/inheritance/statics/companionObject/inheritFromJavaAfterKotlin.txt rename to compiler/testData/diagnostics/tests/scopes/inheritance/statics/companionObject/inheritFromJavaAfterKotlin_after.txt diff --git a/compiler/testData/diagnostics/tests/scopes/inheritance/statics/companionObject/inheritFromJavaAfterKotlin_before.kt b/compiler/testData/diagnostics/tests/scopes/inheritance/statics/companionObject/inheritFromJavaAfterKotlin_before.kt new file mode 100644 index 00000000000..1f1ef98f175 --- /dev/null +++ b/compiler/testData/diagnostics/tests/scopes/inheritance/statics/companionObject/inheritFromJavaAfterKotlin_before.kt @@ -0,0 +1,50 @@ +// !LANGUAGE: -ProhibitVisibilityOfNestedClassifiersFromSupertypesOfCompanion +// FILE: J.java +public class J { + public static void foo() {} +} + +// FILE: test.kt + +open class B : J() { + fun baz() {} +} + +class A { + init { + foo() + bar() + baz() + } + + fun test1() { + foo() + bar() + baz() + } + + object O { + fun test() { + foo() + bar() + baz() + } + } + + + companion object : B() { + init { + foo() + bar() + baz() + } + + fun test() { + foo() + bar() + baz() + } + + fun bar() {} + } +} diff --git a/compiler/testData/diagnostics/tests/scopes/inheritance/statics/companionObject/inheritFromJavaAfterKotlin_before.txt b/compiler/testData/diagnostics/tests/scopes/inheritance/statics/companionObject/inheritFromJavaAfterKotlin_before.txt new file mode 100644 index 00000000000..07d3a9a321d --- /dev/null +++ b/compiler/testData/diagnostics/tests/scopes/inheritance/statics/companionObject/inheritFromJavaAfterKotlin_before.txt @@ -0,0 +1,45 @@ +package + +public final class A { + public constructor A() + 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 final fun test1(): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + + public companion object Companion : B { + private constructor Companion() + public final fun bar(): kotlin.Unit + public final override /*1*/ /*fake_override*/ fun baz(): kotlin.Unit + 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 final fun test(): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } + + public object O { + private constructor O() + 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 final fun test(): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } +} + +public open class B : J { + public constructor B() + public final fun baz(): kotlin.Unit + 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 open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +public open class J { + public constructor J() + 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 open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + + // Static members + public open fun foo(): kotlin.Unit +} diff --git a/compiler/testData/diagnostics/tests/scopes/inheritance/statics/companionObject/inheritFromJava.kt b/compiler/testData/diagnostics/tests/scopes/inheritance/statics/companionObject/inheritFromJava_after.kt similarity index 67% rename from compiler/testData/diagnostics/tests/scopes/inheritance/statics/companionObject/inheritFromJava.kt rename to compiler/testData/diagnostics/tests/scopes/inheritance/statics/companionObject/inheritFromJava_after.kt index 661129794f2..2abf7f10610 100644 --- a/compiler/testData/diagnostics/tests/scopes/inheritance/statics/companionObject/inheritFromJava.kt +++ b/compiler/testData/diagnostics/tests/scopes/inheritance/statics/companionObject/inheritFromJava_after.kt @@ -1,3 +1,4 @@ +// !LANGUAGE: +ProhibitVisibilityOfNestedClassifiersFromSupertypesOfCompanion // FILE: J.java public class J { public static void foo() {} @@ -6,18 +7,18 @@ public class J { // FILE: test.kt class A { init { - foo() + foo() bar() } fun test1() { - foo() + foo() bar() } object O { fun test() { - foo() + foo() bar() } } diff --git a/compiler/testData/diagnostics/tests/scopes/inheritance/statics/companionObject/inheritFromJava.txt b/compiler/testData/diagnostics/tests/scopes/inheritance/statics/companionObject/inheritFromJava_after.txt similarity index 100% rename from compiler/testData/diagnostics/tests/scopes/inheritance/statics/companionObject/inheritFromJava.txt rename to compiler/testData/diagnostics/tests/scopes/inheritance/statics/companionObject/inheritFromJava_after.txt diff --git a/compiler/testData/diagnostics/tests/scopes/inheritance/statics/companionObject/inheritFromJava_before.kt b/compiler/testData/diagnostics/tests/scopes/inheritance/statics/companionObject/inheritFromJava_before.kt new file mode 100644 index 00000000000..8332053753c --- /dev/null +++ b/compiler/testData/diagnostics/tests/scopes/inheritance/statics/companionObject/inheritFromJava_before.kt @@ -0,0 +1,39 @@ +// !LANGUAGE: -ProhibitVisibilityOfNestedClassifiersFromSupertypesOfCompanion +// FILE: J.java +public class J { + public static void foo() {} +} + +// FILE: test.kt +class A { + init { + foo() + bar() + } + + fun test1() { + foo() + bar() + } + + object O { + fun test() { + foo() + bar() + } + } + + companion object : J() { + init { + foo() + bar() + } + + fun test() { + foo() + bar() + } + + fun bar() {} + } +} diff --git a/compiler/testData/diagnostics/tests/scopes/inheritance/statics/companionObject/inheritFromJava_before.txt b/compiler/testData/diagnostics/tests/scopes/inheritance/statics/companionObject/inheritFromJava_before.txt new file mode 100644 index 00000000000..c965ffa5a41 --- /dev/null +++ b/compiler/testData/diagnostics/tests/scopes/inheritance/statics/companionObject/inheritFromJava_before.txt @@ -0,0 +1,36 @@ +package + +public final class A { + public constructor A() + 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 final fun test1(): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + + public companion object Companion : J { + private constructor Companion() + public final fun bar(): kotlin.Unit + 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 final fun test(): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } + + public object O { + private constructor O() + 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 final fun test(): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } +} + +public open class J { + public constructor J() + 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 open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + + // Static members + public open fun foo(): kotlin.Unit +} diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java index 99339a67e8f..fba016c6b12 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java @@ -13870,6 +13870,26 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest { runTest("compiler/testData/diagnostics/tests/objects/kt21515/inheritedFromDeprecatedWithQualificationOld.kt"); } + @TestMetadata("staticsFromJavaNew.kt") + public void testStaticsFromJavaNew() throws Exception { + runTest("compiler/testData/diagnostics/tests/objects/kt21515/staticsFromJavaNew.kt"); + } + + @TestMetadata("staticsFromJavaOld.kt") + public void testStaticsFromJavaOld() throws Exception { + runTest("compiler/testData/diagnostics/tests/objects/kt21515/staticsFromJavaOld.kt"); + } + + @TestMetadata("staticsFromJavaWithQualificationNew.kt") + public void testStaticsFromJavaWithQualificationNew() throws Exception { + runTest("compiler/testData/diagnostics/tests/objects/kt21515/staticsFromJavaWithQualificationNew.kt"); + } + + @TestMetadata("staticsFromJavaWithQualificationOld.kt") + public void testStaticsFromJavaWithQualificationOld() throws Exception { + runTest("compiler/testData/diagnostics/tests/objects/kt21515/staticsFromJavaWithQualificationOld.kt"); + } + @TestMetadata("useDeprecatedConstructorNew.kt") public void testUseDeprecatedConstructorNew() throws Exception { runTest("compiler/testData/diagnostics/tests/objects/kt21515/useDeprecatedConstructorNew.kt"); @@ -17903,33 +17923,58 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest { KotlinTestUtils.runTest(this::doTest, TargetBackend.ANY, testDataFilePath); } - @TestMetadata("accessToStaticMembersOfParentClass.kt") - public void testAccessToStaticMembersOfParentClass() throws Exception { - runTest("compiler/testData/diagnostics/tests/scopes/inheritance/statics/companionObject/accessToStaticMembersOfParentClass.kt"); + @TestMetadata("accessToStaticMembersOfParentClassJKJ_after.kt") + public void testAccessToStaticMembersOfParentClassJKJ_after() throws Exception { + runTest("compiler/testData/diagnostics/tests/scopes/inheritance/statics/companionObject/accessToStaticMembersOfParentClassJKJ_after.kt"); } - @TestMetadata("accessToStaticMembersOfParentClassJKJ.kt") - public void testAccessToStaticMembersOfParentClassJKJ() throws Exception { - runTest("compiler/testData/diagnostics/tests/scopes/inheritance/statics/companionObject/accessToStaticMembersOfParentClassJKJ.kt"); + @TestMetadata("accessToStaticMembersOfParentClassJKJ_before.kt") + public void testAccessToStaticMembersOfParentClassJKJ_before() throws Exception { + runTest("compiler/testData/diagnostics/tests/scopes/inheritance/statics/companionObject/accessToStaticMembersOfParentClassJKJ_before.kt"); + } + + @TestMetadata("accessToStaticMembersOfParentClass_after.kt") + public void testAccessToStaticMembersOfParentClass_after() throws Exception { + runTest("compiler/testData/diagnostics/tests/scopes/inheritance/statics/companionObject/accessToStaticMembersOfParentClass_after.kt"); + } + + @TestMetadata("accessToStaticMembersOfParentClass_before.kt") + public void testAccessToStaticMembersOfParentClass_before() throws Exception { + runTest("compiler/testData/diagnostics/tests/scopes/inheritance/statics/companionObject/accessToStaticMembersOfParentClass_before.kt"); } public void testAllFilesPresentInCompanionObject() throws Exception { KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/diagnostics/tests/scopes/inheritance/statics/companionObject"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true); } - @TestMetadata("inheritFromContainingClass.kt") - public void testInheritFromContainingClass() throws Exception { - runTest("compiler/testData/diagnostics/tests/scopes/inheritance/statics/companionObject/inheritFromContainingClass.kt"); + @TestMetadata("inheritFromContainingClass_after.kt") + public void testInheritFromContainingClass_after() throws Exception { + runTest("compiler/testData/diagnostics/tests/scopes/inheritance/statics/companionObject/inheritFromContainingClass_after.kt"); } - @TestMetadata("inheritFromJava.kt") - public void testInheritFromJava() throws Exception { - runTest("compiler/testData/diagnostics/tests/scopes/inheritance/statics/companionObject/inheritFromJava.kt"); + @TestMetadata("inheritFromContainingClass_before.kt") + public void testInheritFromContainingClass_before() throws Exception { + runTest("compiler/testData/diagnostics/tests/scopes/inheritance/statics/companionObject/inheritFromContainingClass_before.kt"); } - @TestMetadata("inheritFromJavaAfterKotlin.kt") - public void testInheritFromJavaAfterKotlin() throws Exception { - runTest("compiler/testData/diagnostics/tests/scopes/inheritance/statics/companionObject/inheritFromJavaAfterKotlin.kt"); + @TestMetadata("inheritFromJavaAfterKotlin_after.kt") + public void testInheritFromJavaAfterKotlin_after() throws Exception { + runTest("compiler/testData/diagnostics/tests/scopes/inheritance/statics/companionObject/inheritFromJavaAfterKotlin_after.kt"); + } + + @TestMetadata("inheritFromJavaAfterKotlin_before.kt") + public void testInheritFromJavaAfterKotlin_before() throws Exception { + runTest("compiler/testData/diagnostics/tests/scopes/inheritance/statics/companionObject/inheritFromJavaAfterKotlin_before.kt"); + } + + @TestMetadata("inheritFromJava_after.kt") + public void testInheritFromJava_after() throws Exception { + runTest("compiler/testData/diagnostics/tests/scopes/inheritance/statics/companionObject/inheritFromJava_after.kt"); + } + + @TestMetadata("inheritFromJava_before.kt") + public void testInheritFromJava_before() throws Exception { + runTest("compiler/testData/diagnostics/tests/scopes/inheritance/statics/companionObject/inheritFromJava_before.kt"); } } } diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsUsingJavacTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsUsingJavacTestGenerated.java index e529f4f794e..26d03a6db08 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsUsingJavacTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsUsingJavacTestGenerated.java @@ -13870,6 +13870,26 @@ public class DiagnosticsUsingJavacTestGenerated extends AbstractDiagnosticsUsing runTest("compiler/testData/diagnostics/tests/objects/kt21515/inheritedFromDeprecatedWithQualificationOld.kt"); } + @TestMetadata("staticsFromJavaNew.kt") + public void testStaticsFromJavaNew() throws Exception { + runTest("compiler/testData/diagnostics/tests/objects/kt21515/staticsFromJavaNew.kt"); + } + + @TestMetadata("staticsFromJavaOld.kt") + public void testStaticsFromJavaOld() throws Exception { + runTest("compiler/testData/diagnostics/tests/objects/kt21515/staticsFromJavaOld.kt"); + } + + @TestMetadata("staticsFromJavaWithQualificationNew.kt") + public void testStaticsFromJavaWithQualificationNew() throws Exception { + runTest("compiler/testData/diagnostics/tests/objects/kt21515/staticsFromJavaWithQualificationNew.kt"); + } + + @TestMetadata("staticsFromJavaWithQualificationOld.kt") + public void testStaticsFromJavaWithQualificationOld() throws Exception { + runTest("compiler/testData/diagnostics/tests/objects/kt21515/staticsFromJavaWithQualificationOld.kt"); + } + @TestMetadata("useDeprecatedConstructorNew.kt") public void testUseDeprecatedConstructorNew() throws Exception { runTest("compiler/testData/diagnostics/tests/objects/kt21515/useDeprecatedConstructorNew.kt"); @@ -17903,33 +17923,58 @@ public class DiagnosticsUsingJavacTestGenerated extends AbstractDiagnosticsUsing KotlinTestUtils.runTest(this::doTest, TargetBackend.ANY, testDataFilePath); } - @TestMetadata("accessToStaticMembersOfParentClass.kt") - public void testAccessToStaticMembersOfParentClass() throws Exception { - runTest("compiler/testData/diagnostics/tests/scopes/inheritance/statics/companionObject/accessToStaticMembersOfParentClass.kt"); + @TestMetadata("accessToStaticMembersOfParentClassJKJ_after.kt") + public void testAccessToStaticMembersOfParentClassJKJ_after() throws Exception { + runTest("compiler/testData/diagnostics/tests/scopes/inheritance/statics/companionObject/accessToStaticMembersOfParentClassJKJ_after.kt"); } - @TestMetadata("accessToStaticMembersOfParentClassJKJ.kt") - public void testAccessToStaticMembersOfParentClassJKJ() throws Exception { - runTest("compiler/testData/diagnostics/tests/scopes/inheritance/statics/companionObject/accessToStaticMembersOfParentClassJKJ.kt"); + @TestMetadata("accessToStaticMembersOfParentClassJKJ_before.kt") + public void testAccessToStaticMembersOfParentClassJKJ_before() throws Exception { + runTest("compiler/testData/diagnostics/tests/scopes/inheritance/statics/companionObject/accessToStaticMembersOfParentClassJKJ_before.kt"); + } + + @TestMetadata("accessToStaticMembersOfParentClass_after.kt") + public void testAccessToStaticMembersOfParentClass_after() throws Exception { + runTest("compiler/testData/diagnostics/tests/scopes/inheritance/statics/companionObject/accessToStaticMembersOfParentClass_after.kt"); + } + + @TestMetadata("accessToStaticMembersOfParentClass_before.kt") + public void testAccessToStaticMembersOfParentClass_before() throws Exception { + runTest("compiler/testData/diagnostics/tests/scopes/inheritance/statics/companionObject/accessToStaticMembersOfParentClass_before.kt"); } public void testAllFilesPresentInCompanionObject() throws Exception { KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/diagnostics/tests/scopes/inheritance/statics/companionObject"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true); } - @TestMetadata("inheritFromContainingClass.kt") - public void testInheritFromContainingClass() throws Exception { - runTest("compiler/testData/diagnostics/tests/scopes/inheritance/statics/companionObject/inheritFromContainingClass.kt"); + @TestMetadata("inheritFromContainingClass_after.kt") + public void testInheritFromContainingClass_after() throws Exception { + runTest("compiler/testData/diagnostics/tests/scopes/inheritance/statics/companionObject/inheritFromContainingClass_after.kt"); } - @TestMetadata("inheritFromJava.kt") - public void testInheritFromJava() throws Exception { - runTest("compiler/testData/diagnostics/tests/scopes/inheritance/statics/companionObject/inheritFromJava.kt"); + @TestMetadata("inheritFromContainingClass_before.kt") + public void testInheritFromContainingClass_before() throws Exception { + runTest("compiler/testData/diagnostics/tests/scopes/inheritance/statics/companionObject/inheritFromContainingClass_before.kt"); } - @TestMetadata("inheritFromJavaAfterKotlin.kt") - public void testInheritFromJavaAfterKotlin() throws Exception { - runTest("compiler/testData/diagnostics/tests/scopes/inheritance/statics/companionObject/inheritFromJavaAfterKotlin.kt"); + @TestMetadata("inheritFromJavaAfterKotlin_after.kt") + public void testInheritFromJavaAfterKotlin_after() throws Exception { + runTest("compiler/testData/diagnostics/tests/scopes/inheritance/statics/companionObject/inheritFromJavaAfterKotlin_after.kt"); + } + + @TestMetadata("inheritFromJavaAfterKotlin_before.kt") + public void testInheritFromJavaAfterKotlin_before() throws Exception { + runTest("compiler/testData/diagnostics/tests/scopes/inheritance/statics/companionObject/inheritFromJavaAfterKotlin_before.kt"); + } + + @TestMetadata("inheritFromJava_after.kt") + public void testInheritFromJava_after() throws Exception { + runTest("compiler/testData/diagnostics/tests/scopes/inheritance/statics/companionObject/inheritFromJava_after.kt"); + } + + @TestMetadata("inheritFromJava_before.kt") + public void testInheritFromJava_before() throws Exception { + runTest("compiler/testData/diagnostics/tests/scopes/inheritance/statics/companionObject/inheritFromJava_before.kt"); } } } diff --git a/idea/src/org/jetbrains/kotlin/idea/imports/KotlinImportOptimizer.kt b/idea/src/org/jetbrains/kotlin/idea/imports/KotlinImportOptimizer.kt index 312d5c75d2a..c368561df3c 100644 --- a/idea/src/org/jetbrains/kotlin/idea/imports/KotlinImportOptimizer.kt +++ b/idea/src/org/jetbrains/kotlin/idea/imports/KotlinImportOptimizer.kt @@ -122,9 +122,11 @@ class KotlinImportOptimizer : ImportOptimizer { return when (target) { is FunctionDescriptor -> scope.findFunction(target.name, NoLookupLocation.FROM_IDE) { it == target } != null + && bindingContext[BindingContext.DEPRECATED_SHORT_NAME_ACCESS, place] != true is PropertyDescriptor -> scope.findVariable(target.name, NoLookupLocation.FROM_IDE) { it == target } != null + && bindingContext[BindingContext.DEPRECATED_SHORT_NAME_ACCESS, place] != true is ClassDescriptor -> scope.findClassifier(target.name, NoLookupLocation.FROM_IDE) == target diff --git a/idea/testData/editor/optimizeImports/jvm/staticFromJava.dependency.java b/idea/testData/editor/optimizeImports/jvm/staticFromJava.dependency.java new file mode 100644 index 00000000000..dc4c05a8e26 --- /dev/null +++ b/idea/testData/editor/optimizeImports/jvm/staticFromJava.dependency.java @@ -0,0 +1,4 @@ +public class Java { + public static int field = 42; + public static void method() { } +} \ No newline at end of file diff --git a/idea/testData/editor/optimizeImports/jvm/staticFromJava.kt b/idea/testData/editor/optimizeImports/jvm/staticFromJava.kt new file mode 100644 index 00000000000..517141e2a29 --- /dev/null +++ b/idea/testData/editor/optimizeImports/jvm/staticFromJava.kt @@ -0,0 +1,13 @@ +import Java.field; +import Java.method; + +open class Base { + companion object : Java() +} + +class Derived : Base() { + fun test() { + val x = field; + val y = method(); + } +} \ No newline at end of file diff --git a/idea/testData/editor/optimizeImports/jvm/staticFromJava.kt.after b/idea/testData/editor/optimizeImports/jvm/staticFromJava.kt.after new file mode 100644 index 00000000000..517141e2a29 --- /dev/null +++ b/idea/testData/editor/optimizeImports/jvm/staticFromJava.kt.after @@ -0,0 +1,13 @@ +import Java.field; +import Java.method; + +open class Base { + companion object : Java() +} + +class Derived : Base() { + fun test() { + val x = field; + val y = method(); + } +} \ No newline at end of file diff --git a/idea/testData/quickfix/autoImports/kt21515/staticFromJava.test b/idea/testData/quickfix/autoImports/kt21515/staticFromJava.test new file mode 100644 index 00000000000..9202a3ce0be --- /dev/null +++ b/idea/testData/quickfix/autoImports/kt21515/staticFromJava.test @@ -0,0 +1,43 @@ +// LANGUAGE_VERSION: 1.3 +// FILE: first.before.kt +// "Import" "true" +// ERROR: Unresolved reference: foobar +import foo.Bar + +open class Base { + companion object : Bar() { + + } +} + +class Derived : Base() { + fun test() { + val x = foobar + } +} + +// FILE: foo/Bar.java +package foo; + +public class Bar { + public static final String foobar = "foobar"; +} + +// FILE: first.after.kt +// "Import" "true" +// ERROR: Unresolved reference: foobar +import foo.Bar +import foo.Bar.foobar + +open class Base { + companion object : Bar() { + + } +} + +class Derived : Base() { + fun test() { + val x = foobar + } +} + diff --git a/idea/testData/shortenRefs/kt21515/staticFromJava.dependency.java b/idea/testData/shortenRefs/kt21515/staticFromJava.dependency.java new file mode 100644 index 00000000000..dc4c05a8e26 --- /dev/null +++ b/idea/testData/shortenRefs/kt21515/staticFromJava.dependency.java @@ -0,0 +1,4 @@ +public class Java { + public static int field = 42; + public static void method() { } +} \ No newline at end of file diff --git a/idea/testData/shortenRefs/kt21515/staticFromJava.kt b/idea/testData/shortenRefs/kt21515/staticFromJava.kt new file mode 100644 index 00000000000..57e4ea35a73 --- /dev/null +++ b/idea/testData/shortenRefs/kt21515/staticFromJava.kt @@ -0,0 +1,10 @@ +open class Base { + companion object : Java() +} + +class Derived : Base() { + fun test() { + val x = Java.field; + val y = Java.method(); + } +} \ No newline at end of file diff --git a/idea/testData/shortenRefs/kt21515/staticFromJava.kt.after b/idea/testData/shortenRefs/kt21515/staticFromJava.kt.after new file mode 100644 index 00000000000..ceb53cd63dc --- /dev/null +++ b/idea/testData/shortenRefs/kt21515/staticFromJava.kt.after @@ -0,0 +1,10 @@ +open class Base { + companion object : Java() +} + +class Derived : Base() { + fun test() { + val x = Java.field; + val y = Java.method(); + } +} \ No newline at end of file diff --git a/idea/tests/org/jetbrains/kotlin/idea/imports/JvmOptimizeImportsTestGenerated.java b/idea/tests/org/jetbrains/kotlin/idea/imports/JvmOptimizeImportsTestGenerated.java index 7a86e4aae19..bbd8c27dabb 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/imports/JvmOptimizeImportsTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/idea/imports/JvmOptimizeImportsTestGenerated.java @@ -131,6 +131,11 @@ public class JvmOptimizeImportsTestGenerated extends AbstractJvmOptimizeImportsT runTest("idea/testData/editor/optimizeImports/jvm/SamConstructor.kt"); } + @TestMetadata("staticFromJava.kt") + public void testStaticFromJava() throws Exception { + runTest("idea/testData/editor/optimizeImports/jvm/staticFromJava.kt"); + } + @TestMetadata("StaticMethodFromSuper.kt") public void testStaticMethodFromSuper() throws Exception { runTest("idea/testData/editor/optimizeImports/jvm/StaticMethodFromSuper.kt"); diff --git a/idea/tests/org/jetbrains/kotlin/idea/quickfix/AbstractQuickFixMultiFileTest.kt b/idea/tests/org/jetbrains/kotlin/idea/quickfix/AbstractQuickFixMultiFileTest.kt index 4a47feb557b..491f236e905 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/quickfix/AbstractQuickFixMultiFileTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/quickfix/AbstractQuickFixMultiFileTest.kt @@ -127,11 +127,10 @@ abstract class AbstractQuickFixMultiFileTest : KotlinLightCodeInsightFixtureTest multifileText, object : KotlinTestUtils.TestFileFactoryNoModules() { override fun create(fileName: String, text: String, directives: Map): TestFile { - if (text.startsWith("// FILE")) { - // Drop the first line - return TestFile(fileName, StringUtil.substringAfter(text, "\n")!!) + val linesWithoutDirectives = text.lines().filter { + !it.startsWith("// LANGUAGE_VERSION") && !it.startsWith("// FILE") } - return TestFile(fileName, text) + return TestFile(fileName, linesWithoutDirectives.joinToString(separator = "\n")) } }, "") @@ -144,6 +143,7 @@ abstract class AbstractQuickFixMultiFileTest : KotlinLightCodeInsightFixtureTest } configureMultiFileTest(subFiles, beforeFile) + configureCompilerOptions(multifileText, project, module) CommandProcessor.getInstance().executeCommand(project, { try { @@ -167,6 +167,10 @@ abstract class AbstractQuickFixMultiFileTest : KotlinLightCodeInsightFixtureTest TestCase.assertNotNull(".after file should exist", afterFile) if (afterText != afterFile!!.content) { val actualTestFile = StringBuilder() + if (multifileText.startsWith("// LANGUAGE_VERSION")) { + actualTestFile.append(multifileText.lineSequence().first()) + } + actualTestFile.append("// FILE: ").append(beforeFile.path).append("\n").append(beforeFile.content) for (file in subFiles) { actualTestFile.append("// FILE: ").append(file.path).append("\n").append(file.content) diff --git a/idea/tests/org/jetbrains/kotlin/idea/quickfix/QuickFixMultiFileTestGenerated.java b/idea/tests/org/jetbrains/kotlin/idea/quickfix/QuickFixMultiFileTestGenerated.java index f7386b0b664..126a5373b96 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/quickfix/QuickFixMultiFileTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/idea/quickfix/QuickFixMultiFileTestGenerated.java @@ -892,6 +892,11 @@ public class QuickFixMultiFileTestGenerated extends AbstractQuickFixMultiFileTes public void testAllFilesPresentInKt21515() throws Exception { KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/quickfix/autoImports/kt21515"), Pattern.compile("^(\\w+)\\.((before\\.Main\\.\\w+)|(test))$"), TargetBackend.ANY, true); } + + @TestMetadata("staticFromJava.test") + public void testStaticFromJava() throws Exception { + runTest("idea/testData/quickfix/autoImports/kt21515/staticFromJava.test"); + } } @TestMetadata("idea/testData/quickfix/autoImports/mismatchingArgs") diff --git a/idea/tests/org/jetbrains/kotlin/shortenRefs/ShortenRefsTestGenerated.java b/idea/tests/org/jetbrains/kotlin/shortenRefs/ShortenRefsTestGenerated.java index 823356723d7..d554132d3ee 100644 --- a/idea/tests/org/jetbrains/kotlin/shortenRefs/ShortenRefsTestGenerated.java +++ b/idea/tests/org/jetbrains/kotlin/shortenRefs/ShortenRefsTestGenerated.java @@ -335,6 +335,11 @@ public class ShortenRefsTestGenerated extends AbstractShortenRefsTest { runTest("idea/testData/shortenRefs/kt21515/constructor.kt"); } + @TestMetadata("staticFromJava.kt") + public void testStaticFromJava() throws Exception { + runTest("idea/testData/shortenRefs/kt21515/staticFromJava.kt"); + } + @TestMetadata("typeReference.kt") public void testTypeReference() throws Exception { runTest("idea/testData/shortenRefs/kt21515/typeReference.kt");