[FIR-TEST] Add new testdata generated after changes in previous commit

This commit is contained in:
Dmitriy Novozhilov
2019-12-11 16:16:22 +03:00
parent e9c02a1cca
commit 2536fa0cd5
4578 changed files with 104067 additions and 1 deletions
@@ -0,0 +1,18 @@
open class A {
protected fun foo() {}
init {
B.foo() // Ok, receiver (B.Companion) is subtype of A
(B.Companion).foo()
}
}
class B {
companion object : A()
}
class C: A() {
init {
B.foo() // Error: receiver is not suitable
}
}
@@ -0,0 +1,22 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
open class A protected constructor(x: Int) {
protected constructor() : this(1)
protected constructor(x: String) : this(2)
public constructor(x: Double) : this(3)
}
fun foo() {
<!INAPPLICABLE_CANDIDATE!>A<!>()
A(1.0)
}
class B1 : A(1) {}
class B2 : A() {}
class B3 : A("") {}
class B4 : A {
constructor() : <!INAPPLICABLE_CANDIDATE!>super<!>(1)
constructor(x: Int) : super()
constructor(x: Int, y: Int) : <!INAPPLICABLE_CANDIDATE!>super<!>("")
}
@@ -0,0 +1,19 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
open class Outer {
inner open class A protected constructor(x: Int) {
protected constructor() : this(1)
protected constructor(x: String) : this(2)
}
inner class B1 : A(1) {}
inner class B2 : A() {}
inner class B3 : A("") {}
inner class B4 : A {
constructor() : <!INAPPLICABLE_CANDIDATE!>super<!>(1)
constructor(x: Int) : super()
constructor(x: Int, y: Int) : <!INAPPLICABLE_CANDIDATE!>super<!>("")
}
}
@@ -0,0 +1,24 @@
// FILE: p1/BaseClass.java
package p1;
public class BaseClass {
protected class ProtSubClass {
public ProtSubClass() {}
}
}
// FILE: k1/main.kt
package k1
import p1.BaseClass
class Foo : BaseClass() {
fun foo() {
ProtSubClass()
super.ProtSubClass()
}
private val v1: BaseClass.ProtSubClass = ProtSubClass()
}
@@ -0,0 +1,13 @@
open class BaseClass() {
protected class Nested(val x: Int, protected val y: Int)
protected fun foo() = Nested(1, 2)
}
class Foo : BaseClass() {
fun bar() {
val f = foo()
f.x
f.<!INAPPLICABLE_CANDIDATE!>y<!>
}
}
@@ -0,0 +1,58 @@
// FILE: bar/JavaClass.java
package bar;
public class JavaClass {
protected void foo() {}
protected static void bar1() {}
protected static void bar2() {}
protected String field = "";
protected static String CONST1 = "";
protected static String CONST2 = "";
}
// FILE: foo/JavaClassSamePackage.java
package foo;
public class JavaClassSamePackage extends bar.JavaClass {
protected static void bar2() {}
protected static String CONST2 = "";
}
// FILE: foo/main.kt
package foo
import bar.JavaClass
class KotlinClass : JavaClass() {
fun baz() {
foo() // OK
}
}
class KotlinClass2 : JavaClass() {
override fun foo() {}
val field: String = "abc"
}
fun test(a: KotlinClass, b: KotlinClass2) {
a.<!INAPPLICABLE_CANDIDATE!>foo<!>() // Error, protected_and_package declared in different package
b.foo() // Error, protected visibility in same package (but could be protected_and_package)
a.<!INAPPLICABLE_CANDIDATE!>field<!>
JavaClass.<!INAPPLICABLE_CANDIDATE!>bar1<!>()
JavaClass.<!INAPPLICABLE_CANDIDATE!>CONST1<!>
KotlinClass.<!INAPPLICABLE_CANDIDATE!>bar1<!>() // Currently it's unresolved, but it should be prohibited even in case it would be resolved
KotlinClass.<!INAPPLICABLE_CANDIDATE!>CONST1<!>
JavaClassSamePackage.<!INAPPLICABLE_CANDIDATE!>bar1<!>()
JavaClassSamePackage.bar2()
JavaClassSamePackage.<!INAPPLICABLE_CANDIDATE!>CONST1<!>
JavaClassSamePackage.CONST2
}
@@ -0,0 +1,22 @@
// !CHECK_TYPE
// FILE: module1/AbstractModule.java
package module1;
public abstract class AbstractModule<S> {
protected <T> S bind(Class<T> clazz) { return null; }
}
// FILE: module2/main.kt
package module2
import module1.*
fun <T> javaClass(): Class<T> = null!!
public class AppServiceModule : AbstractModule<String>() {
inline fun <reified T> AbstractModule<Int>.bind() {
val x = bind(javaClass<T>())
x checkType { <!INAPPLICABLE_CANDIDATE!>_<!><String>() } // check that Class receiver is used instead of extension one
}
}
@@ -0,0 +1,27 @@
// !WITH_NEW_INFERENCE
// !DIAGNOSTICS: -UNUSED_PARAMETER
open class A protected constructor(x: Int) {
protected constructor() : this(1)
public constructor(x: Double) : this(3)
}
class B4 : A(1) {
init {
A()
A(1)
A(5.0)
}
fun foo() {
A()
A(1)
A(5.0)
object : A() {}
object : A(1) {}
object : A(5.0) {}
class Local : A()
}
}
@@ -0,0 +1,32 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
// FILE: abc/A.java
package abc;
public class A {
protected A() {}
protected A(int x) {}
public A(double x) {}
}
// FILE: main.kt
import abc.*
class B4 : A(1) {
init {
A()
A(1)
A(5.0)
}
fun foo() {
A()
A(1)
A(5.0)
object : A() {}
object : A(1) {}
object : A(5.0) {}
class Local : A()
}
}
@@ -0,0 +1,30 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
// FILE: A.java
public class A {
protected A() {}
protected A(int x) {}
public A(double x) {}
}
// FILE: main.kt
class B4 : A(1) {
init {
A()
A(1)
A(5.0)
}
fun foo() {
A()
A(1)
A(5.0)
object : A() {}
object : A(1) {}
object : A(5.0) {}
class Local : A()
}
}
@@ -0,0 +1,15 @@
open class A {
open protected fun foo() { }
open protected fun foobaz() { }
fun bar(x: B) {
x.foo() // OK, foo declared in A
x.<!INAPPLICABLE_CANDIDATE!>baz<!>() // Declared in B
x.foobaz() // Declared in B
}
}
class B : A() {
protected fun baz() {}
override fun foobaz() {}
}
@@ -0,0 +1,9 @@
abstract class A<T : Any> {
abstract protected fun T.foo()
fun bar(x: T?) {
if (x != null) {
x.foo()
}
}
}
@@ -0,0 +1,45 @@
// FILE: abc/A.java
package abc;
public class A {
public int getAbc() {}
protected int getFoo() { return 1; }
public String getBar() { return ""; }
protected void setBar(String x) { }
}
// FILE: main.kt
import abc.A
class Data(var x: A)
class B : A() {
fun baz(a: A, b: B, d: Data) {
foo
bar = bar + ""
b.foo
b.bar = b.bar + ""
a.foo
// TODO: should be INVISIBLE_SETTER
a.bar = a.bar + ""
if (a is B) {
a.foo
a.bar = a.bar + ""
}
if (d.x is B) {
d.x.abc // Ok
d.x.foo
// TODO: should be INVISIBLE_SETTER
d.x.bar = d.x.bar + ""
}
}
}
fun baz(a: A) {
a.<!INAPPLICABLE_CANDIDATE!>foo<!>
a.bar = a.bar + ""
}
@@ -0,0 +1,31 @@
// !WITH_NEW_INFERENCE
// FILE: abc/A.java
package abc;
public class A {
protected void foo(Runnable x) {}
}
// FILE: main.kt
import abc.A;
class Data(var x: A)
class B : A() {
fun baz(a: A, b: B, d: Data) {
a.foo { }
b.foo { }
if (a is B) {
a.foo {}
}
if (d.x is B) {
d.x.foo {}
}
}
}
fun baz(a: A) {
a.<!INAPPLICABLE_CANDIDATE!>foo<!> { }
}
@@ -0,0 +1,19 @@
// !WITH_NEW_INFERENCE
// !CHECK_TYPE
open class BaseOuter {
protected fun foo() = 1
protected fun bar() { }
}
class Foo(var base: BaseOuter)
fun BaseOuter.foo(): String = ""
class Derived : BaseOuter() {
fun test(foo: Foo) {
if (foo.base is Derived) {
foo.base.foo() checkType { <!INAPPLICABLE_CANDIDATE!>_<!><String>() } // Resolved to extension
foo.base.bar()
}
}
}
@@ -0,0 +1,30 @@
open class Base {
open protected fun foo() {}
open protected fun bar() {}
open protected var x: Int = 1
open var y: Int = 1
protected set
}
class Derived : Base() {
override fun bar() { }
protected fun baz(x: Base) {
x.foo()
x.bar()
x.x = x.x + 1
x.y = x.y + 1
if (x is Derived) {
x.foo()
x.bar()
x.baz(x)
x.x = x.x + 1
// TODO: Should be smart cast
x.y = x.y + 1
}
}
}