From 2da3366a47c8c7136bbd562ed10e5e2c5e2b8031 Mon Sep 17 00:00:00 2001 From: Dmitriy Novozhilov Date: Fri, 18 Jan 2019 14:40:17 +0300 Subject: [PATCH] Fix `PROTECTED_CONSTRUCTOR_NOT_IN_SUPER_CALL` diagnostic in new inference --- .../calls/checkers/ProtectedConstructorCallChecker.kt | 2 +- compiler/testData/diagnostics/tests/inline/kt15410.kt | 2 +- .../scopes/protectedVisibility/nonSuperCallConstructor.kt | 8 ++++---- .../typealias/typeAliasConstructorWrongVisibility.kt | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/checkers/ProtectedConstructorCallChecker.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/checkers/ProtectedConstructorCallChecker.kt index 71bba52fe6d..a41800a6188 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/checkers/ProtectedConstructorCallChecker.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/calls/checkers/ProtectedConstructorCallChecker.kt @@ -55,7 +55,7 @@ object ProtectedConstructorCallChecker : CallChecker { // And without ProtectedConstructorCallChecker such calls would be allowed only because they are performed within subclass // of constructor owner @Suppress("DEPRECATION") - if (Visibilities.findInvisibleMember(Visibilities.FALSE_IF_PROTECTED, descriptor, scopeOwner) == actualConstructor) { + if (Visibilities.findInvisibleMember(Visibilities.FALSE_IF_PROTECTED, descriptor, scopeOwner) == actualConstructor.original) { context.trace.report(Errors.PROTECTED_CONSTRUCTOR_NOT_IN_SUPER_CALL.on(reportOn, descriptor)) } } diff --git a/compiler/testData/diagnostics/tests/inline/kt15410.kt b/compiler/testData/diagnostics/tests/inline/kt15410.kt index 6ac63cf4457..1bfe158cd71 100644 --- a/compiler/testData/diagnostics/tests/inline/kt15410.kt +++ b/compiler/testData/diagnostics/tests/inline/kt15410.kt @@ -6,5 +6,5 @@ open class Foo protected constructor() inline fun foo(f: () -> Unit) = object: Foo() {} class A : Foo() { - inline fun foo(f: () -> Unit) = Foo() + inline fun foo(f: () -> Unit) = Foo() } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/scopes/protectedVisibility/nonSuperCallConstructor.kt b/compiler/testData/diagnostics/tests/scopes/protectedVisibility/nonSuperCallConstructor.kt index 080dcc557f9..f467938fb1b 100644 --- a/compiler/testData/diagnostics/tests/scopes/protectedVisibility/nonSuperCallConstructor.kt +++ b/compiler/testData/diagnostics/tests/scopes/protectedVisibility/nonSuperCallConstructor.kt @@ -8,14 +8,14 @@ open class A protected constructor(x: Int) { class B4 : A(1) { init { - A() - A(1) + A() + A(1) A(5.0) } fun foo() { - A() - A(1) + A() + A(1) A(5.0) object : A() {} diff --git a/compiler/testData/diagnostics/tests/typealias/typeAliasConstructorWrongVisibility.kt b/compiler/testData/diagnostics/tests/typealias/typeAliasConstructorWrongVisibility.kt index d46c107b689..e0deed70027 100644 --- a/compiler/testData/diagnostics/tests/typealias/typeAliasConstructorWrongVisibility.kt +++ b/compiler/testData/diagnostics/tests/typealias/typeAliasConstructorWrongVisibility.kt @@ -23,7 +23,7 @@ class MyDerived : MyClass(1.0) { val test4 = MyAlias(1) val test4a = MyClass(1) val test5 = MyAlias("") - val test5a = MyClass("") + val test5a = MyClass("") val test6 = MyAlias(1.0) val test6a = MyClass(1.0) } \ No newline at end of file