[FIR-TEST] Add new testdata generated after changes in previous commit
This commit is contained in:
+12
@@ -0,0 +1,12 @@
|
||||
// FILE: root.kt
|
||||
fun testFun() = "239"
|
||||
|
||||
// FILE: otherPackage.kt
|
||||
package test
|
||||
|
||||
fun testFun() = 12
|
||||
|
||||
// FILE: using.kt
|
||||
import test.*
|
||||
|
||||
val t: String = testFun()
|
||||
@@ -0,0 +1,18 @@
|
||||
// FILE: a.kt
|
||||
package a
|
||||
|
||||
val v = 1
|
||||
fun f() = 1
|
||||
|
||||
// FILE: b.kt
|
||||
package b
|
||||
|
||||
val v = 1
|
||||
fun f() = 1
|
||||
|
||||
// FILE: main.kt
|
||||
import a.*
|
||||
import b.*
|
||||
|
||||
val vv = <!AMBIGUITY!>v<!>
|
||||
val ff = <!AMBIGUITY!>f<!>()
|
||||
+12
@@ -0,0 +1,12 @@
|
||||
// FILE: root.kt
|
||||
fun testFun() = 12
|
||||
|
||||
// FILE: otherPackage.kt
|
||||
package test
|
||||
|
||||
fun testFun() = 12
|
||||
|
||||
// FILE: using.kt
|
||||
package test
|
||||
|
||||
val t = testFun()
|
||||
@@ -0,0 +1,33 @@
|
||||
fun devNull(obj: Any?) {}
|
||||
|
||||
open class A {
|
||||
companion object {
|
||||
val internal_val = 1
|
||||
public val public_val: Int = 2
|
||||
private val private_val = 3
|
||||
protected val protected_val: Int = 5
|
||||
}
|
||||
|
||||
fun fromClass() {
|
||||
devNull(internal_val)
|
||||
devNull(public_val)
|
||||
devNull(private_val)
|
||||
devNull(protected_val)
|
||||
}
|
||||
}
|
||||
|
||||
fun fromOutside() {
|
||||
devNull(A.internal_val)
|
||||
devNull(A.public_val)
|
||||
devNull(A.<!INAPPLICABLE_CANDIDATE!>private_val<!>)
|
||||
devNull(A.<!INAPPLICABLE_CANDIDATE!>protected_val<!>)
|
||||
}
|
||||
|
||||
class B: A() {
|
||||
fun fromSubclass() {
|
||||
devNull(A.internal_val)
|
||||
devNull(A.public_val)
|
||||
devNull(A.<!INAPPLICABLE_CANDIDATE!>private_val<!>)
|
||||
devNull(A.<!INAPPLICABLE_CANDIDATE!>protected_val<!>)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
package b
|
||||
|
||||
open class A {
|
||||
internal open fun foo() {}
|
||||
}
|
||||
|
||||
class B : A() {
|
||||
protected override fun foo() {}
|
||||
}
|
||||
|
||||
class C : A() {
|
||||
internal override fun foo() {}
|
||||
}
|
||||
|
||||
//------------
|
||||
open class D {
|
||||
private open fun self() : D = this
|
||||
}
|
||||
|
||||
class E : D() {
|
||||
internal override fun self() = this
|
||||
|
||||
fun test() {
|
||||
val s : E = self()
|
||||
}
|
||||
}
|
||||
|
||||
//------------
|
||||
open class F {
|
||||
protected open fun protected_fun() {}
|
||||
}
|
||||
|
||||
class G : F() {
|
||||
override fun protected_fun() {}
|
||||
}
|
||||
|
||||
fun test_fun_stays_protected(g: G) {
|
||||
g.protected_fun()
|
||||
}
|
||||
|
||||
//------------
|
||||
open class H {
|
||||
protected open fun pi_fun() {}
|
||||
}
|
||||
|
||||
class I : H() {
|
||||
protected override fun pi_fun() {}
|
||||
}
|
||||
|
||||
class J : H() {
|
||||
internal override fun pi_fun() {}
|
||||
}
|
||||
|
||||
class K : H() {
|
||||
public override fun pi_fun() {}
|
||||
}
|
||||
|
||||
//-------------
|
||||
interface T {
|
||||
public fun foo() {}
|
||||
}
|
||||
|
||||
open class L : T {
|
||||
override fun foo() {}
|
||||
}
|
||||
|
||||
class M : L() {
|
||||
internal override fun foo() {}
|
||||
}
|
||||
//---------------
|
||||
interface R {
|
||||
fun foo() {}
|
||||
}
|
||||
|
||||
interface P : R {
|
||||
override fun foo() {}
|
||||
}
|
||||
|
||||
interface Q : R {
|
||||
override fun foo() {}
|
||||
}
|
||||
|
||||
class S : P, Q {
|
||||
internal override fun foo() {}
|
||||
}
|
||||
+51
@@ -0,0 +1,51 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
import kotlin.reflect.*
|
||||
|
||||
annotation class Ann(
|
||||
val kc1: KClass<*>,
|
||||
val kc2: KClass<*>,
|
||||
val kc3: KClass<*>,
|
||||
val c: Int,
|
||||
val cc: Int,
|
||||
val cn: Int,
|
||||
val ci: Int,
|
||||
val t1: Int,
|
||||
val t2: Int
|
||||
)
|
||||
|
||||
@Ann(
|
||||
Nested::class,
|
||||
Inner::class,
|
||||
Interface::class,
|
||||
CONST,
|
||||
Companion.CONST,
|
||||
Nested.CONST,
|
||||
Interface.CONST,
|
||||
a,
|
||||
b()
|
||||
)
|
||||
class A {
|
||||
|
||||
class Nested {
|
||||
companion object {
|
||||
const val CONST = 2
|
||||
}
|
||||
}
|
||||
|
||||
inner class Inner
|
||||
|
||||
interface Interface {
|
||||
companion object {
|
||||
const val CONST = 3
|
||||
}
|
||||
}
|
||||
|
||||
val a = 1
|
||||
fun b() = 2
|
||||
|
||||
companion object {
|
||||
const val CONST = 1
|
||||
fun foo(): Nested = null!!
|
||||
}
|
||||
}
|
||||
+65
@@ -0,0 +1,65 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
import kotlin.reflect.*
|
||||
|
||||
annotation class Ann(
|
||||
val kc1: KClass<*>,
|
||||
val kc2: KClass<*>,
|
||||
val kc3: KClass<*>,
|
||||
val c: Int,
|
||||
val cc: Int,
|
||||
val cn: Int,
|
||||
val ci: Int,
|
||||
val t1: Int,
|
||||
val t2: Int
|
||||
)
|
||||
|
||||
class A
|
||||
@Ann(
|
||||
Nested::class,
|
||||
Inner::class,
|
||||
Interface::class,
|
||||
CONST,
|
||||
Companion.CONST,
|
||||
Nested.CONST,
|
||||
Interface.CONST,
|
||||
a,
|
||||
b()
|
||||
)
|
||||
constructor() {
|
||||
|
||||
@Ann(
|
||||
Nested::class,
|
||||
Inner::class,
|
||||
Interface::class,
|
||||
CONST,
|
||||
Companion.CONST,
|
||||
Nested.CONST,
|
||||
Interface.CONST,
|
||||
a,
|
||||
b()
|
||||
)
|
||||
constructor(dummy: Int) : this()
|
||||
|
||||
class Nested {
|
||||
companion object {
|
||||
const val CONST = 2
|
||||
}
|
||||
}
|
||||
|
||||
inner class Inner
|
||||
|
||||
interface Interface {
|
||||
companion object {
|
||||
const val CONST = 3
|
||||
}
|
||||
}
|
||||
|
||||
val a = 1
|
||||
fun b() = 2
|
||||
|
||||
companion object {
|
||||
const val CONST = 1
|
||||
fun foo(): Nested = null!!
|
||||
}
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
class A<T : Nested, F: Inner, G: Interface> {
|
||||
|
||||
class Nested
|
||||
|
||||
inner class Inner
|
||||
|
||||
interface Interface
|
||||
}
|
||||
|
||||
class B<T, F, G> where T : Nested, F: Inner, G: Interface {
|
||||
|
||||
class Nested
|
||||
|
||||
inner class Inner
|
||||
|
||||
interface Interface
|
||||
}
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
interface I<F, G, H>
|
||||
|
||||
class A(impl: Interface) : Nested(), Interface by impl, Inner, I<Nested, Interface, Inner> {
|
||||
|
||||
class Nested
|
||||
|
||||
inner class Inner
|
||||
|
||||
interface Interface
|
||||
}
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
interface I<F, G>
|
||||
|
||||
val aImpl: A.Companion.Interface
|
||||
get() = null!!
|
||||
|
||||
val bImpl: B.Companion.Interface
|
||||
get() = null!!
|
||||
|
||||
interface A {
|
||||
companion object : Nested(), Interface by aImpl, I<Nested, Interface> {
|
||||
|
||||
class Nested
|
||||
|
||||
interface Interface
|
||||
}
|
||||
}
|
||||
|
||||
class B {
|
||||
companion object : Nested(), Interface by aImpl, I<Nested, Interface> {
|
||||
|
||||
class Nested
|
||||
|
||||
interface Interface
|
||||
}
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
open class S(val a: Any, val b: Any, val c: Any) {}
|
||||
|
||||
interface A {
|
||||
companion object : S(prop1, prop2, func()) {
|
||||
val prop1 = 1
|
||||
val prop2: Int
|
||||
get() = 1
|
||||
fun func() {}
|
||||
}
|
||||
}
|
||||
|
||||
class B {
|
||||
companion object : S(prop1, prop2, func()) {
|
||||
val prop1 = 1
|
||||
val prop2: Int
|
||||
get() = 1
|
||||
fun func() {}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
class A(
|
||||
n: Nested = foo(),
|
||||
n2: Nested = Nested(),
|
||||
inn: Inner = null!!,
|
||||
inn2: Inner = Inner(),
|
||||
i: Interface = null!!,
|
||||
c: Int = CONST,
|
||||
cc: Int = Companion.CONST,
|
||||
cn: Int = Nested.CONST,
|
||||
ci: Int = Interface.CONST,
|
||||
t1: Int = a,
|
||||
t2: Int = b()
|
||||
) {
|
||||
|
||||
constructor(
|
||||
dummy: Int,
|
||||
n: Nested = foo(),
|
||||
n2: Nested = Nested(),
|
||||
inn: Inner = null!!,
|
||||
inn2: Inner = Inner(),
|
||||
i: Interface = null!!,
|
||||
c: Int = CONST,
|
||||
cc: Int = Companion.CONST,
|
||||
cn: Int = Nested.CONST,
|
||||
ci: Int = Interface.CONST,
|
||||
t1: Int = a,
|
||||
t2: Int = b()
|
||||
) : this(
|
||||
foo(),
|
||||
Nested(),
|
||||
inn,
|
||||
Inner(),
|
||||
i,
|
||||
CONST,
|
||||
Companion.CONST,
|
||||
Nested.CONST,
|
||||
Interface.CONST,
|
||||
a,
|
||||
b()
|
||||
)
|
||||
|
||||
class Nested {
|
||||
companion object {
|
||||
const val CONST = 2
|
||||
}
|
||||
}
|
||||
|
||||
inner class Inner
|
||||
|
||||
interface Interface {
|
||||
companion object {
|
||||
const val CONST = 3
|
||||
}
|
||||
}
|
||||
|
||||
val a = 1
|
||||
fun b() = 2
|
||||
|
||||
companion object {
|
||||
const val CONST = 1
|
||||
fun foo(): Nested = null!!
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,50 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
interface I
|
||||
|
||||
open class S(
|
||||
n: A.Nested,
|
||||
n2: A.Nested,
|
||||
inn: A.Inner,
|
||||
c: Int,
|
||||
cc: Int,
|
||||
cn: Int,
|
||||
ci: Int,
|
||||
t1: Int,
|
||||
t2: Int
|
||||
) : I
|
||||
|
||||
class A : I by S(
|
||||
foo(),
|
||||
Nested(),
|
||||
Inner(),
|
||||
CONST,
|
||||
Companion.CONST,
|
||||
Nested.CONST,
|
||||
Interface.CONST,
|
||||
a,
|
||||
b()
|
||||
) {
|
||||
|
||||
class Nested {
|
||||
companion object {
|
||||
const val CONST = 2
|
||||
}
|
||||
}
|
||||
|
||||
inner class Inner
|
||||
|
||||
interface Interface {
|
||||
companion object {
|
||||
const val CONST = 3
|
||||
}
|
||||
}
|
||||
|
||||
val a = 1
|
||||
fun b() = 2
|
||||
|
||||
companion object {
|
||||
const val CONST = 1
|
||||
fun foo(): Nested = null!!
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
interface I<F, G>
|
||||
|
||||
val aImpl: A.Interface
|
||||
get() = null!!
|
||||
|
||||
object A : Nested(), Interface by aImpl, I<Nested, Interface> {
|
||||
|
||||
class Nested
|
||||
|
||||
interface Interface
|
||||
}
|
||||
Vendored
+8
@@ -0,0 +1,8 @@
|
||||
open class S(val a: Any, val b: Any, val c: Any) {}
|
||||
|
||||
object A : S(prop1, prop2, func()) {
|
||||
val prop1 = 1
|
||||
val prop2: Int
|
||||
get() = 1
|
||||
fun func() {}
|
||||
}
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
interface I
|
||||
|
||||
class A : I by impl {
|
||||
|
||||
companion object {
|
||||
val impl = object : I {}
|
||||
}
|
||||
}
|
||||
+48
@@ -0,0 +1,48 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
open class S(
|
||||
n: A.Nested,
|
||||
n2: A.Nested,
|
||||
inn: A.Inner,
|
||||
c: Int,
|
||||
cc: Int,
|
||||
cn: Int,
|
||||
ci: Int,
|
||||
t1: Int,
|
||||
t2: Int
|
||||
)
|
||||
|
||||
class A : S (
|
||||
foo(),
|
||||
Nested(),
|
||||
Inner(),
|
||||
CONST,
|
||||
Companion.CONST,
|
||||
Nested.CONST,
|
||||
Interface.CONST,
|
||||
a,
|
||||
b()
|
||||
) {
|
||||
|
||||
class Nested {
|
||||
companion object {
|
||||
const val CONST = 2
|
||||
}
|
||||
}
|
||||
|
||||
inner class Inner
|
||||
|
||||
interface Interface {
|
||||
companion object {
|
||||
const val CONST = 3
|
||||
}
|
||||
}
|
||||
|
||||
val a = 1
|
||||
fun b() = 2
|
||||
|
||||
companion object {
|
||||
const val CONST = 1
|
||||
fun foo(): Nested = null!!
|
||||
}
|
||||
}
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
open class S(
|
||||
n: A.Nested,
|
||||
n2: A.Nested,
|
||||
inn: A.Inner,
|
||||
c: Int,
|
||||
cc: Int,
|
||||
cn: Int,
|
||||
ci: Int,
|
||||
t1: Int,
|
||||
t2: Int
|
||||
)
|
||||
|
||||
class A : S {
|
||||
|
||||
constructor() : <!INAPPLICABLE_CANDIDATE!>super<!>(
|
||||
foo(),
|
||||
Nested(),
|
||||
Inner(),
|
||||
CONST,
|
||||
Companion.CONST,
|
||||
Nested.CONST,
|
||||
Interface.CONST,
|
||||
a,
|
||||
b()
|
||||
)
|
||||
|
||||
class Nested {
|
||||
companion object {
|
||||
const val CONST = 2
|
||||
}
|
||||
}
|
||||
|
||||
inner class Inner
|
||||
|
||||
interface Interface {
|
||||
companion object {
|
||||
const val CONST = 3
|
||||
}
|
||||
}
|
||||
|
||||
val a = 1
|
||||
fun b() = 2
|
||||
|
||||
companion object {
|
||||
const val CONST = 1
|
||||
fun foo(): Nested = null!!
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
class A<T> {
|
||||
class T
|
||||
|
||||
object E {
|
||||
init {
|
||||
T()
|
||||
}
|
||||
}
|
||||
|
||||
class F {
|
||||
init {
|
||||
T()
|
||||
}
|
||||
}
|
||||
|
||||
inner class I {
|
||||
init {
|
||||
T() // todo: https://jetbrains.quip.com/hPM5AJcc1nca
|
||||
}
|
||||
}
|
||||
|
||||
init {
|
||||
T()
|
||||
}
|
||||
}
|
||||
|
||||
class B<T> {
|
||||
companion object {
|
||||
class T;
|
||||
|
||||
init {
|
||||
T()
|
||||
}
|
||||
}
|
||||
|
||||
object E {
|
||||
init {
|
||||
T()
|
||||
}
|
||||
}
|
||||
|
||||
class F {
|
||||
init {
|
||||
T()
|
||||
}
|
||||
}
|
||||
|
||||
inner class I {
|
||||
init {
|
||||
T()
|
||||
}
|
||||
}
|
||||
|
||||
init {
|
||||
T()
|
||||
}
|
||||
}
|
||||
+5
@@ -0,0 +1,5 @@
|
||||
class A(val foo: Int)
|
||||
|
||||
fun A.test(foo: String) {
|
||||
val a: String = foo
|
||||
}
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
// !LANGUAGE: -ProhibitVisibilityOfNestedClassifiersFromSupertypesOfCompanion
|
||||
|
||||
interface A {
|
||||
companion object {
|
||||
fun foo() {}
|
||||
|
||||
class A_
|
||||
}
|
||||
}
|
||||
|
||||
open class B {
|
||||
companion object {
|
||||
fun bar() {}
|
||||
|
||||
class B_
|
||||
}
|
||||
}
|
||||
|
||||
class C: B(), A {
|
||||
init {
|
||||
<!UNRESOLVED_REFERENCE!>foo<!>()
|
||||
A.foo()
|
||||
A.Companion.foo()
|
||||
C.<!UNRESOLVED_REFERENCE!>foo<!>()
|
||||
|
||||
<!UNRESOLVED_REFERENCE!>A_<!>()
|
||||
A.A_()
|
||||
A.Companion.A_()
|
||||
C.<!UNRESOLVED_REFERENCE!>A_<!>()
|
||||
|
||||
bar()
|
||||
B.bar()
|
||||
B.Companion.bar()
|
||||
C.<!UNRESOLVED_REFERENCE!>bar<!>()
|
||||
|
||||
B_()
|
||||
B.B_()
|
||||
B.Companion.B_()
|
||||
C.<!UNRESOLVED_REFERENCE!>B_<!>()
|
||||
}
|
||||
}
|
||||
+52
@@ -0,0 +1,52 @@
|
||||
// !LANGUAGE: -ProhibitVisibilityOfNestedClassifiersFromSupertypesOfCompanion
|
||||
|
||||
// FILE: 1.kt
|
||||
interface A {
|
||||
companion object {
|
||||
fun foo() {}
|
||||
|
||||
class A_
|
||||
}
|
||||
}
|
||||
|
||||
open class B {
|
||||
companion object {
|
||||
fun bar() {}
|
||||
|
||||
class B_
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: C.java
|
||||
public class C extends B implements A {
|
||||
|
||||
}
|
||||
|
||||
// FILE: 2.kt
|
||||
class D: C() {
|
||||
init {
|
||||
<!UNRESOLVED_REFERENCE!>foo<!>()
|
||||
A.foo()
|
||||
A.Companion.foo()
|
||||
C.<!UNRESOLVED_REFERENCE!>foo<!>()
|
||||
D.<!UNRESOLVED_REFERENCE!>foo<!>()
|
||||
|
||||
<!UNRESOLVED_REFERENCE!>A_<!>()
|
||||
A.A_()
|
||||
A.Companion.A_()
|
||||
C.<!UNRESOLVED_REFERENCE!>A_<!>()
|
||||
D.<!UNRESOLVED_REFERENCE!>A_<!>()
|
||||
|
||||
bar()
|
||||
B.bar()
|
||||
B.Companion.bar()
|
||||
C.<!UNRESOLVED_REFERENCE!>bar<!>()
|
||||
D.<!UNRESOLVED_REFERENCE!>bar<!>()
|
||||
|
||||
B_()
|
||||
B.B_()
|
||||
B.Companion.B_()
|
||||
C.<!UNRESOLVED_REFERENCE!>B_<!>()
|
||||
D.<!UNRESOLVED_REFERENCE!>B_<!>()
|
||||
}
|
||||
}
|
||||
+37
@@ -0,0 +1,37 @@
|
||||
// !DIAGNOSTICS: -UNUSED_VARIABLE
|
||||
open class A {
|
||||
companion object {
|
||||
fun bar() = 1
|
||||
}
|
||||
init {
|
||||
val a: Int = <!INAPPLICABLE_CANDIDATE!>foo<!>()
|
||||
val b: Int = bar()
|
||||
}
|
||||
}
|
||||
|
||||
open class B: A() {
|
||||
companion object {
|
||||
fun bar() = ""
|
||||
}
|
||||
init {
|
||||
val a: String = <!INAPPLICABLE_CANDIDATE!>foo<!>()
|
||||
val b: String = bar()
|
||||
}
|
||||
}
|
||||
|
||||
fun A.Companion.foo() = 1
|
||||
fun B.Companion.foo() = ""
|
||||
|
||||
class C: A() {
|
||||
init {
|
||||
val a: Int = <!INAPPLICABLE_CANDIDATE!>foo<!>()
|
||||
val b: Int = bar()
|
||||
}
|
||||
}
|
||||
|
||||
class D: B() {
|
||||
init {
|
||||
val a: String = <!INAPPLICABLE_CANDIDATE!>foo<!>()
|
||||
val b: String = bar()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
// !LANGUAGE: -ProhibitVisibilityOfNestedClassifiersFromSupertypesOfCompanion
|
||||
|
||||
open class A {
|
||||
inner class B {
|
||||
fun foo() {}
|
||||
}
|
||||
|
||||
inner class D
|
||||
|
||||
companion object {
|
||||
class B {
|
||||
fun bar() {}
|
||||
}
|
||||
|
||||
class C
|
||||
}
|
||||
|
||||
init {
|
||||
B().foo()
|
||||
B().<!UNRESOLVED_REFERENCE!>bar<!>()
|
||||
|
||||
D()
|
||||
C()
|
||||
}
|
||||
}
|
||||
|
||||
class E: A() {
|
||||
init {
|
||||
B().foo()
|
||||
B().<!UNRESOLVED_REFERENCE!>bar<!>()
|
||||
|
||||
D()
|
||||
C()
|
||||
}
|
||||
|
||||
object Z {
|
||||
init {
|
||||
B().foo()
|
||||
B().<!UNRESOLVED_REFERENCE!>bar<!>()
|
||||
|
||||
D()
|
||||
C()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class F: A() {
|
||||
class B {
|
||||
fun fas() {}
|
||||
}
|
||||
inner class D {
|
||||
fun f() {}
|
||||
}
|
||||
|
||||
init {
|
||||
B().fas()
|
||||
D().f()
|
||||
}
|
||||
|
||||
companion object {
|
||||
init {
|
||||
B().fas()
|
||||
D().f()
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
fun foo(init: A.() -> Unit) { }
|
||||
|
||||
class A {
|
||||
var x: Int = 0
|
||||
companion object {
|
||||
val f = foo() {
|
||||
x = 1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class B(val a: String) {
|
||||
fun f() = 0
|
||||
companion object {
|
||||
fun B.bar() = a + f()
|
||||
}
|
||||
}
|
||||
|
||||
open class C {
|
||||
fun bar() {}
|
||||
}
|
||||
|
||||
class E: C() {
|
||||
|
||||
class D {
|
||||
init {
|
||||
with(C()) {
|
||||
bar()
|
||||
this.bar()
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
+34
@@ -0,0 +1,34 @@
|
||||
// !WITH_NEW_INFERENCE
|
||||
// !DIAGNOSTICS: -UNUSED_VARIABLE
|
||||
// FILE: A.java
|
||||
public class A {
|
||||
int foo() {return 1;}
|
||||
}
|
||||
|
||||
// FILE: 1.kt
|
||||
|
||||
fun foo() = ""
|
||||
|
||||
open class B: A() {
|
||||
init {
|
||||
val a: Int = foo()
|
||||
}
|
||||
}
|
||||
|
||||
fun test() {
|
||||
fun foo() = ""
|
||||
|
||||
class B: A() {
|
||||
init {
|
||||
val a: Int = foo() // todo
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class E: A() {
|
||||
fun foo() = A()
|
||||
|
||||
init {
|
||||
val a: A = foo() // todo: discuss
|
||||
}
|
||||
}
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
// FILE: A.java
|
||||
public interface A {
|
||||
public class A_ {}
|
||||
}
|
||||
|
||||
// FILE: 1.kt
|
||||
interface B {
|
||||
class B_
|
||||
}
|
||||
|
||||
class X: A {
|
||||
val a: A_ = A_()
|
||||
val b: A.A_ = A.A_()
|
||||
|
||||
companion object {
|
||||
val a: A_ = A_()
|
||||
}
|
||||
}
|
||||
|
||||
class Y: B {
|
||||
val a: B_ = B_()
|
||||
val b: B.B_ = B.B_()
|
||||
|
||||
companion object {
|
||||
val b: B_ = B_()
|
||||
}
|
||||
}
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
// !LANGUAGE: -ProhibitVisibilityOfNestedClassifiersFromSupertypesOfCompanion
|
||||
|
||||
open class A {
|
||||
companion object {
|
||||
class B
|
||||
}
|
||||
}
|
||||
|
||||
class C: A() {
|
||||
val b: B = null!!
|
||||
|
||||
init {
|
||||
B()
|
||||
}
|
||||
|
||||
object O {
|
||||
val b: B = null!!
|
||||
|
||||
init {
|
||||
B()
|
||||
}
|
||||
}
|
||||
|
||||
class K {
|
||||
val b: B = null!!
|
||||
|
||||
init {
|
||||
B()
|
||||
}
|
||||
}
|
||||
|
||||
inner class I {
|
||||
val b: B = null!!
|
||||
|
||||
init {
|
||||
B()
|
||||
}
|
||||
}
|
||||
}
|
||||
+95
@@ -0,0 +1,95 @@
|
||||
// !LANGUAGE: -ProhibitVisibilityOfNestedClassifiersFromSupertypesOfCompanion
|
||||
|
||||
open class A {
|
||||
class X {
|
||||
fun A_X() {}
|
||||
}
|
||||
|
||||
class Y {
|
||||
fun A_Y() {}
|
||||
}
|
||||
|
||||
companion object {
|
||||
class X {
|
||||
fun A_C_X() {}
|
||||
}
|
||||
|
||||
class Z {
|
||||
fun A_C_Z() {}
|
||||
}
|
||||
}
|
||||
|
||||
init {
|
||||
X().A_X()
|
||||
X().<!UNRESOLVED_REFERENCE!>A_C_X<!>()
|
||||
}
|
||||
}
|
||||
|
||||
class Simple: A() {
|
||||
init {
|
||||
Y().A_Y()
|
||||
Z().A_C_Z()
|
||||
}
|
||||
}
|
||||
|
||||
class B: A() {
|
||||
class Y {
|
||||
fun B_Y() {}
|
||||
}
|
||||
|
||||
class Z {
|
||||
fun B_Z() {}
|
||||
}
|
||||
|
||||
init {
|
||||
X().A_X()
|
||||
X().<!UNRESOLVED_REFERENCE!>A_C_X<!>()
|
||||
|
||||
Y().B_Y()
|
||||
Y().<!UNRESOLVED_REFERENCE!>A_Y<!>()
|
||||
|
||||
Z().B_Z()
|
||||
Z().<!UNRESOLVED_REFERENCE!>A_C_Z<!>()
|
||||
}
|
||||
|
||||
companion object {
|
||||
init {
|
||||
X().A_X()
|
||||
X().<!UNRESOLVED_REFERENCE!>A_C_X<!>()
|
||||
|
||||
Y().B_Y()
|
||||
Y().<!UNRESOLVED_REFERENCE!>A_Y<!>()
|
||||
|
||||
Z().B_Z()
|
||||
Z().<!UNRESOLVED_REFERENCE!>A_C_Z<!>()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class C: A() {
|
||||
companion object {
|
||||
class Y {
|
||||
fun C_C_Y() {}
|
||||
}
|
||||
|
||||
class Z {
|
||||
fun C_C_Z() {}
|
||||
}
|
||||
|
||||
init {
|
||||
Y().C_C_Y()
|
||||
Y().<!UNRESOLVED_REFERENCE!>A_Y<!>()
|
||||
|
||||
Z().C_C_Z()
|
||||
Z().<!UNRESOLVED_REFERENCE!>A_C_Z<!>()
|
||||
}
|
||||
}
|
||||
|
||||
init {
|
||||
Y().<!UNRESOLVED_REFERENCE!>C_C_Y<!>()
|
||||
Y().A_Y()
|
||||
|
||||
Z().C_C_Z()
|
||||
Z().<!UNRESOLVED_REFERENCE!>A_C_Z<!>()
|
||||
}
|
||||
}
|
||||
Vendored
+47
@@ -0,0 +1,47 @@
|
||||
// !LANGUAGE: -ProhibitVisibilityOfNestedClassifiersFromSupertypesOfCompanion
|
||||
|
||||
// FILE: 1.kt
|
||||
open class A {
|
||||
class Y {
|
||||
fun A_Y() {}
|
||||
}
|
||||
|
||||
companion object {
|
||||
class Z {
|
||||
fun A_C_Z() {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: B.java
|
||||
public class B extends A {
|
||||
class Y {
|
||||
void B_Y() {}
|
||||
}
|
||||
|
||||
class Z {
|
||||
void B_Z() {}
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: C.java
|
||||
public class C extends A {}
|
||||
|
||||
// FILE: 2.kt
|
||||
class E: B() {
|
||||
init {
|
||||
Y().B_Y()
|
||||
Y().<!UNRESOLVED_REFERENCE!>A_Y<!>()
|
||||
|
||||
Z().B_Z()
|
||||
Z().<!UNRESOLVED_REFERENCE!>A_C_Z<!>()
|
||||
}
|
||||
}
|
||||
|
||||
class Y: C() {
|
||||
init {
|
||||
Y().A_Y()
|
||||
|
||||
Z().A_C_Z()
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,90 @@
|
||||
// FILE: A.java
|
||||
public interface A {
|
||||
public class A_S { // static
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: B.java
|
||||
public class B {
|
||||
public static class B_S {
|
||||
|
||||
}
|
||||
public class B_ {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: C.java
|
||||
public class C extends B implements A {
|
||||
|
||||
}
|
||||
|
||||
// FILE: 1.kt
|
||||
|
||||
class X: A {
|
||||
val a_s: A_S = null!!
|
||||
|
||||
init {
|
||||
A_S()
|
||||
A.A_S()
|
||||
X.A_S()
|
||||
}
|
||||
|
||||
object xD {
|
||||
val a_: A_S = null!!
|
||||
|
||||
init {
|
||||
A_S()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class Y: B() {
|
||||
val b_: B_ = null!!
|
||||
val b_s: B_S = null!!
|
||||
|
||||
init {
|
||||
B_()
|
||||
B.<!UNRESOLVED_REFERENCE!>B_<!>()
|
||||
Y.<!UNRESOLVED_REFERENCE!>B_<!>()
|
||||
|
||||
B_S()
|
||||
B.B_S()
|
||||
Y.B_S()
|
||||
}
|
||||
|
||||
object X {
|
||||
val b_: B_ = null!!
|
||||
val b_s: B_S = null!!
|
||||
|
||||
init {
|
||||
B_()
|
||||
B_S()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class Z: C() {
|
||||
val a_s: A_S = null!!
|
||||
val b_: B_ = null!!
|
||||
val b_s: B_S = null!!
|
||||
|
||||
init {
|
||||
A_S()
|
||||
B_()
|
||||
B_S()
|
||||
}
|
||||
|
||||
object X {
|
||||
val a_s: A_S = null!!
|
||||
val b_: B_ = null!!
|
||||
val b_s: B_S = null!!
|
||||
|
||||
init {
|
||||
A_S()
|
||||
B_()
|
||||
B_S()
|
||||
}
|
||||
}
|
||||
}
|
||||
+82
@@ -0,0 +1,82 @@
|
||||
// FILE: A.java
|
||||
public interface A {
|
||||
class A_S {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: B.java
|
||||
public class B {
|
||||
static class B_S {
|
||||
|
||||
}
|
||||
class B_ {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: C.java
|
||||
public class C extends B implements A {
|
||||
|
||||
}
|
||||
|
||||
// FILE: 1.kt
|
||||
interface E {
|
||||
class E_S
|
||||
}
|
||||
|
||||
open class D: C(), E
|
||||
|
||||
// FILE: F.java
|
||||
public class F extends D {
|
||||
|
||||
}
|
||||
|
||||
// FILE: 2.kt
|
||||
class X: D() {
|
||||
init {
|
||||
B_()
|
||||
B.<!UNRESOLVED_REFERENCE!>B_<!>()
|
||||
C.<!UNRESOLVED_REFERENCE!>B_<!>()
|
||||
D.<!UNRESOLVED_REFERENCE!>B_<!>()
|
||||
X.<!UNRESOLVED_REFERENCE!>B_<!>()
|
||||
|
||||
A_S()
|
||||
A.A_S()
|
||||
C.A_S()
|
||||
D.A_S()
|
||||
X.A_S()
|
||||
|
||||
B_S()
|
||||
B.B_S()
|
||||
C.B_S()
|
||||
D.B_S()
|
||||
X.B_S()
|
||||
|
||||
E_S()
|
||||
E.E_S()
|
||||
D.E_S()
|
||||
X.E_S()
|
||||
}
|
||||
}
|
||||
|
||||
class Y: F() {
|
||||
init {
|
||||
|
||||
B_()
|
||||
F.<!UNRESOLVED_REFERENCE!>B_<!>()
|
||||
Y.<!UNRESOLVED_REFERENCE!>B_<!>()
|
||||
|
||||
A_S()
|
||||
F.A_S()
|
||||
Y.A_S()
|
||||
|
||||
B_S()
|
||||
F.B_S()
|
||||
Y.B_S()
|
||||
|
||||
E_S()
|
||||
F.E_S()
|
||||
Y.E_S()
|
||||
}
|
||||
}
|
||||
+38
@@ -0,0 +1,38 @@
|
||||
// !LANGUAGE: -ProhibitVisibilityOfNestedClassifiersFromSupertypesOfCompanion
|
||||
|
||||
class X {
|
||||
fun T_X() {}
|
||||
}
|
||||
|
||||
class Y {
|
||||
fun T_Y() {}
|
||||
}
|
||||
|
||||
open class A {
|
||||
class X {
|
||||
fun A_X() {}
|
||||
}
|
||||
companion object {
|
||||
class Y {
|
||||
fun A_C_Y() {}
|
||||
}
|
||||
}
|
||||
|
||||
init {
|
||||
X().A_X()
|
||||
X().<!UNRESOLVED_REFERENCE!>T_X<!>()
|
||||
|
||||
Y().A_C_Y()
|
||||
Y().<!UNRESOLVED_REFERENCE!>T_Y<!>()
|
||||
}
|
||||
}
|
||||
|
||||
class B: A() {
|
||||
init {
|
||||
X().A_X()
|
||||
X().<!UNRESOLVED_REFERENCE!>T_X<!>()
|
||||
|
||||
Y().A_C_Y()
|
||||
Y().<!UNRESOLVED_REFERENCE!>T_Y<!>()
|
||||
}
|
||||
}
|
||||
+22
@@ -0,0 +1,22 @@
|
||||
// !DIAGNOSTICS: -UNUSED_VARIABLE
|
||||
open class A {
|
||||
companion object {
|
||||
fun foo() = 1
|
||||
fun bar(a: String) = a
|
||||
}
|
||||
}
|
||||
|
||||
open class B: A() {
|
||||
companion object {
|
||||
fun foo() = ""
|
||||
fun bar(a: Int) = a
|
||||
}
|
||||
}
|
||||
|
||||
class C: B() {
|
||||
init {
|
||||
val a: String = foo()
|
||||
val b: Int = bar(1)
|
||||
val c: String = bar("")
|
||||
}
|
||||
}
|
||||
+55
@@ -0,0 +1,55 @@
|
||||
// !LANGUAGE: +ProhibitVisibilityOfNestedClassifiersFromSupertypesOfCompanion
|
||||
// FILE: J.java
|
||||
public class J {
|
||||
public static void foo() {}
|
||||
}
|
||||
|
||||
// FILE: J2.java
|
||||
public class J2 extends A {
|
||||
public static void boo() {}
|
||||
}
|
||||
|
||||
// FILE: test.kt
|
||||
open class A {
|
||||
companion object : J() {
|
||||
fun bar() {}
|
||||
}
|
||||
}
|
||||
|
||||
class B : J2() {
|
||||
init {
|
||||
<!UNRESOLVED_REFERENCE!>foo<!>()
|
||||
bar()
|
||||
boo()
|
||||
}
|
||||
|
||||
fun test2() {
|
||||
<!UNRESOLVED_REFERENCE!>foo<!>()
|
||||
bar()
|
||||
boo()
|
||||
}
|
||||
|
||||
object O {
|
||||
fun test() {
|
||||
<!UNRESOLVED_REFERENCE!>foo<!>()
|
||||
bar()
|
||||
<!UNRESOLVED_REFERENCE!>boo<!>()
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
init {
|
||||
<!UNRESOLVED_REFERENCE!>foo<!>()
|
||||
bar()
|
||||
<!UNRESOLVED_REFERENCE!>boo<!>()
|
||||
}
|
||||
|
||||
fun test() {
|
||||
<!UNRESOLVED_REFERENCE!>foo<!>()
|
||||
bar()
|
||||
<!UNRESOLVED_REFERENCE!>boo<!>()
|
||||
}
|
||||
|
||||
fun bar() {}
|
||||
}
|
||||
}
|
||||
+55
@@ -0,0 +1,55 @@
|
||||
// !LANGUAGE: -ProhibitVisibilityOfNestedClassifiersFromSupertypesOfCompanion
|
||||
// FILE: J.java
|
||||
public class J {
|
||||
public static void foo() {}
|
||||
}
|
||||
|
||||
// FILE: J2.java
|
||||
public class J2 extends A {
|
||||
public static void boo() {}
|
||||
}
|
||||
|
||||
// FILE: test.kt
|
||||
open class A {
|
||||
companion object : J() {
|
||||
fun bar() {}
|
||||
}
|
||||
}
|
||||
|
||||
class B : J2() {
|
||||
init {
|
||||
<!UNRESOLVED_REFERENCE!>foo<!>()
|
||||
bar()
|
||||
boo()
|
||||
}
|
||||
|
||||
fun test2() {
|
||||
<!UNRESOLVED_REFERENCE!>foo<!>()
|
||||
bar()
|
||||
boo()
|
||||
}
|
||||
|
||||
object O {
|
||||
fun test() {
|
||||
<!UNRESOLVED_REFERENCE!>foo<!>()
|
||||
bar()
|
||||
<!UNRESOLVED_REFERENCE!>boo<!>()
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
init {
|
||||
<!UNRESOLVED_REFERENCE!>foo<!>()
|
||||
bar()
|
||||
<!UNRESOLVED_REFERENCE!>boo<!>()
|
||||
}
|
||||
|
||||
fun test() {
|
||||
<!UNRESOLVED_REFERENCE!>foo<!>()
|
||||
bar()
|
||||
<!UNRESOLVED_REFERENCE!>boo<!>()
|
||||
}
|
||||
|
||||
fun bar() {}
|
||||
}
|
||||
}
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
// !LANGUAGE: +ProhibitVisibilityOfNestedClassifiersFromSupertypesOfCompanion
|
||||
// FILE: J.java
|
||||
public class J {
|
||||
public static void foo() {}
|
||||
}
|
||||
|
||||
// FILE: test.kt
|
||||
open class A {
|
||||
companion object : J() {
|
||||
fun bar() {}
|
||||
}
|
||||
}
|
||||
|
||||
class B : A() {
|
||||
init {
|
||||
<!UNRESOLVED_REFERENCE!>foo<!>()
|
||||
bar()
|
||||
}
|
||||
|
||||
fun test2() {
|
||||
<!UNRESOLVED_REFERENCE!>foo<!>()
|
||||
bar()
|
||||
}
|
||||
|
||||
object O {
|
||||
fun test() {
|
||||
<!UNRESOLVED_REFERENCE!>foo<!>()
|
||||
bar()
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
init {
|
||||
<!UNRESOLVED_REFERENCE!>foo<!>()
|
||||
bar()
|
||||
}
|
||||
|
||||
fun test() {
|
||||
<!UNRESOLVED_REFERENCE!>foo<!>()
|
||||
bar()
|
||||
}
|
||||
|
||||
fun bar() {}
|
||||
}
|
||||
}
|
||||
|
||||
+46
@@ -0,0 +1,46 @@
|
||||
// !LANGUAGE: -ProhibitVisibilityOfNestedClassifiersFromSupertypesOfCompanion
|
||||
// FILE: J.java
|
||||
public class J {
|
||||
public static void foo() {}
|
||||
}
|
||||
|
||||
// FILE: test.kt
|
||||
open class A {
|
||||
companion object : J() {
|
||||
fun bar() {}
|
||||
}
|
||||
}
|
||||
|
||||
class B : A() {
|
||||
init {
|
||||
<!UNRESOLVED_REFERENCE!>foo<!>()
|
||||
bar()
|
||||
}
|
||||
|
||||
fun test2() {
|
||||
<!UNRESOLVED_REFERENCE!>foo<!>()
|
||||
bar()
|
||||
}
|
||||
|
||||
object O {
|
||||
fun test() {
|
||||
<!UNRESOLVED_REFERENCE!>foo<!>()
|
||||
bar()
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
init {
|
||||
<!UNRESOLVED_REFERENCE!>foo<!>()
|
||||
bar()
|
||||
}
|
||||
|
||||
fun test() {
|
||||
<!UNRESOLVED_REFERENCE!>foo<!>()
|
||||
bar()
|
||||
}
|
||||
|
||||
fun bar() {}
|
||||
}
|
||||
}
|
||||
|
||||
+54
@@ -0,0 +1,54 @@
|
||||
// !LANGUAGE: +ProhibitVisibilityOfNestedClassifiersFromSupertypesOfCompanion
|
||||
// !WITH_NEW_INFERENCE
|
||||
// !DIAGNOSTICS: -UNUSED_VARIABLE
|
||||
|
||||
// FILE: J.java
|
||||
public class J {
|
||||
public static void foo() {}
|
||||
}
|
||||
|
||||
// FILE: test.kt
|
||||
open class A<T> : J() {
|
||||
init {
|
||||
foo()
|
||||
bar()
|
||||
val a: Int = baz()
|
||||
val b: T = baz()
|
||||
}
|
||||
|
||||
fun test1() {
|
||||
foo()
|
||||
bar()
|
||||
val a: Int = baz()
|
||||
val b: T = baz()
|
||||
}
|
||||
|
||||
fun baz(): T = null!!
|
||||
|
||||
object O {
|
||||
fun test() {
|
||||
<!UNRESOLVED_REFERENCE!>foo<!>()
|
||||
bar()
|
||||
val a: Int = <!UNRESOLVED_REFERENCE!>baz<!>()
|
||||
val b: T = <!UNRESOLVED_REFERENCE!>baz<!>()
|
||||
}
|
||||
}
|
||||
|
||||
companion object : A<Int>() {
|
||||
init {
|
||||
foo()
|
||||
bar()
|
||||
val a: Int = baz()
|
||||
val b: T = baz()
|
||||
}
|
||||
|
||||
fun test() {
|
||||
foo()
|
||||
bar()
|
||||
val a: Int = baz()
|
||||
val b: T = baz()
|
||||
}
|
||||
|
||||
fun bar() {}
|
||||
}
|
||||
}
|
||||
+54
@@ -0,0 +1,54 @@
|
||||
// !LANGUAGE: -ProhibitVisibilityOfNestedClassifiersFromSupertypesOfCompanion
|
||||
// !WITH_NEW_INFERENCE
|
||||
// !DIAGNOSTICS: -UNUSED_VARIABLE
|
||||
|
||||
// FILE: J.java
|
||||
public class J {
|
||||
public static void foo() {}
|
||||
}
|
||||
|
||||
// FILE: test.kt
|
||||
open class A<T> : J() {
|
||||
init {
|
||||
foo()
|
||||
bar()
|
||||
val a: Int = baz()
|
||||
val b: T = baz()
|
||||
}
|
||||
|
||||
fun test1() {
|
||||
foo()
|
||||
bar()
|
||||
val a: Int = baz()
|
||||
val b: T = baz()
|
||||
}
|
||||
|
||||
fun baz(): T = null!!
|
||||
|
||||
object O {
|
||||
fun test() {
|
||||
<!UNRESOLVED_REFERENCE!>foo<!>()
|
||||
bar()
|
||||
val a: Int = <!UNRESOLVED_REFERENCE!>baz<!>()
|
||||
val b: T = <!UNRESOLVED_REFERENCE!>baz<!>()
|
||||
}
|
||||
}
|
||||
|
||||
companion object : A<Int>() {
|
||||
init {
|
||||
foo()
|
||||
bar()
|
||||
val a: Int = baz()
|
||||
val b: T = baz()
|
||||
}
|
||||
|
||||
fun test() {
|
||||
foo()
|
||||
bar()
|
||||
val a: Int = baz()
|
||||
val b: T = baz()
|
||||
}
|
||||
|
||||
fun bar() {}
|
||||
}
|
||||
}
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
// !LANGUAGE: +ProhibitVisibilityOfNestedClassifiersFromSupertypesOfCompanion
|
||||
// FILE: J.java
|
||||
public class J {
|
||||
public static void foo() {}
|
||||
}
|
||||
|
||||
// FILE: test.kt
|
||||
|
||||
open class B : J() {
|
||||
fun baz() {}
|
||||
}
|
||||
|
||||
class A {
|
||||
init {
|
||||
<!UNRESOLVED_REFERENCE!>foo<!>()
|
||||
bar()
|
||||
<!UNRESOLVED_REFERENCE!>baz<!>()
|
||||
}
|
||||
|
||||
fun test1() {
|
||||
<!UNRESOLVED_REFERENCE!>foo<!>()
|
||||
bar()
|
||||
<!UNRESOLVED_REFERENCE!>baz<!>()
|
||||
}
|
||||
|
||||
object O {
|
||||
fun test() {
|
||||
<!UNRESOLVED_REFERENCE!>foo<!>()
|
||||
bar()
|
||||
<!UNRESOLVED_REFERENCE!>baz<!>()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
companion object : B() {
|
||||
init {
|
||||
foo()
|
||||
bar()
|
||||
baz()
|
||||
}
|
||||
|
||||
fun test() {
|
||||
foo()
|
||||
bar()
|
||||
baz()
|
||||
}
|
||||
|
||||
fun bar() {}
|
||||
}
|
||||
}
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
// !LANGUAGE: -ProhibitVisibilityOfNestedClassifiersFromSupertypesOfCompanion
|
||||
// FILE: J.java
|
||||
public class J {
|
||||
public static void foo() {}
|
||||
}
|
||||
|
||||
// FILE: test.kt
|
||||
|
||||
open class B : J() {
|
||||
fun baz() {}
|
||||
}
|
||||
|
||||
class A {
|
||||
init {
|
||||
<!UNRESOLVED_REFERENCE!>foo<!>()
|
||||
bar()
|
||||
<!UNRESOLVED_REFERENCE!>baz<!>()
|
||||
}
|
||||
|
||||
fun test1() {
|
||||
<!UNRESOLVED_REFERENCE!>foo<!>()
|
||||
bar()
|
||||
<!UNRESOLVED_REFERENCE!>baz<!>()
|
||||
}
|
||||
|
||||
object O {
|
||||
fun test() {
|
||||
<!UNRESOLVED_REFERENCE!>foo<!>()
|
||||
bar()
|
||||
<!UNRESOLVED_REFERENCE!>baz<!>()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
companion object : B() {
|
||||
init {
|
||||
foo()
|
||||
bar()
|
||||
baz()
|
||||
}
|
||||
|
||||
fun test() {
|
||||
foo()
|
||||
bar()
|
||||
baz()
|
||||
}
|
||||
|
||||
fun bar() {}
|
||||
}
|
||||
}
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
// !LANGUAGE: +ProhibitVisibilityOfNestedClassifiersFromSupertypesOfCompanion
|
||||
// FILE: J.java
|
||||
public class J {
|
||||
public static void foo() {}
|
||||
}
|
||||
|
||||
// FILE: test.kt
|
||||
class A {
|
||||
init {
|
||||
<!UNRESOLVED_REFERENCE!>foo<!>()
|
||||
bar()
|
||||
}
|
||||
|
||||
fun test1() {
|
||||
<!UNRESOLVED_REFERENCE!>foo<!>()
|
||||
bar()
|
||||
}
|
||||
|
||||
object O {
|
||||
fun test() {
|
||||
<!UNRESOLVED_REFERENCE!>foo<!>()
|
||||
bar()
|
||||
}
|
||||
}
|
||||
|
||||
companion object : J() {
|
||||
init {
|
||||
foo()
|
||||
bar()
|
||||
}
|
||||
|
||||
fun test() {
|
||||
foo()
|
||||
bar()
|
||||
}
|
||||
|
||||
fun bar() {}
|
||||
}
|
||||
}
|
||||
+39
@@ -0,0 +1,39 @@
|
||||
// !LANGUAGE: -ProhibitVisibilityOfNestedClassifiersFromSupertypesOfCompanion
|
||||
// FILE: J.java
|
||||
public class J {
|
||||
public static void foo() {}
|
||||
}
|
||||
|
||||
// FILE: test.kt
|
||||
class A {
|
||||
init {
|
||||
<!UNRESOLVED_REFERENCE!>foo<!>()
|
||||
bar()
|
||||
}
|
||||
|
||||
fun test1() {
|
||||
<!UNRESOLVED_REFERENCE!>foo<!>()
|
||||
bar()
|
||||
}
|
||||
|
||||
object O {
|
||||
fun test() {
|
||||
<!UNRESOLVED_REFERENCE!>foo<!>()
|
||||
bar()
|
||||
}
|
||||
}
|
||||
|
||||
companion object : J() {
|
||||
init {
|
||||
foo()
|
||||
bar()
|
||||
}
|
||||
|
||||
fun test() {
|
||||
foo()
|
||||
bar()
|
||||
}
|
||||
|
||||
fun bar() {}
|
||||
}
|
||||
}
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
// FILE: A.java
|
||||
|
||||
class A {
|
||||
private static int a = 1;
|
||||
private static void foo() {}
|
||||
|
||||
protected static int b = 1;
|
||||
protected static void bar() {}
|
||||
}
|
||||
|
||||
// FILE: B.java
|
||||
|
||||
class B extends A {
|
||||
public static int a = 1;
|
||||
public static void foo() {}
|
||||
public static void foo(int i) {}
|
||||
|
||||
public static int b = 1;
|
||||
public static void bar() {}
|
||||
public static void bar(int i) {}
|
||||
}
|
||||
|
||||
// FILE: test.kt
|
||||
|
||||
fun test() {
|
||||
A.<!INAPPLICABLE_CANDIDATE!>a<!>
|
||||
A.<!INAPPLICABLE_CANDIDATE!>foo<!>()
|
||||
A.b
|
||||
A.bar()
|
||||
B.a
|
||||
B.foo()
|
||||
B.foo(1)
|
||||
B.<!AMBIGUITY!>b<!>
|
||||
B.bar()
|
||||
B.bar(1)
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
// FILE: I.java
|
||||
|
||||
public interface I {
|
||||
int a = 1;
|
||||
}
|
||||
|
||||
// FILE: C.java
|
||||
|
||||
public class C implements I {
|
||||
static int b = 1;
|
||||
static void bar() {}
|
||||
}
|
||||
|
||||
// FILE: K.kt
|
||||
|
||||
open class K : C()
|
||||
|
||||
// FILE: D.java
|
||||
|
||||
public class D extends K {
|
||||
static int c = 1;
|
||||
static void baz() {}
|
||||
}
|
||||
|
||||
// FILE: test.kt
|
||||
|
||||
fun test() {
|
||||
I.a
|
||||
|
||||
C.a
|
||||
C.b
|
||||
C.bar()
|
||||
|
||||
K.a
|
||||
K.b
|
||||
K.bar()
|
||||
|
||||
D.a
|
||||
D.b
|
||||
D.c
|
||||
D.bar()
|
||||
D.baz()
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
// FILE: K.kt
|
||||
|
||||
open class K {
|
||||
companion object {
|
||||
fun foo() {}
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: D.java
|
||||
|
||||
class D extends K {
|
||||
static int b = 1;
|
||||
static void bar() {}
|
||||
}
|
||||
|
||||
// FILE: K.kt
|
||||
|
||||
class K2 {
|
||||
companion object {
|
||||
fun baz() {}
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: test.kt
|
||||
|
||||
fun test() {
|
||||
K.foo()
|
||||
|
||||
D.b
|
||||
D.bar()
|
||||
D.<!UNRESOLVED_REFERENCE!>foo<!>()
|
||||
|
||||
K2.<!UNRESOLVED_REFERENCE!>b<!>
|
||||
K2.<!UNRESOLVED_REFERENCE!>bar<!>()
|
||||
K2.<!UNRESOLVED_REFERENCE!>foo<!>()
|
||||
K2.baz()
|
||||
}
|
||||
+27
@@ -0,0 +1,27 @@
|
||||
// !WITH_NEW_INFERENCE
|
||||
// !DIAGNOSTICS: -UNUSED_VARIABLE
|
||||
// FILE: A.java
|
||||
public class A {
|
||||
public static int foo() {return 1;}
|
||||
}
|
||||
|
||||
// FILE: 1.kt
|
||||
|
||||
fun foo() = ""
|
||||
|
||||
class B: A() {
|
||||
init {
|
||||
val a: Int = foo()
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: 2.kt
|
||||
fun test() {
|
||||
fun foo() = ""
|
||||
|
||||
class B: A() {
|
||||
init {
|
||||
val a: Int = foo() // todo
|
||||
}
|
||||
}
|
||||
}
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
// FILE: A.java
|
||||
|
||||
public interface A {
|
||||
int field = 1;
|
||||
}
|
||||
|
||||
// FILE: B.java
|
||||
|
||||
public interface B {
|
||||
String field = 1;
|
||||
}
|
||||
|
||||
// FILE: E.java
|
||||
|
||||
public class E implements A, B {
|
||||
}
|
||||
|
||||
// FILE: O.java
|
||||
|
||||
public class O implements A, B {
|
||||
public static double field = 1;
|
||||
}
|
||||
|
||||
// FILE: test.kt
|
||||
|
||||
fun test() {
|
||||
A.field
|
||||
B.field
|
||||
|
||||
E.<!AMBIGUITY!>field<!>
|
||||
O.<!AMBIGUITY!>field<!>
|
||||
}
|
||||
+32
@@ -0,0 +1,32 @@
|
||||
// FILE: A.java
|
||||
|
||||
public interface A {
|
||||
int field = 1;
|
||||
}
|
||||
|
||||
// FILE: B.java
|
||||
|
||||
public interface B extends A {
|
||||
String field = 1;
|
||||
}
|
||||
|
||||
// FILE: E.java
|
||||
|
||||
public class E implements A, B {
|
||||
}
|
||||
|
||||
// FILE: O.java
|
||||
|
||||
public class O implements A, B {
|
||||
public static double field = 1;
|
||||
}
|
||||
|
||||
// FILE: test.kt
|
||||
|
||||
fun test() {
|
||||
A.field
|
||||
B.<!AMBIGUITY!>field<!>
|
||||
|
||||
E.<!AMBIGUITY!>field<!>
|
||||
O.<!AMBIGUITY!>field<!>
|
||||
}
|
||||
+66
@@ -0,0 +1,66 @@
|
||||
// FILE: A.java
|
||||
|
||||
public interface A {
|
||||
int field = 1;
|
||||
}
|
||||
|
||||
// FILE: B.java
|
||||
|
||||
public interface B {
|
||||
String field = 1;
|
||||
}
|
||||
|
||||
// FILE: C.java
|
||||
|
||||
public interface C extends A {
|
||||
}
|
||||
|
||||
// FILE: D.java
|
||||
|
||||
public interface D extends B {
|
||||
}
|
||||
|
||||
// FILE: E.java
|
||||
|
||||
public class E implements C, D {
|
||||
}
|
||||
|
||||
// FILE: EE.java
|
||||
|
||||
public class EE extends E {
|
||||
}
|
||||
|
||||
// FILE: EO.java
|
||||
|
||||
public class EO extends E {
|
||||
public static double field = 1;
|
||||
}
|
||||
|
||||
// FILE: O.java
|
||||
|
||||
public class O implements C, D {
|
||||
public static double field = 1;
|
||||
}
|
||||
|
||||
// FILE: OO.java
|
||||
|
||||
public class OO extends O {
|
||||
}
|
||||
|
||||
// FILE: test.kt
|
||||
|
||||
fun test() {
|
||||
A.field
|
||||
B.field
|
||||
|
||||
C.field
|
||||
D.field
|
||||
|
||||
E.<!AMBIGUITY!>field<!>
|
||||
O.<!AMBIGUITY!>field<!>
|
||||
|
||||
EE.<!AMBIGUITY!>field<!>
|
||||
EO.<!AMBIGUITY!>field<!>
|
||||
|
||||
OO.<!AMBIGUITY!>field<!>
|
||||
}
|
||||
Vendored
+55
@@ -0,0 +1,55 @@
|
||||
// FILE: I.java
|
||||
|
||||
public interface I {
|
||||
int a = 1;
|
||||
}
|
||||
|
||||
// FILE: C.java
|
||||
|
||||
public class C implements I {
|
||||
static int b = 1;
|
||||
static void bar() {}
|
||||
}
|
||||
|
||||
// FILE: K.kt
|
||||
|
||||
open class K : C(), I
|
||||
|
||||
// FILE: D.java
|
||||
|
||||
public class D extends K implements I {
|
||||
static int c = 1;
|
||||
static void baz() {}
|
||||
}
|
||||
|
||||
// FILE: E.java
|
||||
|
||||
public class E extends D implements I {
|
||||
static int a = 1;
|
||||
}
|
||||
|
||||
// FILE: test.kt
|
||||
|
||||
fun test() {
|
||||
I.a
|
||||
|
||||
C.a
|
||||
C.b
|
||||
C.bar()
|
||||
|
||||
K.a
|
||||
K.b
|
||||
K.bar()
|
||||
|
||||
D.a
|
||||
D.b
|
||||
D.c
|
||||
D.bar()
|
||||
D.baz()
|
||||
|
||||
E.<!AMBIGUITY!>a<!>
|
||||
E.b
|
||||
E.c
|
||||
E.bar()
|
||||
E.baz()
|
||||
}
|
||||
+20
@@ -0,0 +1,20 @@
|
||||
// !DIAGNOSTICS: -UNUSED_VARIABLE
|
||||
// FILE: A.java
|
||||
public class A {
|
||||
static void foo() {}
|
||||
static int bar() { return 1; }
|
||||
}
|
||||
|
||||
// FILE: B.java
|
||||
public class B extends A {
|
||||
static void foo() {}
|
||||
static long bar() { return 1; }
|
||||
}
|
||||
|
||||
// FILE: 1.kt
|
||||
class E: B() {
|
||||
init {
|
||||
foo()
|
||||
val a: Long = bar()
|
||||
}
|
||||
}
|
||||
+50
@@ -0,0 +1,50 @@
|
||||
// !DIAGNOSTICS: -UNUSED_VARIABLE
|
||||
// FILE: A.java
|
||||
public class A {
|
||||
static void foo() {}
|
||||
static int bar() {return 1;}
|
||||
}
|
||||
|
||||
// FILE: B.java
|
||||
public class B extends A {}
|
||||
|
||||
// FILE: C.java
|
||||
public class C {
|
||||
static void bar() {}
|
||||
}
|
||||
|
||||
// FILE: 1.kt
|
||||
import A.foo
|
||||
import B.bar
|
||||
|
||||
class E: A() {
|
||||
init {
|
||||
foo()
|
||||
bar()
|
||||
}
|
||||
}
|
||||
|
||||
class F: B() {
|
||||
init {
|
||||
foo()
|
||||
bar()
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: 2.kt
|
||||
import C.bar
|
||||
|
||||
class Z: A() {
|
||||
init {
|
||||
val a: Int = bar()
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: 3.kt
|
||||
import C.*
|
||||
|
||||
class Q: A() {
|
||||
init {
|
||||
val a: Int = bar()
|
||||
}
|
||||
}
|
||||
Vendored
+59
@@ -0,0 +1,59 @@
|
||||
// !DIAGNOSTICS: -UNUSED_VARIABLE
|
||||
// FILE: A.java
|
||||
public class A {
|
||||
static byte foo = 1;
|
||||
static int bar = 2;
|
||||
}
|
||||
|
||||
// FILE: B.java
|
||||
public class B extends A {}
|
||||
|
||||
// FILE: C.java
|
||||
public class C {
|
||||
static long bar = 3;
|
||||
}
|
||||
|
||||
// FILE: 1.kt
|
||||
import A.foo
|
||||
import B.bar
|
||||
|
||||
class E: A() {
|
||||
init {
|
||||
foo
|
||||
bar
|
||||
}
|
||||
}
|
||||
|
||||
class F: B() {
|
||||
init {
|
||||
foo
|
||||
bar
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: 2.kt
|
||||
import C.bar
|
||||
|
||||
class Z: A() {
|
||||
init {
|
||||
val a: Int = bar
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: 3.kt
|
||||
import C.*
|
||||
|
||||
class Q: A() {
|
||||
init {
|
||||
val a: Int = bar
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: 4.kt
|
||||
val bar = ""
|
||||
|
||||
class W: A() {
|
||||
init {
|
||||
val a: Int = bar
|
||||
}
|
||||
}
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
// !DIAGNOSTICS: -UNUSED_VARIABLE
|
||||
// FILE: A.java
|
||||
public class A {
|
||||
static void foo() {}
|
||||
}
|
||||
|
||||
// FILE: 1.kt
|
||||
open class B : A() {
|
||||
companion object {
|
||||
fun foo() = 1
|
||||
}
|
||||
|
||||
init {
|
||||
val a: Int = foo()
|
||||
}
|
||||
}
|
||||
|
||||
class C: B() {
|
||||
init {
|
||||
val a: Int = foo()
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: X.java
|
||||
public class X extends B {
|
||||
static double foo() {
|
||||
return 1.0;
|
||||
}
|
||||
}
|
||||
|
||||
// FILE: 2.kt
|
||||
class Y: X() {
|
||||
init {
|
||||
val a: Double = foo()
|
||||
}
|
||||
}
|
||||
+69
@@ -0,0 +1,69 @@
|
||||
// !DIAGNOSTICS: -UNUSED_VARIABLE
|
||||
// FILE: A.java
|
||||
public class A {
|
||||
public static int foo() { return 1; }
|
||||
public static int bar = 1;
|
||||
}
|
||||
|
||||
// FILE: 1.kt
|
||||
|
||||
class B: A() {
|
||||
companion object {
|
||||
init {
|
||||
val a: Int = <!UNRESOLVED_REFERENCE!>foo<!>()
|
||||
val b: Int = <!UNRESOLVED_REFERENCE!>bar<!>
|
||||
}
|
||||
}
|
||||
|
||||
init {
|
||||
val a: Int = foo()
|
||||
val b: Int = bar
|
||||
}
|
||||
}
|
||||
|
||||
open class C: A() {
|
||||
val bar = ""
|
||||
fun foo() = ""
|
||||
|
||||
init {
|
||||
val a: String = foo()
|
||||
val b: String = <!AMBIGUITY!>bar<!>
|
||||
}
|
||||
}
|
||||
|
||||
class E: C() {
|
||||
init {
|
||||
val a: String = foo()
|
||||
val b: String = <!AMBIGUITY!>bar<!>
|
||||
}
|
||||
}
|
||||
|
||||
open class F: A() {
|
||||
companion object {
|
||||
val bar = ""
|
||||
fun foo() = ""
|
||||
|
||||
init {
|
||||
val a: String = foo()
|
||||
val b: String = bar
|
||||
}
|
||||
}
|
||||
init {
|
||||
val a: String = foo()
|
||||
val b: String = bar
|
||||
}
|
||||
}
|
||||
|
||||
class G: F() {
|
||||
companion object {
|
||||
init {
|
||||
val a: String = foo()
|
||||
val b: String = bar
|
||||
}
|
||||
}
|
||||
|
||||
init {
|
||||
val a: String = foo()
|
||||
val b: String = bar
|
||||
}
|
||||
}
|
||||
+19
@@ -0,0 +1,19 @@
|
||||
// FILE: A.java
|
||||
public class A {
|
||||
public static int foo() {return 1;}
|
||||
}
|
||||
|
||||
// FILE: B.java
|
||||
public class B extends A {
|
||||
public static int foo() {return 1;}
|
||||
}
|
||||
|
||||
// FILE: 1.kt
|
||||
|
||||
fun foo() = ""
|
||||
|
||||
class C: B() {
|
||||
init {
|
||||
val a: Int = foo()
|
||||
}
|
||||
}
|
||||
+51
@@ -0,0 +1,51 @@
|
||||
// FILE: A.java
|
||||
public class A {
|
||||
public static void foo() {}
|
||||
}
|
||||
|
||||
// FILE: B.java
|
||||
public class B extends A {
|
||||
public static void bar() {}
|
||||
}
|
||||
|
||||
// FILE: 1.kt
|
||||
open class X: A() {
|
||||
init {
|
||||
foo()
|
||||
A.foo()
|
||||
}
|
||||
}
|
||||
|
||||
open class Y: B() {
|
||||
init {
|
||||
foo()
|
||||
A.foo()
|
||||
B.foo()
|
||||
|
||||
bar()
|
||||
B.bar()
|
||||
}
|
||||
}
|
||||
|
||||
class XN: X() {
|
||||
init {
|
||||
foo()
|
||||
A.foo()
|
||||
X.foo()
|
||||
XN.foo()
|
||||
}
|
||||
}
|
||||
|
||||
class YN: Y() {
|
||||
init {
|
||||
foo()
|
||||
A.foo()
|
||||
Y.foo()
|
||||
YN.foo()
|
||||
|
||||
bar()
|
||||
B.bar()
|
||||
Y.bar()
|
||||
YN.bar()
|
||||
}
|
||||
}
|
||||
Vendored
+27
@@ -0,0 +1,27 @@
|
||||
// FILE: A.java
|
||||
public class A {
|
||||
public static void foo() {}
|
||||
}
|
||||
|
||||
// FILE: 1.kt
|
||||
open class B: A()
|
||||
|
||||
// FILE: C.java
|
||||
public class C extends B {
|
||||
public static void bar() {}
|
||||
}
|
||||
|
||||
// FILE: 2.kt
|
||||
class D: C() {
|
||||
init {
|
||||
foo()
|
||||
A.foo()
|
||||
B.foo()
|
||||
C.foo()
|
||||
D.foo()
|
||||
|
||||
bar()
|
||||
C.bar()
|
||||
D.bar()
|
||||
}
|
||||
}
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
// NI_EXPECTED_FILE
|
||||
|
||||
package i
|
||||
|
||||
val <T> List<T>.length = <!UNRESOLVED_REFERENCE!>size<!>
|
||||
|
||||
val <T> List<T>.length1 : Int get() = size
|
||||
|
||||
val String.bd = this + "!"
|
||||
|
||||
val String.bd1 : String get() = this + "!"
|
||||
|
||||
|
||||
class A {
|
||||
val ii : Int = 1
|
||||
}
|
||||
|
||||
val A.foo = <!UNRESOLVED_REFERENCE!>ii<!>
|
||||
|
||||
val A.foo1 : Int get() = ii
|
||||
|
||||
|
||||
class C {
|
||||
inner class D {}
|
||||
}
|
||||
|
||||
val C.foo : C.D = <!UNRESOLVED_REFERENCE!>D<!>()
|
||||
|
||||
val C.bar : C.D = C().D()
|
||||
|
||||
val C.foo1 : C.D get() = D()
|
||||
@@ -0,0 +1,9 @@
|
||||
class A<T> {
|
||||
public var x: Int = 0
|
||||
private set
|
||||
}
|
||||
|
||||
fun main() {
|
||||
val a = A<Any>()
|
||||
a.x = 1
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
//KT-1078 Problem with visibility in do-while
|
||||
|
||||
package kt1078
|
||||
|
||||
fun test() : B {
|
||||
do {
|
||||
val x = foo()
|
||||
} while(x.bar()) // x is not visible here!
|
||||
return B()
|
||||
}
|
||||
|
||||
class B() {
|
||||
fun bar() = true
|
||||
}
|
||||
|
||||
fun foo() = B()
|
||||
@@ -0,0 +1,19 @@
|
||||
//FILE:a.kt
|
||||
//KT-1080 Don't use previously imported packages while resolving import references
|
||||
|
||||
package kt1080
|
||||
|
||||
import reflect.Constructor
|
||||
|
||||
import b.*
|
||||
import d
|
||||
import d.Test
|
||||
import b.d
|
||||
|
||||
class Some: Test()
|
||||
|
||||
//FILE:b.kt
|
||||
|
||||
package b.d
|
||||
|
||||
public open class Test
|
||||
@@ -0,0 +1,13 @@
|
||||
//KT-1244 Frontend allows access to private members of other classes
|
||||
|
||||
package kt1244
|
||||
|
||||
class A {
|
||||
private var a = ""
|
||||
}
|
||||
|
||||
class B() {
|
||||
init {
|
||||
A().<!INAPPLICABLE_CANDIDATE!>a<!> = "Hello"
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
//KT-1248 Control visibility of overrides needed
|
||||
package kt1248
|
||||
|
||||
interface ParseResult<out T> {
|
||||
public val success : Boolean
|
||||
public val value : T
|
||||
}
|
||||
|
||||
class Success<T>(internal override val value : T) : ParseResult<T> {
|
||||
internal override val success : Boolean = true
|
||||
}
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
//KT-151 Inherit visibility when overriding
|
||||
package kt151
|
||||
|
||||
open class A {
|
||||
protected open fun x() {}
|
||||
}
|
||||
|
||||
class B : A() {
|
||||
override fun x() {} // No visibility modifier required
|
||||
}
|
||||
|
||||
fun test(b: B) {
|
||||
b.x()
|
||||
}
|
||||
|
||||
|
||||
//more tests
|
||||
open class C {
|
||||
internal open fun foo() {}
|
||||
}
|
||||
|
||||
interface T {
|
||||
fun foo() {}
|
||||
}
|
||||
|
||||
class D : C(), T {
|
||||
protected override fun foo() {}
|
||||
}
|
||||
|
||||
class E : C(), T {
|
||||
internal override fun foo() {}
|
||||
}
|
||||
|
||||
class F : C(), T {
|
||||
private override fun foo() {}
|
||||
}
|
||||
|
||||
class G : C(), T {
|
||||
public override fun foo() {}
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
//FILE:a.kt
|
||||
//KT-1579 Can't import nested class/interface
|
||||
package lib
|
||||
interface WithInner {
|
||||
interface Inner {
|
||||
}
|
||||
}
|
||||
//FILE:b.kt
|
||||
package user
|
||||
import lib.WithInner.Inner
|
||||
@@ -0,0 +1,19 @@
|
||||
//FILE:a.kt
|
||||
//+JDK
|
||||
package a
|
||||
import kotlin.collections.Map.*
|
||||
|
||||
fun foo(b : Entry<String, String>) = b
|
||||
|
||||
//FILE:b.kt
|
||||
//+JDK
|
||||
package b
|
||||
|
||||
import kotlin.collections.Map.Entry
|
||||
fun bar(b : Entry<String, String>) = b
|
||||
|
||||
//FILE:c.kt
|
||||
//+JDK
|
||||
package c
|
||||
|
||||
fun fff(b: Map.Entry<String, String>) = b
|
||||
@@ -0,0 +1,15 @@
|
||||
//FILE:a.kt
|
||||
//KT-1580 Can't access nested class/interface from other package
|
||||
package lib
|
||||
interface WithInner {
|
||||
interface Inner {
|
||||
}
|
||||
}
|
||||
|
||||
//FILE:b.kt
|
||||
package user
|
||||
|
||||
import lib.WithInner
|
||||
|
||||
fun main(a : WithInner, b : WithInner.Inner) {
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
//FILE:a.kt
|
||||
//KT-1642 kotlin subpackages hide Java's toplevel packages
|
||||
package a.java
|
||||
|
||||
//FILE:b.kt
|
||||
//+JDK
|
||||
package a
|
||||
|
||||
import java.util.ArrayList
|
||||
@@ -0,0 +1,11 @@
|
||||
//KT-1738 Make it possible to define visibility for constructor parameters which become properties
|
||||
|
||||
package kt1738
|
||||
|
||||
class A(private var i: Int, var j: Int) {
|
||||
}
|
||||
|
||||
fun test(a: A) {
|
||||
a.<!INAPPLICABLE_CANDIDATE, INAPPLICABLE_CANDIDATE!>i<!><!UNRESOLVED_REFERENCE!>++<!>
|
||||
a.j++
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package kt1805
|
||||
//KT-1805 Better diagnostic for access to private field of parent class
|
||||
|
||||
open class Some {
|
||||
private val privateField = 12
|
||||
}
|
||||
|
||||
class SomeSubclass : Some() {
|
||||
fun test() {
|
||||
this.<!INAPPLICABLE_CANDIDATE!>privateField<!> // 1. Unresolved reference
|
||||
}
|
||||
}
|
||||
|
||||
fun test() {
|
||||
val s2 = Some()
|
||||
s2.<!INAPPLICABLE_CANDIDATE!>privateField<!> // 2. Can't access to 'privateField' in Some
|
||||
|
||||
val s1 = SomeSubclass()
|
||||
s1.<!INAPPLICABLE_CANDIDATE!>privateField<!> // 3. Unresolved reference
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
//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.<!INAPPLICABLE_CANDIDATE!>message<!>)
|
||||
}
|
||||
|
||||
class Test {
|
||||
private val MyObject1 = object {
|
||||
private var message: String = "'Static'"
|
||||
}
|
||||
|
||||
fun test2() {
|
||||
doSmth(MyObject1.<!INAPPLICABLE_CANDIDATE!>message<!>)
|
||||
}
|
||||
}
|
||||
|
||||
fun doSmth(s: String) = s
|
||||
@@ -0,0 +1,30 @@
|
||||
//KT-1822 Error 'cannot infer visibility' required
|
||||
package kt1822
|
||||
|
||||
open class C {
|
||||
internal open fun foo() {}
|
||||
}
|
||||
|
||||
interface T {
|
||||
protected fun foo() {}
|
||||
}
|
||||
|
||||
class G : C(), T {
|
||||
override fun foo() {} //should be an error "cannot infer visibility"; for now 'public' is inferred in such cases
|
||||
}
|
||||
|
||||
open class A {
|
||||
internal open fun foo() {}
|
||||
}
|
||||
|
||||
interface B {
|
||||
protected fun foo() {}
|
||||
}
|
||||
|
||||
interface D {
|
||||
public fun foo() {}
|
||||
}
|
||||
|
||||
class E : A(), B, D {
|
||||
override fun foo() {}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
//FILE:a/C.java
|
||||
//KT-1942 Package local members from Java are visible in subclasses
|
||||
package a;
|
||||
|
||||
public class C {
|
||||
int myValue;
|
||||
}
|
||||
|
||||
//FILE:d.kt
|
||||
|
||||
package d
|
||||
|
||||
import a.C
|
||||
|
||||
class A : C() {
|
||||
fun test() {
|
||||
val v = <!INAPPLICABLE_CANDIDATE!>myValue<!>
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package kt2262
|
||||
|
||||
//KT-2262 Cannot access protected member from inner class of subclass
|
||||
|
||||
abstract class Foo {
|
||||
protected val color: String = "red"
|
||||
}
|
||||
|
||||
class Bar : Foo() {
|
||||
protected val i: Int = 1
|
||||
|
||||
inner class Baz {
|
||||
val copy = color // INVISIBLE_MEMBER: Cannot access 'color' in 'Bar'
|
||||
val j = i
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package kt_250_617_10
|
||||
|
||||
import java.util.ArrayList
|
||||
import java.util.HashMap
|
||||
|
||||
//KT-250 Incorrect variable resolve in constructor arguments of superclass
|
||||
open class A(val x: Int)
|
||||
class B(y: Int) : A(x) //x is resolved as a property in a, so no error is generated
|
||||
|
||||
//KT-617 Prohibit dollars in call to superclass constructors
|
||||
open class M(p: Int)
|
||||
class N(val p: Int) : A(<!SYNTAX!><!SYNTAX!><!>$p<!><!SYNTAX!>)<!>
|
||||
|
||||
//KT-10 Don't allow to use properties in supertype initializers
|
||||
open class Element()
|
||||
class TextElement(name: String) : Element()
|
||||
|
||||
abstract class Tag(val name : String) {
|
||||
val children = ArrayList<Element>()
|
||||
val attributes = HashMap<String, String>()
|
||||
}
|
||||
|
||||
abstract class TagWithText(name : String) : Tag(name) {
|
||||
operator fun String.unaryPlus() {
|
||||
children.add(TextElement(this))
|
||||
}
|
||||
}
|
||||
|
||||
open class BodyTag(name : String) : TagWithText(name) {
|
||||
}
|
||||
|
||||
class Body() : BodyTag(name) { // Must be an error!
|
||||
}
|
||||
class Body1() : BodyTag(this.name) { // Must be an error!
|
||||
}
|
||||
|
||||
//more tests
|
||||
|
||||
open class X(p: Int, r: Int) {
|
||||
val s = "s"
|
||||
}
|
||||
|
||||
class Y(i: Int) : X(i, rrr) {
|
||||
val rrr = 3
|
||||
}
|
||||
|
||||
class Z(val i: Int) : <!INAPPLICABLE_CANDIDATE!>X<!>(s, x) {
|
||||
val x = 2
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
//KT-323 Handle visibility interactions with overriding
|
||||
package kt323
|
||||
|
||||
open class A {
|
||||
open var a : Int = 0
|
||||
}
|
||||
|
||||
class B : A() {
|
||||
override val a = 34
|
||||
|
||||
var b : Int
|
||||
public get() = 23
|
||||
set(i: Int) {}
|
||||
|
||||
protected var c : Int
|
||||
get() = 23
|
||||
private set(i: Int) {}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
//KT-37 Typechecker doesn't complain about accessing non-public property
|
||||
package kt37
|
||||
|
||||
class C() {
|
||||
private var f: Int
|
||||
|
||||
init {
|
||||
f = 610
|
||||
}
|
||||
}
|
||||
|
||||
fun box(): String {
|
||||
val c = C()
|
||||
if (c.<!INAPPLICABLE_CANDIDATE!>f<!> != 610) return "fail"
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
// KT-587 Unresolved reference
|
||||
|
||||
class Main {
|
||||
companion object {
|
||||
class States() {
|
||||
companion object {
|
||||
public val N: States = States() // : States unresolved
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
// import all members from companion object
|
||||
package c
|
||||
|
||||
import c.A.Companion.B
|
||||
import c.M.*
|
||||
|
||||
fun foo() {
|
||||
val b: B = B()
|
||||
var r: R = R()
|
||||
}
|
||||
|
||||
class A() {
|
||||
companion object {
|
||||
class B() {
|
||||
companion object {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
object M {
|
||||
fun foo() {}
|
||||
class R() {}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package d
|
||||
|
||||
//import from objects before properties resolve
|
||||
|
||||
import d.A.*
|
||||
import d.M.R
|
||||
import d.M.R.bar
|
||||
import d.M.T
|
||||
import d.M.Y
|
||||
|
||||
var r: T = T()
|
||||
val y: T = Y
|
||||
|
||||
fun f() {
|
||||
bar()
|
||||
R.bar()
|
||||
B.foo()
|
||||
}
|
||||
|
||||
object M {
|
||||
object R {
|
||||
fun bar() {}
|
||||
}
|
||||
open class T() {}
|
||||
|
||||
object Y : T() {}
|
||||
}
|
||||
|
||||
object A {
|
||||
object B {
|
||||
fun foo() {}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
//FILE:a.kt
|
||||
//KT-900 Inaccessible class should be unresolved
|
||||
|
||||
package a
|
||||
|
||||
fun foo() {
|
||||
val b : B = <!UNRESOLVED_REFERENCE!>B<!>() //only B() is unresolved, but in ": B" and "B.foo()" B should also be unresolved
|
||||
<!UNRESOLVED_REFERENCE!>B<!>.<!UNRESOLVED_REFERENCE!>foo<!>()
|
||||
|
||||
<!UNRESOLVED_REFERENCE!>P<!>.<!UNRESOLVED_REFERENCE!>foo<!>()
|
||||
|
||||
<!UNRESOLVED_REFERENCE!>M<!>.<!UNRESOLVED_REFERENCE!>bar<!>()
|
||||
}
|
||||
|
||||
class A() {
|
||||
companion object {
|
||||
class B() {
|
||||
companion object {
|
||||
fun foo() {}
|
||||
}
|
||||
}
|
||||
|
||||
object P {
|
||||
fun foo() {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
object N {
|
||||
object M {
|
||||
fun bar() {}
|
||||
}
|
||||
}
|
||||
|
||||
//FILE:b.kt
|
||||
package b
|
||||
|
||||
import b.N.M
|
||||
import b.A.Companion.P
|
||||
import b.A.Companion.B
|
||||
|
||||
fun foo() {
|
||||
val b : B = B()
|
||||
B.foo()
|
||||
|
||||
P.foo()
|
||||
|
||||
M.bar()
|
||||
}
|
||||
|
||||
class A() {
|
||||
companion object {
|
||||
class B() {
|
||||
companion object {
|
||||
fun foo() {}
|
||||
}
|
||||
}
|
||||
|
||||
object P {
|
||||
fun foo() {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
object N {
|
||||
object M {
|
||||
fun bar() {}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package kt939
|
||||
|
||||
//KT-939 CommonSupertypes erases scopes associated to types
|
||||
|
||||
fun compare(o1 : String?, o2 : String?) : Int {
|
||||
val l1 = o1?.length ?: 0
|
||||
val l2 = o2?.length ?: 0
|
||||
return l1 - l2 // '-' is unresolved, because the type of l1 is Int with an empty member scope
|
||||
}
|
||||
|
||||
//KT-1117 Unresolved reference to multiply sign
|
||||
|
||||
fun test() {
|
||||
(System.getProperty("path.separator")?.length ?: 4) * 55 + 5
|
||||
|
||||
val x = System.getProperty("path.separator")?.length ?: 4
|
||||
x * 55 + 5
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
open class A {
|
||||
protected fun foo() {}
|
||||
}
|
||||
|
||||
class B: A()
|
||||
|
||||
class C: A() {
|
||||
fun bar() {
|
||||
A().foo()
|
||||
B().foo()
|
||||
}
|
||||
}
|
||||
|
||||
class D {
|
||||
fun qux() { B().<!INAPPLICABLE_CANDIDATE!>foo<!>() }
|
||||
}
|
||||
+18
@@ -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
|
||||
}
|
||||
}
|
||||
+22
@@ -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<!>("")
|
||||
}
|
||||
+19
@@ -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<!>("")
|
||||
}
|
||||
}
|
||||
|
||||
+24
@@ -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()
|
||||
}
|
||||
+13
@@ -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<!>
|
||||
}
|
||||
}
|
||||
Vendored
+58
@@ -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
|
||||
}
|
||||
}
|
||||
Vendored
+27
@@ -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()
|
||||
}
|
||||
}
|
||||
+32
@@ -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()
|
||||
}
|
||||
}
|
||||
+30
@@ -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()
|
||||
}
|
||||
}
|
||||
Vendored
+15
@@ -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() {}
|
||||
}
|
||||
Vendored
+9
@@ -0,0 +1,9 @@
|
||||
abstract class A<T : Any> {
|
||||
abstract protected fun T.foo()
|
||||
|
||||
fun bar(x: T?) {
|
||||
if (x != null) {
|
||||
x.foo()
|
||||
}
|
||||
}
|
||||
}
|
||||
Vendored
+45
@@ -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 + ""
|
||||
}
|
||||
Vendored
+31
@@ -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<!> { }
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user