Added check for incompatible variance modifiers and repeated modifiers
This commit is contained in:
+4
-1
@@ -4,4 +4,7 @@ package d
|
||||
|
||||
fun test() {
|
||||
f()
|
||||
}
|
||||
}
|
||||
|
||||
var g: Int = 1
|
||||
<!PACKAGE_MEMBER_CANNOT_BE_PROTECTED!>protected<!> set(i: Int) {}
|
||||
+1
@@ -2,5 +2,6 @@ package
|
||||
|
||||
package d {
|
||||
internal val f: () -> kotlin.Int
|
||||
internal var g: kotlin.Int
|
||||
internal fun test(): kotlin.Unit
|
||||
}
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
// !DIAGNOSTICS: -UNUSED_VARIABLE
|
||||
|
||||
trait Foo<T>
|
||||
trait Foo1<<!INCOMPATIBLE_MODIFIERS!>in<!> <!INCOMPATIBLE_MODIFIERS!>out<!> T>
|
||||
trait Foo2<<!REPEATED_MODIFIER!>in<!> <!REPEATED_MODIFIER!>in<!> T>
|
||||
|
||||
fun test1(foo: Foo<<!INCOMPATIBLE_MODIFIERS!>in<!> <!INCOMPATIBLE_MODIFIERS!>out<!> Int>) = foo
|
||||
fun test2(): Foo<<!REPEATED_MODIFIER!>in<!> <!REPEATED_MODIFIER!>in<!> Int> = throw Exception()
|
||||
|
||||
fun test3() {
|
||||
val f: Foo<<!REPEATED_MODIFIER!>out<!> <!REPEATED_MODIFIER!>out<!> <!REPEATED_MODIFIER!>out<!> <!REPEATED_MODIFIER!>out<!> Int>
|
||||
|
||||
class Bzz<<!REPEATED_MODIFIER!>in<!> <!REPEATED_MODIFIER!>in<!> T>
|
||||
}
|
||||
|
||||
class A {
|
||||
fun <<!VARIANCE_ON_TYPE_PARAMETER_OF_FUNCTION_OR_PROPERTY, REPEATED_MODIFIER!>out<!> <!REPEATED_MODIFIER!>out<!> T> bar() {
|
||||
}
|
||||
}
|
||||
|
||||
fun test4(a: A) {
|
||||
a.bar<<!PROJECTION_ON_NON_CLASS_TYPE_ARGUMENT, REPEATED_MODIFIER!>out<!> <!REPEATED_MODIFIER!>out<!> Int>()
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package
|
||||
|
||||
internal fun test1(/*0*/ foo: Foo<in kotlin.Int>): Foo<in kotlin.Int>
|
||||
internal fun test2(): Foo<in kotlin.Int>
|
||||
internal fun test3(): kotlin.Unit
|
||||
internal fun test4(/*0*/ a: A): kotlin.Unit
|
||||
|
||||
internal final class A {
|
||||
public constructor A()
|
||||
internal final fun </*0*/ out T> bar(): 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
|
||||
}
|
||||
|
||||
internal trait Foo</*0*/ 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
|
||||
}
|
||||
|
||||
internal trait Foo1</*0*/ out 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
|
||||
}
|
||||
|
||||
internal trait Foo2</*0*/ in 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
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
<!REPEATED_MODIFIER!>abstract<!> <!REPEATED_MODIFIER!>abstract<!> class Foo
|
||||
<!REPEATED_MODIFIER!>public<!> <!REPEATED_MODIFIER!>public<!> class Bar
|
||||
<!REPEATED_MODIFIER, INCOMPATIBLE_MODIFIERS!>open<!> <!REPEATED_MODIFIER!>open<!> <!INCOMPATIBLE_MODIFIERS!>final<!> class Baz {
|
||||
<!REPEATED_MODIFIER!>private<!> <!REPEATED_MODIFIER!>private<!> fun foo() {}
|
||||
}
|
||||
|
||||
class Bzz(<!REPEATED_MODIFIER!>public<!> <!REPEATED_MODIFIER!>public<!> val q: Int = 1) {
|
||||
<!REPEATED_MODIFIER!>public<!> <!REPEATED_MODIFIER!>public<!> val x: Int = 2
|
||||
|
||||
public val y: Int
|
||||
<!REPEATED_MODIFIER, REDUNDANT_MODIFIER_IN_GETTER!>public<!> <!REPEATED_MODIFIER!>public<!> get() = 3
|
||||
|
||||
val z: Int
|
||||
<!INCOMPATIBLE_MODIFIERS, ILLEGAL_MODIFIER!>open<!> <!INCOMPATIBLE_MODIFIERS, ILLEGAL_MODIFIER!>final<!> get() = 4
|
||||
|
||||
<!REPEATED_MODIFIER!>public<!> <!REPEATED_MODIFIER!>public<!> class B(<!REPEATED_MODIFIER!>public<!> <!REPEATED_MODIFIER!>public<!> val z: Int = 1) {
|
||||
<!REPEATED_MODIFIER!>public<!> <!REPEATED_MODIFIER!>public<!> val y: Int = 2
|
||||
|
||||
public val x: Int
|
||||
<!REPEATED_MODIFIER, REDUNDANT_MODIFIER_IN_GETTER!>public<!> <!REPEATED_MODIFIER!>public<!> get() = 3
|
||||
}
|
||||
|
||||
<!REPEATED_MODIFIER!>public<!> <!REPEATED_MODIFIER!>public<!> object C {
|
||||
<!REPEATED_MODIFIER!>public<!> <!REPEATED_MODIFIER!>public<!> val y: Int = 1
|
||||
<!REPEATED_MODIFIER!>public<!> <!REPEATED_MODIFIER!>public<!> fun z(): Int = 1
|
||||
}
|
||||
}
|
||||
|
||||
<!REPEATED_MODIFIER!>public<!> <!REPEATED_MODIFIER!>public<!> val bar: Int = 1
|
||||
|
||||
<!REPEATED_MODIFIER!>public<!> <!REPEATED_MODIFIER!>public<!> fun foo(): Int = 1
|
||||
|
||||
fun test() {
|
||||
<!REPEATED_MODIFIER!>public<!> <!REPEATED_MODIFIER!>public<!> class B(<!REPEATED_MODIFIER!>public<!> <!REPEATED_MODIFIER!>public<!> val z: Int = 1) {
|
||||
<!REPEATED_MODIFIER!>public<!> <!REPEATED_MODIFIER!>public<!> val y: Int = 2
|
||||
|
||||
public val x: Int
|
||||
<!REPEATED_MODIFIER, REDUNDANT_MODIFIER_IN_GETTER!>public<!> <!REPEATED_MODIFIER!>public<!> get() = 3
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
package
|
||||
|
||||
public val bar: kotlin.Int = 1
|
||||
public fun foo(): kotlin.Int
|
||||
internal fun test(): kotlin.Unit
|
||||
|
||||
public final class Bar {
|
||||
public constructor Bar()
|
||||
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
|
||||
}
|
||||
|
||||
internal open class Baz {
|
||||
public constructor Baz()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
private final fun foo(): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
internal final class Bzz {
|
||||
public constructor Bzz(/*0*/ q: kotlin.Int = ...)
|
||||
public final val q: kotlin.Int
|
||||
public final val x: kotlin.Int = 2
|
||||
public final val y: kotlin.Int
|
||||
internal final val z: kotlin.Int
|
||||
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 B {
|
||||
public constructor B(/*0*/ z: kotlin.Int = ...)
|
||||
public final val x: kotlin.Int
|
||||
public final val y: kotlin.Int = 2
|
||||
public final val z: kotlin.Int
|
||||
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 C {
|
||||
private constructor C()
|
||||
public final val y: kotlin.Int = 1
|
||||
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 fun z(): kotlin.Int
|
||||
|
||||
public class object <class-object-for-C> : Bzz.C {
|
||||
private constructor <class-object-for-C>()
|
||||
public final override /*1*/ /*fake_override*/ val y: kotlin.Int
|
||||
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 override /*1*/ /*fake_override*/ fun z(): kotlin.Int
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
internal abstract class Foo {
|
||||
public constructor Foo()
|
||||
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
|
||||
}
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
//ALLOW_AST_ACCESS
|
||||
package test;
|
||||
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
//ALLOW_AST_ACCESS
|
||||
package test
|
||||
|
||||
public class ArrayTypeVariance {
|
||||
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
//ALLOW_AST_ACCESS
|
||||
package test
|
||||
|
||||
import java.util.*
|
||||
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
//ALLOW_AST_ACCESS
|
||||
package test
|
||||
|
||||
import java.util.*
|
||||
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
//ALLOW_AST_ACCESS
|
||||
package test
|
||||
|
||||
import java.util.*
|
||||
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
//ALLOW_AST_ACCESS
|
||||
package test
|
||||
|
||||
import java.util.*
|
||||
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
//ALLOW_AST_ACCESS
|
||||
package test
|
||||
|
||||
public trait ChangeProjectionKind1 {
|
||||
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
//ALLOW_AST_ACCESS
|
||||
package test
|
||||
|
||||
public trait InheritNotVararg {
|
||||
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
//ALLOW_AST_ACCESS
|
||||
package test
|
||||
|
||||
public trait InheritNotVarargInteger {
|
||||
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
//ALLOW_AST_ACCESS
|
||||
package test
|
||||
|
||||
public trait InheritNotVarargNotNull {
|
||||
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
//ALLOW_AST_ACCESS
|
||||
package test
|
||||
|
||||
public trait InheritProjectionKind {
|
||||
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
//ALLOW_AST_ACCESS
|
||||
package test
|
||||
|
||||
public trait InheritVarargNotNull {
|
||||
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
//ALLOW_AST_ACCESS
|
||||
package test
|
||||
|
||||
public trait InheritProjectionKind {
|
||||
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
//ALLOW_AST_ACCESS
|
||||
package test
|
||||
|
||||
public trait SameProjectionKind {
|
||||
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
//ALLOW_AST_ACCESS
|
||||
package test
|
||||
|
||||
public trait TwoSuperclassesConflictingProjectionKinds {
|
||||
|
||||
@@ -3,9 +3,6 @@ package test
|
||||
var Long.date1: Any get() = java.util.Date()
|
||||
set(value) {}
|
||||
|
||||
var Long.date2: Any get() = java.util.Date()
|
||||
protected set(value) {}
|
||||
|
||||
var Long.date3: Any get() = java.util.Date()
|
||||
private set(value) {}
|
||||
|
||||
@@ -21,8 +18,5 @@ public var Long.date8: java.util.Date get() = java.util.Date()
|
||||
public var Long.date9: java.util.Date get() = java.util.Date()
|
||||
private set(value) {}
|
||||
|
||||
public var Long.date10: java.util.Date get() = java.util.Date()
|
||||
protected set(value) {}
|
||||
|
||||
public var Long.date11: java.util.Date get() = java.util.Date()
|
||||
public set(value) {}
|
||||
|
||||
@@ -3,15 +3,9 @@ package test
|
||||
internal var kotlin.Long.date1: kotlin.Any
|
||||
internal fun kotlin.Long.<get-date1>(): kotlin.Any
|
||||
internal fun kotlin.Long.<set-date1>(/*0*/ value: kotlin.Any): kotlin.Unit
|
||||
public var kotlin.Long.date10: java.util.Date
|
||||
public fun kotlin.Long.<get-date10>(): java.util.Date
|
||||
protected fun kotlin.Long.<set-date10>(/*0*/ value: java.util.Date): kotlin.Unit
|
||||
public var kotlin.Long.date11: java.util.Date
|
||||
public fun kotlin.Long.<get-date11>(): java.util.Date
|
||||
public fun kotlin.Long.<set-date11>(/*0*/ value: java.util.Date): kotlin.Unit
|
||||
internal var kotlin.Long.date2: kotlin.Any
|
||||
internal fun kotlin.Long.<get-date2>(): kotlin.Any
|
||||
protected fun kotlin.Long.<set-date2>(/*0*/ value: kotlin.Any): kotlin.Unit
|
||||
internal var kotlin.Long.date3: kotlin.Any
|
||||
internal fun kotlin.Long.<get-date3>(): kotlin.Any
|
||||
private fun kotlin.Long.<set-date3>(/*0*/ value: kotlin.Any): kotlin.Unit
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
//ALLOW_AST_ACCESS
|
||||
package test
|
||||
|
||||
fun nothing(): Array<in Number> = throw Exception()
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
//ALLOW_AST_ACCESS
|
||||
package test
|
||||
|
||||
fun nothing(): Array<out Number> = throw Exception()
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
//ALLOW_AST_ACCESS
|
||||
package test
|
||||
|
||||
fun <T> nothing(): Array<out T> = throw Exception()
|
||||
|
||||
Reference in New Issue
Block a user