diff --git a/compiler/testData/cfg-variables/bugs/localObjectInConstructor.instructions b/compiler/testData/cfg-variables/bugs/localObjectInConstructor.instructions index 72611e50337..fd557350425 100644 --- a/compiler/testData/cfg-variables/bugs/localObjectInConstructor.instructions +++ b/compiler/testData/cfg-variables/bugs/localObjectInConstructor.instructions @@ -330,6 +330,26 @@ error: sink: USE: in: {} out: {} ===================== +== run == +fun T.run(f: T.() -> R) = f() +--------------------- +L0: + 1 INIT: in: {} out: {} + v(f: T.() -> R) INIT: in: {} out: {} + magic[FAKE_INITIALIZER](f: T.() -> R) -> INIT: in: {} out: {} + w(f|) INIT: in: {} out: {} + r(f) -> INIT: in: {} out: {} + magic[IMPLICIT_RECEIVER](f()) -> + mark(f()) + call(f(), invoke|, ) -> + ret(*|) L1 +L1: + +error: + +sink: + USE: in: {} out: {} +===================== == exec == fun exec(f: () -> T): T = f() --------------------- diff --git a/compiler/testData/cfg-variables/bugs/localObjectInConstructor.kt b/compiler/testData/cfg-variables/bugs/localObjectInConstructor.kt index 704464b5a14..ee07b401639 100644 --- a/compiler/testData/cfg-variables/bugs/localObjectInConstructor.kt +++ b/compiler/testData/cfg-variables/bugs/localObjectInConstructor.kt @@ -60,6 +60,7 @@ class Demo3 { private var state: Boolean = true } +fun T.run(f: T.() -> R) = f() fun exec(f: () -> T): T = f() class Demo4 { diff --git a/compiler/testData/cfg-variables/bugs/localObjectInConstructor.values b/compiler/testData/cfg-variables/bugs/localObjectInConstructor.values index 2fb99acd580..4585a75c232 100644 --- a/compiler/testData/cfg-variables/bugs/localObjectInConstructor.values +++ b/compiler/testData/cfg-variables/bugs/localObjectInConstructor.values @@ -175,6 +175,14 @@ state : * NEW: r(state| println(state) : * NEW: call(println(state), println|) -> if (state) state = true println(state) // OK : * COPY ===================== +== run == +fun T.run(f: T.() -> R) = f() +--------------------- + : {<: T.() -> R} NEW: magic[FAKE_INITIALIZER](f: T.() -> R) -> + : {<: T} NEW: magic[IMPLICIT_RECEIVER](f()) -> +f : {<: (T) -> R} NEW: r(f) -> +f() : {<: R} NEW: call(f(), invoke|, ) -> +===================== == exec == fun exec(f: () -> T): T = f() --------------------- diff --git a/compiler/testData/cfg/controlStructures/incorrectIndex_After.instructions b/compiler/testData/cfg/controlStructures/incorrectIndex_After.instructions new file mode 100644 index 00000000000..97dbcd09ff1 --- /dev/null +++ b/compiler/testData/cfg/controlStructures/incorrectIndex_After.instructions @@ -0,0 +1,151 @@ +== s == +val s = mutableListOf() +--------------------- +L0: + 1 + v(val s = mutableListOf()) + mark(mutableListOf()) + magic[UNRESOLVED_CALL](mutableListOf()|!) -> + w(s|) +L1: + NEXT:[] +error: + PREV:[] +sink: + PREV:[, ] +===================== +== test == +fun test(name: String?, flag: Boolean): Boolean { + try { + name?.let { + if (flag) { + s.add(it) + } + else { + s.remove(it) + } + + return true + } + + return false + } finally { + name?.hashCode() + } +} +--------------------- +L0: + 1 + v(name: String?) + magic[FAKE_INITIALIZER](name: String?) -> + w(name|) + v(flag: Boolean) + magic[FAKE_INITIALIZER](flag: Boolean) -> + w(flag|) + 2 mark({ try { name?.let { if (flag) { s.add(it) } else { s.remove(it) } return true } return false } finally { name?.hashCode() } }) + mark(try { name?.let { if (flag) { s.add(it) } else { s.remove(it) } return true } return false } finally { name?.hashCode() }) + jmp?(L2) NEXT:[mark({ name?.hashCode() }), mark({ name?.let { if (flag) { s.add(it) } else { s.remove(it) } return true } return false })] + 3 mark({ name?.let { if (flag) { s.add(it) } else { s.remove(it) } return true } return false }) + mark(name?.let { if (flag) { s.add(it) } else { s.remove(it) } return true }) + jf(L3) NEXT:[jmp?(L2), r(name) -> ] + r(name) -> + mark({ if (flag) { s.add(it) } else { s.remove(it) } return true }) + r({ if (flag) { s.add(it) } else { s.remove(it) } return true }) -> + mark(let { if (flag) { s.add(it) } else { s.remove(it) } return true }) + call(let { if (flag) { s.add(it) } else { s.remove(it) } return true }, let|, ) +L4 [before inlined declaration]: + inlined({ if (flag) { s.add(it) } else { s.remove(it) } return true }) NEXT:[] +L3 [result of call]: +L5 [after inlined declaration]: + jmp?(L2) NEXT:[mark({ name?.hashCode() }), r(false) -> ] PREV:[jf(L3)] + r(false) -> + 6 mark({ name?.hashCode() }) + mark(name?.hashCode()) + jf(L13) NEXT:[ret(*|) L1, r(name) -> ] + r(name) -> + mark(hashCode()) + call(hashCode(), hashCode|) -> +L13 [copy of L11, result of call]: + 3 ret(*|) L1 NEXT:[] PREV:[jf(L13), call(hashCode(), hashCode|) -> ] +- 2 jmp?(L2) NEXT:[mark({ name?.hashCode() }), jmp(L14)] PREV:[] +- jmp(L14) NEXT:[mark({ name?.hashCode() })] PREV:[] +L2 [onExceptionToFinallyBlock]: + 6 mark({ name?.hashCode() }) PREV:[jmp?(L2), jmp?(L2)] + mark(name?.hashCode()) + jf(L15) NEXT:[jmp(error), r(name) -> ] + r(name) -> + mark(hashCode()) + call(hashCode(), hashCode|) -> +L15 [copy of L11, result of call]: + 2 jmp(error) NEXT:[] PREV:[jf(L15), call(hashCode(), hashCode|) -> ] +L14 [skipFinallyToErrorBlock]: +- 6 mark({ name?.hashCode() }) PREV:[] +- mark(name?.hashCode()) PREV:[] +- jf(L16) NEXT:[merge(try { name?.let { if (flag) { s.add(it) } else { s.remove(it) } return true } return false } finally { name?.hashCode() }|!) -> , r(name) -> ] PREV:[] +- r(name) -> PREV:[] +- mark(hashCode()) PREV:[] +- call(hashCode(), hashCode|) -> PREV:[] +L16 [copy of L11, result of call]: +- 2 merge(try { name?.let { if (flag) { s.add(it) } else { s.remove(it) } return true } return false } finally { name?.hashCode() }|!) -> PREV:[] +L1: + 1 NEXT:[] PREV:[ret(*|) L1, ret(*|) L1] +error: + PREV:[jmp(error)] +sink: + PREV:[, , inlined({ if (flag) { s.add(it) } else { s.remove(it) } return true })] +===================== +== inlined anonymous_0 == +{ + if (flag) { + s.add(it) + } + else { + s.remove(it) + } + + return true + } +--------------------- +L6: + 4 + 5 mark(if (flag) { s.add(it) } else { s.remove(it) } return true) + mark(if (flag) { s.add(it) } else { s.remove(it) }) + r(flag) -> + jf(L8|) NEXT:[mark({ s.remove(it) }), mark({ s.add(it) })] + 6 mark({ s.add(it) }) + mark(s.add(it)) + r(s) -> + r(it) -> + magic[VALUE_CONSUMER](it|) -> + mark(add(it)) + call(add(it), |) -> + 5 jmp(L9) NEXT:[merge(if (flag) { s.add(it) } else { s.remove(it) }|, ) -> ] +L8 [else branch]: + 6 mark({ s.remove(it) }) PREV:[jf(L8|)] + mark(s.remove(it)) + r(s) -> + r(it) -> + magic[VALUE_CONSUMER](it|) -> + mark(remove(it)) + call(remove(it), |) -> +L9 ['if' expression result]: + 5 merge(if (flag) { s.add(it) } else { s.remove(it) }|, ) -> PREV:[jmp(L9), call(remove(it), |) -> ] + r(true) -> +L10 [start finally]: + 6 mark({ name?.hashCode() }) + mark(name?.hashCode()) + jf(L11) NEXT:[ret(*|) L1, r(name) -> ] + r(name) -> + mark(hashCode()) + call(hashCode(), hashCode|) -> +L11 [result of call]: +L12 [finish finally]: + 5 ret(*|) L1 NEXT:[] PREV:[jf(L11), call(hashCode(), hashCode|) -> ] +- 4 ret(*|!) L7 PREV:[] +L7: +- NEXT:[] PREV:[] +error: +- PREV:[] +sink: +- PREV:[] +===================== diff --git a/compiler/testData/cfg/controlStructures/incorrectIndex.kt b/compiler/testData/cfg/controlStructures/incorrectIndex_After.kt similarity index 84% rename from compiler/testData/cfg/controlStructures/incorrectIndex.kt rename to compiler/testData/cfg/controlStructures/incorrectIndex_After.kt index 6502ae81a5b..428fc83197d 100644 --- a/compiler/testData/cfg/controlStructures/incorrectIndex.kt +++ b/compiler/testData/cfg/controlStructures/incorrectIndex_After.kt @@ -1,3 +1,4 @@ +// !LANGUAGE: +ReadDeserializedContracts +UseCallsInPlaceEffect // See KT-18698 val s = mutableListOf() diff --git a/compiler/testData/cfg/controlStructures/incorrectIndex_After.values b/compiler/testData/cfg/controlStructures/incorrectIndex_After.values new file mode 100644 index 00000000000..138050ba676 --- /dev/null +++ b/compiler/testData/cfg/controlStructures/incorrectIndex_After.values @@ -0,0 +1,68 @@ +== s == +val s = mutableListOf() +--------------------- +mutableListOf !: * +mutableListOf() : {<: [ERROR : Type for mutableListOf()]} NEW: magic[UNRESOLVED_CALL](mutableListOf()|!) -> +===================== +== test == +fun test(name: String?, flag: Boolean): Boolean { + try { + name?.let { + if (flag) { + s.add(it) + } + else { + s.remove(it) + } + + return true + } + + return false + } finally { + name?.hashCode() + } +} +--------------------- + : {<: String?} NEW: magic[FAKE_INITIALIZER](name: String?) -> + : Boolean NEW: magic[FAKE_INITIALIZER](flag: Boolean) -> +name : String NEW: r(name) -> +{ if (flag) { s.add(it) } else { s.remove(it) } return true } : {<: (String) -> Nothing} NEW: r({ if (flag) { s.add(it) } else { s.remove(it) } return true }) -> +let { if (flag) { s.add(it) } else { s.remove(it) } return true } !: * +name?.let { if (flag) { s.add(it) } else { s.remove(it) } return true } !: * COPY +false : Boolean NEW: r(false) -> +return false !: * +{ name?.let { if (flag) { s.add(it) } else { s.remove(it) } return true } return false } !: * COPY +try { name?.let { if (flag) { s.add(it) } else { s.remove(it) } return true } return false } finally { name?.hashCode() } : * NEW: merge(try { name?.let { if (flag) { s.add(it) } else { s.remove(it) } return true } return false } finally { name?.hashCode() }|!) -> +{ try { name?.let { if (flag) { s.add(it) } else { s.remove(it) } return true } return false } finally { name?.hashCode() } } : * COPY +===================== +== inlined anonymous_0 == +{ + if (flag) { + s.add(it) + } + else { + s.remove(it) + } + + return true + } +--------------------- + : * NEW: magic[VALUE_CONSUMER](it|) -> + : * NEW: magic[VALUE_CONSUMER](it|) -> +flag : Boolean NEW: r(flag) -> +s : * NEW: r(s) -> +it : * NEW: r(it) -> +add(it) : * NEW: call(add(it), |) -> +s.add(it) : * COPY +{ s.add(it) } : * COPY +s : * NEW: r(s) -> +it : * NEW: r(it) -> +remove(it) : * NEW: call(remove(it), |) -> +s.remove(it) : * COPY +{ s.remove(it) } : * COPY +if (flag) { s.add(it) } else { s.remove(it) } : * NEW: merge(if (flag) { s.add(it) } else { s.remove(it) }|, ) -> +true : Boolean NEW: r(true) -> +return true !: * +if (flag) { s.add(it) } else { s.remove(it) } return true !: * COPY +===================== diff --git a/compiler/testData/cfg/controlStructures/incorrectIndex.instructions b/compiler/testData/cfg/controlStructures/incorrectIndex_Before.instructions similarity index 100% rename from compiler/testData/cfg/controlStructures/incorrectIndex.instructions rename to compiler/testData/cfg/controlStructures/incorrectIndex_Before.instructions diff --git a/compiler/testData/cfg/controlStructures/incorrectIndex_Before.kt b/compiler/testData/cfg/controlStructures/incorrectIndex_Before.kt new file mode 100644 index 00000000000..5eb0ef3c653 --- /dev/null +++ b/compiler/testData/cfg/controlStructures/incorrectIndex_Before.kt @@ -0,0 +1,23 @@ +// !LANGUAGE: -ReadDeserializedContracts -UseCallsInPlaceEffect +// See KT-18698 + +val s = mutableListOf() + +fun test(name: String?, flag: Boolean): Boolean { + try { + name?.let { + if (flag) { + s.add(it) + } + else { + s.remove(it) + } + + return true + } + + return false + } finally { + name?.hashCode() + } +} \ No newline at end of file diff --git a/compiler/testData/cfg/controlStructures/incorrectIndex.values b/compiler/testData/cfg/controlStructures/incorrectIndex_Before.values similarity index 100% rename from compiler/testData/cfg/controlStructures/incorrectIndex.values rename to compiler/testData/cfg/controlStructures/incorrectIndex_Before.values diff --git a/compiler/testData/cfg/deadCode/notLocalReturn_after.instructions b/compiler/testData/cfg/deadCode/notLocalReturn_after.instructions new file mode 100644 index 00000000000..414ca507675 --- /dev/null +++ b/compiler/testData/cfg/deadCode/notLocalReturn_after.instructions @@ -0,0 +1,206 @@ +== doCall == +inline fun doCall(f: () -> Unit) = f() +--------------------- +L0: + 1 + v(f: () -> Unit) + magic[FAKE_INITIALIZER](f: () -> Unit) -> + w(f|) + r(f) -> + mark(f()) + call(f(), invoke|) -> + ret(*|) L1 +L1: + NEXT:[] +error: + PREV:[] +sink: + PREV:[, ] +===================== +== test1 == +fun test1(nonLocal: String): String { + val localResult = doCall { + return nonLocal //unreachable + } + return "NON_LOCAL_FAILED $localResult" //unreachable +} +--------------------- +L0: + 1 + v(nonLocal: String) + magic[FAKE_INITIALIZER](nonLocal: String) -> + w(nonLocal|) + 2 mark({ val localResult = doCall { return nonLocal //unreachable } return "NON_LOCAL_FAILED $localResult" //unreachable }) + v(val localResult = doCall { return nonLocal //unreachable }) + mark({ return nonLocal //unreachable }) + jmp?(L2) NEXT:[r({ return nonLocal //unreachable }) -> , d({ return nonLocal //unreachable })] + d({ return nonLocal //unreachable }) NEXT:[] +L2 [after local declaration]: + r({ return nonLocal //unreachable }) -> PREV:[jmp?(L2)] + mark(doCall { return nonLocal //unreachable }) + call(doCall { return nonLocal //unreachable }, doCall|) -> + w(localResult|) + mark("NON_LOCAL_FAILED $localResult") + r(localResult) -> + magic[STRING_TEMPLATE]("NON_LOCAL_FAILED $localResult"|) -> + ret(*|) L1 +L1: + 1 NEXT:[] PREV:[ret(*|) L1, ret(*|) L1] +error: + PREV:[] +sink: + PREV:[, , d({ return nonLocal //unreachable })] +===================== +== anonymous_0 == +{ + return nonLocal //unreachable + } +--------------------- +L3: + 3 + 4 mark(return nonLocal //unreachable) + r(nonLocal) -> + ret(*|) L1 NEXT:[] +L4: + 3 NEXT:[] PREV:[] +error: + PREV:[] +sink: + PREV:[, ] +===================== +== doSomething == +fun doSomething() {} +--------------------- +L0: + 1 + 2 mark({}) + read (Unit) +L1: + 1 NEXT:[] +error: + PREV:[] +sink: + PREV:[, ] +===================== +== test2 == +fun test2() { + fun f(x: Any?) = x + f(null?.let { return }) + + // false unreachable here + doSomething() +} +--------------------- +L0: + 1 + 2 mark({ fun f(x: Any?) = x f(null?.let { return }) // false unreachable here doSomething() }) + jmp?(L2) NEXT:[mark(null?.let { return }), d(fun f(x: Any?) = x)] + d(fun f(x: Any?) = x) NEXT:[] +L2 [after local declaration]: + mark(null?.let { return }) PREV:[jmp?(L2)] + jf(L5) NEXT:[mark(f(null?.let { return })), r(null) -> ] + r(null) -> + mark({ return }) + r({ return }) -> + mark(let { return }) + call(let { return }, let|, ) +L6 [before inlined declaration]: + inlined({ return }) NEXT:[] +L5 [result of call]: +L7 [after inlined declaration]: + mark(f(null?.let { return })) PREV:[jf(L5)] + call(f(null?.let { return }), f|!) -> + mark(doSomething()) + call(doSomething(), doSomething) -> +L1: + 1 NEXT:[] PREV:[ret L1, call(doSomething(), doSomething) -> ] +error: + PREV:[] +sink: + PREV:[, , d(fun f(x: Any?) = x), inlined({ return })] +===================== +== f == +fun f(x: Any?) = x +--------------------- +L3: + 3 + v(x: Any?) + magic[FAKE_INITIALIZER](x: Any?) -> + w(x|) + r(x) -> + ret(*|) L4 +L4: + NEXT:[] +error: + PREV:[] +sink: + PREV:[, ] +===================== +== inlined anonymous_1 == +{ return } +--------------------- +L8: + 3 + 4 mark(return) + ret L1 NEXT:[] +- 3 ret(*|!) L9 PREV:[] +L9: +- NEXT:[] PREV:[] +error: +- PREV:[] +sink: +- PREV:[] +===================== +== test3 == +fun test3(x: Any?): Boolean = + x?.let { + return true + } ?: false +--------------------- +L0: + 1 + v(x: Any?) + magic[FAKE_INITIALIZER](x: Any?) -> + w(x|) + mark(x?.let { return true }) + jf(L2) NEXT:[mark(x?.let { return true } ?: false), r(x) -> ] + r(x) -> + mark({ return true }) + r({ return true }) -> + mark(let { return true }) + call(let { return true }, let|, ) +L3 [before inlined declaration]: + inlined({ return true }) NEXT:[] +L2 [result of call]: +L4 [after inlined declaration]: + mark(x?.let { return true } ?: false) PREV:[jf(L2)] + jt(L7|!) NEXT:[r(false) -> , merge(x?.let { return true } ?: false|!, ) -> ] + r(false) -> +L7 [after elvis operator]: + merge(x?.let { return true } ?: false|!, ) -> PREV:[jt(L7|!), r(false) -> ] + ret(*|) L1 +L1: + NEXT:[] PREV:[ret(*|) L1, ret(*|) L1] +error: + PREV:[] +sink: + PREV:[, , inlined({ return true })] +===================== +== inlined anonymous_2 == +{ + return true + } +--------------------- +L5: + 2 + 3 mark(return true) + r(true) -> + ret(*|) L1 NEXT:[] +- 2 ret(*|!) L6 PREV:[] +L6: +- NEXT:[] PREV:[] +error: +- PREV:[] +sink: +- PREV:[] +===================== diff --git a/compiler/testData/cfg/deadCode/notLocalReturn.kt b/compiler/testData/cfg/deadCode/notLocalReturn_after.kt similarity index 85% rename from compiler/testData/cfg/deadCode/notLocalReturn.kt rename to compiler/testData/cfg/deadCode/notLocalReturn_after.kt index 804e44b34ae..cc945e79c1f 100644 --- a/compiler/testData/cfg/deadCode/notLocalReturn.kt +++ b/compiler/testData/cfg/deadCode/notLocalReturn_after.kt @@ -1,3 +1,4 @@ +// !LANGUAGE: +ReadDeserializedContracts +UseCallsInPlaceEffect // See also KT-5198 / KT-10186 inline fun doCall(f: () -> Unit) = f() @@ -20,6 +21,6 @@ fun test2() { } fun test3(x: Any?): Boolean = - x?.let { + x?.let { return true } ?: false diff --git a/compiler/testData/cfg/deadCode/notLocalReturn_after.values b/compiler/testData/cfg/deadCode/notLocalReturn_after.values new file mode 100644 index 00000000000..2fb3c721a07 --- /dev/null +++ b/compiler/testData/cfg/deadCode/notLocalReturn_after.values @@ -0,0 +1,88 @@ +== doCall == +inline fun doCall(f: () -> Unit) = f() +--------------------- + : {<: () -> Unit} NEW: magic[FAKE_INITIALIZER](f: () -> Unit) -> +f : {<: () -> Unit} NEW: r(f) -> +f() : Unit NEW: call(f(), invoke|) -> +===================== +== test1 == +fun test1(nonLocal: String): String { + val localResult = doCall { + return nonLocal //unreachable + } + return "NON_LOCAL_FAILED $localResult" //unreachable +} +--------------------- + : String NEW: magic[FAKE_INITIALIZER](nonLocal: String) -> +{ return nonLocal //unreachable } : {<: () -> Unit} NEW: r({ return nonLocal //unreachable }) -> +doCall { return nonLocal //unreachable } : Unit NEW: call(doCall { return nonLocal //unreachable }, doCall|) -> +localResult : * NEW: r(localResult) -> +"NON_LOCAL_FAILED $localResult" : String NEW: magic[STRING_TEMPLATE]("NON_LOCAL_FAILED $localResult"|) -> +return "NON_LOCAL_FAILED $localResult" !: * +{ val localResult = doCall { return nonLocal //unreachable } return "NON_LOCAL_FAILED $localResult" //unreachable } !: * COPY +===================== +== anonymous_0 == +{ + return nonLocal //unreachable + } +--------------------- +nonLocal : String NEW: r(nonLocal) -> +return nonLocal !: * +return nonLocal //unreachable !: * COPY +===================== +== doSomething == +fun doSomething() {} +--------------------- +===================== +== test2 == +fun test2() { + fun f(x: Any?) = x + f(null?.let { return }) + + // false unreachable here + doSomething() +} +--------------------- +null : Nothing NEW: r(null) -> +{ return } : {<: (Nothing) -> Nothing} NEW: r({ return }) -> +let { return } !: * +null?.let { return } !: * COPY +f(null?.let { return }) : * NEW: call(f(null?.let { return }), f|!) -> +doSomething() : * NEW: call(doSomething(), doSomething) -> +{ fun f(x: Any?) = x f(null?.let { return }) // false unreachable here doSomething() } : * COPY +===================== +== f == +fun f(x: Any?) = x +--------------------- + : * NEW: magic[FAKE_INITIALIZER](x: Any?) -> +x : * NEW: r(x) -> +===================== +== inlined anonymous_1 == +{ return } +--------------------- +return !: * +return !: * COPY +===================== +== test3 == +fun test3(x: Any?): Boolean = + x?.let { + return true + } ?: false +--------------------- + : * NEW: magic[FAKE_INITIALIZER](x: Any?) -> +x : {<: Any} NEW: r(x) -> +{ return true } : {<: (Any) -> Nothing} NEW: r({ return true }) -> +let { return true } !: * +x?.let { return true } !: * COPY +false : Boolean NEW: r(false) -> +x?.let { return true } ?: false : Boolean NEW: merge(x?.let { return true } ?: false|!, ) -> +===================== +== inlined anonymous_2 == +{ + return true + } +--------------------- +true : Boolean NEW: r(true) -> +return true !: * +return true !: * COPY +===================== diff --git a/compiler/testData/cfg/deadCode/notLocalReturn.instructions b/compiler/testData/cfg/deadCode/notLocalReturn_before.instructions similarity index 100% rename from compiler/testData/cfg/deadCode/notLocalReturn.instructions rename to compiler/testData/cfg/deadCode/notLocalReturn_before.instructions diff --git a/compiler/testData/cfg/deadCode/notLocalReturn_before.kt b/compiler/testData/cfg/deadCode/notLocalReturn_before.kt new file mode 100644 index 00000000000..c0192726bcf --- /dev/null +++ b/compiler/testData/cfg/deadCode/notLocalReturn_before.kt @@ -0,0 +1,26 @@ +// !LANGUAGE: -ReadDeserializedContracts -UseCallsInPlaceEffect +// See also KT-5198 / KT-10186 + +inline fun doCall(f: () -> Unit) = f() + +fun test1(nonLocal: String): String { + val localResult = doCall { + return nonLocal //unreachable + } + return "NON_LOCAL_FAILED $localResult" //unreachable +} + +fun doSomething() {} + +fun test2() { + fun f(x: Any?) = x + f(null?.let { return }) + + // false unreachable here + doSomething() +} + +fun test3(x: Any?): Boolean = + x?.let { + return true + } ?: false diff --git a/compiler/testData/cfg/deadCode/notLocalReturn.values b/compiler/testData/cfg/deadCode/notLocalReturn_before.values similarity index 100% rename from compiler/testData/cfg/deadCode/notLocalReturn.values rename to compiler/testData/cfg/deadCode/notLocalReturn_before.values diff --git a/compiler/testData/diagnostics/tests/backingField/FieldReassignmentError.kt b/compiler/testData/diagnostics/tests/backingField/FieldReassignment_after.kt similarity index 100% rename from compiler/testData/diagnostics/tests/backingField/FieldReassignmentError.kt rename to compiler/testData/diagnostics/tests/backingField/FieldReassignment_after.kt diff --git a/compiler/testData/diagnostics/tests/backingField/FieldReassignment.txt b/compiler/testData/diagnostics/tests/backingField/FieldReassignment_after.txt similarity index 100% rename from compiler/testData/diagnostics/tests/backingField/FieldReassignment.txt rename to compiler/testData/diagnostics/tests/backingField/FieldReassignment_after.txt diff --git a/compiler/testData/diagnostics/tests/backingField/FieldReassignment.kt b/compiler/testData/diagnostics/tests/backingField/FieldReassignment_before.kt similarity index 64% rename from compiler/testData/diagnostics/tests/backingField/FieldReassignment.kt rename to compiler/testData/diagnostics/tests/backingField/FieldReassignment_before.kt index 1c37a864b4d..2ac370e074f 100644 --- a/compiler/testData/diagnostics/tests/backingField/FieldReassignment.kt +++ b/compiler/testData/diagnostics/tests/backingField/FieldReassignment_before.kt @@ -1,3 +1,5 @@ +// !LANGUAGE: -RestrictionOfValReassignmentViaBackingField + val my: Int = 1 get() { field++ diff --git a/compiler/testData/diagnostics/tests/backingField/FieldReassignmentError.txt b/compiler/testData/diagnostics/tests/backingField/FieldReassignment_before.txt similarity index 100% rename from compiler/testData/diagnostics/tests/backingField/FieldReassignmentError.txt rename to compiler/testData/diagnostics/tests/backingField/FieldReassignment_before.txt diff --git a/compiler/testData/diagnostics/tests/classObjects/InnerClassAccessThroughEnum_after.kt b/compiler/testData/diagnostics/tests/classObjects/InnerClassAccessThroughEnum_after.kt new file mode 100644 index 00000000000..e5156b5429c --- /dev/null +++ b/compiler/testData/diagnostics/tests/classObjects/InnerClassAccessThroughEnum_after.kt @@ -0,0 +1,50 @@ +// !LANGUAGE: +NestedClassesInEnumEntryShouldBeInner + +package a + + +enum class C { + E1, E2, E3 { + object O_O + + fun b() { + O_O + } + + class G + }, + + E4 { + fun c() { + this.B() + + C.A() + A() + //TODO: should be resolved with error + this.A() + } + }; + + class A + inner class B + object O { + object InO + } +} + +fun f() { + C.E1.A + C.E1.A() + C.E2.B() + + C.E2.O + C.E3.O.InO + + C.O + C.O.InO + C.A() + C.B() + + C.E3.O_O + C.E3.G() +} diff --git a/compiler/testData/diagnostics/tests/classObjects/InnerClassAccessThroughEnum.txt b/compiler/testData/diagnostics/tests/classObjects/InnerClassAccessThroughEnum_after.txt similarity index 100% rename from compiler/testData/diagnostics/tests/classObjects/InnerClassAccessThroughEnum.txt rename to compiler/testData/diagnostics/tests/classObjects/InnerClassAccessThroughEnum_after.txt diff --git a/compiler/testData/diagnostics/tests/classObjects/InnerClassAccessThroughEnum.kt b/compiler/testData/diagnostics/tests/classObjects/InnerClassAccessThroughEnum_before.kt similarity index 93% rename from compiler/testData/diagnostics/tests/classObjects/InnerClassAccessThroughEnum.kt rename to compiler/testData/diagnostics/tests/classObjects/InnerClassAccessThroughEnum_before.kt index 2186ffae287..f1510ed050a 100644 --- a/compiler/testData/diagnostics/tests/classObjects/InnerClassAccessThroughEnum.kt +++ b/compiler/testData/diagnostics/tests/classObjects/InnerClassAccessThroughEnum_before.kt @@ -1,3 +1,5 @@ +// !LANGUAGE: -NestedClassesInEnumEntryShouldBeInner + package a diff --git a/compiler/testData/diagnostics/tests/classObjects/InnerClassAccessThroughEnum_before.txt b/compiler/testData/diagnostics/tests/classObjects/InnerClassAccessThroughEnum_before.txt new file mode 100644 index 00000000000..b1980ed4e66 --- /dev/null +++ b/compiler/testData/diagnostics/tests/classObjects/InnerClassAccessThroughEnum_before.txt @@ -0,0 +1,58 @@ +package + +package a { + public fun f(): kotlin.Unit + + public final enum class C : kotlin.Enum { + enum entry E1 + + enum entry E2 + + enum entry E3 + + enum entry E4 + + private constructor C() + public final override /*1*/ /*fake_override*/ val name: kotlin.String + public final override /*1*/ /*fake_override*/ val ordinal: kotlin.Int + protected final override /*1*/ /*fake_override*/ fun clone(): kotlin.Any + public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: a.C): kotlin.Int + public final override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + protected/*protected and package*/ final override /*1*/ /*fake_override*/ /*isHiddenForResolutionEverywhereBesideSupercalls*/ fun finalize(): kotlin.Unit + public final override /*1*/ /*fake_override*/ /*isHiddenForResolutionEverywhereBesideSupercalls*/ fun getDeclaringClass(): java.lang.Class! + public final override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + + public final class A { + public constructor A() + 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 inner class B { + public constructor B() + 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 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 open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + + public object InO { + private constructor InO() + 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 + } + } + + // Static members + public final /*synthesized*/ fun valueOf(/*0*/ value: kotlin.String): a.C + public final /*synthesized*/ fun values(): kotlin.Array + } +} diff --git a/compiler/testData/diagnostics/tests/controlFlowAnalysis/backingFieldInsideGetter_after.kt b/compiler/testData/diagnostics/tests/controlFlowAnalysis/backingFieldInsideGetter_after.kt new file mode 100644 index 00000000000..1c021d93eda --- /dev/null +++ b/compiler/testData/diagnostics/tests/controlFlowAnalysis/backingFieldInsideGetter_after.kt @@ -0,0 +1,23 @@ +// !LANGUAGE: +RestrictionOfValReassignmentViaBackingField + +package a + +import java.util.HashSet + +val a: MutableSet? = null + get() { + if (a == null) { + field = HashSet() + } + return a + } + +class R { + val b: String? = null + get() { + if (b == null) { + field = "b" + } + return b + } +} diff --git a/compiler/testData/diagnostics/tests/controlFlowAnalysis/backingFieldInsideGetter.txt b/compiler/testData/diagnostics/tests/controlFlowAnalysis/backingFieldInsideGetter_after.txt similarity index 100% rename from compiler/testData/diagnostics/tests/controlFlowAnalysis/backingFieldInsideGetter.txt rename to compiler/testData/diagnostics/tests/controlFlowAnalysis/backingFieldInsideGetter_after.txt diff --git a/compiler/testData/diagnostics/tests/controlFlowAnalysis/backingFieldInsideGetter.kt b/compiler/testData/diagnostics/tests/controlFlowAnalysis/backingFieldInsideGetter_before.kt similarity index 87% rename from compiler/testData/diagnostics/tests/controlFlowAnalysis/backingFieldInsideGetter.kt rename to compiler/testData/diagnostics/tests/controlFlowAnalysis/backingFieldInsideGetter_before.kt index 2d0093d4c2f..eba3f97535f 100644 --- a/compiler/testData/diagnostics/tests/controlFlowAnalysis/backingFieldInsideGetter.kt +++ b/compiler/testData/diagnostics/tests/controlFlowAnalysis/backingFieldInsideGetter_before.kt @@ -1,3 +1,5 @@ +// !LANGUAGE: -RestrictionOfValReassignmentViaBackingField + package a import java.util.HashSet @@ -19,4 +21,3 @@ class R { return b } } - diff --git a/compiler/testData/diagnostics/tests/controlFlowAnalysis/backingFieldInsideGetter_before.txt b/compiler/testData/diagnostics/tests/controlFlowAnalysis/backingFieldInsideGetter_before.txt new file mode 100644 index 00000000000..c20819a92b9 --- /dev/null +++ b/compiler/testData/diagnostics/tests/controlFlowAnalysis/backingFieldInsideGetter_before.txt @@ -0,0 +1,13 @@ +package + +package a { + public val a: kotlin.collections.MutableSet? = null + + public final class R { + public constructor R() + public final val b: kotlin.String? = null + 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 + } +} diff --git a/compiler/testData/diagnostics/tests/controlFlowAnalysis/initializationInLocalViaExplicitThis_after.kt b/compiler/testData/diagnostics/tests/controlFlowAnalysis/initializationInLocalViaExplicitThis_after.kt new file mode 100644 index 00000000000..fea2541eafd --- /dev/null +++ b/compiler/testData/diagnostics/tests/controlFlowAnalysis/initializationInLocalViaExplicitThis_after.kt @@ -0,0 +1,18 @@ +// !LANGUAGE: +ReadDeserializedContracts +UseCallsInPlaceEffect +// See KT-17479 + +class Test { + val str: String + init { + run { + this@Test.str = "A" + } + + run { + // Not sure do we need diagnostic also here + this@Test.str = "B" + } + + str = "C" + } +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/controlFlowAnalysis/initializationInLocalViaExplicitThis.txt b/compiler/testData/diagnostics/tests/controlFlowAnalysis/initializationInLocalViaExplicitThis_after.txt similarity index 100% rename from compiler/testData/diagnostics/tests/controlFlowAnalysis/initializationInLocalViaExplicitThis.txt rename to compiler/testData/diagnostics/tests/controlFlowAnalysis/initializationInLocalViaExplicitThis_after.txt diff --git a/compiler/testData/diagnostics/tests/controlFlowAnalysis/initializationInLocalViaExplicitThis.kt b/compiler/testData/diagnostics/tests/controlFlowAnalysis/initializationInLocalViaExplicitThis_before.kt similarity index 82% rename from compiler/testData/diagnostics/tests/controlFlowAnalysis/initializationInLocalViaExplicitThis.kt rename to compiler/testData/diagnostics/tests/controlFlowAnalysis/initializationInLocalViaExplicitThis_before.kt index 95015c9c3ea..6c07c4ba357 100644 --- a/compiler/testData/diagnostics/tests/controlFlowAnalysis/initializationInLocalViaExplicitThis.kt +++ b/compiler/testData/diagnostics/tests/controlFlowAnalysis/initializationInLocalViaExplicitThis_before.kt @@ -1,3 +1,4 @@ +// !LANGUAGE: -ReadDeserializedContracts -UseCallsInPlaceEffect // See KT-17479 class Test { diff --git a/compiler/testData/diagnostics/tests/controlFlowAnalysis/initializationInLocalViaExplicitThis_before.txt b/compiler/testData/diagnostics/tests/controlFlowAnalysis/initializationInLocalViaExplicitThis_before.txt new file mode 100644 index 00000000000..582fbdd5e04 --- /dev/null +++ b/compiler/testData/diagnostics/tests/controlFlowAnalysis/initializationInLocalViaExplicitThis_before.txt @@ -0,0 +1,9 @@ +package + +public final class Test { + public constructor Test() + public final val str: kotlin.String + 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 +} diff --git a/compiler/testData/diagnostics/tests/cyclicHierarchy/withCompanion/everythingInOneScope_after.kt b/compiler/testData/diagnostics/tests/cyclicHierarchy/withCompanion/everythingInOneScope_after.kt new file mode 100644 index 00000000000..0ec91659685 --- /dev/null +++ b/compiler/testData/diagnostics/tests/cyclicHierarchy/withCompanion/everythingInOneScope_after.kt @@ -0,0 +1,15 @@ +// !LANGUAGE: +ProhibitVisibilityOfNestedClassifiersFromSupertypesOfCompanion +// see https://youtrack.jetbrains.com/issue/KT-21515 + +open class Container { + open class Base { + open fun m() {} + } + + // note that Base() supertype will be resolved in scope that was created on recursion + abstract class DerivedAbstract : Base() + + companion object : DerivedAbstract() { + override fun m() {} + } +} diff --git a/compiler/testData/diagnostics/tests/cyclicHierarchy/withCompanion/everythingInOneScope_after.txt b/compiler/testData/diagnostics/tests/cyclicHierarchy/withCompanion/everythingInOneScope_after.txt new file mode 100644 index 00000000000..ca3390dc67d --- /dev/null +++ b/compiler/testData/diagnostics/tests/cyclicHierarchy/withCompanion/everythingInOneScope_after.txt @@ -0,0 +1,32 @@ +package + +public open class Container { + public constructor Container() + 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 open class Base { + public constructor Base() + 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 fun m(): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } + + public companion object Companion : Container.DerivedAbstract { + private constructor Companion() + 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*/ fun m(): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } + + public abstract class DerivedAbstract : Container.Base { + public constructor DerivedAbstract() + 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 m(): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } +} diff --git a/compiler/testData/diagnostics/tests/cyclicHierarchy/withCompanion/everythingInOneScope.kt b/compiler/testData/diagnostics/tests/cyclicHierarchy/withCompanion/everythingInOneScope_before.kt similarity index 85% rename from compiler/testData/diagnostics/tests/cyclicHierarchy/withCompanion/everythingInOneScope.kt rename to compiler/testData/diagnostics/tests/cyclicHierarchy/withCompanion/everythingInOneScope_before.kt index 84b65570cda..9cdabaa036d 100644 --- a/compiler/testData/diagnostics/tests/cyclicHierarchy/withCompanion/everythingInOneScope.kt +++ b/compiler/testData/diagnostics/tests/cyclicHierarchy/withCompanion/everythingInOneScope_before.kt @@ -1,3 +1,4 @@ +// !LANGUAGE: -ProhibitVisibilityOfNestedClassifiersFromSupertypesOfCompanion // see https://youtrack.jetbrains.com/issue/KT-21515 open class Container { diff --git a/compiler/testData/diagnostics/tests/cyclicHierarchy/withCompanion/everythingInOneScope.txt b/compiler/testData/diagnostics/tests/cyclicHierarchy/withCompanion/everythingInOneScope_before.txt similarity index 100% rename from compiler/testData/diagnostics/tests/cyclicHierarchy/withCompanion/everythingInOneScope.txt rename to compiler/testData/diagnostics/tests/cyclicHierarchy/withCompanion/everythingInOneScope_before.txt diff --git a/compiler/testData/diagnostics/tests/cyclicHierarchy/withCompanion/noMembers_after.kt b/compiler/testData/diagnostics/tests/cyclicHierarchy/withCompanion/noMembers_after.kt new file mode 100644 index 00000000000..114c803484e --- /dev/null +++ b/compiler/testData/diagnostics/tests/cyclicHierarchy/withCompanion/noMembers_after.kt @@ -0,0 +1,15 @@ +// !LANGUAGE: +ProhibitVisibilityOfNestedClassifiersFromSupertypesOfCompanion +// see https://youtrack.jetbrains.com/issue/KT-21515 + +abstract class DerivedAbstract : C.Base() { + open class Data +} + +public class C { + + open class Base () + + class Foo : Data() + + companion object : DerivedAbstract() +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/cyclicHierarchy/withCompanion/noMembers_after.txt b/compiler/testData/diagnostics/tests/cyclicHierarchy/withCompanion/noMembers_after.txt new file mode 100644 index 00000000000..3aa8221dfad --- /dev/null +++ b/compiler/testData/diagnostics/tests/cyclicHierarchy/withCompanion/noMembers_after.txt @@ -0,0 +1,43 @@ +package + +public final class C { + public constructor C() + 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 open class Base { + public constructor Base() + 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 companion object Companion : DerivedAbstract { + private constructor Companion() + 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 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 + } +} + +public abstract class DerivedAbstract : C.Base { + public constructor DerivedAbstract() + 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 open class Data { + public constructor Data() + 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 + } +} diff --git a/compiler/testData/diagnostics/tests/cyclicHierarchy/withCompanion/noMembers.kt b/compiler/testData/diagnostics/tests/cyclicHierarchy/withCompanion/noMembers_before.kt similarity index 82% rename from compiler/testData/diagnostics/tests/cyclicHierarchy/withCompanion/noMembers.kt rename to compiler/testData/diagnostics/tests/cyclicHierarchy/withCompanion/noMembers_before.kt index 14792344c85..5848a03a29e 100644 --- a/compiler/testData/diagnostics/tests/cyclicHierarchy/withCompanion/noMembers.kt +++ b/compiler/testData/diagnostics/tests/cyclicHierarchy/withCompanion/noMembers_before.kt @@ -1,3 +1,4 @@ +// !LANGUAGE: -ProhibitVisibilityOfNestedClassifiersFromSupertypesOfCompanion // see https://youtrack.jetbrains.com/issue/KT-21515 abstract class DerivedAbstract : C.Base() { diff --git a/compiler/testData/diagnostics/tests/cyclicHierarchy/withCompanion/noMembers.txt b/compiler/testData/diagnostics/tests/cyclicHierarchy/withCompanion/noMembers_before.txt similarity index 100% rename from compiler/testData/diagnostics/tests/cyclicHierarchy/withCompanion/noMembers.txt rename to compiler/testData/diagnostics/tests/cyclicHierarchy/withCompanion/noMembers_before.txt diff --git a/compiler/testData/diagnostics/tests/cyclicHierarchy/withCompanion/onlyInterfaces_after.kt b/compiler/testData/diagnostics/tests/cyclicHierarchy/withCompanion/onlyInterfaces_after.kt new file mode 100644 index 00000000000..9418f3babc2 --- /dev/null +++ b/compiler/testData/diagnostics/tests/cyclicHierarchy/withCompanion/onlyInterfaces_after.kt @@ -0,0 +1,18 @@ +// !LANGUAGE: +ProhibitVisibilityOfNestedClassifiersFromSupertypesOfCompanion +// see https://youtrack.jetbrains.com/issue/KT-21515 + +open class Container { + // Note that here we also have errors and diagnostics, even though there are actually no loops. + // (this is case because we can't know if there are any loops without resolving, but resolving + // itself provokes loops) + + interface Base { + open fun m() {} + } + + interface DerivedAbstract : Base + + companion object : DerivedAbstract { + override fun m() {} + } +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/cyclicHierarchy/withCompanion/onlyInterfaces_after.txt b/compiler/testData/diagnostics/tests/cyclicHierarchy/withCompanion/onlyInterfaces_after.txt new file mode 100644 index 00000000000..7580d79c839 --- /dev/null +++ b/compiler/testData/diagnostics/tests/cyclicHierarchy/withCompanion/onlyInterfaces_after.txt @@ -0,0 +1,30 @@ +package + +public open class Container { + public constructor Container() + 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 Base { + 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 fun m(): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } + + public companion object Companion : Container.DerivedAbstract { + private constructor Companion() + 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*/ fun m(): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } + + public interface DerivedAbstract : Container.Base { + 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 m(): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } +} diff --git a/compiler/testData/diagnostics/tests/cyclicHierarchy/withCompanion/onlyInterfaces.kt b/compiler/testData/diagnostics/tests/cyclicHierarchy/withCompanion/onlyInterfaces_before.kt similarity index 88% rename from compiler/testData/diagnostics/tests/cyclicHierarchy/withCompanion/onlyInterfaces.kt rename to compiler/testData/diagnostics/tests/cyclicHierarchy/withCompanion/onlyInterfaces_before.kt index e2e3643a16c..d9e74d1c97e 100644 --- a/compiler/testData/diagnostics/tests/cyclicHierarchy/withCompanion/onlyInterfaces.kt +++ b/compiler/testData/diagnostics/tests/cyclicHierarchy/withCompanion/onlyInterfaces_before.kt @@ -1,3 +1,4 @@ +// !LANGUAGE: -ProhibitVisibilityOfNestedClassifiersFromSupertypesOfCompanion // see https://youtrack.jetbrains.com/issue/KT-21515 open class Container { diff --git a/compiler/testData/diagnostics/tests/cyclicHierarchy/withCompanion/onlyInterfaces.txt b/compiler/testData/diagnostics/tests/cyclicHierarchy/withCompanion/onlyInterfaces_before.txt similarity index 100% rename from compiler/testData/diagnostics/tests/cyclicHierarchy/withCompanion/onlyInterfaces.txt rename to compiler/testData/diagnostics/tests/cyclicHierarchy/withCompanion/onlyInterfaces_before.txt diff --git a/compiler/testData/diagnostics/tests/cyclicHierarchy/withCompanion/withIrrelevantInterface_after.kt b/compiler/testData/diagnostics/tests/cyclicHierarchy/withCompanion/withIrrelevantInterface_after.kt new file mode 100644 index 00000000000..8b19f086a00 --- /dev/null +++ b/compiler/testData/diagnostics/tests/cyclicHierarchy/withCompanion/withIrrelevantInterface_after.kt @@ -0,0 +1,20 @@ +// !LANGUAGE: +ProhibitVisibilityOfNestedClassifiersFromSupertypesOfCompanion +// see https://youtrack.jetbrains.com/issue/KT-21515 + +interface SomeIrrelevantInterface + +// note that C.Base() supertype will be resolved in normal scope +abstract class DerivedAbstract : C.Base() + +class Data + +public class C { + + val data: Data = Data() + + // Note that any supertype of Base will be resolved in error-scope, even if it absolutely irrelevant + // to the types in cycle. + open class Base() : SomeIrrelevantInterface + + companion object : DerivedAbstract() +} diff --git a/compiler/testData/diagnostics/tests/cyclicHierarchy/withCompanion/withIrrelevantInterface_after.txt b/compiler/testData/diagnostics/tests/cyclicHierarchy/withCompanion/withIrrelevantInterface_after.txt new file mode 100644 index 00000000000..674872f21b2 --- /dev/null +++ b/compiler/testData/diagnostics/tests/cyclicHierarchy/withCompanion/withIrrelevantInterface_after.txt @@ -0,0 +1,43 @@ +package + +public final class C { + public constructor C() + public final val data: Data + 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 open class Base : SomeIrrelevantInterface { + public constructor Base() + 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 companion object Companion : DerivedAbstract { + private constructor Companion() + 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 Data { + public constructor Data() + 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 abstract class DerivedAbstract : C.Base { + public constructor DerivedAbstract() + 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 SomeIrrelevantInterface { + 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 +} diff --git a/compiler/testData/diagnostics/tests/cyclicHierarchy/withCompanion/withIrrelevantInterface.kt b/compiler/testData/diagnostics/tests/cyclicHierarchy/withCompanion/withIrrelevantInterface_before.kt similarity index 88% rename from compiler/testData/diagnostics/tests/cyclicHierarchy/withCompanion/withIrrelevantInterface.kt rename to compiler/testData/diagnostics/tests/cyclicHierarchy/withCompanion/withIrrelevantInterface_before.kt index 4b5a114b8e3..10030afa03a 100644 --- a/compiler/testData/diagnostics/tests/cyclicHierarchy/withCompanion/withIrrelevantInterface.kt +++ b/compiler/testData/diagnostics/tests/cyclicHierarchy/withCompanion/withIrrelevantInterface_before.kt @@ -1,3 +1,4 @@ +// !LANGUAGE: -ProhibitVisibilityOfNestedClassifiersFromSupertypesOfCompanion // see https://youtrack.jetbrains.com/issue/KT-21515 interface SomeIrrelevantInterface diff --git a/compiler/testData/diagnostics/tests/cyclicHierarchy/withCompanion/withIrrelevantInterface.txt b/compiler/testData/diagnostics/tests/cyclicHierarchy/withCompanion/withIrrelevantInterface_before.txt similarity index 100% rename from compiler/testData/diagnostics/tests/cyclicHierarchy/withCompanion/withIrrelevantInterface.txt rename to compiler/testData/diagnostics/tests/cyclicHierarchy/withCompanion/withIrrelevantInterface_before.txt diff --git a/compiler/testData/diagnostics/tests/cyclicHierarchy/withCompanion/withMembers_after.kt b/compiler/testData/diagnostics/tests/cyclicHierarchy/withCompanion/withMembers_after.kt new file mode 100644 index 00000000000..f73dccd3e5e --- /dev/null +++ b/compiler/testData/diagnostics/tests/cyclicHierarchy/withCompanion/withMembers_after.kt @@ -0,0 +1,58 @@ +// !LANGUAGE: +ProhibitVisibilityOfNestedClassifiersFromSupertypesOfCompanion +// see https://youtrack.jetbrains.com/issue/KT-21515 + +object WithFunctionInBase { + abstract class DerivedAbstract : C.Base() + + class Data + + public class C { + val data: Data = Data() + + open class Base() { + fun foo(): Int = 42 + } + + companion object : DerivedAbstract() + } +} + +object WithPropertyInBase { + // This case is very similar to previous one, but there are subtle differences from POV of implementation + + abstract class DerivedAbstract : C.Base() + + class Data + + public class C { + + open class Base() { + val foo: Int = 42 + } + + val data: Data = Data() + + companion object : DerivedAbstract() + } +} + +object WithPropertyInBaseDifferentOrder { + // This case is very similar to previous one, but there are subtle differences from POV of implementation + // Note how position of property in file affected order of resolve, and, consequently, its results and + // diagnostics. + + abstract class DerivedAbstract : C.Base() + + class Data + + public class C { + val data: Data = Data() + + open class Base() { + val foo: Int = 42 + + } + + companion object : DerivedAbstract() + } +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/cyclicHierarchy/withCompanion/withMembers_after.txt b/compiler/testData/diagnostics/tests/cyclicHierarchy/withCompanion/withMembers_after.txt new file mode 100644 index 00000000000..6cab9f911d5 --- /dev/null +++ b/compiler/testData/diagnostics/tests/cyclicHierarchy/withCompanion/withMembers_after.txt @@ -0,0 +1,139 @@ +package + +public object WithFunctionInBase { + private constructor WithFunctionInBase() + 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 C { + public constructor C() + public final val data: WithFunctionInBase.Data + 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 open class Base { + public constructor Base() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public final fun foo(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } + + public companion object Companion : WithFunctionInBase.DerivedAbstract { + private constructor Companion() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public final override /*1*/ /*fake_override*/ fun foo(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } + } + + public final class Data { + public constructor Data() + 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 abstract class DerivedAbstract : WithFunctionInBase.C.Base { + public constructor DerivedAbstract() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public final override /*1*/ /*fake_override*/ fun foo(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + } +} + +public object WithPropertyInBase { + private constructor WithPropertyInBase() + 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 C { + public constructor C() + public final val data: WithPropertyInBase.Data + 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 open class Base { + public constructor Base() + public final val foo: kotlin.Int = 42 + 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 companion object Companion : WithPropertyInBase.DerivedAbstract { + private constructor Companion() + public final override /*1*/ /*fake_override*/ val foo: 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 Data { + public constructor Data() + 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 abstract class DerivedAbstract : WithPropertyInBase.C.Base { + public constructor DerivedAbstract() + public final override /*1*/ /*fake_override*/ val foo: 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 WithPropertyInBaseDifferentOrder { + private constructor WithPropertyInBaseDifferentOrder() + 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 C { + public constructor C() + public final val data: WithPropertyInBaseDifferentOrder.Data + 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 open class Base { + public constructor Base() + public final val foo: kotlin.Int = 42 + 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 companion object Companion : WithPropertyInBaseDifferentOrder.DerivedAbstract { + private constructor Companion() + public final override /*1*/ /*fake_override*/ val foo: 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 Data { + public constructor Data() + 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 abstract class DerivedAbstract : WithPropertyInBaseDifferentOrder.C.Base { + public constructor DerivedAbstract() + public final override /*1*/ /*fake_override*/ val foo: 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 + } +} diff --git a/compiler/testData/diagnostics/tests/cyclicHierarchy/withCompanion/withMembers.kt b/compiler/testData/diagnostics/tests/cyclicHierarchy/withCompanion/withMembers_before.kt similarity index 96% rename from compiler/testData/diagnostics/tests/cyclicHierarchy/withCompanion/withMembers.kt rename to compiler/testData/diagnostics/tests/cyclicHierarchy/withCompanion/withMembers_before.kt index 8de24cb9cf3..6d93190c4a5 100644 --- a/compiler/testData/diagnostics/tests/cyclicHierarchy/withCompanion/withMembers.kt +++ b/compiler/testData/diagnostics/tests/cyclicHierarchy/withCompanion/withMembers_before.kt @@ -1,3 +1,4 @@ +// !LANGUAGE: -ProhibitVisibilityOfNestedClassifiersFromSupertypesOfCompanion // see https://youtrack.jetbrains.com/issue/KT-21515 object WithFunctionInBase { diff --git a/compiler/testData/diagnostics/tests/cyclicHierarchy/withCompanion/withMembers.txt b/compiler/testData/diagnostics/tests/cyclicHierarchy/withCompanion/withMembers_before.txt similarity index 100% rename from compiler/testData/diagnostics/tests/cyclicHierarchy/withCompanion/withMembers.txt rename to compiler/testData/diagnostics/tests/cyclicHierarchy/withCompanion/withMembers_before.txt diff --git a/compiler/testData/diagnostics/tests/enum/dontCreatePackageTypeForEnumEntry_after.kt b/compiler/testData/diagnostics/tests/enum/dontCreatePackageTypeForEnumEntry_after.kt new file mode 100644 index 00000000000..85ccb01c43e --- /dev/null +++ b/compiler/testData/diagnostics/tests/enum/dontCreatePackageTypeForEnumEntry_after.kt @@ -0,0 +1,16 @@ +// !LANGUAGE: +NestedClassesInEnumEntryShouldBeInner + +enum class E { + FIRST, + SECOND { + class A + }; +} + +val foo: Any.() -> Unit = {} + +fun f1() = E.FIRST.foo() +fun f2() = E.FIRST.(foo)() +fun f3() = E.SECOND.foo() +fun f4() = E.SECOND.(foo)() +fun f5() = E.SECOND.A() diff --git a/compiler/testData/diagnostics/tests/enum/dontCreatePackageTypeForEnumEntry.txt b/compiler/testData/diagnostics/tests/enum/dontCreatePackageTypeForEnumEntry_after.txt similarity index 100% rename from compiler/testData/diagnostics/tests/enum/dontCreatePackageTypeForEnumEntry.txt rename to compiler/testData/diagnostics/tests/enum/dontCreatePackageTypeForEnumEntry_after.txt diff --git a/compiler/testData/diagnostics/tests/enum/dontCreatePackageTypeForEnumEntry.kt b/compiler/testData/diagnostics/tests/enum/dontCreatePackageTypeForEnumEntry_before.kt similarity index 83% rename from compiler/testData/diagnostics/tests/enum/dontCreatePackageTypeForEnumEntry.kt rename to compiler/testData/diagnostics/tests/enum/dontCreatePackageTypeForEnumEntry_before.kt index 5d400cb6a73..97d18c53e8e 100644 --- a/compiler/testData/diagnostics/tests/enum/dontCreatePackageTypeForEnumEntry.kt +++ b/compiler/testData/diagnostics/tests/enum/dontCreatePackageTypeForEnumEntry_before.kt @@ -1,3 +1,5 @@ +// !LANGUAGE: -NestedClassesInEnumEntryShouldBeInner + enum class E { FIRST, SECOND { diff --git a/compiler/testData/diagnostics/tests/enum/dontCreatePackageTypeForEnumEntry_before.txt b/compiler/testData/diagnostics/tests/enum/dontCreatePackageTypeForEnumEntry_before.txt new file mode 100644 index 00000000000..49b2833c444 --- /dev/null +++ b/compiler/testData/diagnostics/tests/enum/dontCreatePackageTypeForEnumEntry_before.txt @@ -0,0 +1,29 @@ +package + +public val foo: kotlin.Any.() -> kotlin.Unit +public fun f1(): kotlin.Unit +public fun f2(): kotlin.Unit +public fun f3(): kotlin.Unit +public fun f4(): kotlin.Unit +public fun f5(): [ERROR : Error function type] + +public final enum class E : kotlin.Enum { + enum entry FIRST + + enum entry SECOND + + private constructor E() + public final override /*1*/ /*fake_override*/ val name: kotlin.String + public final override /*1*/ /*fake_override*/ val ordinal: kotlin.Int + protected final override /*1*/ /*fake_override*/ fun clone(): kotlin.Any + public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: E): kotlin.Int + public final override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + protected/*protected and package*/ final override /*1*/ /*fake_override*/ /*isHiddenForResolutionEverywhereBesideSupercalls*/ fun finalize(): kotlin.Unit + public final override /*1*/ /*fake_override*/ /*isHiddenForResolutionEverywhereBesideSupercalls*/ fun getDeclaringClass(): java.lang.Class! + public final override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + + // Static members + public final /*synthesized*/ fun valueOf(/*0*/ value: kotlin.String): E + public final /*synthesized*/ fun values(): kotlin.Array +} diff --git a/compiler/testData/diagnostics/tests/enum/inner/insideEnumEntry_after.kt b/compiler/testData/diagnostics/tests/enum/inner/insideEnumEntry_after.kt new file mode 100644 index 00000000000..c9029173db2 --- /dev/null +++ b/compiler/testData/diagnostics/tests/enum/inner/insideEnumEntry_after.kt @@ -0,0 +1,9 @@ +// !LANGUAGE: +NestedClassesInEnumEntryShouldBeInner + +enum class E { + ABC { + enum class F { + DEF + } + } +} diff --git a/compiler/testData/diagnostics/tests/enum/inner/insideEnumEntry.txt b/compiler/testData/diagnostics/tests/enum/inner/insideEnumEntry_after.txt similarity index 100% rename from compiler/testData/diagnostics/tests/enum/inner/insideEnumEntry.txt rename to compiler/testData/diagnostics/tests/enum/inner/insideEnumEntry_after.txt diff --git a/compiler/testData/diagnostics/tests/enum/inner/insideEnumEntry.kt b/compiler/testData/diagnostics/tests/enum/inner/insideEnumEntry_before.kt similarity index 67% rename from compiler/testData/diagnostics/tests/enum/inner/insideEnumEntry.kt rename to compiler/testData/diagnostics/tests/enum/inner/insideEnumEntry_before.kt index 259231b842a..299d3783354 100644 --- a/compiler/testData/diagnostics/tests/enum/inner/insideEnumEntry.kt +++ b/compiler/testData/diagnostics/tests/enum/inner/insideEnumEntry_before.kt @@ -1,3 +1,5 @@ +// !LANGUAGE: -NestedClassesInEnumEntryShouldBeInner + enum class E { ABC { enum class F { diff --git a/compiler/testData/diagnostics/tests/enum/inner/insideEnumEntry_before.txt b/compiler/testData/diagnostics/tests/enum/inner/insideEnumEntry_before.txt new file mode 100644 index 00000000000..e38f5953a46 --- /dev/null +++ b/compiler/testData/diagnostics/tests/enum/inner/insideEnumEntry_before.txt @@ -0,0 +1,20 @@ +package + +public final enum class E : kotlin.Enum { + enum entry ABC + + private constructor E() + public final override /*1*/ /*fake_override*/ val name: kotlin.String + public final override /*1*/ /*fake_override*/ val ordinal: kotlin.Int + protected final override /*1*/ /*fake_override*/ fun clone(): kotlin.Any + public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: E): kotlin.Int + public final override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + protected/*protected and package*/ final override /*1*/ /*fake_override*/ /*isHiddenForResolutionEverywhereBesideSupercalls*/ fun finalize(): kotlin.Unit + public final override /*1*/ /*fake_override*/ /*isHiddenForResolutionEverywhereBesideSupercalls*/ fun getDeclaringClass(): java.lang.Class! + public final override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + + // Static members + public final /*synthesized*/ fun valueOf(/*0*/ value: kotlin.String): E + public final /*synthesized*/ fun values(): kotlin.Array +} diff --git a/compiler/testData/diagnostics/tests/generics/innerClasses/implicitArguments/fromCompanionObject_after.kt b/compiler/testData/diagnostics/tests/generics/innerClasses/implicitArguments/fromCompanionObject_after.kt new file mode 100644 index 00000000000..79ae47ad23b --- /dev/null +++ b/compiler/testData/diagnostics/tests/generics/innerClasses/implicitArguments/fromCompanionObject_after.kt @@ -0,0 +1,22 @@ +// !LANGUAGE: +ProhibitVisibilityOfNestedClassifiersFromSupertypesOfCompanion +// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE +open class Outer { + inner class Inner + +} + +class Derived : Outer() { + // Inner here means Outer.Inner + fun foo(x: Inner) {} +} + +class A { + companion object : Outer() + + // Does not work, could be Outer.Inner + // TODO: Should work? + fun foo(x: Inner) { + // Inner() call use companion as implicit receiver + val y: Outer.Inner = Inner() + } +} diff --git a/compiler/testData/diagnostics/tests/generics/innerClasses/implicitArguments/fromCompanionObject_after.txt b/compiler/testData/diagnostics/tests/generics/innerClasses/implicitArguments/fromCompanionObject_after.txt new file mode 100644 index 00000000000..608739004b7 --- /dev/null +++ b/compiler/testData/diagnostics/tests/generics/innerClasses/implicitArguments/fromCompanionObject_after.txt @@ -0,0 +1,38 @@ +package + +public final class A { + public constructor A() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public final fun foo(/*0*/ x: [ERROR : Inner]): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + + public companion object Companion : Outer { + private constructor Companion() + 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 Derived : Outer { + public constructor Derived() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public final fun foo(/*0*/ x: Outer.Inner): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +public open class Outer { + public constructor Outer() + 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 inner class Inner /*captured type parameters: /*1*/ E*/ { + public constructor Inner() + 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 + } +} diff --git a/compiler/testData/diagnostics/tests/generics/innerClasses/implicitArguments/fromCompanionObject.kt b/compiler/testData/diagnostics/tests/generics/innerClasses/implicitArguments/fromCompanionObject_before.kt similarity index 88% rename from compiler/testData/diagnostics/tests/generics/innerClasses/implicitArguments/fromCompanionObject.kt rename to compiler/testData/diagnostics/tests/generics/innerClasses/implicitArguments/fromCompanionObject_before.kt index 21cd7627e58..a5049826b6f 100644 --- a/compiler/testData/diagnostics/tests/generics/innerClasses/implicitArguments/fromCompanionObject.kt +++ b/compiler/testData/diagnostics/tests/generics/innerClasses/implicitArguments/fromCompanionObject_before.kt @@ -1,3 +1,4 @@ +// !LANGUAGE: -ProhibitVisibilityOfNestedClassifiersFromSupertypesOfCompanion // !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE open class Outer { inner class Inner diff --git a/compiler/testData/diagnostics/tests/generics/innerClasses/implicitArguments/fromCompanionObject.txt b/compiler/testData/diagnostics/tests/generics/innerClasses/implicitArguments/fromCompanionObject_before.txt similarity index 100% rename from compiler/testData/diagnostics/tests/generics/innerClasses/implicitArguments/fromCompanionObject.txt rename to compiler/testData/diagnostics/tests/generics/innerClasses/implicitArguments/fromCompanionObject_before.txt diff --git a/compiler/testData/diagnostics/tests/inner/nestedClassNotAllowed_after.kt b/compiler/testData/diagnostics/tests/inner/nestedClassNotAllowed_after.kt new file mode 100644 index 00000000000..8d16e2aa03e --- /dev/null +++ b/compiler/testData/diagnostics/tests/inner/nestedClassNotAllowed_after.kt @@ -0,0 +1,26 @@ +// !LANGUAGE: +NestedClassesInEnumEntryShouldBeInner + +class A { + inner class B { + class C + } + + fun foo() { + class B { + class C + } + } +} + +fun foo() { + class B { + class C + } +} + + +enum class E { + E1 { + class D + } +} diff --git a/compiler/testData/diagnostics/tests/inner/nestedClassNotAllowed.txt b/compiler/testData/diagnostics/tests/inner/nestedClassNotAllowed_after.txt similarity index 100% rename from compiler/testData/diagnostics/tests/inner/nestedClassNotAllowed.txt rename to compiler/testData/diagnostics/tests/inner/nestedClassNotAllowed_after.txt diff --git a/compiler/testData/diagnostics/tests/inner/nestedClassNotAllowed.kt b/compiler/testData/diagnostics/tests/inner/nestedClassNotAllowed_before.kt similarity index 83% rename from compiler/testData/diagnostics/tests/inner/nestedClassNotAllowed.kt rename to compiler/testData/diagnostics/tests/inner/nestedClassNotAllowed_before.kt index 3642f922a3a..ce6d4138dbb 100644 --- a/compiler/testData/diagnostics/tests/inner/nestedClassNotAllowed.kt +++ b/compiler/testData/diagnostics/tests/inner/nestedClassNotAllowed_before.kt @@ -1,3 +1,5 @@ +// !LANGUAGE: -NestedClassesInEnumEntryShouldBeInner + class A { inner class B { class C @@ -19,7 +21,6 @@ fun foo() { enum class E { E1 { - // Not allowed in Java, but no reason to disallow in Kotlin class D } } diff --git a/compiler/testData/diagnostics/tests/inner/nestedClassNotAllowed_before.txt b/compiler/testData/diagnostics/tests/inner/nestedClassNotAllowed_before.txt new file mode 100644 index 00000000000..da19be04c4d --- /dev/null +++ b/compiler/testData/diagnostics/tests/inner/nestedClassNotAllowed_before.txt @@ -0,0 +1,44 @@ +package + +public fun foo(): kotlin.Unit + +public final class A { + public constructor A() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public 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 + + public final inner class B { + public constructor B() + 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 C { + public constructor C() + 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 enum class E : kotlin.Enum { + enum entry E1 + + private constructor E() + public final override /*1*/ /*fake_override*/ val name: kotlin.String + public final override /*1*/ /*fake_override*/ val ordinal: kotlin.Int + protected final override /*1*/ /*fake_override*/ fun clone(): kotlin.Any + public final override /*1*/ /*fake_override*/ fun compareTo(/*0*/ other: E): kotlin.Int + public final override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + protected/*protected and package*/ final override /*1*/ /*fake_override*/ /*isHiddenForResolutionEverywhereBesideSupercalls*/ fun finalize(): kotlin.Unit + public final override /*1*/ /*fake_override*/ /*isHiddenForResolutionEverywhereBesideSupercalls*/ fun getDeclaringClass(): java.lang.Class! + public final override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String + + // Static members + public final /*synthesized*/ fun valueOf(/*0*/ value: kotlin.String): E + public final /*synthesized*/ fun values(): kotlin.Array +} diff --git a/compiler/tests/org/jetbrains/kotlin/cfg/ControlFlowTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/cfg/ControlFlowTestGenerated.java index 4ef4b6f06a2..6a7373f7b33 100644 --- a/compiler/tests/org/jetbrains/kotlin/cfg/ControlFlowTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/cfg/ControlFlowTestGenerated.java @@ -222,9 +222,14 @@ public class ControlFlowTestGenerated extends AbstractControlFlowTest { runTest("compiler/testData/cfg/controlStructures/If.kt"); } - @TestMetadata("incorrectIndex.kt") - public void testIncorrectIndex() throws Exception { - runTest("compiler/testData/cfg/controlStructures/incorrectIndex.kt"); + @TestMetadata("incorrectIndex_After.kt") + public void testIncorrectIndex_After() throws Exception { + runTest("compiler/testData/cfg/controlStructures/incorrectIndex_After.kt"); + } + + @TestMetadata("incorrectIndex_Before.kt") + public void testIncorrectIndex_Before() throws Exception { + runTest("compiler/testData/cfg/controlStructures/incorrectIndex_Before.kt"); } @TestMetadata("InfiniteLoops.kt") @@ -318,9 +323,14 @@ public class ControlFlowTestGenerated extends AbstractControlFlowTest { runTest("compiler/testData/cfg/deadCode/DeadCode.kt"); } - @TestMetadata("notLocalReturn.kt") - public void testNotLocalReturn() throws Exception { - runTest("compiler/testData/cfg/deadCode/notLocalReturn.kt"); + @TestMetadata("notLocalReturn_after.kt") + public void testNotLocalReturn_after() throws Exception { + runTest("compiler/testData/cfg/deadCode/notLocalReturn_after.kt"); + } + + @TestMetadata("notLocalReturn_before.kt") + public void testNotLocalReturn_before() throws Exception { + runTest("compiler/testData/cfg/deadCode/notLocalReturn_before.kt"); } @TestMetadata("returnInElvis.kt") diff --git a/compiler/tests/org/jetbrains/kotlin/cfg/PseudoValueTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/cfg/PseudoValueTestGenerated.java index 4717d476c69..a0f660ff72c 100644 --- a/compiler/tests/org/jetbrains/kotlin/cfg/PseudoValueTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/cfg/PseudoValueTestGenerated.java @@ -222,9 +222,14 @@ public class PseudoValueTestGenerated extends AbstractPseudoValueTest { runTest("compiler/testData/cfg/controlStructures/If.kt"); } - @TestMetadata("incorrectIndex.kt") - public void testIncorrectIndex() throws Exception { - runTest("compiler/testData/cfg/controlStructures/incorrectIndex.kt"); + @TestMetadata("incorrectIndex_After.kt") + public void testIncorrectIndex_After() throws Exception { + runTest("compiler/testData/cfg/controlStructures/incorrectIndex_After.kt"); + } + + @TestMetadata("incorrectIndex_Before.kt") + public void testIncorrectIndex_Before() throws Exception { + runTest("compiler/testData/cfg/controlStructures/incorrectIndex_Before.kt"); } @TestMetadata("InfiniteLoops.kt") @@ -318,9 +323,14 @@ public class PseudoValueTestGenerated extends AbstractPseudoValueTest { runTest("compiler/testData/cfg/deadCode/DeadCode.kt"); } - @TestMetadata("notLocalReturn.kt") - public void testNotLocalReturn() throws Exception { - runTest("compiler/testData/cfg/deadCode/notLocalReturn.kt"); + @TestMetadata("notLocalReturn_after.kt") + public void testNotLocalReturn_after() throws Exception { + runTest("compiler/testData/cfg/deadCode/notLocalReturn_after.kt"); + } + + @TestMetadata("notLocalReturn_before.kt") + public void testNotLocalReturn_before() throws Exception { + runTest("compiler/testData/cfg/deadCode/notLocalReturn_before.kt"); } @TestMetadata("returnInElvis.kt") diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java index 8afed55a72f..6866a741c19 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java @@ -1568,14 +1568,14 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest { runTest("compiler/testData/diagnostics/tests/backingField/FieldOnVar.kt"); } - @TestMetadata("FieldReassignment.kt") - public void testFieldReassignment() throws Exception { - runTest("compiler/testData/diagnostics/tests/backingField/FieldReassignment.kt"); + @TestMetadata("FieldReassignment_after.kt") + public void testFieldReassignment_after() throws Exception { + runTest("compiler/testData/diagnostics/tests/backingField/FieldReassignment_after.kt"); } - @TestMetadata("FieldReassignmentError.kt") - public void testFieldReassignmentError() throws Exception { - runTest("compiler/testData/diagnostics/tests/backingField/FieldReassignmentError.kt"); + @TestMetadata("FieldReassignment_before.kt") + public void testFieldReassignment_before() throws Exception { + runTest("compiler/testData/diagnostics/tests/backingField/FieldReassignment_before.kt"); } @TestMetadata("FieldShadow.kt") @@ -3044,9 +3044,14 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest { runTest("compiler/testData/diagnostics/tests/classObjects/InnerClassAccessThroughClassObject.kt"); } - @TestMetadata("InnerClassAccessThroughEnum.kt") - public void testInnerClassAccessThroughEnum() throws Exception { - runTest("compiler/testData/diagnostics/tests/classObjects/InnerClassAccessThroughEnum.kt"); + @TestMetadata("InnerClassAccessThroughEnum_after.kt") + public void testInnerClassAccessThroughEnum_after() throws Exception { + runTest("compiler/testData/diagnostics/tests/classObjects/InnerClassAccessThroughEnum_after.kt"); + } + + @TestMetadata("InnerClassAccessThroughEnum_before.kt") + public void testInnerClassAccessThroughEnum_before() throws Exception { + runTest("compiler/testData/diagnostics/tests/classObjects/InnerClassAccessThroughEnum_before.kt"); } @TestMetadata("InnerClassClassObject.kt") @@ -3313,9 +3318,14 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest { runTest("compiler/testData/diagnostics/tests/controlFlowAnalysis/assignmentInLocalsInConstructor.kt"); } - @TestMetadata("backingFieldInsideGetter.kt") - public void testBackingFieldInsideGetter() throws Exception { - runTest("compiler/testData/diagnostics/tests/controlFlowAnalysis/backingFieldInsideGetter.kt"); + @TestMetadata("backingFieldInsideGetter_after.kt") + public void testBackingFieldInsideGetter_after() throws Exception { + runTest("compiler/testData/diagnostics/tests/controlFlowAnalysis/backingFieldInsideGetter_after.kt"); + } + + @TestMetadata("backingFieldInsideGetter_before.kt") + public void testBackingFieldInsideGetter_before() throws Exception { + runTest("compiler/testData/diagnostics/tests/controlFlowAnalysis/backingFieldInsideGetter_before.kt"); } @TestMetadata("breakContinueInTryFinally.kt") @@ -3408,9 +3418,14 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest { runTest("compiler/testData/diagnostics/tests/controlFlowAnalysis/initializationInLocalFun.kt"); } - @TestMetadata("initializationInLocalViaExplicitThis.kt") - public void testInitializationInLocalViaExplicitThis() throws Exception { - runTest("compiler/testData/diagnostics/tests/controlFlowAnalysis/initializationInLocalViaExplicitThis.kt"); + @TestMetadata("initializationInLocalViaExplicitThis_after.kt") + public void testInitializationInLocalViaExplicitThis_after() throws Exception { + runTest("compiler/testData/diagnostics/tests/controlFlowAnalysis/initializationInLocalViaExplicitThis_after.kt"); + } + + @TestMetadata("initializationInLocalViaExplicitThis_before.kt") + public void testInitializationInLocalViaExplicitThis_before() throws Exception { + runTest("compiler/testData/diagnostics/tests/controlFlowAnalysis/initializationInLocalViaExplicitThis_before.kt"); } @TestMetadata("kt1001.kt") @@ -4250,19 +4265,34 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest { KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/diagnostics/tests/cyclicHierarchy/withCompanion"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true); } - @TestMetadata("everythingInOneScope.kt") - public void testEverythingInOneScope() throws Exception { - runTest("compiler/testData/diagnostics/tests/cyclicHierarchy/withCompanion/everythingInOneScope.kt"); + @TestMetadata("everythingInOneScope_after.kt") + public void testEverythingInOneScope_after() throws Exception { + runTest("compiler/testData/diagnostics/tests/cyclicHierarchy/withCompanion/everythingInOneScope_after.kt"); } - @TestMetadata("noMembers.kt") - public void testNoMembers() throws Exception { - runTest("compiler/testData/diagnostics/tests/cyclicHierarchy/withCompanion/noMembers.kt"); + @TestMetadata("everythingInOneScope_before.kt") + public void testEverythingInOneScope_before() throws Exception { + runTest("compiler/testData/diagnostics/tests/cyclicHierarchy/withCompanion/everythingInOneScope_before.kt"); } - @TestMetadata("onlyInterfaces.kt") - public void testOnlyInterfaces() throws Exception { - runTest("compiler/testData/diagnostics/tests/cyclicHierarchy/withCompanion/onlyInterfaces.kt"); + @TestMetadata("noMembers_after.kt") + public void testNoMembers_after() throws Exception { + runTest("compiler/testData/diagnostics/tests/cyclicHierarchy/withCompanion/noMembers_after.kt"); + } + + @TestMetadata("noMembers_before.kt") + public void testNoMembers_before() throws Exception { + runTest("compiler/testData/diagnostics/tests/cyclicHierarchy/withCompanion/noMembers_before.kt"); + } + + @TestMetadata("onlyInterfaces_after.kt") + public void testOnlyInterfaces_after() throws Exception { + runTest("compiler/testData/diagnostics/tests/cyclicHierarchy/withCompanion/onlyInterfaces_after.kt"); + } + + @TestMetadata("onlyInterfaces_before.kt") + public void testOnlyInterfaces_before() throws Exception { + runTest("compiler/testData/diagnostics/tests/cyclicHierarchy/withCompanion/onlyInterfaces_before.kt"); } @TestMetadata("typeIsLowEnough.kt") @@ -4270,14 +4300,24 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest { runTest("compiler/testData/diagnostics/tests/cyclicHierarchy/withCompanion/typeIsLowEnough.kt"); } - @TestMetadata("withIrrelevantInterface.kt") - public void testWithIrrelevantInterface() throws Exception { - runTest("compiler/testData/diagnostics/tests/cyclicHierarchy/withCompanion/withIrrelevantInterface.kt"); + @TestMetadata("withIrrelevantInterface_after.kt") + public void testWithIrrelevantInterface_after() throws Exception { + runTest("compiler/testData/diagnostics/tests/cyclicHierarchy/withCompanion/withIrrelevantInterface_after.kt"); } - @TestMetadata("withMembers.kt") - public void testWithMembers() throws Exception { - runTest("compiler/testData/diagnostics/tests/cyclicHierarchy/withCompanion/withMembers.kt"); + @TestMetadata("withIrrelevantInterface_before.kt") + public void testWithIrrelevantInterface_before() throws Exception { + runTest("compiler/testData/diagnostics/tests/cyclicHierarchy/withCompanion/withIrrelevantInterface_before.kt"); + } + + @TestMetadata("withMembers_after.kt") + public void testWithMembers_after() throws Exception { + runTest("compiler/testData/diagnostics/tests/cyclicHierarchy/withCompanion/withMembers_after.kt"); + } + + @TestMetadata("withMembers_before.kt") + public void testWithMembers_before() throws Exception { + runTest("compiler/testData/diagnostics/tests/cyclicHierarchy/withCompanion/withMembers_before.kt"); } @TestMetadata("withoutTypeReference.kt") @@ -6647,9 +6687,14 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest { runTest("compiler/testData/diagnostics/tests/enum/constructorWithDefaultParametersOnly.kt"); } - @TestMetadata("dontCreatePackageTypeForEnumEntry.kt") - public void testDontCreatePackageTypeForEnumEntry() throws Exception { - runTest("compiler/testData/diagnostics/tests/enum/dontCreatePackageTypeForEnumEntry.kt"); + @TestMetadata("dontCreatePackageTypeForEnumEntry_after.kt") + public void testDontCreatePackageTypeForEnumEntry_after() throws Exception { + runTest("compiler/testData/diagnostics/tests/enum/dontCreatePackageTypeForEnumEntry_after.kt"); + } + + @TestMetadata("dontCreatePackageTypeForEnumEntry_before.kt") + public void testDontCreatePackageTypeForEnumEntry_before() throws Exception { + runTest("compiler/testData/diagnostics/tests/enum/dontCreatePackageTypeForEnumEntry_before.kt"); } @TestMetadata("emptyConstructor.kt") @@ -6904,9 +6949,14 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest { runTest("compiler/testData/diagnostics/tests/enum/inner/insideEnum.kt"); } - @TestMetadata("insideEnumEntry.kt") - public void testInsideEnumEntry() throws Exception { - runTest("compiler/testData/diagnostics/tests/enum/inner/insideEnumEntry.kt"); + @TestMetadata("insideEnumEntry_after.kt") + public void testInsideEnumEntry_after() throws Exception { + runTest("compiler/testData/diagnostics/tests/enum/inner/insideEnumEntry_after.kt"); + } + + @TestMetadata("insideEnumEntry_before.kt") + public void testInsideEnumEntry_before() throws Exception { + runTest("compiler/testData/diagnostics/tests/enum/inner/insideEnumEntry_before.kt"); } @TestMetadata("insideInnerClassNotAllowed.kt") @@ -8127,9 +8177,14 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest { KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/diagnostics/tests/generics/innerClasses/implicitArguments"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true); } - @TestMetadata("fromCompanionObject.kt") - public void testFromCompanionObject() throws Exception { - runTest("compiler/testData/diagnostics/tests/generics/innerClasses/implicitArguments/fromCompanionObject.kt"); + @TestMetadata("fromCompanionObject_after.kt") + public void testFromCompanionObject_after() throws Exception { + runTest("compiler/testData/diagnostics/tests/generics/innerClasses/implicitArguments/fromCompanionObject_after.kt"); + } + + @TestMetadata("fromCompanionObject_before.kt") + public void testFromCompanionObject_before() throws Exception { + runTest("compiler/testData/diagnostics/tests/generics/innerClasses/implicitArguments/fromCompanionObject_before.kt"); } @TestMetadata("fromOuterClassInObjectLiteral.kt") @@ -10964,9 +11019,14 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest { runTest("compiler/testData/diagnostics/tests/inner/nestedClassInObject.kt"); } - @TestMetadata("nestedClassNotAllowed.kt") - public void testNestedClassNotAllowed() throws Exception { - runTest("compiler/testData/diagnostics/tests/inner/nestedClassNotAllowed.kt"); + @TestMetadata("nestedClassNotAllowed_after.kt") + public void testNestedClassNotAllowed_after() throws Exception { + runTest("compiler/testData/diagnostics/tests/inner/nestedClassNotAllowed_after.kt"); + } + + @TestMetadata("nestedClassNotAllowed_before.kt") + public void testNestedClassNotAllowed_before() throws Exception { + runTest("compiler/testData/diagnostics/tests/inner/nestedClassNotAllowed_before.kt"); } @TestMetadata("nestedObject.kt") diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsUsingJavacTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsUsingJavacTestGenerated.java index 637c4fb2f13..2b4ade1eb6b 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsUsingJavacTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsUsingJavacTestGenerated.java @@ -1568,14 +1568,14 @@ public class DiagnosticsUsingJavacTestGenerated extends AbstractDiagnosticsUsing runTest("compiler/testData/diagnostics/tests/backingField/FieldOnVar.kt"); } - @TestMetadata("FieldReassignment.kt") - public void testFieldReassignment() throws Exception { - runTest("compiler/testData/diagnostics/tests/backingField/FieldReassignment.kt"); + @TestMetadata("FieldReassignment_after.kt") + public void testFieldReassignment_after() throws Exception { + runTest("compiler/testData/diagnostics/tests/backingField/FieldReassignment_after.kt"); } - @TestMetadata("FieldReassignmentError.kt") - public void testFieldReassignmentError() throws Exception { - runTest("compiler/testData/diagnostics/tests/backingField/FieldReassignmentError.kt"); + @TestMetadata("FieldReassignment_before.kt") + public void testFieldReassignment_before() throws Exception { + runTest("compiler/testData/diagnostics/tests/backingField/FieldReassignment_before.kt"); } @TestMetadata("FieldShadow.kt") @@ -3044,9 +3044,14 @@ public class DiagnosticsUsingJavacTestGenerated extends AbstractDiagnosticsUsing runTest("compiler/testData/diagnostics/tests/classObjects/InnerClassAccessThroughClassObject.kt"); } - @TestMetadata("InnerClassAccessThroughEnum.kt") - public void testInnerClassAccessThroughEnum() throws Exception { - runTest("compiler/testData/diagnostics/tests/classObjects/InnerClassAccessThroughEnum.kt"); + @TestMetadata("InnerClassAccessThroughEnum_after.kt") + public void testInnerClassAccessThroughEnum_after() throws Exception { + runTest("compiler/testData/diagnostics/tests/classObjects/InnerClassAccessThroughEnum_after.kt"); + } + + @TestMetadata("InnerClassAccessThroughEnum_before.kt") + public void testInnerClassAccessThroughEnum_before() throws Exception { + runTest("compiler/testData/diagnostics/tests/classObjects/InnerClassAccessThroughEnum_before.kt"); } @TestMetadata("InnerClassClassObject.kt") @@ -3313,9 +3318,14 @@ public class DiagnosticsUsingJavacTestGenerated extends AbstractDiagnosticsUsing runTest("compiler/testData/diagnostics/tests/controlFlowAnalysis/assignmentInLocalsInConstructor.kt"); } - @TestMetadata("backingFieldInsideGetter.kt") - public void testBackingFieldInsideGetter() throws Exception { - runTest("compiler/testData/diagnostics/tests/controlFlowAnalysis/backingFieldInsideGetter.kt"); + @TestMetadata("backingFieldInsideGetter_after.kt") + public void testBackingFieldInsideGetter_after() throws Exception { + runTest("compiler/testData/diagnostics/tests/controlFlowAnalysis/backingFieldInsideGetter_after.kt"); + } + + @TestMetadata("backingFieldInsideGetter_before.kt") + public void testBackingFieldInsideGetter_before() throws Exception { + runTest("compiler/testData/diagnostics/tests/controlFlowAnalysis/backingFieldInsideGetter_before.kt"); } @TestMetadata("breakContinueInTryFinally.kt") @@ -3408,9 +3418,14 @@ public class DiagnosticsUsingJavacTestGenerated extends AbstractDiagnosticsUsing runTest("compiler/testData/diagnostics/tests/controlFlowAnalysis/initializationInLocalFun.kt"); } - @TestMetadata("initializationInLocalViaExplicitThis.kt") - public void testInitializationInLocalViaExplicitThis() throws Exception { - runTest("compiler/testData/diagnostics/tests/controlFlowAnalysis/initializationInLocalViaExplicitThis.kt"); + @TestMetadata("initializationInLocalViaExplicitThis_after.kt") + public void testInitializationInLocalViaExplicitThis_after() throws Exception { + runTest("compiler/testData/diagnostics/tests/controlFlowAnalysis/initializationInLocalViaExplicitThis_after.kt"); + } + + @TestMetadata("initializationInLocalViaExplicitThis_before.kt") + public void testInitializationInLocalViaExplicitThis_before() throws Exception { + runTest("compiler/testData/diagnostics/tests/controlFlowAnalysis/initializationInLocalViaExplicitThis_before.kt"); } @TestMetadata("kt1001.kt") @@ -4250,19 +4265,34 @@ public class DiagnosticsUsingJavacTestGenerated extends AbstractDiagnosticsUsing KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/diagnostics/tests/cyclicHierarchy/withCompanion"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true); } - @TestMetadata("everythingInOneScope.kt") - public void testEverythingInOneScope() throws Exception { - runTest("compiler/testData/diagnostics/tests/cyclicHierarchy/withCompanion/everythingInOneScope.kt"); + @TestMetadata("everythingInOneScope_after.kt") + public void testEverythingInOneScope_after() throws Exception { + runTest("compiler/testData/diagnostics/tests/cyclicHierarchy/withCompanion/everythingInOneScope_after.kt"); } - @TestMetadata("noMembers.kt") - public void testNoMembers() throws Exception { - runTest("compiler/testData/diagnostics/tests/cyclicHierarchy/withCompanion/noMembers.kt"); + @TestMetadata("everythingInOneScope_before.kt") + public void testEverythingInOneScope_before() throws Exception { + runTest("compiler/testData/diagnostics/tests/cyclicHierarchy/withCompanion/everythingInOneScope_before.kt"); } - @TestMetadata("onlyInterfaces.kt") - public void testOnlyInterfaces() throws Exception { - runTest("compiler/testData/diagnostics/tests/cyclicHierarchy/withCompanion/onlyInterfaces.kt"); + @TestMetadata("noMembers_after.kt") + public void testNoMembers_after() throws Exception { + runTest("compiler/testData/diagnostics/tests/cyclicHierarchy/withCompanion/noMembers_after.kt"); + } + + @TestMetadata("noMembers_before.kt") + public void testNoMembers_before() throws Exception { + runTest("compiler/testData/diagnostics/tests/cyclicHierarchy/withCompanion/noMembers_before.kt"); + } + + @TestMetadata("onlyInterfaces_after.kt") + public void testOnlyInterfaces_after() throws Exception { + runTest("compiler/testData/diagnostics/tests/cyclicHierarchy/withCompanion/onlyInterfaces_after.kt"); + } + + @TestMetadata("onlyInterfaces_before.kt") + public void testOnlyInterfaces_before() throws Exception { + runTest("compiler/testData/diagnostics/tests/cyclicHierarchy/withCompanion/onlyInterfaces_before.kt"); } @TestMetadata("typeIsLowEnough.kt") @@ -4270,14 +4300,24 @@ public class DiagnosticsUsingJavacTestGenerated extends AbstractDiagnosticsUsing runTest("compiler/testData/diagnostics/tests/cyclicHierarchy/withCompanion/typeIsLowEnough.kt"); } - @TestMetadata("withIrrelevantInterface.kt") - public void testWithIrrelevantInterface() throws Exception { - runTest("compiler/testData/diagnostics/tests/cyclicHierarchy/withCompanion/withIrrelevantInterface.kt"); + @TestMetadata("withIrrelevantInterface_after.kt") + public void testWithIrrelevantInterface_after() throws Exception { + runTest("compiler/testData/diagnostics/tests/cyclicHierarchy/withCompanion/withIrrelevantInterface_after.kt"); } - @TestMetadata("withMembers.kt") - public void testWithMembers() throws Exception { - runTest("compiler/testData/diagnostics/tests/cyclicHierarchy/withCompanion/withMembers.kt"); + @TestMetadata("withIrrelevantInterface_before.kt") + public void testWithIrrelevantInterface_before() throws Exception { + runTest("compiler/testData/diagnostics/tests/cyclicHierarchy/withCompanion/withIrrelevantInterface_before.kt"); + } + + @TestMetadata("withMembers_after.kt") + public void testWithMembers_after() throws Exception { + runTest("compiler/testData/diagnostics/tests/cyclicHierarchy/withCompanion/withMembers_after.kt"); + } + + @TestMetadata("withMembers_before.kt") + public void testWithMembers_before() throws Exception { + runTest("compiler/testData/diagnostics/tests/cyclicHierarchy/withCompanion/withMembers_before.kt"); } @TestMetadata("withoutTypeReference.kt") @@ -6647,9 +6687,14 @@ public class DiagnosticsUsingJavacTestGenerated extends AbstractDiagnosticsUsing runTest("compiler/testData/diagnostics/tests/enum/constructorWithDefaultParametersOnly.kt"); } - @TestMetadata("dontCreatePackageTypeForEnumEntry.kt") - public void testDontCreatePackageTypeForEnumEntry() throws Exception { - runTest("compiler/testData/diagnostics/tests/enum/dontCreatePackageTypeForEnumEntry.kt"); + @TestMetadata("dontCreatePackageTypeForEnumEntry_after.kt") + public void testDontCreatePackageTypeForEnumEntry_after() throws Exception { + runTest("compiler/testData/diagnostics/tests/enum/dontCreatePackageTypeForEnumEntry_after.kt"); + } + + @TestMetadata("dontCreatePackageTypeForEnumEntry_before.kt") + public void testDontCreatePackageTypeForEnumEntry_before() throws Exception { + runTest("compiler/testData/diagnostics/tests/enum/dontCreatePackageTypeForEnumEntry_before.kt"); } @TestMetadata("emptyConstructor.kt") @@ -6904,9 +6949,14 @@ public class DiagnosticsUsingJavacTestGenerated extends AbstractDiagnosticsUsing runTest("compiler/testData/diagnostics/tests/enum/inner/insideEnum.kt"); } - @TestMetadata("insideEnumEntry.kt") - public void testInsideEnumEntry() throws Exception { - runTest("compiler/testData/diagnostics/tests/enum/inner/insideEnumEntry.kt"); + @TestMetadata("insideEnumEntry_after.kt") + public void testInsideEnumEntry_after() throws Exception { + runTest("compiler/testData/diagnostics/tests/enum/inner/insideEnumEntry_after.kt"); + } + + @TestMetadata("insideEnumEntry_before.kt") + public void testInsideEnumEntry_before() throws Exception { + runTest("compiler/testData/diagnostics/tests/enum/inner/insideEnumEntry_before.kt"); } @TestMetadata("insideInnerClassNotAllowed.kt") @@ -8127,9 +8177,14 @@ public class DiagnosticsUsingJavacTestGenerated extends AbstractDiagnosticsUsing KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/diagnostics/tests/generics/innerClasses/implicitArguments"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true); } - @TestMetadata("fromCompanionObject.kt") - public void testFromCompanionObject() throws Exception { - runTest("compiler/testData/diagnostics/tests/generics/innerClasses/implicitArguments/fromCompanionObject.kt"); + @TestMetadata("fromCompanionObject_after.kt") + public void testFromCompanionObject_after() throws Exception { + runTest("compiler/testData/diagnostics/tests/generics/innerClasses/implicitArguments/fromCompanionObject_after.kt"); + } + + @TestMetadata("fromCompanionObject_before.kt") + public void testFromCompanionObject_before() throws Exception { + runTest("compiler/testData/diagnostics/tests/generics/innerClasses/implicitArguments/fromCompanionObject_before.kt"); } @TestMetadata("fromOuterClassInObjectLiteral.kt") @@ -10964,9 +11019,14 @@ public class DiagnosticsUsingJavacTestGenerated extends AbstractDiagnosticsUsing runTest("compiler/testData/diagnostics/tests/inner/nestedClassInObject.kt"); } - @TestMetadata("nestedClassNotAllowed.kt") - public void testNestedClassNotAllowed() throws Exception { - runTest("compiler/testData/diagnostics/tests/inner/nestedClassNotAllowed.kt"); + @TestMetadata("nestedClassNotAllowed_after.kt") + public void testNestedClassNotAllowed_after() throws Exception { + runTest("compiler/testData/diagnostics/tests/inner/nestedClassNotAllowed_after.kt"); + } + + @TestMetadata("nestedClassNotAllowed_before.kt") + public void testNestedClassNotAllowed_before() throws Exception { + runTest("compiler/testData/diagnostics/tests/inner/nestedClassNotAllowed_before.kt"); } @TestMetadata("nestedObject.kt")