diff --git a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java index 422b1ca2188..9bd87fffe39 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java @@ -395,6 +395,9 @@ public interface Errors { DiagnosticFactory0 USELESS_VARARG_ON_PARAMETER = DiagnosticFactory0.create(WARNING); + DiagnosticFactory1 FUNCTION_RETURN_TYPE_DEPENDS_ON_LOCAL_CLASS = DiagnosticFactory1.create(ERROR, DECLARATION_RETURN_TYPE); + DiagnosticFactory1 PROPERTY_TYPE_DEPENDS_ON_LOCAL_CLASS = DiagnosticFactory1.create(ERROR, DECLARATION_RETURN_TYPE); + // Named parameters DiagnosticFactory0 DEFAULT_VALUE_NOT_ALLOWED_IN_OVERRIDE = DiagnosticFactory0.create(ERROR, PARAMETER_DEFAULT_VALUE); diff --git a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java index 19bd60dc3ff..700be23ac76 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java @@ -268,6 +268,8 @@ public class DefaultErrorMessages { MAP.put(UNUSED_CHANGED_VALUE, "The value changed at ''{0}'' is never used", ELEMENT_TEXT); MAP.put(UNUSED_EXPRESSION, "The expression is unused"); MAP.put(UNUSED_FUNCTION_LITERAL, "The function literal is unused. If you mean block, you can use 'run { ... }'"); + MAP.put(FUNCTION_RETURN_TYPE_DEPENDS_ON_LOCAL_CLASS, "Function return type depends on local class or object {0}", NAME); + MAP.put(PROPERTY_TYPE_DEPENDS_ON_LOCAL_CLASS, "Property type depends on local class or object {0}", NAME); MAP.put(VAL_REASSIGNMENT, "Val cannot be reassigned", NAME); MAP.put(SETTER_PROJECTED_OUT, "Setter for ''{0}'' is removed by type projection", NAME); diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/DeclarationsChecker.java b/compiler/frontend/src/org/jetbrains/kotlin/resolve/DeclarationsChecker.java index 92f6e698ccd..3d4c6f46496 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/DeclarationsChecker.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/DeclarationsChecker.java @@ -24,6 +24,7 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.kotlin.builtins.KotlinBuiltIns; import org.jetbrains.kotlin.descriptors.*; +import org.jetbrains.kotlin.diagnostics.DiagnosticFactory1; import org.jetbrains.kotlin.diagnostics.DiagnosticFactory0; import org.jetbrains.kotlin.diagnostics.Errors; import org.jetbrains.kotlin.lexer.JetModifierKeywordToken; @@ -653,6 +654,58 @@ public class DeclarationsChecker { } } + private void checkLocalTypesInFunctionReturnType(@NotNull JetFunction function, @NotNull FunctionDescriptor functionDescriptor) { + if (functionDescriptor instanceof ConstructorDescriptor) return; + if (!isExposedAsPublicAPI(functionDescriptor)) return; + JetType returnType = functionDescriptor.getReturnType(); + if (returnType == null) return; + checkLocalTypesExposedInType(function, functionDescriptor, returnType, + FUNCTION_RETURN_TYPE_DEPENDS_ON_LOCAL_CLASS, + new HashSet()); + } + + private void checkLocalTypesInPropertyType(@NotNull JetProperty property, @NotNull PropertyDescriptor propertyDescriptor) { + if (!isExposedAsPublicAPI(propertyDescriptor)) return; + JetType propertyType = propertyDescriptor.getType(); + checkLocalTypesExposedInType(property, propertyDescriptor, propertyType, + PROPERTY_TYPE_DEPENDS_ON_LOCAL_CLASS, + new HashSet()); + } + + private static boolean isExposedAsPublicAPI(@NotNull DeclarationDescriptor descriptor) { + for (DeclarationDescriptor finger = descriptor; finger != null; finger = finger.getContainingDeclaration()) { + if (finger instanceof DeclarationDescriptorWithVisibility) { + Visibility visibility = ((DeclarationDescriptorWithVisibility) finger).getVisibility(); + if (Visibilities.isPrivate(visibility) || visibility == Visibilities.LOCAL) { + return false; + } + } + } + return true; + } + + private void checkLocalTypesExposedInType( + @NotNull D reportOnDeclaration, + @NotNull DeclarationDescriptor parentDeclarationDescriptor, + @NotNull JetType type, + @NotNull DiagnosticFactory1 diagnostic, + @NotNull Set visitedTypes + ) { + visitedTypes.add(type); + ClassDescriptor classDescriptor = TypeUtils.getClassDescriptor(type); + if (classDescriptor != null) { + if (DescriptorUtils.isLocal(classDescriptor) && DescriptorUtils.isAncestor(parentDeclarationDescriptor, classDescriptor, true)) { + trace.report(diagnostic.on(reportOnDeclaration, classDescriptor)); + } + } + for (TypeProjection projection : type.getArguments()) { + JetType projectedType = projection.getType(); + if (!visitedTypes.contains(projectedType)) { + checkLocalTypesExposedInType(reportOnDeclaration, parentDeclarationDescriptor, projectedType, diagnostic, visitedTypes); + } + } + } + private void checkPropertyExposedType(@NotNull JetProperty property, @NotNull PropertyDescriptor propertyDescriptor) { EffectiveVisibility propertyVisibility = EffectiveVisibility.Companion.forMember(propertyDescriptor); EffectiveVisibility typeVisibility = EffectiveVisibility.Companion.forType(propertyDescriptor.getType()); @@ -660,6 +713,7 @@ public class DeclarationsChecker { trace.report(EXPOSED_PROPERTY_TYPE.on(property, propertyVisibility, typeVisibility)); } checkMemberReceiverExposedType(property.getReceiverTypeReference(), propertyDescriptor); + checkLocalTypesInPropertyType(property, propertyDescriptor); } protected void checkFunction(JetNamedFunction function, SimpleFunctionDescriptor functionDescriptor) { @@ -729,6 +783,7 @@ public class DeclarationsChecker { i++; } checkMemberReceiverExposedType(function.getReceiverTypeReference(), functionDescriptor); + checkLocalTypesInFunctionReturnType(function, functionDescriptor); } private void checkAccessors(@NotNull JetProperty property, @NotNull PropertyDescriptor propertyDescriptor) { diff --git a/compiler/testData/codegen/box/objects/objectLiteralInClosure.kt b/compiler/testData/codegen/box/objects/objectLiteralInClosure.kt index 34ea54ddebf..49e19260616 100644 --- a/compiler/testData/codegen/box/objects/objectLiteralInClosure.kt +++ b/compiler/testData/codegen/box/objects/objectLiteralInClosure.kt @@ -1,6 +1,6 @@ package p -class C(val y: Int) { +private class C(val y: Int) { val initChild = { -> object { override fun toString(): String { diff --git a/compiler/testData/codegen/boxWithStdlib/regressions/kt3850.kt b/compiler/testData/codegen/boxWithStdlib/regressions/kt3850.kt index ca5e250355d..03acfce7df7 100644 --- a/compiler/testData/codegen/boxWithStdlib/regressions/kt3850.kt +++ b/compiler/testData/codegen/boxWithStdlib/regressions/kt3850.kt @@ -1,6 +1,7 @@ -class One { +private class One { val a1 = arrayOf( object { val fy = "text"} - )} + ) +} fun box() = if (One().a1[0].fy == "text") "OK" else "fail" \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/declarationChecks/ambiguousObjectExpressionType.kt b/compiler/testData/diagnostics/tests/declarationChecks/ambiguousObjectExpressionType.kt index aad1486a8e7..e12826cbafe 100644 --- a/compiler/testData/diagnostics/tests/declarationChecks/ambiguousObjectExpressionType.kt +++ b/compiler/testData/diagnostics/tests/declarationChecks/ambiguousObjectExpressionType.kt @@ -16,13 +16,13 @@ class Foo { privateProperty.f2() } - protected val protectedProperty = object : MyClass(), MyTrait {} + protected val protectedProperty = object : MyClass(), MyTrait {} - val internalProperty = object : MyClass(), MyTrait {} + val internalProperty = object : MyClass(), MyTrait {} - internal val internal2Property = object : MyClass(), MyTrait {} + internal val internal2Property = object : MyClass(), MyTrait {} - public val publicProperty = object : MyClass(), MyTrait {} + public val publicProperty = object : MyClass(), MyTrait {} private fun privateFunction() = object : MyClass(), MyTrait {} @@ -32,13 +32,13 @@ class Foo { privateFunction().f2() } - protected fun protectedFunction() = object : MyClass(), MyTrait {} + protected fun protectedFunction() = object : MyClass(), MyTrait {} - fun internalFunction() = object : MyClass(), MyTrait {} + fun internalFunction() = object : MyClass(), MyTrait {} - internal fun internal2Function() = object : MyClass(), MyTrait {} + internal fun internal2Function() = object : MyClass(), MyTrait {} - public fun publicFunction() = object : MyClass(), MyTrait {} + public fun publicFunction() = object : MyClass(), MyTrait {} @@ -50,13 +50,13 @@ class Foo { privatePropertyInner.f2() } - protected val protectedProperty = object : MyClass(), MyTrait {} + protected val protectedProperty = object : MyClass(), MyTrait {} - val internalProperty = object : MyClass(), MyTrait {} + val internalProperty = object : MyClass(), MyTrait {} - internal val internal2Property = object : MyClass(), MyTrait {} + internal val internal2Property = object : MyClass(), MyTrait {} - public val publicProperty = object : MyClass(), MyTrait {} + public val publicProperty = object : MyClass(), MyTrait {} private fun privateFunctionInner() = object : MyClass(), MyTrait {} @@ -66,13 +66,13 @@ class Foo { privateFunctionInner().f2() } - protected fun protectedFunction() = object : MyClass(), MyTrait {} + protected fun protectedFunction() = object : MyClass(), MyTrait {} - fun internalFunction() = object : MyClass(), MyTrait {} + fun internalFunction() = object : MyClass(), MyTrait {} - internal fun internal2Function() = object : MyClass(), MyTrait {} + internal fun internal2Function() = object : MyClass(), MyTrait {} - public fun publicFunction() = object : MyClass(), MyTrait {} + public fun publicFunction() = object : MyClass(), MyTrait {} } @@ -90,21 +90,21 @@ class Foo { private val packagePrivateProperty = object : MyClass(), MyTrait {} -protected val packageProtectedProperty = object : MyClass(), MyTrait {} +protected val packageProtectedProperty = object : MyClass(), MyTrait {} -val packageInternalProperty = object : MyClass(), MyTrait {} +val packageInternalProperty = object : MyClass(), MyTrait {} -internal val packageInternal2Property = object : MyClass(), MyTrait {} +internal val packageInternal2Property = object : MyClass(), MyTrait {} -public val packagePublicProperty = object : MyClass(), MyTrait {} +public val packagePublicProperty = object : MyClass(), MyTrait {} -protected fun packageProtectedFunction() = object : MyClass(), MyTrait {} +protected fun packageProtectedFunction() = object : MyClass(), MyTrait {} -fun packageInternalFunction() = object : MyClass(), MyTrait {} +fun packageInternalFunction() = object : MyClass(), MyTrait {} -internal fun packageInternal2Function() = object : MyClass(), MyTrait {} +internal fun packageInternal2Function() = object : MyClass(), MyTrait {} -public fun packagePublicFunction() = object : MyClass(), MyTrait {} +public fun packagePublicFunction() = object : MyClass(), MyTrait {} fun fooPackage() { val packageLocalVar = object : MyClass(), MyTrait {} diff --git a/compiler/testData/diagnostics/tests/exposed/local.kt b/compiler/testData/diagnostics/tests/exposed/local.kt index 27a29159e09..bd067eda702 100644 --- a/compiler/testData/diagnostics/tests/exposed/local.kt +++ b/compiler/testData/diagnostics/tests/exposed/local.kt @@ -2,21 +2,21 @@ fun run(f: () -> T): T { return f() } -// valid, A here is effectively Any -fun foo() = run { +// invalid, depends on local class +fun foo() = run { class A A() } -// valid, B here is also effectively Any -fun gav() = { +// invalid, depends on local class +fun gav() = { class B B() } abstract class My -// valid, object literal here is also effectively Any +// valid, object literal here is effectively My fun bar() = run { object: My() {} -} +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/exposed/localInFunReturnType.kt b/compiler/testData/diagnostics/tests/exposed/localInFunReturnType.kt new file mode 100644 index 00000000000..8729e367f53 --- /dev/null +++ b/compiler/testData/diagnostics/tests/exposed/localInFunReturnType.kt @@ -0,0 +1,64 @@ +fun run(f: () -> T): T { + return f() +} + +class My(val value: T) + +open class Base + +fun invalid1() = run { + class Local + My(Local()) +} + +fun invalid2() = My(object {}) + +fun invalid3() = My(object : Base() {}) + +fun invalid4() = run { + class Local + My(My(Local())) +} + +fun invalid5() = run { + fun invalid5a() = run { + class Local + Local() + } + My(invalid5a()) +} + +// Valid: effectively Any +fun valid1() = object {} + +// Valid: effectively Base +fun valid2() = object : Base() {} + +// Valid: explicit type argument +fun valid3() = My(object : Base() {}) + +// Valid: explicit type specified +fun valid4() : My = My(object : Base() {}) + +// Valid: local class denotable in local scope +fun valid5() = run { + class Local + fun valid5a() = My(Local()) + My(valid5a()) +} + +// Valid: local class denotable in local scope +fun valid6() = run { + class Local + fun valid6a() = run { + fun valid6b() = My(Local()) + valid6b() + } + My(valid6a()) +} + +// Valid: effectively My +fun valid7() = run { + class Local + My>(My(Local())) +} diff --git a/compiler/testData/diagnostics/tests/exposed/localInFunReturnType.txt b/compiler/testData/diagnostics/tests/exposed/localInFunReturnType.txt new file mode 100644 index 00000000000..c59df0b8916 --- /dev/null +++ b/compiler/testData/diagnostics/tests/exposed/localInFunReturnType.txt @@ -0,0 +1,30 @@ +package + +public fun invalid1(): My.Local> +public fun invalid2(): My> +public fun invalid3(): My> +public fun invalid4(): My.Local>> +public fun invalid5(): My.invalid5a..Local> +public fun run(/*0*/ f: () -> T): T +public fun valid1(): kotlin.Any +public fun valid2(): Base +public fun valid3(): My +public fun valid4(): My +public fun valid5(): My +public fun valid6(): My +public fun valid7(): My> + +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 final class My { + public constructor My(/*0*/ value: T) + public final val value: 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 open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/testData/diagnostics/tests/exposed/localInMemberType.kt b/compiler/testData/diagnostics/tests/exposed/localInMemberType.kt new file mode 100644 index 00000000000..2d81a039dd1 --- /dev/null +++ b/compiler/testData/diagnostics/tests/exposed/localInMemberType.kt @@ -0,0 +1,24 @@ +fun run(f: () -> T): T = f() + + +class Something { + public val publicVal1 = object { override fun toString() = "!" } + protected val protectedVal1 = object { override fun toString() = "!" } + internal val internalVal1 = object { override fun toString() = "!" } + private val privateVal1 = object { override fun toString() = "!" } + + public val publicVal2 = run { class A; A() } + protected val protectedVal2 = run { class A; A() } + internal val internalVal2 = run { class A; A() } + private val privateVal2 = run { class A; A() } + + public fun publicFun1() = object { override fun toString() = "!" } + protected fun protectedFun1() = object { override fun toString() = "!" } + internal fun internalFun1() = object { override fun toString() = "!" } + private fun privateFun1() = object { override fun toString() = "!" } + + public fun publicFun2() = run { class A; A() } + protected fun protectedFun2() = run { class A; A() } + internal fun internalFun2() = run { class A; A() } + private fun privateFun2() = run { class A; A() } +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/exposed/localInMemberType.txt b/compiler/testData/diagnostics/tests/exposed/localInMemberType.txt new file mode 100644 index 00000000000..44735439fc8 --- /dev/null +++ b/compiler/testData/diagnostics/tests/exposed/localInMemberType.txt @@ -0,0 +1,26 @@ +package + +public fun run(/*0*/ f: () -> T): T + +public final class Something { + public constructor Something() + internal final val internalVal1: kotlin.Any + internal final val internalVal2: Something.internalVal2..A + private final val privateVal1: Something.privateVal1. + private final val privateVal2: Something.privateVal2..A + protected final val protectedVal1: kotlin.Any + protected final val protectedVal2: Something.protectedVal2..A + public final val publicVal1: kotlin.Any + public final val publicVal2: Something.publicVal2..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 + internal final fun internalFun1(): kotlin.Any + internal final fun internalFun2(): Something.internalFun2..A + private final fun privateFun1(): Something.privateFun1. + private final fun privateFun2(): Something.privateFun2..A + protected final fun protectedFun1(): kotlin.Any + protected final fun protectedFun2(): Something.protectedFun2..A + public final fun publicFun1(): kotlin.Any + public final fun publicFun2(): Something.publicFun2..A + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/testData/diagnostics/tests/exposed/localInPropertyType.kt b/compiler/testData/diagnostics/tests/exposed/localInPropertyType.kt new file mode 100644 index 00000000000..695fc8830b4 --- /dev/null +++ b/compiler/testData/diagnostics/tests/exposed/localInPropertyType.kt @@ -0,0 +1,64 @@ +fun run(f: () -> T): T { + return f() +} + +class My(val value: T) + +open class Base + +val invalid1 = run { + class Local + My(Local()) +} + +val invalid2 = My(object {}) + +val invalid3 = My(object : Base() {}) + +val invalid4 = run { + class Local + My(My(Local())) +} + +val invalid5 = run { + fun invalid5a() = run { + class Local + Local() + } + My(invalid5a()) +} + +// Valid: effectively Any +val valid1 = object {} + +// Valid: effectively Base +val valid2 = object : Base() {} + +// Valid: explicit type argument +val valid3 = My(object : Base() {}) + +// Valid: explicit type specified +val valid4 : My = My(object : Base() {}) + +// Valid: local class denotable in local scope +val valid5 = run { + class Local + fun valid5a() = My(Local()) + My(valid5a()) +} + +// Valid: local class denotable in local scope +val valid6 = run { + class Local + fun valid6a() = run { + fun valid6b() = My(Local()) + valid6b() + } + My(valid6a()) +} + +// Valid: effectively My +val valid7 = run { + class Local + My>(My(Local())) +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/exposed/localInPropertyType.txt b/compiler/testData/diagnostics/tests/exposed/localInPropertyType.txt new file mode 100644 index 00000000000..698ff01d067 --- /dev/null +++ b/compiler/testData/diagnostics/tests/exposed/localInPropertyType.txt @@ -0,0 +1,30 @@ +package + +public val invalid1: My.Local> +public val invalid2: My> +public val invalid3: My> +public val invalid4: My.Local>> +public val invalid5: My.invalid5a..Local> +public val valid1: kotlin.Any +public val valid2: Base +public val valid3: My +public val valid4: My +public val valid5: My +public val valid6: My +public val valid7: My> +public fun run(/*0*/ f: () -> T): T + +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 final class My { + public constructor My(/*0*/ value: T) + public final val value: 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 open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/testData/diagnostics/tests/subtyping/localClasses.kt b/compiler/testData/diagnostics/tests/subtyping/localClasses.kt index 4683bd66ceb..ef6b12f4c61 100644 --- a/compiler/testData/diagnostics/tests/subtyping/localClasses.kt +++ b/compiler/testData/diagnostics/tests/subtyping/localClasses.kt @@ -6,12 +6,12 @@ fun run(f: () -> T): T { return f() } -fun foo(a: Int) = run { +private fun foo(a: Int) = run { class A A() } -fun foo() = run { +private fun foo() = run { class A A() } diff --git a/compiler/testData/diagnostics/tests/subtyping/localClasses.txt b/compiler/testData/diagnostics/tests/subtyping/localClasses.txt index 28ac40e5c3d..6dfc3b90898 100644 --- a/compiler/testData/diagnostics/tests/subtyping/localClasses.txt +++ b/compiler/testData/diagnostics/tests/subtyping/localClasses.txt @@ -1,8 +1,8 @@ package package p { - public fun foo(): p.foo..A - public fun foo(/*0*/ a: kotlin.Int): p.foo..A + private fun foo(): p.foo..A + private fun foo(/*0*/ a: kotlin.Int): p.foo..A public fun run(/*0*/ f: () -> T): T public fun test(): kotlin.Unit } diff --git a/compiler/testData/diagnostics/tests/subtyping/nestedIntoLocalClasses.kt b/compiler/testData/diagnostics/tests/subtyping/nestedIntoLocalClasses.kt index 4154728c38f..7de8004b5c6 100644 --- a/compiler/testData/diagnostics/tests/subtyping/nestedIntoLocalClasses.kt +++ b/compiler/testData/diagnostics/tests/subtyping/nestedIntoLocalClasses.kt @@ -6,14 +6,14 @@ fun run(f: () -> T): T { return f() } -fun foo(a: Int) = run { +private fun foo(a: Int) = run { object { inner class A fun foo() = A() }.foo() } -fun foo() = run { +private fun foo() = run { object { inner class A fun foo() = A() diff --git a/compiler/testData/diagnostics/tests/subtyping/nestedIntoLocalClasses.txt b/compiler/testData/diagnostics/tests/subtyping/nestedIntoLocalClasses.txt index 8bc514a0054..9f888781e53 100644 --- a/compiler/testData/diagnostics/tests/subtyping/nestedIntoLocalClasses.txt +++ b/compiler/testData/diagnostics/tests/subtyping/nestedIntoLocalClasses.txt @@ -1,8 +1,8 @@ package package p { - public fun foo(): p.foo...A - public fun foo(/*0*/ a: kotlin.Int): p.foo...A + private fun foo(): p.foo...A + private fun foo(/*0*/ a: kotlin.Int): p.foo...A public fun run(/*0*/ f: () -> T): T public fun test(): kotlin.Unit } diff --git a/compiler/testData/diagnostics/tests/subtyping/nestedLocalClasses.kt b/compiler/testData/diagnostics/tests/subtyping/nestedLocalClasses.kt index 35c5df482d8..7a66372714a 100644 --- a/compiler/testData/diagnostics/tests/subtyping/nestedLocalClasses.kt +++ b/compiler/testData/diagnostics/tests/subtyping/nestedLocalClasses.kt @@ -6,14 +6,14 @@ fun run(f: () -> T): T { return f() } -fun foo(a: Int) = run { +private fun foo(a: Int) = run { class A { inner class B } A().B() } -fun foo() = run { +private fun foo() = run { class A { inner class B } diff --git a/compiler/testData/diagnostics/tests/subtyping/nestedLocalClasses.txt b/compiler/testData/diagnostics/tests/subtyping/nestedLocalClasses.txt index 5b21759c37a..f0475258b96 100644 --- a/compiler/testData/diagnostics/tests/subtyping/nestedLocalClasses.txt +++ b/compiler/testData/diagnostics/tests/subtyping/nestedLocalClasses.txt @@ -1,8 +1,8 @@ package package p { - public fun foo(): p.foo..A.B - public fun foo(/*0*/ a: kotlin.Int): p.foo..A.B + private fun foo(): p.foo..A.B + private fun foo(/*0*/ a: kotlin.Int): p.foo..A.B public fun run(/*0*/ f: () -> T): T public fun test(): kotlin.Unit } diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java index 3e5d6e79b4e..6282c1b1867 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/JetDiagnosticsTestGenerated.java @@ -5760,6 +5760,24 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest { doTest(fileName); } + @TestMetadata("localInFunReturnType.kt") + public void testLocalInFunReturnType() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/exposed/localInFunReturnType.kt"); + doTest(fileName); + } + + @TestMetadata("localInMemberType.kt") + public void testLocalInMemberType() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/exposed/localInMemberType.kt"); + doTest(fileName); + } + + @TestMetadata("localInPropertyType.kt") + public void testLocalInPropertyType() throws Exception { + String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/exposed/localInPropertyType.kt"); + doTest(fileName); + } + @TestMetadata("nested.kt") public void testNested() throws Exception { String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/exposed/nested.kt"); diff --git a/idea/testData/intentions/convertToBlockBody/valueIsAnonymousObject4.kt b/idea/testData/intentions/convertToBlockBody/valueIsAnonymousObject4.kt index 23082e4560f..4aabbaf1457 100644 --- a/idea/testData/intentions/convertToBlockBody/valueIsAnonymousObject4.kt +++ b/idea/testData/intentions/convertToBlockBody/valueIsAnonymousObject4.kt @@ -2,4 +2,4 @@ interface I -fun f() = listOf(object : I { }) +private fun f() = listOf(object : I { }) diff --git a/idea/testData/intentions/replaceExplicitFunctionLiteralParamWithIt/notApplicable_notFunctionLiteralParameter.kt b/idea/testData/intentions/replaceExplicitFunctionLiteralParamWithIt/notApplicable_notFunctionLiteralParameter.kt index b7fb3a3c8e6..88710a364ab 100644 --- a/idea/testData/intentions/replaceExplicitFunctionLiteralParamWithIt/notApplicable_notFunctionLiteralParameter.kt +++ b/idea/testData/intentions/replaceExplicitFunctionLiteralParamWithIt/notApplicable_notFunctionLiteralParameter.kt @@ -1,6 +1,6 @@ // IS_APPLICABLE: false -val foo = { x: Int -> +private val foo = { x: Int -> class Inner() { fun temp(y: Int) : Int { return x + y } }