From 08e18e5d9c49806d6030e6741ca0c2bdebef4e1c Mon Sep 17 00:00:00 2001 From: Svetlana Isakova Date: Wed, 18 Apr 2012 19:59:34 +0400 Subject: [PATCH] KT-1806 accessing private member in object class/anonymous object is not highlighted as error #KT-1806 fixed --- .../jet/lang/descriptors/Visibilities.java | 4 ++-- .../diagnostics/tests/scopes/kt1806.jet | 22 +++++++++++++++++++ 2 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 compiler/testData/diagnostics/tests/scopes/kt1806.jet diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/Visibilities.java b/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/Visibilities.java index 5fce7230afd..10df49710e6 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/Visibilities.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/descriptors/Visibilities.java @@ -38,8 +38,8 @@ public class Visibilities { DeclarationDescriptor parent = what; while (parent != null) { parent = parent.getContainingDeclaration(); - if ((parent instanceof ClassDescriptor && ((ClassDescriptor)parent).getKind() != ClassKind.OBJECT) || - parent instanceof NamespaceDescriptor) { + if ((parent instanceof ClassDescriptor && !DescriptorUtils.isClassObject(parent)) || + parent instanceof NamespaceDescriptor) { break; } } diff --git a/compiler/testData/diagnostics/tests/scopes/kt1806.jet b/compiler/testData/diagnostics/tests/scopes/kt1806.jet new file mode 100644 index 00000000000..674d89f069d --- /dev/null +++ b/compiler/testData/diagnostics/tests/scopes/kt1806.jet @@ -0,0 +1,22 @@ +//KT-1806 accessing private member in object class/anonymous object is not highlighted as error +package kt1806 + +object MyObject { + private var message: String = "'Static'" + +} + +fun test1() { + + doSmth(MyObject.message) +} + +val MyObject1 = object { + private var message: String = "'Static'" +} + +fun test2() { + doSmth(MyObject1.message) +} + +fun doSmth(s: String) = s \ No newline at end of file