Exposed visibility deprecation warnings made errors + relevant test fixes

This commit is contained in:
Mikhail Glukhikh
2015-11-17 18:59:04 +03:00
parent e8e5d700d2
commit 4e44466cf9
63 changed files with 93 additions and 87 deletions
@@ -73,13 +73,13 @@ public interface Errors {
DiagnosticFactory3<PsiElement, DeclarationDescriptor, Visibility, DeclarationDescriptor> INVISIBLE_MEMBER = DiagnosticFactory3.create(ERROR, CALL_ELEMENT);
// Exposed visibility group
DiagnosticFactory2<KtProperty, EffectiveVisibility, EffectiveVisibility> EXPOSED_PROPERTY_TYPE = DiagnosticFactory2.create(WARNING);
DiagnosticFactory2<PsiElement, EffectiveVisibility, EffectiveVisibility> EXPOSED_FUNCTION_RETURN_TYPE = DiagnosticFactory2.create(WARNING);
DiagnosticFactory2<KtParameter, EffectiveVisibility, EffectiveVisibility> EXPOSED_PARAMETER_TYPE = DiagnosticFactory2.create(WARNING);
DiagnosticFactory2<KtTypeReference, EffectiveVisibility, EffectiveVisibility> EXPOSED_RECEIVER_TYPE = DiagnosticFactory2.create(WARNING);
DiagnosticFactory2<KtTypeParameter, EffectiveVisibility, EffectiveVisibility> EXPOSED_TYPE_PARAMETER_BOUND = DiagnosticFactory2.create(WARNING);
DiagnosticFactory2<KtDelegationSpecifier, EffectiveVisibility, EffectiveVisibility> EXPOSED_SUPER_CLASS = DiagnosticFactory2.create(WARNING);
DiagnosticFactory2<KtDelegationSpecifier, EffectiveVisibility, EffectiveVisibility> EXPOSED_SUPER_INTERFACE = DiagnosticFactory2.create(WARNING);
DiagnosticFactory2<KtProperty, EffectiveVisibility, EffectiveVisibility> EXPOSED_PROPERTY_TYPE = DiagnosticFactory2.create(ERROR);
DiagnosticFactory2<PsiElement, EffectiveVisibility, EffectiveVisibility> EXPOSED_FUNCTION_RETURN_TYPE = DiagnosticFactory2.create(ERROR);
DiagnosticFactory2<KtParameter, EffectiveVisibility, EffectiveVisibility> EXPOSED_PARAMETER_TYPE = DiagnosticFactory2.create(ERROR);
DiagnosticFactory2<KtTypeReference, EffectiveVisibility, EffectiveVisibility> EXPOSED_RECEIVER_TYPE = DiagnosticFactory2.create(ERROR);
DiagnosticFactory2<KtTypeParameter, EffectiveVisibility, EffectiveVisibility> EXPOSED_TYPE_PARAMETER_BOUND = DiagnosticFactory2.create(ERROR);
DiagnosticFactory2<KtDelegationSpecifier, EffectiveVisibility, EffectiveVisibility> EXPOSED_SUPER_CLASS = DiagnosticFactory2.create(ERROR);
DiagnosticFactory2<KtDelegationSpecifier, EffectiveVisibility, EffectiveVisibility> EXPOSED_SUPER_INTERFACE = DiagnosticFactory2.create(ERROR);
DiagnosticFactory1<KtElement, Collection<ClassDescriptor>> PLATFORM_CLASS_MAPPED_TO_KOTLIN = DiagnosticFactory1.create(WARNING);
@@ -112,13 +112,13 @@ public class DefaultErrorMessages {
MAP.put(INVISIBLE_REFERENCE, "Cannot access ''{0}'': it is ''{1}'' in {2}", NAME, TO_STRING, NAME_OF_PARENT_OR_FILE);
MAP.put(INVISIBLE_MEMBER, "Cannot access ''{0}'': it is ''{1}'' in {2}", NAME, TO_STRING, NAME_OF_PARENT_OR_FILE);
MAP.put(EXPOSED_PROPERTY_TYPE, "Deprecated: property effective visibility ''{0}'' should be the same or less permissive than its type effective visibility ''{1}''", TO_STRING, TO_STRING);
MAP.put(EXPOSED_FUNCTION_RETURN_TYPE, "Deprecated: function effective visibility ''{0}'' should be the same or less permissive than its return type effective visibility ''{1}''", TO_STRING, TO_STRING);
MAP.put(EXPOSED_PARAMETER_TYPE, "Deprecated: function effective visibility ''{0}'' should be the same or less permissive than its parameter type effective visibility ''{1}''", TO_STRING, TO_STRING);
MAP.put(EXPOSED_RECEIVER_TYPE, "Deprecated: member effective visibility ''{0}'' should be the same or less permissive than its receiver type effective visibility ''{1}''", TO_STRING, TO_STRING);
MAP.put(EXPOSED_TYPE_PARAMETER_BOUND, "Deprecated: generic effective visibility ''{0}'' should be the same or less permissive than its type parameter bound effective visibility ''{1}''", TO_STRING, TO_STRING);
MAP.put(EXPOSED_SUPER_CLASS, "Deprecated: subclass effective visibility ''{0}'' should be the same or less permissive than its superclass effective visibility ''{1}''", TO_STRING, TO_STRING);
MAP.put(EXPOSED_SUPER_INTERFACE, "Deprecated: sub-interface effective visibility ''{0}'' should be the same or less permissive than its super-interface effective visibility ''{1}''", TO_STRING, TO_STRING);
MAP.put(EXPOSED_PROPERTY_TYPE, "Property effective visibility ''{0}'' should be the same or less permissive than its type effective visibility ''{1}''", TO_STRING, TO_STRING);
MAP.put(EXPOSED_FUNCTION_RETURN_TYPE, "Function effective visibility ''{0}'' should be the same or less permissive than its return type effective visibility ''{1}''", TO_STRING, TO_STRING);
MAP.put(EXPOSED_PARAMETER_TYPE, "Function effective visibility ''{0}'' should be the same or less permissive than its parameter type effective visibility ''{1}''", TO_STRING, TO_STRING);
MAP.put(EXPOSED_RECEIVER_TYPE, "Member effective visibility ''{0}'' should be the same or less permissive than its receiver type effective visibility ''{1}''", TO_STRING, TO_STRING);
MAP.put(EXPOSED_TYPE_PARAMETER_BOUND, "Generic effective visibility ''{0}'' should be the same or less permissive than its type parameter bound effective visibility ''{1}''", TO_STRING, TO_STRING);
MAP.put(EXPOSED_SUPER_CLASS, "Subclass effective visibility ''{0}'' should be the same or less permissive than its superclass effective visibility ''{1}''", TO_STRING, TO_STRING);
MAP.put(EXPOSED_SUPER_INTERFACE, "Sub-interface effective visibility ''{0}'' should be the same or less permissive than its super-interface effective visibility ''{1}''", TO_STRING, TO_STRING);
MAP.put(REDECLARATION, "Redeclaration: {0}", STRING);
MAP.put(NAME_SHADOWING, "Name shadowed: {0}", STRING);
+1 -1
View File
@@ -1,5 +1,5 @@
class Foo(private val s: String) {
private inner class Inner {
inner class Inner {
private val x = {
this@Foo.s
}()
@@ -6,7 +6,7 @@ internal class B : A {
override fun foo() = "OK"
}
val global = B()
internal val global = B()
internal class C(x: Int) : A by global {
constructor(): this(1)
@@ -1,10 +1,10 @@
interface B : A {
internal interface B : A {
fun bar() = 1
}
interface C : B
internal interface C : B
class D : C {
internal class D : C {
override fun foo() {}
}
@@ -1,4 +1,4 @@
class fieldAccessViaSubclass {
public class fieldAccessViaSubclass {
public String fieldO;
public static String fieldK;
@@ -1,4 +1,4 @@
fun getInterface(): GenericInterface<String> {
internal fun getInterface(): GenericInterface<String> {
return GenericInterface { d, i, j, s ->
"OK"
}
@@ -1,4 +1,4 @@
class KotlinSubclass: JavaClass() {
internal class KotlinSubclass: JavaClass() {
}
fun box(): String {
@@ -1,4 +1,4 @@
class KotlinClass : JavaClass<String>() {
internal class KotlinClass : JavaClass<String>() {
fun doIt(): String {
var result = ""
execute("") {
@@ -1,4 +1,4 @@
class KotlinClass(): JavaClass(null) {
internal class KotlinClass(): JavaClass(null) {
}
fun box(): String {
@@ -1,6 +1,6 @@
var status: String = "fail" // global property to avoid issues with accessing closure from local class (KT-4174)
class KotlinClass(): JavaClass({status="OK"}) {
internal class KotlinClass(): JavaClass({status="OK"}) {
}
fun box(): String {
@@ -2,4 +2,4 @@ fun box(): String {
return f(JavaClass())
}
fun f(c: C) = c.ok
internal fun f(c: C) = c.ok
@@ -2,7 +2,7 @@ fun box(): String {
return JavaClass().doIt()
}
fun JavaClass.doIt(): String {
internal fun JavaClass.doIt(): String {
x = "OK"
return x
}
@@ -1,3 +1,3 @@
abstract class Test<F> {
public abstract class Test<F> {
protected final F value = null;
}
@@ -1,4 +1,4 @@
interface Simple {
public interface Simple {
default String test(String s) {
return s + "K";
}
@@ -1,4 +1,4 @@
interface Simple {
public interface Simple {
default String test(String s) {
return s + "K";
}
@@ -1,4 +1,4 @@
interface Simple {
public interface Simple {
default String test(String s) {
return s + "Fail";
}
@@ -1,4 +1,4 @@
fun bar(a: A<String, Int>, b: B<String>, c: C) {
internal fun bar(a: A<String, Int>, b: B<String>, c: C) {
val sa: String = a.foo()
val sb: String = b.foo()
val sc: String = c.foo()
+1 -1
View File
@@ -20,7 +20,7 @@ public object Objects {
}
}
internal open class NestedClass
public open class NestedClass
}
+1 -1
View File
@@ -43,7 +43,7 @@ PsiJetFileStubImpl[package=]
REFERENCE_EXPRESSION:[referencedName=kotlin]
REFERENCE_EXPRESSION:[referencedName=Unit]
CLASS:[fqName=Objects.NestedClass, isEnumEntry=false, isInterface=false, isLocal=false, isTopLevel=false, name=NestedClass, superNames=[]]
MODIFIER_LIST:[open internal]
MODIFIER_LIST:[open public]
PRIMARY_CONSTRUCTOR:
MODIFIER_LIST:[public]
VALUE_PARAMETER_LIST:
@@ -3,4 +3,4 @@
// ACTION: Convert to block body
// ERROR: Unresolved reference: Foo
fun test(): A = <caret>Foo(2, "2")
internal fun test(): A = <caret>Foo(2, "2")
@@ -1,6 +1,6 @@
// "Create class 'Foo'" "true"
// ERROR: Unresolved reference: Foo
class A<T>(val b: B<T>) {
fun test() = B.Foo<Int, String>(2, "2")
class A<T> internal constructor(val b: B<T>) {
internal fun test() = B.Foo<Int, String>(2, "2")
}
@@ -1,6 +1,6 @@
// "Create class 'Foo'" "true"
// ERROR: Unresolved reference: Foo
class A<T>(val b: B<T>) {
fun test() = B.<caret>Foo<Int, String>(2, "2")
class A<T> internal constructor(val b: B<T>) {
internal fun test() = B.<caret>Foo<Int, String>(2, "2")
}
@@ -1,6 +1,6 @@
// "Create class 'Foo'" "true"
// ERROR: Unresolved reference: Foo
class A<T>(val b: B<T>) {
fun test() = b.Foo<Int, String>(2, "2")
class A<T> internal constructor(val b: B<T>) {
internal fun test() = b.Foo<Int, String>(2, "2")
}
@@ -1,6 +1,6 @@
// "Create class 'Foo'" "true"
// ERROR: Unresolved reference: Foo
class A<T>(val b: B<T>) {
fun test() = b.<caret>Foo<Int, String>(2, "2")
class A<T> internal constructor(val b: B<T>) {
internal fun test() = b.<caret>Foo<Int, String>(2, "2")
}
@@ -1,6 +1,6 @@
// "Create class 'Foo'" "true"
// ERROR: Unresolved reference: Foo
class A<T>(val b: B<T>) {
fun test() = b.Foo<String>(2, "2")
class A<T> internal constructor(val b: B<T>) {
internal fun test() = b.Foo<String>(2, "2")
}
@@ -1,6 +1,6 @@
// "Create class 'Foo'" "true"
// ERROR: Unresolved reference: Foo
class A<T>(val b: B<T>) {
fun test() = b.<caret>Foo<String>(2, "2")
class A<T> internal constructor(val b: B<T>) {
internal fun test() = b.<caret>Foo<String>(2, "2")
}
@@ -1,6 +1,6 @@
// "Create class 'Foo'" "true"
// ERROR: Unresolved reference: Foo
class A<T>(val b: B<T>) {
fun test() = b.Foo<T, Int, String>(2, "2")
class A<T> internal constructor(val b: B<T>) {
internal fun test() = b.Foo<T, Int, String>(2, "2")
}
@@ -1,6 +1,6 @@
// "Create class 'Foo'" "true"
// ERROR: Unresolved reference: Foo
class A<T>(val b: B<T>) {
fun test() = b.<caret>Foo<T, Int, String>(2, "2")
class A<T> internal constructor(val b: B<T>) {
internal fun test() = b.<caret>Foo<T, Int, String>(2, "2")
}
@@ -1,6 +1,6 @@
// "Create class 'Foo'" "true"
// ERROR: Unresolved reference: Foo
class A<T>(val b: B<T>) {
fun test() = B.Foo<String>(2, "2")
class A<T> internal constructor(val b: B<T>) {
internal fun test() = B.Foo<String>(2, "2")
}
@@ -1,6 +1,6 @@
// "Create class 'Foo'" "true"
// ERROR: Unresolved reference: Foo
class A<T>(val b: B<T>) {
fun test() = B.<caret>Foo<String>(2, "2")
class A<T> internal constructor(val b: B<T>) {
internal fun test() = B.<caret>Foo<String>(2, "2")
}
@@ -2,4 +2,4 @@
// ACTION: Convert to block body
// ACTION: Create member property 'A'
// ERROR: Unresolved reference: A
fun foo(): J = J.<caret>A
internal fun foo(): J = J.<caret>A
@@ -2,4 +2,4 @@
// ACTION: Convert to block body
// ACTION: Create member property 'A'
// ERROR: Unresolved reference: A
fun foo(): X = E.<caret>A
internal fun foo(): X = E.<caret>A
@@ -1,6 +1,6 @@
// "Create member function 'foo'" "true"
// ERROR: Unresolved reference: foo
fun test(a: A): Int? {
internal fun test(a: A): Int? {
return a.foo<String, Int>(1, "2")
}
@@ -1,6 +1,6 @@
// "Create member function 'foo'" "true"
// ERROR: Unresolved reference: foo
fun test(a: A): Int? {
internal fun test(a: A): Int? {
return a.<caret>foo<String, Int>(1, "2")
}
@@ -1,7 +1,7 @@
// "Create member function 'foo'" "true"
// ERROR: Unresolved reference: foo
class A<T>(val b: B<T>) {
class A<T> internal constructor(val b: B<T>) {
fun test(): Int {
return b.foo<Int, String>(2, "2")
}
@@ -1,7 +1,7 @@
// "Create member function 'foo'" "true"
// ERROR: Unresolved reference: foo
class A<T>(val b: B<T>) {
class A<T> internal constructor(val b: B<T>) {
fun test(): Int {
return b.<caret>foo<Int, String>(2, "2")
}
@@ -1,7 +1,7 @@
// "Create member function 'foo'" "true"
// ERROR: Unresolved reference: foo
class A<T>(val b: B<T>) {
class A<T> internal constructor(val b: B<T>) {
fun test(): Int {
return b.foo<Int>(2, "2")
}
@@ -1,7 +1,7 @@
// "Create member function 'foo'" "true"
// ERROR: Unresolved reference: foo
class A<T>(val b: B<T>) {
class A<T> internal constructor(val b: B<T>) {
fun test(): Int {
return b.<caret>foo<Int>(2, "2")
}
@@ -1,7 +1,7 @@
// "Create member function 'foo'" "true"
// ERROR: Unresolved reference: foo
class A<T>(val b: B<T>) {
class A<T> internal constructor(val b: B<T>) {
fun test(): Int {
return b.foo<Int, String>(2, "2")
}
@@ -1,7 +1,7 @@
// "Create member function 'foo'" "true"
// ERROR: Unresolved reference: foo
class A<T>(val b: B<T>) {
class A<T> internal constructor(val b: B<T>) {
fun test(): Int {
return b.<caret>foo<T, Int, String>(2, "2")
}
@@ -1,6 +1,6 @@
// "Create secondary constructor" "true"
// ERROR: Too many arguments for public/*package*/ constructor J() defined in J
class B: J(1) {
internal class B: J(1) {
}
@@ -1,6 +1,6 @@
// "Create secondary constructor" "true"
// ERROR: Too many arguments for public/*package*/ constructor J() defined in J
class B: J(<caret>1) {
internal class B: J(<caret>1) {
}
@@ -1,4 +1,4 @@
// "Create secondary constructor" "true"
// ERROR: Too many arguments for public/*package*/ constructor J() defined in J
fun test() = J(1)
internal fun test() = J(1)
@@ -1,4 +1,4 @@
// "Create secondary constructor" "true"
// ERROR: Too many arguments for public/*package*/ constructor J() defined in J
fun test() = J(<caret>1)
internal fun test() = J(<caret>1)
@@ -1,7 +1,7 @@
// "Create secondary constructor" "true"
// ERROR: Too many arguments for public/*package*/ constructor J() defined in J
class B: J {
internal class B: J {
constructor(): super(1) {
}
@@ -1,7 +1,7 @@
// "Create secondary constructor" "true"
// ERROR: Too many arguments for public/*package*/ constructor J() defined in J
class B: J {
internal class B: J {
constructor(): super(<caret>1) {
}
@@ -1,4 +1,4 @@
// "Create parameter 's'" "true"
// ERROR: Unresolved reference: s
fun foo(s: String?) = C(s)
internal fun foo(s: String?) = C(s)
@@ -1,4 +1,4 @@
// "Create parameter 's'" "true"
// ERROR: Unresolved reference: s
fun foo() = C(<caret>s)
internal fun foo() = C(<caret>s)
@@ -3,6 +3,6 @@
// ACTION: Create extension property 'foo'
// ERROR: Unresolved reference: foo
fun test(a: A): String? {
internal fun test(a: A): String? {
return a.<caret>foo
}
+1 -1
View File
@@ -19,7 +19,7 @@ class Frame {
public void addWindowListener(WindowListener listener){}
}
public final class Client extends Frame {
final class Client extends Frame {
Client() {
WindowAdapter a = new WindowAdapter() {
@Override
+1 -1
View File
@@ -17,7 +17,7 @@ internal open class Frame {
}
}
class Client internal constructor() : Frame() {
internal class Client : Frame() {
init {
val a = object : WindowAdapter() {
override fun windowClosing() {
+1 -1
View File
@@ -1,6 +1,6 @@
package test;
class JavaClass {
public class JavaClass {
public int field = 0;
protected int myProperty = 0;
+1 -1
View File
@@ -1,6 +1,6 @@
package test
internal open class JavaClass {
open class JavaClass {
var field = 0
var property = 0
@@ -1,6 +1,6 @@
package test;
class C extends JavaClass {
public class C extends JavaClass {
public void foo(JavaClass javaClass) {
javaClass.field++;
--javaClass.field;
@@ -1,6 +1,6 @@
package test;
class C extends JavaClass {
public class C extends JavaClass {
public void foo(JavaClass javaClass) {
javaClass.setField(javaClass.getField() + 1);
javaClass.setField(javaClass.getField() - 1);
+1 -1
View File
@@ -1,4 +1,4 @@
class B {
public class B {
void foo(AAA a) {
a.setX(a.getX() + 1);
y += "a";
+2 -2
View File
@@ -1,5 +1,5 @@
internal class B {
fun foo(a: AAA) {
class B {
internal fun foo(a: AAA) {
a.x = a.x + 1
yy += "a"
}
@@ -4,4 +4,7 @@ Cannot access 'InternalClass1': it is 'internal' in 'test' at line 8, column 36
Cannot access 'InternalClass2': it is 'internal' in 'test' at line 19, column 15
Cannot access 'InternalClassAnnotation': it is 'internal' in 'test' at line 10, column 2
Cannot access 'InternalFileAnnotation': it is 'internal' in 'test' at line 1, column 7
Cannot access 'member': it is 'invisible_fake' in 'ClassAA1' at line 27, column 25
Cannot access 'member': it is 'invisible_fake' in 'ClassAA1' at line 27, column 25
Subclass effective visibility 'public' should be the same or less permissive than its superclass effective visibility 'internal' at line 18, column 36
Subclass effective visibility 'public' should be the same or less permissive than its superclass effective visibility 'internal' at line 19, column 15
Subclass effective visibility 'public' should be the same or less permissive than its superclass effective visibility 'internal' at line 8, column 36
@@ -3,4 +3,6 @@ Cannot access 'InternalClass1': it is 'internal' in 'test' at line 5, column 13
Cannot access 'InternalClass1': it is 'internal' in 'test' at line 8, column 36
Cannot access 'InternalClassAnnotation': it is 'internal' in 'test' at line 10, column 2
Cannot access 'InternalTestAnnotation': it is 'internal' in 'test' at line 1, column 7
Cannot access 'member': it is 'invisible_fake' in 'ClassAA1' at line 27, column 25
Cannot access 'member': it is 'invisible_fake' in 'ClassAA1' at line 27, column 25
Subclass effective visibility 'public' should be the same or less permissive than its superclass effective visibility 'internal' at line 18, column 36
Subclass effective visibility 'public' should be the same or less permissive than its superclass effective visibility 'internal' at line 8, column 36
@@ -22,5 +22,6 @@ Cannot access 'A': it is 'internal' in 'a'
Cannot access 'FileAnnotation': it is 'internal' in 'a'
Cannot access 'ClassAnnotation': it is 'internal' in 'a'
Cannot access 'ClassAnnotation': it is 'internal' in 'a'
Function effective visibility 'public' should be the same or less permissive than its parameter type effective visibility 'internal'
Cannot access 'A': it is 'internal' in 'a'
Cannot access 'a': it is 'internal' in 'a'
@@ -24,7 +24,7 @@ public class M {
public fun applyM<T>(arg: T, func: (T)->T): T = func(arg)
}
private class N {
internal class N {
inline
public fun applyN<T>(arg: T, func: (T)->T): T = func(arg)
}
@@ -9,7 +9,7 @@ class ListBinarySearchTest {
fun notFound(index: Int) = -(index + 1)
val comparator = compareBy<IncomparableDataItem<Int>?> { it?.value }
private val comparator = compareBy<IncomparableDataItem<Int>?> { it?.value }
@Test
fun binarySearchByElement() {