A few forgotten checks added for objects (function members effective visibility, multiple varargs) #KT-10753 Fixed
This commit is contained in:
@@ -98,10 +98,11 @@ class DeclarationsChecker(
|
|||||||
for ((classOrObject, classDescriptor) in bodiesResolveContext.declaredClasses.entries) {
|
for ((classOrObject, classDescriptor) in bodiesResolveContext.declaredClasses.entries) {
|
||||||
checkSupertypesForConsistency(classDescriptor, classOrObject)
|
checkSupertypesForConsistency(classDescriptor, classOrObject)
|
||||||
checkTypesInClassHeader(classOrObject)
|
checkTypesInClassHeader(classOrObject)
|
||||||
|
checkClassOrObjectMembers(classDescriptor)
|
||||||
|
|
||||||
when (classOrObject) {
|
when (classOrObject) {
|
||||||
is KtClass -> {
|
is KtClass -> {
|
||||||
checkClass(classOrObject, classDescriptor)
|
checkClassButNotObject(classOrObject, classDescriptor)
|
||||||
descriptorResolver.checkNamesInConstraints(
|
descriptorResolver.checkNamesInConstraints(
|
||||||
classOrObject, classDescriptor, classDescriptor.scopeForClassHeaderResolution, trace)
|
classOrObject, classDescriptor, classDescriptor.scopeForClassHeaderResolution, trace)
|
||||||
}
|
}
|
||||||
@@ -315,7 +316,7 @@ class DeclarationsChecker(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun checkClass(aClass: KtClass, classDescriptor: ClassDescriptorWithResolutionScopes) {
|
private fun checkClassButNotObject(aClass: KtClass, classDescriptor: ClassDescriptorWithResolutionScopes) {
|
||||||
checkOpenMembers(classDescriptor)
|
checkOpenMembers(classDescriptor)
|
||||||
checkTypeParameters(aClass)
|
checkTypeParameters(aClass)
|
||||||
checkTypeParameterConstraints(aClass)
|
checkTypeParameterConstraints(aClass)
|
||||||
@@ -336,7 +337,9 @@ class DeclarationsChecker(
|
|||||||
else if (aClass is KtEnumEntry) {
|
else if (aClass is KtEnumEntry) {
|
||||||
checkEnumEntry(aClass, classDescriptor)
|
checkEnumEntry(aClass, classDescriptor)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun checkClassOrObjectMembers(classDescriptor: ClassDescriptorWithResolutionScopes) {
|
||||||
for (memberDescriptor in classDescriptor.declaredCallableMembers) {
|
for (memberDescriptor in classDescriptor.declaredCallableMembers) {
|
||||||
if (memberDescriptor.kind != CallableMemberDescriptor.Kind.DECLARATION) continue
|
if (memberDescriptor.kind != CallableMemberDescriptor.Kind.DECLARATION) continue
|
||||||
val member = DescriptorToSourceUtils.descriptorToDeclaration(memberDescriptor) as? KtFunction
|
val member = DescriptorToSourceUtils.descriptorToDeclaration(memberDescriptor) as? KtFunction
|
||||||
|
|||||||
+8
@@ -25,3 +25,11 @@ abstract class C(<!MULTIPLE_VARARG_PARAMETERS!>vararg<!> x1: Int, <!MULTIPLE_VAR
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
object O {
|
||||||
|
fun test(<!MULTIPLE_VARARG_PARAMETERS!>vararg<!> x1: Int, <!MULTIPLE_VARARG_PARAMETERS!>vararg<!> x2: Int) {}
|
||||||
|
|
||||||
|
class CC(<!MULTIPLE_VARARG_PARAMETERS!>vararg<!> x1: Int, <!MULTIPLE_VARARG_PARAMETERS!>vararg<!> x2: Int, b: Boolean) {
|
||||||
|
constructor(<!MULTIPLE_VARARG_PARAMETERS!>vararg<!> x1: Int, <!MULTIPLE_VARARG_PARAMETERS!>vararg<!> x2: Int) {}
|
||||||
|
fun test(<!MULTIPLE_VARARG_PARAMETERS!>vararg<!> x1: Int, <!MULTIPLE_VARARG_PARAMETERS!>vararg<!> x2: Int) {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
+17
@@ -27,3 +27,20 @@ public interface I {
|
|||||||
public abstract fun test(/*0*/ vararg x1: kotlin.Int /*kotlin.IntArray*/, /*1*/ vararg x2: kotlin.Int /*kotlin.IntArray*/): kotlin.Unit
|
public abstract fun test(/*0*/ vararg x1: kotlin.Int /*kotlin.IntArray*/, /*1*/ vararg x2: kotlin.Int /*kotlin.IntArray*/): kotlin.Unit
|
||||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
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(/*0*/ vararg x1: kotlin.Int /*kotlin.IntArray*/, /*1*/ vararg x2: kotlin.Int /*kotlin.IntArray*/): kotlin.Unit
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
|
||||||
|
public final class CC {
|
||||||
|
public constructor CC(/*0*/ vararg x1: kotlin.Int /*kotlin.IntArray*/, /*1*/ vararg x2: kotlin.Int /*kotlin.IntArray*/)
|
||||||
|
public constructor CC(/*0*/ vararg x1: kotlin.Int /*kotlin.IntArray*/, /*1*/ vararg x2: kotlin.Int /*kotlin.IntArray*/, /*2*/ b: kotlin.Boolean)
|
||||||
|
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*/ vararg x1: kotlin.Int /*kotlin.IntArray*/, /*1*/ vararg x2: kotlin.Int /*kotlin.IntArray*/): kotlin.Unit
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -0,0 +1,30 @@
|
|||||||
|
// From KT-10753
|
||||||
|
object My : <!EXPOSED_SUPER_CLASS!>Inter()<!> {
|
||||||
|
fun <!EXPOSED_FUNCTION_RETURN_TYPE!>foo<!>(<!EXPOSED_PARAMETER_TYPE!>arg: Inter<!>): Inter = arg
|
||||||
|
<!EXPOSED_PROPERTY_TYPE!>val x: Inter? = null<!>
|
||||||
|
}
|
||||||
|
|
||||||
|
internal open class Inter
|
||||||
|
|
||||||
|
// From KT-10799
|
||||||
|
open class Test {
|
||||||
|
protected class Protected
|
||||||
|
|
||||||
|
fun <!EXPOSED_FUNCTION_RETURN_TYPE!>foo<!>(<!EXPOSED_PARAMETER_TYPE!>x: Protected<!>) = x
|
||||||
|
|
||||||
|
interface NestedInterface {
|
||||||
|
fun create(<!EXPOSED_PARAMETER_TYPE!>x: Protected<!>)
|
||||||
|
}
|
||||||
|
|
||||||
|
class NestedClass {
|
||||||
|
fun <!EXPOSED_FUNCTION_RETURN_TYPE!>create<!>(<!EXPOSED_PARAMETER_TYPE!>x: Protected<!>) = x
|
||||||
|
}
|
||||||
|
|
||||||
|
object NestedObject {
|
||||||
|
fun <!EXPOSED_FUNCTION_RETURN_TYPE!>create<!>(<!EXPOSED_PARAMETER_TYPE!>x: Protected<!>) = x
|
||||||
|
}
|
||||||
|
|
||||||
|
companion object {
|
||||||
|
fun <!EXPOSED_FUNCTION_RETURN_TYPE!>create<!>(<!EXPOSED_PARAMETER_TYPE!>x: Protected<!>) = x
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,63 @@
|
|||||||
|
package
|
||||||
|
|
||||||
|
internal open class Inter {
|
||||||
|
public constructor Inter()
|
||||||
|
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 object My : Inter {
|
||||||
|
private constructor My()
|
||||||
|
public final val x: Inter? = null
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public final fun foo(/*0*/ arg: Inter): Inter
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
}
|
||||||
|
|
||||||
|
public open class Test {
|
||||||
|
public constructor Test()
|
||||||
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
|
public final fun foo(/*0*/ x: Test.Protected): Test.Protected
|
||||||
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
|
|
||||||
|
public companion object Companion {
|
||||||
|
private constructor Companion()
|
||||||
|
public final fun create(/*0*/ x: Test.Protected): Test.Protected
|
||||||
|
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 NestedClass {
|
||||||
|
public constructor NestedClass()
|
||||||
|
public final fun create(/*0*/ x: Test.Protected): Test.Protected
|
||||||
|
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 interface NestedInterface {
|
||||||
|
public abstract fun create(/*0*/ x: Test.Protected): 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 object NestedObject {
|
||||||
|
private constructor NestedObject()
|
||||||
|
public final fun create(/*0*/ x: Test.Protected): Test.Protected
|
||||||
|
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
|
||||||
|
}
|
||||||
|
|
||||||
|
protected final class Protected {
|
||||||
|
public constructor Protected()
|
||||||
|
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
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -6210,6 +6210,12 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest {
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("object.kt")
|
||||||
|
public void testObject() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/exposed/object.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("packagePrivate.kt")
|
@TestMetadata("packagePrivate.kt")
|
||||||
public void testPackagePrivate() throws Exception {
|
public void testPackagePrivate() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/exposed/packagePrivate.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/exposed/packagePrivate.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user