diff --git a/compiler/frontend/src/org/jetbrains/jet/checkers/CheckerTestUtil.java b/compiler/frontend/src/org/jetbrains/jet/checkers/CheckerTestUtil.java index 1ec4ebddbcd..1ea243434dd 100644 --- a/compiler/frontend/src/org/jetbrains/jet/checkers/CheckerTestUtil.java +++ b/compiler/frontend/src/org/jetbrains/jet/checkers/CheckerTestUtil.java @@ -28,9 +28,11 @@ import org.jetbrains.annotations.NotNull; import org.jetbrains.jet.lang.diagnostics.Diagnostic; import org.jetbrains.jet.lang.diagnostics.DiagnosticFactory; import org.jetbrains.jet.lang.diagnostics.Severity; +import org.jetbrains.jet.lang.psi.JetExpression; import org.jetbrains.jet.lang.psi.JetReferenceExpression; import org.jetbrains.jet.lang.resolve.AnalyzingUtils; import org.jetbrains.jet.lang.resolve.BindingContext; +import org.jetbrains.jet.lang.types.JetType; import java.util.*; import java.util.regex.Matcher; @@ -104,6 +106,13 @@ public class CheckerTestUtil { debugAnnotations.add(new DebugInfoDiagnostic(expression, factory)); } }); + // this code is used in tests and in internal action 'copy current file as diagnostic test' + //noinspection TestOnlyProblems + for (JetExpression expression : bindingContext.getSliceContents(BindingContext.AUTOCAST).keySet()) { + if (PsiTreeUtil.isAncestor(root, expression, false)) { + debugAnnotations.add(new DebugInfoDiagnostic(expression, DebugInfoDiagnosticFactory.AUTOCAST)); + } + } return debugAnnotations; } @@ -389,16 +398,21 @@ public class CheckerTestUtil { } public static class DebugInfoDiagnosticFactory extends DiagnosticFactory { + public static final DebugInfoDiagnosticFactory AUTOCAST = new DebugInfoDiagnosticFactory("AUTOCAST"); public static final DebugInfoDiagnosticFactory ELEMENT_WITH_ERROR_TYPE = new DebugInfoDiagnosticFactory("ELEMENT_WITH_ERROR_TYPE"); public static final DebugInfoDiagnosticFactory UNRESOLVED_WITH_TARGET = new DebugInfoDiagnosticFactory("UNRESOLVED_WITH_TARGET"); public static final DebugInfoDiagnosticFactory MISSING_UNRESOLVED = new DebugInfoDiagnosticFactory("MISSING_UNRESOLVED"); private final String name; - private DebugInfoDiagnosticFactory(String name) { - super(Severity.ERROR); + private DebugInfoDiagnosticFactory(String name, Severity severity) { + super(severity); this.name = name; } + private DebugInfoDiagnosticFactory(String name) { + this(name, Severity.ERROR); + } + @NotNull @Override public String getName() { @@ -407,7 +421,7 @@ public class CheckerTestUtil { } public static class DebugInfoDiagnostic extends AbstractDiagnosticForTests { - public DebugInfoDiagnostic(@NotNull JetReferenceExpression reference, @NotNull DebugInfoDiagnosticFactory factory) { + public DebugInfoDiagnostic(@NotNull JetExpression reference, @NotNull DebugInfoDiagnosticFactory factory) { super(reference, factory); } } diff --git a/compiler/testData/diagnostics/tests/AutocastsForStableIdentifiers.kt b/compiler/testData/diagnostics/tests/AutocastsForStableIdentifiers.kt index 2e0aa61f5ba..5d75540f81b 100644 --- a/compiler/testData/diagnostics/tests/AutocastsForStableIdentifiers.kt +++ b/compiler/testData/diagnostics/tests/AutocastsForStableIdentifiers.kt @@ -1,6 +1,6 @@ // FILE: a.kt package example.ns - val y : Any? = 2 +val y : Any? = 2 // FILE: b.kt package example @@ -20,53 +20,53 @@ val x : Any? = 1 fun Any?.vars(a: Any?) : Int { var b: Int = 0 if (ns.y is Int) { - b = ns.y + b = ns.y } if (ns.y is Int) { - b = example.ns.y + b = example.ns.y } if (example.ns.y is Int) { - b = ns.y + b = ns.y } if (example.ns.y is Int) { - b = example.ns.y + b = example.ns.y } // if (namespace.bottles.ns.y is Int) { // b = ns.y // } if (Obj.y is Int) { - b = Obj.y + b = Obj.y } if (example.Obj.y is Int) { - b = Obj.y + b = Obj.y } if (AClass.y is Int) { - b = AClass.y + b = AClass.y } if (example.AClass.y is Int) { - b = AClass.y + b = AClass.y } if (x is Int) { - b = x + b = x } if (example.x is Int) { - b = x + b = x } if (example.x is Int) { - b = example.x + b = example.x } return 1 } fun Any?.foo() : Int { if (this is Int) - return this + return this if (this@foo is Int) - return this + return this if (this@foo is Int) - return this@foo + return this@foo if (this is Int) - return this@foo + return this@foo return 1 } @@ -77,16 +77,16 @@ open class C { fun foo() { var t : T? = null if (this is T) { - t = this + t = this } if (this is T) { - t = this@C + t = this@C } if (this@C is T) { - t = this + t = this } if (this@C is T) { - t = this@C + t = this@C } } -} +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/BreakContinue.kt b/compiler/testData/diagnostics/tests/BreakContinue.kt index ba2ada76655..6d5d0f6c44b 100644 --- a/compiler/testData/diagnostics/tests/BreakContinue.kt +++ b/compiler/testData/diagnostics/tests/BreakContinue.kt @@ -38,7 +38,7 @@ class C { break; } } - a.compareTo("2") + a.compareTo("2") } fun containsBreakWithLabel(a: String?) { @@ -52,7 +52,7 @@ class C { @loop while(a == null) { break@label } - a.compareTo("2") + a.compareTo("2") } fun containsBreakToOuterLoop(a: String?, b: String?) { @@ -60,7 +60,7 @@ class C { while(a == null) { break@loop } - a.compareTo("2") + a.compareTo("2") } } diff --git a/compiler/testData/diagnostics/tests/Builders.kt b/compiler/testData/diagnostics/tests/Builders.kt index f5979bded5b..80abb8d8b97 100644 --- a/compiler/testData/diagnostics/tests/Builders.kt +++ b/compiler/testData/diagnostics/tests/Builders.kt @@ -135,7 +135,7 @@ class A() : BodyTag("a") { get() = attributes["href"] set(value) { if (value != null) { - attributes.put("href", value) + attributes.put("href", value) // attributes["href"] = value //doesn't work: KT-1355 } } diff --git a/compiler/testData/diagnostics/tests/InferNullabilityInThenBlock.kt b/compiler/testData/diagnostics/tests/InferNullabilityInThenBlock.kt index ccc21f8c95d..07888c114a6 100644 --- a/compiler/testData/diagnostics/tests/InferNullabilityInThenBlock.kt +++ b/compiler/testData/diagnostics/tests/InferNullabilityInThenBlock.kt @@ -4,6 +4,6 @@ fun gg() { val a: String? = "" if (a != null) { - ff(a) + ff(a) } } diff --git a/compiler/testData/diagnostics/tests/MergePackagesWithJava.kt b/compiler/testData/diagnostics/tests/MergePackagesWithJava.kt index 4e4ddf6eec3..bb792477ae9 100644 --- a/compiler/testData/diagnostics/tests/MergePackagesWithJava.kt +++ b/compiler/testData/diagnostics/tests/MergePackagesWithJava.kt @@ -5,4 +5,4 @@ package java val c : lang.Class<*>? = null -val Array?.length : Int get() = if (this != null) this.size else throw NullPointerException() +val Array?.length : Int get() = if (this != null) this.size else throw NullPointerException() \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/Nullability.kt b/compiler/testData/diagnostics/tests/Nullability.kt index ef418de3b99..b2d1e26221f 100644 --- a/compiler/testData/diagnostics/tests/Nullability.kt +++ b/compiler/testData/diagnostics/tests/Nullability.kt @@ -1,7 +1,7 @@ fun test() { val a : Int? = 0 if (a != null) { - a.plus(1) + a.plus(1) } else { a?.plus(1) @@ -14,122 +14,131 @@ fun test() { ins?.read() if (ins != null) { - ins.read() + ins.read() out?.println() if (out != null) { - ins.read(); - out.println(); + ins.read(); + out.println(); } } if (out != null && ins != null) { - ins.read(); - out.println(); + ins.read(); + out.println(); } if (out == null) { out?.println() } else { - out.println() + out.println() } if (out != null && ins != null || out != null) { ins?.read(); - out.println(); + ins.read(); + out.println(); } - if (out == null || out.println(0) == Unit.VALUE) { + if (out == null || out.println(0) == Unit.VALUE) { out?.println(1) + out.println(1) } else { - out.println(2) + out.println(2) } - if (out != null && out.println() == Unit.VALUE) { - out.println(); + if (out != null && out.println() == Unit.VALUE) { + out.println(); } else { out?.println(); } - if (out == null || out.println() == Unit.VALUE) { + if (out == null || out.println() == Unit.VALUE) { out?.println(); } else { - out.println(); + out.println(); } - if (1 == 2 || out != null && out.println(1) == Unit.VALUE) { + if (1 == 2 || out != null && out.println(1) == Unit.VALUE) { out?.println(2); + out.println(2); } else { out?.println(3) + out.println(3) } out?.println() ins?.read() if (ins != null) { - ins.read() + ins.read() out?.println() if (out != null) { - ins.read(); - out.println(); + ins.read(); + out.println(); } } if (out != null && ins != null) { - ins.read(); - out.println(); + ins.read(); + out.println(); } if (out == null) { out?.println() } else { - out.println() + out.println() } if (out != null && ins != null || out != null) { ins?.read(); - out.println(); + out.println(); } - if (out == null || out.println(0) == Unit.VALUE) { + if (out == null || out.println(0) == Unit.VALUE) { out?.println(1) + out.println(1) } else { - out.println(2) + out.println(2) } - if (out != null && out.println() == Unit.VALUE) { - out.println(); + if (out != null && out.println() == Unit.VALUE) { + out.println(); } else { out?.println(); + out.println(); } - if (out == null || out.println() == Unit.VALUE) { + if (out == null || out.println() == Unit.VALUE) { out?.println(); + out.println(); } else { - out.println(); + out.println(); } - if (1 == 2 || out != null && out.println(1) == Unit.VALUE) { + if (1 == 2 || out != null && out.println(1) == Unit.VALUE) { out?.println(2); + out.println(2); } else { out?.println(3) + out.println(3) } if (1 > 2) { if (out == null) return; - out.println(); + out.println(); } out?.println(); while (out != null) { - out.println(); + out.println(); } out?.println(); @@ -137,16 +146,18 @@ fun test() { while (out2 == null) { out2?.println(); + out2.println(); } - out2.println() + out2.println() } fun f(out : String?) { out?.get(0) + out.get(0) if (out != null) else return; - out.get(0) + out.get(0) } fun f1(out : String?) { @@ -155,7 +166,7 @@ fun f1(out : String?) { 1 + 2 return; } - out.get(0) + out.get(0) } fun f2(out : String?) { @@ -164,7 +175,7 @@ fun f2(out : String?) { 1 + 2 return; } - out.get(0) + out.get(0) } fun f3(out : String?) { @@ -176,25 +187,25 @@ fun f3(out : String?) { else { 1 + 2 } - out.get(0) + out.get(0) } fun f4(s : String?) { s?.get(0) while (1 < 2 && s != null) { - s.get(0) + s.get(0) } s?.get(0) while (s == null || 1 < 2) { s?.get(0) } - s.get(0) + s.get(0) } fun f5(s : String?) { s?.get(0) while (1 < 2 && s != null) { - s.get(0) + s.get(0) } s?.get(0) while (s == null || 1 < 2) { @@ -214,24 +225,24 @@ fun f6(s : String?) { do { s?.get(0) } while (s == null) - s.get(0) + s.get(0) } fun f7(s : String?, t : String?) { s?.get(0) if (!(s == null)) { - s.get(0) + s.get(0) } s?.get(0) if (!(s != null)) { s?.get(0) } else { - s.get(0) + s.get(0) } s?.get(0) if (!!(s != null)) { - s.get(0) + s.get(0) } else { s?.get(0) @@ -239,8 +250,8 @@ fun f7(s : String?, t : String?) { s?.get(0) t?.get(0) if (!(s == null || t == null)) { - s.get(0) - t.get(0) + s.get(0) + t.get(0) } else { s?.get(0) @@ -249,7 +260,7 @@ fun f7(s : String?, t : String?) { s?.get(0) t?.get(0) if (!(s == null)) { - s.get(0) + s.get(0) t?.get(0) } else { @@ -261,22 +272,22 @@ fun f7(s : String?, t : String?) { fun f8(b : String?, a : String) { b?.get(0) if (b == a) { - b.get(0); + b.get(0); } b?.get(0) if (a == b) { - b.get(0) + b.get(0) } if (a != b) { b?.get(0) } else { - b.get(0) + b.get(0) } } fun f9(a : Int?) : Int { if (a != null) - return a + return a return 1 } diff --git a/compiler/testData/diagnostics/tests/cast/DowncastMap.kt b/compiler/testData/diagnostics/tests/cast/DowncastMap.kt index 3b2e1bb7fda..043d728250d 100644 --- a/compiler/testData/diagnostics/tests/cast/DowncastMap.kt +++ b/compiler/testData/diagnostics/tests/cast/DowncastMap.kt @@ -5,6 +5,6 @@ trait MutableMap: Map { fun p(p: Map) { if (p is MutableMap) { - p[""] = 1 + p[""] = 1 } } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/cast/bare/EitherIs.kt b/compiler/testData/diagnostics/tests/cast/bare/EitherIs.kt index cde3454f2ca..f02378659a8 100644 --- a/compiler/testData/diagnostics/tests/cast/bare/EitherIs.kt +++ b/compiler/testData/diagnostics/tests/cast/bare/EitherIs.kt @@ -1,3 +1,4 @@ +// !DIAGNOSTICS: -DEBUG_INFO_AUTOCAST trait Either trait Left: Either { val value: A diff --git a/compiler/testData/diagnostics/tests/cast/bare/EitherNotIs.kt b/compiler/testData/diagnostics/tests/cast/bare/EitherNotIs.kt index 54dfb3caa3c..33dadd96156 100644 --- a/compiler/testData/diagnostics/tests/cast/bare/EitherNotIs.kt +++ b/compiler/testData/diagnostics/tests/cast/bare/EitherNotIs.kt @@ -1,3 +1,4 @@ +// !DIAGNOSTICS: -DEBUG_INFO_AUTOCAST trait Either trait Left: Either { val value: A diff --git a/compiler/testData/diagnostics/tests/cast/bare/EitherWhen.kt b/compiler/testData/diagnostics/tests/cast/bare/EitherWhen.kt index c9800abd0fb..45293302570 100644 --- a/compiler/testData/diagnostics/tests/cast/bare/EitherWhen.kt +++ b/compiler/testData/diagnostics/tests/cast/bare/EitherWhen.kt @@ -1,3 +1,4 @@ +// !DIAGNOSTICS: -DEBUG_INFO_AUTOCAST trait Either trait Left: Either { val value: A diff --git a/compiler/testData/diagnostics/tests/controlFlowAnalysis/definiteReturnInWhen.kt b/compiler/testData/diagnostics/tests/controlFlowAnalysis/definiteReturnInWhen.kt index 947fa170e11..68ad88fa900 100644 --- a/compiler/testData/diagnostics/tests/controlFlowAnalysis/definiteReturnInWhen.kt +++ b/compiler/testData/diagnostics/tests/controlFlowAnalysis/definiteReturnInWhen.kt @@ -1,6 +1,6 @@ fun illegalWhenBlock(a: Any): Int { when(a) { - is Int -> return a - is String -> return a.length + is Int -> return a + is String -> return a.length } } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/controlStructures/forLoopWithNullableRange.kt b/compiler/testData/diagnostics/tests/controlStructures/forLoopWithNullableRange.kt index 8482ed6bbbf..50bc9a154ba 100644 --- a/compiler/testData/diagnostics/tests/controlStructures/forLoopWithNullableRange.kt +++ b/compiler/testData/diagnostics/tests/controlStructures/forLoopWithNullableRange.kt @@ -11,6 +11,6 @@ fun test(c: Coll?) { for (x in c) {} if (c != null) { - for(x in c) {} + for(x in c) {} } } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/dataFlow/CalleeExpression.kt b/compiler/testData/diagnostics/tests/dataFlow/CalleeExpression.kt index 7343419e835..5a486ecfdd1 100644 --- a/compiler/testData/diagnostics/tests/dataFlow/CalleeExpression.kt +++ b/compiler/testData/diagnostics/tests/dataFlow/CalleeExpression.kt @@ -2,6 +2,6 @@ class C(val f : () -> Unit) fun test(e : Any) { if (e is C) { - (e.f)() + (e.f)() } } diff --git a/compiler/testData/diagnostics/tests/dataFlow/EmptyIf.kt b/compiler/testData/diagnostics/tests/dataFlow/EmptyIf.kt index 15e3db15c4d..21b2b1cef50 100644 --- a/compiler/testData/diagnostics/tests/dataFlow/EmptyIf.kt +++ b/compiler/testData/diagnostics/tests/dataFlow/EmptyIf.kt @@ -1,13 +1,13 @@ fun f1(s: String?) { if (s!! == ""); - s : String + s : String } fun f2(s: Number?) { if (s is Int); s : Int if (s as Int == 42); - s : Int + s : Int } fun f3(s: Number?) { diff --git a/compiler/testData/diagnostics/tests/dataFlow/WhenSubject.kt b/compiler/testData/diagnostics/tests/dataFlow/WhenSubject.kt index 663e35aeb4a..f8f04bdadea 100644 --- a/compiler/testData/diagnostics/tests/dataFlow/WhenSubject.kt +++ b/compiler/testData/diagnostics/tests/dataFlow/WhenSubject.kt @@ -3,7 +3,7 @@ class BinOp(val operator : String) : Expr fun test(e : Expr) { if (e is BinOp) { - when (e.operator) { + when (e.operator) { else -> 0 } } diff --git a/compiler/testData/diagnostics/tests/dataFlow/local/LocalClassBase.kt b/compiler/testData/diagnostics/tests/dataFlow/local/LocalClassBase.kt index 5875f99ead4..503ced7abe3 100644 --- a/compiler/testData/diagnostics/tests/dataFlow/local/LocalClassBase.kt +++ b/compiler/testData/diagnostics/tests/dataFlow/local/LocalClassBase.kt @@ -4,7 +4,7 @@ fun test(x: Any, y: Int?) { if (x !is String) return if (y == null) return - class Local: Base(x, y) { + class Local: Base(x, y) { } } diff --git a/compiler/testData/diagnostics/tests/dataFlow/local/LocalClassDefaultParameters.kt b/compiler/testData/diagnostics/tests/dataFlow/local/LocalClassDefaultParameters.kt index 8795f2753e1..e4c2387ffb8 100644 --- a/compiler/testData/diagnostics/tests/dataFlow/local/LocalClassDefaultParameters.kt +++ b/compiler/testData/diagnostics/tests/dataFlow/local/LocalClassDefaultParameters.kt @@ -1,8 +1,8 @@ fun test(x: Any) { if (x !is String) return - class Local(s: String = x) { - fun foo(s: String = x): String = s + class Local(s: String = x) { + fun foo(s: String = x): String = s } } diff --git a/compiler/testData/diagnostics/tests/dataFlow/local/LocalClassDelegatedProperties.kt b/compiler/testData/diagnostics/tests/dataFlow/local/LocalClassDelegatedProperties.kt index dcf3819d921..301cd32e6af 100644 --- a/compiler/testData/diagnostics/tests/dataFlow/local/LocalClassDelegatedProperties.kt +++ b/compiler/testData/diagnostics/tests/dataFlow/local/LocalClassDelegatedProperties.kt @@ -9,8 +9,8 @@ fun test(del: Any?) { if (del !is Del) return class Local { - val delegatedVal by df(del) - val delegatedVal1: Int by df(del) + val delegatedVal by df(del) + val delegatedVal1: Int by df(del) } } diff --git a/compiler/testData/diagnostics/tests/dataFlow/local/LocalClassDelegation.kt b/compiler/testData/diagnostics/tests/dataFlow/local/LocalClassDelegation.kt index c787dedd627..134305aa9d2 100644 --- a/compiler/testData/diagnostics/tests/dataFlow/local/LocalClassDelegation.kt +++ b/compiler/testData/diagnostics/tests/dataFlow/local/LocalClassDelegation.kt @@ -5,7 +5,7 @@ trait D { fun test(d: Any?) { if (d !is D) return - class Local : D by d { + class Local : D by d { } } diff --git a/compiler/testData/diagnostics/tests/dataFlow/local/LocalClassFunctions.kt b/compiler/testData/diagnostics/tests/dataFlow/local/LocalClassFunctions.kt index ef8d270c722..26ff8d4458d 100644 --- a/compiler/testData/diagnostics/tests/dataFlow/local/LocalClassFunctions.kt +++ b/compiler/testData/diagnostics/tests/dataFlow/local/LocalClassFunctions.kt @@ -7,12 +7,12 @@ fun test(d: Any?) { class Local { fun f() { - d.foo() + d.foo() } - fun f1() = d.foo() + fun f1() = d.foo() - fun f2(): String = d.foo() + fun f2(): String = d.foo() } } diff --git a/compiler/testData/diagnostics/tests/dataFlow/local/LocalClassInMemberOfLocalClass.kt b/compiler/testData/diagnostics/tests/dataFlow/local/LocalClassInMemberOfLocalClass.kt index 3fa684b6ba2..24e5ffc6f65 100644 --- a/compiler/testData/diagnostics/tests/dataFlow/local/LocalClassInMemberOfLocalClass.kt +++ b/compiler/testData/diagnostics/tests/dataFlow/local/LocalClassInMemberOfLocalClass.kt @@ -6,8 +6,8 @@ fun test(x: Any) { if (y !is String) return class Local { { - x.length - y.length + x.length + y.length } } } diff --git a/compiler/testData/diagnostics/tests/dataFlow/local/LocalClassInitializer.kt b/compiler/testData/diagnostics/tests/dataFlow/local/LocalClassInitializer.kt index f6d4a78113a..65538fb50bd 100644 --- a/compiler/testData/diagnostics/tests/dataFlow/local/LocalClassInitializer.kt +++ b/compiler/testData/diagnostics/tests/dataFlow/local/LocalClassInitializer.kt @@ -2,9 +2,9 @@ fun f(a: Any?) { if (a is B) { - class C : X(a) { + class C : X(a) { { - a.foo() + a.foo() } } } diff --git a/compiler/testData/diagnostics/tests/dataFlow/local/LocalClassProperty.kt b/compiler/testData/diagnostics/tests/dataFlow/local/LocalClassProperty.kt index d16f0448fbe..79f8a93a66f 100644 --- a/compiler/testData/diagnostics/tests/dataFlow/local/LocalClassProperty.kt +++ b/compiler/testData/diagnostics/tests/dataFlow/local/LocalClassProperty.kt @@ -2,11 +2,11 @@ fun test(x: Any?) { if (x !is String) return class C { - val v = x.length + val v = x.length val vGet: Int - get() = x.length + get() = x.length - val s: String = x + val s: String = x } } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/dataFlow/local/LocalObject.kt b/compiler/testData/diagnostics/tests/dataFlow/local/LocalObject.kt index e867333101a..1e366076144 100644 --- a/compiler/testData/diagnostics/tests/dataFlow/local/LocalObject.kt +++ b/compiler/testData/diagnostics/tests/dataFlow/local/LocalObject.kt @@ -1,7 +1,7 @@ fun foo(x: Any?) { if (x is String) { - object : Base(x) { - fun bar() = x.length + object : Base(x) { + fun bar() = x.length } } } diff --git a/compiler/testData/diagnostics/tests/dataFlow/local/LocalObjectDelegation.kt b/compiler/testData/diagnostics/tests/dataFlow/local/LocalObjectDelegation.kt index c5c97e76f5f..10310610a58 100644 --- a/compiler/testData/diagnostics/tests/dataFlow/local/LocalObjectDelegation.kt +++ b/compiler/testData/diagnostics/tests/dataFlow/local/LocalObjectDelegation.kt @@ -9,7 +9,7 @@ class B : A { } fun foo(b: B?) : Int { if (b == null) return 0 - val o = object : A by b { //no info about b not null check + val o = object : A by b { //no info about b not null check } return o.foo() } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/dataFlow/local/NestedLocalClass.kt b/compiler/testData/diagnostics/tests/dataFlow/local/NestedLocalClass.kt index 4bff6de4554..d6d1cbb533f 100644 --- a/compiler/testData/diagnostics/tests/dataFlow/local/NestedLocalClass.kt +++ b/compiler/testData/diagnostics/tests/dataFlow/local/NestedLocalClass.kt @@ -4,7 +4,7 @@ fun test(x: Any) { class LocalOuter { inner class Local { { - x.length + x.length } } } diff --git a/compiler/testData/diagnostics/tests/dataFlow/local/kt2835.kt b/compiler/testData/diagnostics/tests/dataFlow/local/kt2835.kt index 4ceb7330873..51e4e392f06 100644 --- a/compiler/testData/diagnostics/tests/dataFlow/local/kt2835.kt +++ b/compiler/testData/diagnostics/tests/dataFlow/local/kt2835.kt @@ -2,7 +2,7 @@ open class X(val s: String) fun f(a: String?) { if (a != null) { - object : X(a) { // Type mismatch: inferred type is jet.String? but jet.String was expected + object : X(a) { // Type mismatch: inferred type is jet.String? but jet.String was expected } } } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/AndOr.kt b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/AndOr.kt index a2272cfd94c..16c55054fa5 100644 --- a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/AndOr.kt +++ b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/AndOr.kt @@ -1,3 +1,4 @@ +// !DIAGNOSTICS: -DEBUG_INFO_AUTOCAST fun bar(x: Int): Int = x + 1 fun foo() { diff --git a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/ArrayAccess.kt b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/ArrayAccess.kt index c7cb7312883..de52458fb1c 100644 --- a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/ArrayAccess.kt +++ b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/ArrayAccess.kt @@ -4,10 +4,10 @@ fun foo() { val x: Int? = null val a = Array(3, {0}) - if (x != null) bar(a[x]) else bar(a[x]) - bar(a[if (x == null) 0 else x]) + if (x != null) bar(a[x]) else bar(a[x]) + bar(a[if (x == null) 0 else x]) bar(a[x]) "123"[x]; - if (x != null) "123"[x]; + if (x != null) "123"[x]; } diff --git a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/ArrayExpression.kt b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/ArrayExpression.kt index 23efb657124..c17fc043bb5 100644 --- a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/ArrayExpression.kt +++ b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/ArrayExpression.kt @@ -1,5 +1,5 @@ fun foo(arr: Array): Int { val result = (arr as Array)[0] - arr : Array + arr : Array return result } diff --git a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/ArrayGetSetConvention.kt b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/ArrayGetSetConvention.kt index 473daa3f4f1..c753cc03a16 100644 --- a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/ArrayGetSetConvention.kt +++ b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/ArrayGetSetConvention.kt @@ -4,23 +4,23 @@ trait G { } fun foo1(a: Int?, b: G) { - b[a!!, a!!] = a - a : Int + b[a!!, a!!] = a + a : Int } fun foo2(a: Int?, b: G) { - b[0, a!!] = a - a : Int + b[0, a!!] = a + a : Int } fun foo3(a: Int?, b: G) { - val r = b[a!!, a] - a : Int + val r = b[a!!, a] + a : Int r : Int } fun foo4(a: Int?, b: G) { val r = b[0, a!!] - a : Int + a : Int r : Int } diff --git a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/ArrayIndices.kt b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/ArrayIndices.kt index 47a89090034..ebc46a180b6 100644 --- a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/ArrayIndices.kt +++ b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/ArrayIndices.kt @@ -1,9 +1,9 @@ fun foo1(a: Int?, b: Array>) { - b[a!!][a!!] = a - a : Int + b[a!!][a!!] = a + a : Int } fun foo2(a: Int?, b: Array>) { - b[0][a!!] = a - a : Int + b[0][a!!] = a + a : Int } diff --git a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/Assignment.kt b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/Assignment.kt index ef3dc45a9f6..c50f194841b 100644 --- a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/Assignment.kt +++ b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/Assignment.kt @@ -5,13 +5,13 @@ trait B : A { fun bar1(a: A) { var b: B = a as B - a.foo() + a.foo() b.foo() } fun id(b: B) = b fun bar2(a: A) { var b: B = id(a as B) - a.foo() + a.foo() b.foo() } diff --git a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/AssignmentInInitializer.kt b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/AssignmentInInitializer.kt index b99f106811b..e770b86b427 100644 --- a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/AssignmentInInitializer.kt +++ b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/AssignmentInInitializer.kt @@ -10,12 +10,12 @@ fun baz(b: B) = b fun bar1(a: A) { val b = a as B - a.foo() + a.foo() b.foo() } fun bar2(a: A) { val b = baz(a as B) - a.foo() + a.foo() b.foo() } diff --git a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/AssignmentOperation.kt b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/AssignmentOperation.kt index 98b9e7d4c08..dfb447018fe 100644 --- a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/AssignmentOperation.kt +++ b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/AssignmentOperation.kt @@ -1,15 +1,15 @@ fun bar1(x: Number, y: Int) { var yy = y yy += x as Int - x : Int + x : Int } fun bar2(x: Number) { y += x as Int - x : Int + x : Int } fun bar3(x: Number, y: Array) { y[0] += x as Int - x : Int + x : Int } diff --git a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/AssignmentToArrayElement.kt b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/AssignmentToArrayElement.kt index af023632ffc..4eb3aa3c182 100644 --- a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/AssignmentToArrayElement.kt +++ b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/AssignmentToArrayElement.kt @@ -1,10 +1,10 @@ fun arrayAccessRHS(a: Int?, b: Array) { b[0] = a!! - a : Int + a : Int } fun arrayAccessLHS(a: Int?, b: Array) { - b[a!!] = a - a : Int + b[a!!] = a + a : Int } diff --git a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/BinaryExpression.kt b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/BinaryExpression.kt index e64572a063c..f39b6d80526 100644 --- a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/BinaryExpression.kt +++ b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/BinaryExpression.kt @@ -1,3 +1,4 @@ +// !DIAGNOSTICS: -DEBUG_INFO_AUTOCAST fun bar(x: Int): Int = x + 1 fun foo() { diff --git a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/BinaryExpressionBooleanOperations.kt b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/BinaryExpressionBooleanOperations.kt index 06def90e8da..e8438bc12b4 100644 --- a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/BinaryExpressionBooleanOperations.kt +++ b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/BinaryExpressionBooleanOperations.kt @@ -6,7 +6,7 @@ fun foo1(x: Number, cond: Boolean): Boolean { fun foo2(x: Number, cond: Boolean): Boolean { val result = ((x as Int) == 42) && cond - x : Int + x : Int return result } @@ -18,6 +18,6 @@ fun foo3(x: Number, cond: Boolean): Boolean { fun foo4(x: Number, cond: Boolean): Boolean { val result = ((x as Int) == 42) || cond - x : Int + x : Int return result } diff --git a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/BinaryExpressionCompareToConvention.kt b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/BinaryExpressionCompareToConvention.kt index 637522393d3..85a35d21215 100644 --- a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/BinaryExpressionCompareToConvention.kt +++ b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/BinaryExpressionCompareToConvention.kt @@ -4,13 +4,13 @@ trait B : A fun B.compareTo(b: B) = if (this == b) 0 else 1 fun foo(a: A): Boolean { - val result = (a as B) < a - a : B + val result = (a as B) < a + a : B return result } fun bar(a: A, b: B): Boolean { val result = b < (a as B) - a : B + a : B return result } diff --git a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/BinaryExpressionContainsConvention.kt b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/BinaryExpressionContainsConvention.kt index 99729c6d947..ab41d0beb7e 100644 --- a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/BinaryExpressionContainsConvention.kt +++ b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/BinaryExpressionContainsConvention.kt @@ -1,5 +1,5 @@ fun foo(x: Number): Boolean { val result = (x as Int) in 1..5 - x : Int + x : Int return result } diff --git a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/BinaryExpressionElvis.kt b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/BinaryExpressionElvis.kt index f9940025c3b..3639d538845 100644 --- a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/BinaryExpressionElvis.kt +++ b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/BinaryExpressionElvis.kt @@ -1,8 +1,8 @@ fun foo(x: Int?): Int = x!! fun elvis(x: Number?): Int { - val result = (x as Int?) ?: foo(x) - x : Int? + val result = (x as Int?) ?: foo(x) + x : Int? return result } diff --git a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/BinaryExpressionEqualsConvention.kt b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/BinaryExpressionEqualsConvention.kt index 1bd719f0abe..e84fc53be6b 100644 --- a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/BinaryExpressionEqualsConvention.kt +++ b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/BinaryExpressionEqualsConvention.kt @@ -3,12 +3,12 @@ trait B : A fun foo1(a: A, b: B): Boolean { val result = (a as B) == b - a : B + a : B return result } fun foo2(a: A, b: B): Boolean { val result = b == (a as B) - a : B + a : B return result } diff --git a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/BinaryExpressionIdentifier.kt b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/BinaryExpressionIdentifier.kt index 6b1518c79c9..ce61c6757c0 100644 --- a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/BinaryExpressionIdentifier.kt +++ b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/BinaryExpressionIdentifier.kt @@ -1,11 +1,11 @@ fun foo(a: Number): Int { - val result = (a as Int) compareTo a - a : Int + val result = (a as Int) compareTo a + a : Int return result } fun bar(a: Number): Int { val result = 42 compareTo (a as Int) - a : Int + a : Int return result } diff --git a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/BinaryExpressionPlusConvention.kt b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/BinaryExpressionPlusConvention.kt index fdb09b3ecb3..332e81db5fa 100644 --- a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/BinaryExpressionPlusConvention.kt +++ b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/BinaryExpressionPlusConvention.kt @@ -4,13 +4,13 @@ trait B : A fun B.plus(b: B) = if (this == b) b else this fun foo(a: A): B { - val result = (a as B) + a - a : B + val result = (a as B) + a + a : B return result } fun bar(a: A, b: B): B { val result = b + (a as B) - a : B + a : B return result } diff --git a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/Condition.kt b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/Condition.kt index 34d643e4933..f8024b6435a 100644 --- a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/Condition.kt +++ b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/Condition.kt @@ -1,5 +1,5 @@ fun foo(x: Int?): Boolean { - val result = ((x!! == 0) && ((x : Int) == 0)) - x : Int + val result = ((x!! == 0) && ((x : Int) == 0)) + x : Int return result } diff --git a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/ContinueOuterLoop.kt b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/ContinueOuterLoop.kt index 5aec16dc745..26e9c3c45df 100644 --- a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/ContinueOuterLoop.kt +++ b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/ContinueOuterLoop.kt @@ -5,7 +5,7 @@ fun whileLoop(x: Int?) { } x : Int } - x : Int + x : Int } fun doWhileLoop(x: Int?) { @@ -15,7 +15,7 @@ fun doWhileLoop(x: Int?) { } while (x == null) x : Int } - x : Int + x : Int } fun whileLoopContinueInnerOuter(x: Int?) { @@ -26,7 +26,7 @@ fun whileLoopContinueInnerOuter(x: Int?) { } x : Int } - x : Int + x : Int } - x : Int + x : Int } diff --git a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/DeepIf.kt b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/DeepIf.kt index 28681d401db..37ecb549250 100644 --- a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/DeepIf.kt +++ b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/DeepIf.kt @@ -1,3 +1,4 @@ +// !DIAGNOSTICS: -DEBUG_INFO_AUTOCAST fun bar(x: Int) = x + 1 fun foo() { diff --git a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/DoWhile.kt b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/DoWhile.kt index 7117aeb2c1c..129a797c8c9 100644 --- a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/DoWhile.kt +++ b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/DoWhile.kt @@ -6,7 +6,7 @@ fun foo() { do { bar(x) } while (x == null) - bar(x) + bar(x) val y: Int? = null do { diff --git a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/DoWhileCondition.kt b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/DoWhileCondition.kt index f9024de80d7..c61848e9957 100644 --- a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/DoWhileCondition.kt +++ b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/DoWhileCondition.kt @@ -4,7 +4,7 @@ fun simpleDoWhile(x: Int?, y0: Int) { x : Int? y++ } while (x!! == y) - x : Int + x : Int } fun doWhileWithBreak(x: Int?, y0: Int) { diff --git a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/Elvis.kt b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/Elvis.kt index 99f3f3068ae..2136f7b1375 100644 --- a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/Elvis.kt +++ b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/Elvis.kt @@ -4,6 +4,6 @@ fun foo() { val x: Int? = null bar(x ?: 0) - if (x != null) bar(x ?: x) + if (x != null) bar(x ?: x) bar(x) } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/For.kt b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/For.kt index 136384a32bd..bc2551b2f8e 100644 --- a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/For.kt +++ b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/For.kt @@ -9,16 +9,16 @@ fun foo() { for (p in a) { bar(x) if (x == null) continue - bar(x) + bar(x) for (q in a) { - bar(x) - if (x == null) bar(x) + bar(x) + if (x == null) bar(x) } } for (p in a) { bar(x) if (x == null) break - bar(x) + bar(x) } } diff --git a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/ForLoopRange.kt b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/ForLoopRange.kt index 4999262a9e2..e654764fd92 100644 --- a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/ForLoopRange.kt +++ b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/ForLoopRange.kt @@ -1,6 +1,6 @@ fun foo(arr: Array?) { for (x in arr!!) { - arr : Array + arr : Array } - arr : Array + arr : Array } diff --git a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/FunctionLiteral.kt b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/FunctionLiteral.kt index b78bfc8489f..5e7cdc48916 100644 --- a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/FunctionLiteral.kt +++ b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/FunctionLiteral.kt @@ -4,6 +4,6 @@ fun foo() { val x: Int? = null fun baz() = bar(x) - fun quux() = if (x != null) bar(x) else baz() - fun quuux() = bar(if (x == null) 0 else x) + fun quux() = if (x != null) bar(x) else baz() + fun quuux() = bar(if (x == null) 0 else x) } diff --git a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/IfStatement.kt b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/IfStatement.kt index d50c887f76f..1e2adf48afa 100644 --- a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/IfStatement.kt +++ b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/IfStatement.kt @@ -1,24 +1,24 @@ fun ifThen(x: Int?) { if (x!! == 0) { - x : Int + x : Int } - x : Int + x : Int } fun ifElse(x: Int?) { if (x!! == 0) else { - x : Int + x : Int } - x : Int + x : Int } fun ifThenElse(x: Int?) { if (x!! == 0) { - x : Int + x : Int } else { - x : Int + x : Int } - x : Int + x : Int } fun ifIs(x: Int?, cond: Boolean) { diff --git a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/IfThenElse.kt b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/IfThenElse.kt index 6d14c43e8ca..08a3a2163a7 100644 --- a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/IfThenElse.kt +++ b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/IfThenElse.kt @@ -3,27 +3,27 @@ fun bar(x: Int): Int = x + 1 fun foo() { val x: Int? = null - bar(if (x == null) 0 else x) + bar(if (x == null) 0 else x) if (x == null) { bar(x) return } else { - bar(x) + bar(x) } - bar(x) + bar(x) val y: Int? = null if (y is Int) { - bar(y) + bar(y) } else { bar(y) return } - bar(y) + bar(y) val z: Int? = null - if (z != null) bar(z) + if (z != null) bar(z) bar(z) bar(z!!) if (z != null) bar(z!!) diff --git a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/IfThenElseBothInvalid.kt b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/IfThenElseBothInvalid.kt index 4bbf9d836ba..da4bb298f2b 100644 --- a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/IfThenElseBothInvalid.kt +++ b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/IfThenElseBothInvalid.kt @@ -12,5 +12,5 @@ fun foo() { if (x == null) return 2+ } - bar(x) + bar(x) } diff --git a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/IsExpression.kt b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/IsExpression.kt index 202bb63b5f8..2f184b26619 100644 --- a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/IsExpression.kt +++ b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/IsExpression.kt @@ -1,6 +1,6 @@ fun foo(x: Number) { if ((x as Int) is Int) { - x : Int + x : Int } - x : Int + x : Int } diff --git a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/MultiDeclaration.kt b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/MultiDeclaration.kt index 0640943825e..5945f000093 100644 --- a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/MultiDeclaration.kt +++ b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/MultiDeclaration.kt @@ -2,6 +2,6 @@ fun Int.component1() = "a" fun foo(a: Number) { val (x) = a as Int - a : Int + a : Int x : String } diff --git a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/ObjectExpression.kt b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/ObjectExpression.kt index 74ed7fbbdc0..94b814918a1 100644 --- a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/ObjectExpression.kt +++ b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/ObjectExpression.kt @@ -4,7 +4,7 @@ fun foo() { val x: Int? = null val a = object { - fun baz() = bar(if (x == null) 0 else x) - fun quux(): Int = if (x == null) x else x + fun baz() = bar(if (x == null) 0 else x) + fun quux(): Int = if (x == null) x else x } } diff --git a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/QualifiedExpression.kt b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/QualifiedExpression.kt index 94c36bb42c2..8b82c0e7afe 100644 --- a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/QualifiedExpression.kt +++ b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/QualifiedExpression.kt @@ -9,5 +9,5 @@ fun foo() { A().bar(x) if (x == null) return - A().bar(x) + A().bar(x) } diff --git a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/Return.kt b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/Return.kt index 99ab397035b..6d2d70ab372 100644 --- a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/Return.kt +++ b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/Return.kt @@ -1,3 +1,4 @@ +// !DIAGNOSTICS: -DEBUG_INFO_AUTOCAST fun bar(x: Int): Int = x + 1 fun foo(): Int { diff --git a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/StringTemplate.kt b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/StringTemplate.kt index 5b81085f6ce..38124565013 100644 --- a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/StringTemplate.kt +++ b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/StringTemplate.kt @@ -1,6 +1,6 @@ fun foo(x: Number, y: String?): String { val result = "abcde $x ${x as Int} ${y!!} $x $y" - x : Int - y : String + x : Int + y : String return result } diff --git a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/ThisSuper.kt b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/ThisSuper.kt index c2b4ee9fdd2..52c01ad32a7 100644 --- a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/ThisSuper.kt +++ b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/ThisSuper.kt @@ -11,11 +11,11 @@ class Derived : Base() { super.bar(x) this.baz(x) if (x == null) return - super.bar(x) - this.baz(x) + super.bar(x) + this.baz(x) val y: Int? = null - if (y != null) super.bar(this.baz(y)) + if (y != null) super.bar(this.baz(y)) else this.baz(super.bar(y)) } } diff --git a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/Throw.kt b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/Throw.kt index e90ce7eb897..2990c149d5f 100644 --- a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/Throw.kt +++ b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/Throw.kt @@ -4,6 +4,6 @@ fun foo() { val x: Int? = null if (x == null) throw bar(x) - throw bar(x) - throw bar(x) + throw bar(x) + throw bar(x) } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/TryCatch.kt b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/TryCatch.kt index f3f8ce0347c..123ab81ac05 100644 --- a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/TryCatch.kt +++ b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/TryCatch.kt @@ -6,10 +6,10 @@ fun foo() { bar(x) if (x == null) return try { - bar(x) + bar(x) } catch (e: Exception) { - bar(x) + bar(x) } - bar(x) + bar(x) } diff --git a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/TryFinally.kt b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/TryFinally.kt index 794937848f9..4900ed1143f 100644 --- a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/TryFinally.kt +++ b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/TryFinally.kt @@ -3,7 +3,7 @@ fun tryFinally(x: Int?) { } finally { x!! } - x : Int + x : Int } fun tryCatchFinally(x: Int?) { @@ -15,5 +15,5 @@ fun tryCatchFinally(x: Int?) { x : Int x!! } - x : Int + x : Int } diff --git a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/UnaryExpression.kt b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/UnaryExpression.kt index 8803f8d30bf..db5dd8fa4e9 100644 --- a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/UnaryExpression.kt +++ b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/UnaryExpression.kt @@ -5,10 +5,10 @@ fun foo() { val x: Int? = null bar(-x) - if (x != null) bar(-x) + if (x != null) bar(-x) bar(-x) val b: Boolean? = null baz(!b) - if (b != null) baz(!b) + if (b != null) baz(!b) } diff --git a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/When.kt b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/When.kt index 06b49dbf4d5..6828369eee3 100644 --- a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/When.kt +++ b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/When.kt @@ -5,7 +5,7 @@ fun foo() { if (x != null) { when (x) { - 0 -> bar(x) + 0 -> bar(x) else -> {} } } @@ -14,5 +14,5 @@ fun foo() { 0 -> { if (x == null) return } else -> { if (x == null) return } } - bar(x) + bar(x) } diff --git a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/WhenEntry.kt b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/WhenEntry.kt index 2d989fed980..0beb0170e89 100644 --- a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/WhenEntry.kt +++ b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/WhenEntry.kt @@ -1,6 +1,6 @@ fun foo(x: Number, y: Int) { when (x) { - x as Int -> x : Int + x as Int -> x : Int y -> {} else -> {} } @@ -9,16 +9,16 @@ fun foo(x: Number, y: Int) { fun bar(x: Number) { when (x) { - x as Int -> x : Int + x as Int -> x : Int else -> {} } - x : Int + x : Int } fun whenWithoutSubject(x: Number) { when { - (x as Int) == 42 -> x : Int + (x as Int) == 42 -> x : Int else -> {} } - x : Int + x : Int } diff --git a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/WhenIn.kt b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/WhenIn.kt index 0c37b690e8e..717f1d60bec 100644 --- a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/WhenIn.kt +++ b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/WhenIn.kt @@ -1,13 +1,13 @@ fun foo(x: Int, list: List?) { when (x) { - in list!! -> list : List + in list!! -> list : List else -> {} } } fun whenWithoutSubject(x: Int, list: List?) { when { - x in list!! -> list : List + x in list!! -> list : List else -> {} } } diff --git a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/WhenSubject.kt b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/WhenSubject.kt index 70bcc6dc394..1b7ec52690c 100644 --- a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/WhenSubject.kt +++ b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/WhenSubject.kt @@ -1,6 +1,6 @@ fun foo(x: Number) { when (x as Int) { - else -> x : Int + else -> x : Int } - x : Int + x : Int } diff --git a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/While.kt b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/While.kt index 8cf3c7b7df3..93ce58e08cb 100644 --- a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/While.kt +++ b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/While.kt @@ -5,11 +5,11 @@ fun foo() { while (x == null) { bar(x) } - bar(x) + bar(x) val y: Int? = null while (y != null) { - bar(y) + bar(y) } bar(y) diff --git a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/WhileCondition.kt b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/WhileCondition.kt index 32e54cb159f..574719de0bd 100644 --- a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/WhileCondition.kt +++ b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/WhileCondition.kt @@ -1,19 +1,19 @@ fun simpleWhile(x: Int?, y0: Int) { var y = y0 while (x!! == y) { - x : Int + x : Int y++ } - x : Int + x : Int } fun whileWithBreak(x: Int?, y0: Int) { var y = y0 while (x!! == y) { - x : Int + x : Int break } - x : Int + x : Int } fun whileWithNoCondition(x: Int?) { diff --git a/compiler/testData/diagnostics/tests/declarationChecks/DataFlowInfoInMultiDecl.kt b/compiler/testData/diagnostics/tests/declarationChecks/DataFlowInfoInMultiDecl.kt index 1e2ea2247c8..0da6bbbc88a 100644 --- a/compiler/testData/diagnostics/tests/declarationChecks/DataFlowInfoInMultiDecl.kt +++ b/compiler/testData/diagnostics/tests/declarationChecks/DataFlowInfoInMultiDecl.kt @@ -5,10 +5,10 @@ class A { fun a(aa : A?, b : Any) { if (aa != null) { - val (a1, b1) = aa; + val (a1, b1) = aa; } if (b is A) { - val (a1, b1) = b; + val (a1, b1) = b; } } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/deparenthesize/checkDeparenthesizedType.kt b/compiler/testData/diagnostics/tests/deparenthesize/checkDeparenthesizedType.kt index 7b85984652f..fa0eccb5fea 100644 --- a/compiler/testData/diagnostics/tests/deparenthesize/checkDeparenthesizedType.kt +++ b/compiler/testData/diagnostics/tests/deparenthesize/checkDeparenthesizedType.kt @@ -2,10 +2,10 @@ package m fun test(i: Int?) { if (i != null) { - foo(@l1 i) - foo((i)) - foo(@l2 (i)) - foo((@l3 i)) + foo(@l1 i) + foo((i)) + foo(@l2 (i)) + foo((@l3 i)) } val a: Int = @l4 "" diff --git a/compiler/testData/diagnostics/tests/extensions/kt819ExtensionProperties.kt b/compiler/testData/diagnostics/tests/extensions/kt819ExtensionProperties.kt index ed897999755..2602df3945a 100644 --- a/compiler/testData/diagnostics/tests/extensions/kt819ExtensionProperties.kt +++ b/compiler/testData/diagnostics/tests/extensions/kt819ExtensionProperties.kt @@ -4,10 +4,10 @@ import java.io.* inline val InputStream.buffered : BufferedInputStream - get() = if(this is BufferedInputStream) this else BufferedInputStream(this) + get() = if(this is BufferedInputStream) this else BufferedInputStream(this) inline val Reader.buffered : BufferedReader - get() = if(this is BufferedReader) this else BufferedReader(this) + get() = if(this is BufferedReader) this else BufferedReader(this) //more tests diff --git a/compiler/testData/diagnostics/tests/incompleteCode/SupertypeOfErrorType.kt b/compiler/testData/diagnostics/tests/incompleteCode/SupertypeOfErrorType.kt index 29e1b112e3f..399fc23f47e 100644 --- a/compiler/testData/diagnostics/tests/incompleteCode/SupertypeOfErrorType.kt +++ b/compiler/testData/diagnostics/tests/incompleteCode/SupertypeOfErrorType.kt @@ -1,3 +1,4 @@ +// !DIAGNOSTICS: -DEBUG_INFO_AUTOCAST package a import java.util.Date diff --git a/compiler/testData/diagnostics/tests/inference/regressions/kt1358.kt b/compiler/testData/diagnostics/tests/inference/regressions/kt1358.kt index 5c28166bb42..afe85753944 100644 --- a/compiler/testData/diagnostics/tests/inference/regressions/kt1358.kt +++ b/compiler/testData/diagnostics/tests/inference/regressions/kt1358.kt @@ -3,8 +3,8 @@ package d fun bar(a: Any?) { if (a != null) { - a.foo() //overload resolution ambiguity - a.sure() //overload resolution ambiguity + a.foo() //overload resolution ambiguity + a.sure() //overload resolution ambiguity } } diff --git a/compiler/testData/diagnostics/tests/infos/Autocasts.kt b/compiler/testData/diagnostics/tests/infos/Autocasts.kt index dbc70c7e176..b661293e910 100644 --- a/compiler/testData/diagnostics/tests/infos/Autocasts.kt +++ b/compiler/testData/diagnostics/tests/infos/Autocasts.kt @@ -11,8 +11,8 @@ fun f9(init : A?) { a?.foo() a?.bar() if (a is B) { - a.bar() - a.foo() + a.bar() + a.foo() } a?.foo() a?.bar() @@ -20,14 +20,14 @@ fun f9(init : A?) { a?.bar() a?.foo() } - if (!(a is B) || a.bar() == Unit.VALUE) { + if (!(a is B) || a.bar() == Unit.VALUE) { a?.bar() } if (!(a is B)) { return; } - a.bar() - a.foo() + a.bar() + a.foo() } fun f10(init : A?) { @@ -48,15 +48,15 @@ class C() : A() { fun f101(a : A?) { if (a is C) { - a.bar(); + a.bar(); } } fun f11(a : A?) { when (a) { - is B -> a.bar() - is A -> a.foo() - is Any -> a.foo() + is B -> a.bar() + is A -> a.foo() + is Any -> a.foo() is Any? -> a.bar() else -> a?.foo() } @@ -64,11 +64,11 @@ fun f11(a : A?) { fun f12(a : A?) { when (a) { - is B -> a.bar() - is A -> a.foo() - is Any -> a.foo(); + is B -> a.bar() + is A -> a.foo() + is Any -> a.foo(); is Any? -> a.bar() - is C -> a.bar() + is C -> a.bar() else -> a?.foo() } @@ -76,15 +76,15 @@ fun f12(a : A?) { a?.bar() } if (a is B) { - a.foo() - a.bar() + a.foo() + a.bar() } } fun f13(a : A?) { if (a is B) { - a.foo() - a.bar() + a.foo() + a.bar() } else { a?.foo() @@ -97,14 +97,14 @@ fun f13(a : A?) { c.bar() } else { - a.foo() + a.foo() c.bar() } a?.foo() - if (a is B && a.foo() == Unit.VALUE) { - a.foo() - a.bar() + if (a is B && a.foo() == Unit.VALUE) { + a.foo() + a.bar() } else { a?.foo() @@ -120,70 +120,70 @@ fun f13(a : A?) { } if (!(a is B)) return - a.bar() + a.bar() } fun f14(a : A?) { while (!(a is B)) { } - a.bar() + a.bar() } fun f15(a : A?) { do { } while (!(a is B)) - a.bar() + a.bar() } fun getStringLength(obj : Any) : Char? { if (obj !is String) return null - return obj.get(0) // no cast to String is needed + return obj.get(0) // no cast to String is needed } -fun toInt(i: Int?): Int = if (i != null) i else 0 +fun toInt(i: Int?): Int = if (i != null) i else 0 fun illegalWhenBody(a: Any): Int = when(a) { - is Int -> a + is Int -> a is String -> a } fun illegalWhenBlock(a: Any): Int { when(a) { - is Int -> return a + is Int -> return a is String -> return a } } fun declarations(a: Any?) { if (a is String) { - val p4: String = a + val p4: String = a } if (a is String?) { if (a != null) { - val s: String = a + val s: String = a } } if (a != null) { if (a is String?) { - val s: String = a + val s: String = a } } } fun vars(a: Any?) { var b: Int = 0 if (a is Int) { - b = a + b = a } } fun returnFunctionLiteralBlock(a: Any?): Function0 { - if (a is Int) return { a } + if (a is Int) return { a } else return { 1 } } fun returnFunctionLiteral(a: Any?): Function0 = - if (a is Int) { (): Int -> a } + if (a is Int) { (): Int -> a } else { () -> 1 } fun mergeAutocasts(a: Any?) { if (a is String || a is Int) { a.compareTo("") - a.toString() + a.toString() } if (a is Int || a is String) { a.compareTo("") @@ -192,9 +192,9 @@ fun mergeAutocasts(a: Any?) { is String, is Any -> a.compareTo("") } if (a is String && a is Any) { - val i: Int = a.compareTo("") + val i: Int = a.compareTo("") } - if (a is String && a.compareTo("") == 0) {} + if (a is String && a.compareTo("") == 0) {} if (a is String || a.compareTo("") == 0) {} } diff --git a/compiler/testData/diagnostics/tests/j+k/kt2641.kt b/compiler/testData/diagnostics/tests/j+k/kt2641.kt index 02679e02348..e020c8218f8 100644 --- a/compiler/testData/diagnostics/tests/j+k/kt2641.kt +++ b/compiler/testData/diagnostics/tests/j+k/kt2641.kt @@ -9,7 +9,7 @@ fun bar(any: Any): java.lang.Iterable val c : Iterator? = null if (any is Iterator<*>) { - any : Iterator<*> + any : Iterator<*> } any as Iterator<*> return null diff --git a/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/NullableNothingIsExactlyNull.kt b/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/NullableNothingIsExactlyNull.kt index 3c52c45b1b9..cf4efd88050 100644 --- a/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/NullableNothingIsExactlyNull.kt +++ b/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/NullableNothingIsExactlyNull.kt @@ -2,7 +2,7 @@ fun test() { val out : Int? = null val x : Nothing? = null if (out != x) - out.plus(1) + out.plus(1) if (out == x) return - out.plus(1) + out.plus(1) } diff --git a/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/QualifiedExpressionNullability.kt b/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/QualifiedExpressionNullability.kt index a8d14c07da6..86226014ce7 100644 --- a/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/QualifiedExpressionNullability.kt +++ b/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/QualifiedExpressionNullability.kt @@ -1,3 +1,4 @@ +// !DIAGNOSTICS: -DEBUG_INFO_AUTOCAST class Foo { fun foo(a: Foo): Foo = a } diff --git a/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/funcLiteralArgsInsideAmbiguity.kt b/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/funcLiteralArgsInsideAmbiguity.kt index b5a286c1d30..8abe2f2f4a5 100644 --- a/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/funcLiteralArgsInsideAmbiguity.kt +++ b/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/funcLiteralArgsInsideAmbiguity.kt @@ -5,7 +5,7 @@ fun bar() { val i: Int? = 42 if (i != null) { doSmth1 { - val x = i + 1 + val x = i + 1 } } } diff --git a/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/funcLiteralArgsInsideUnresolvedFunction.kt b/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/funcLiteralArgsInsideUnresolvedFunction.kt index 7b2104f6a76..d1beef739c9 100644 --- a/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/funcLiteralArgsInsideUnresolvedFunction.kt +++ b/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/funcLiteralArgsInsideUnresolvedFunction.kt @@ -4,7 +4,7 @@ fun foo() { val i : Int? = 42 if (i != null) { doSmth { - val x = i + 1 + val x = i + 1 } } } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/kt1778.kt b/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/kt1778.kt index eaa1d54f244..1c526ff5437 100644 --- a/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/kt1778.kt +++ b/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/kt1778.kt @@ -4,8 +4,8 @@ package kt1778 fun main(args : Array) { val x = args[0]: Any if(x is java.lang.CharSequence) { - if ("a" == x) x.length() else x.length() // OK - if ("a" == x || "b" == x) x.length() else x.length() // <– THEN ERROR - if ("a" == x && "a" == x) x.length() else x.length() // <– ELSE ERROR + if ("a" == x) x.length() else x.length() // OK + if ("a" == x || "b" == x) x.length() else x.length() // <– THEN ERROR + if ("a" == x && "a" == x) x.length() else x.length() // <– ELSE ERROR } } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/kt2146.kt b/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/kt2146.kt index acf19b90e48..f7d5bf56374 100644 --- a/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/kt2146.kt +++ b/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/kt2146.kt @@ -4,35 +4,35 @@ package kt2146 fun f1(s: Int?): Int { return when (s) { null -> 3 - else -> s + else -> s } } fun f2(s: Int?): Int { return when (s) { !is Int -> s - else -> s + else -> s } } fun f3(s: Int?): Int { return when (s) { - is Int -> s + is Int -> s else -> s } } fun f4(s: Int?): Int { return when { - s == 4 -> s + s == 4 -> s s == null -> s - else -> s + else -> s } } fun f5(s: Int?): Int { return when (s) { - s!! -> s + s!! -> s s -> s else -> 0 } @@ -40,7 +40,7 @@ fun f5(s: Int?): Int { fun f6(s: Int?): Int { return when { - s is Int -> s + s is Int -> s else -> s } } @@ -48,6 +48,6 @@ fun f6(s: Int?): Int { fun f7(s: Int?): Int { return when { s !is Int -> s - else -> s + else -> s } } diff --git a/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/kt2164.kt b/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/kt2164.kt index 79029f1165a..f555460aec4 100644 --- a/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/kt2164.kt +++ b/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/kt2164.kt @@ -9,30 +9,30 @@ fun main(args : Array) { foo(x) if (x != null) { - foo(x) + foo(x) foo(x!!) - foo(x) + foo(x) } foo(x) if (x != null) { - foo(x) + foo(x) foo(x!!) - foo(x) + foo(x) } else { foo(x) foo(x!!) - foo(x) + foo(x) } - foo(x) + foo(x) foo(x!!) - foo(x) + foo(x) val y: Int? = null y!! y!! - foo(y) + foo(y) foo(y!!) } diff --git a/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/kt2176.kt b/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/kt2176.kt index 4935c0fe2ad..2a1b58cb19a 100644 --- a/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/kt2176.kt +++ b/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/kt2176.kt @@ -3,7 +3,7 @@ package kt2176 fun f1(a: String?) { a!! - a: String + a: String } fun f2(a: String) { @@ -13,12 +13,12 @@ fun f2(a: String) { fun f3(a: Any?) { a as String - a: String + a: String } fun f4(a: Any) { a as String - a: String + a: String } fun f5(a: String) { diff --git a/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/kt2195.kt b/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/kt2195.kt index 1455b4bb676..555be364465 100644 --- a/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/kt2195.kt +++ b/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/kt2195.kt @@ -3,6 +3,6 @@ package foo private fun sendCommand(errorCallback: (()->Unit)? = null) { if (errorCallback != null) { - errorCallback() + errorCallback() } } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/kt2212.kt b/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/kt2212.kt index da86e52a048..6f3136e8418 100644 --- a/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/kt2212.kt +++ b/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/kt2212.kt @@ -4,5 +4,5 @@ package kt2212 fun main(args: Array) { val x: Int? = 1 if (x == null) return - System.out.println(x.plus(x!!)) + System.out.println(x.plus(x!!)) } diff --git a/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/kt2216.kt b/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/kt2216.kt index 4fccab1539d..c97d9339bb5 100644 --- a/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/kt2216.kt +++ b/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/kt2216.kt @@ -1,3 +1,4 @@ +// !DIAGNOSTICS: -DEBUG_INFO_AUTOCAST //KT-2216 Nullability of a value determined in function parameter computation doesn't pass to code following package kt2216 diff --git a/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/kt2234.kt b/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/kt2234.kt index 3898cada328..c02da4558eb 100644 --- a/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/kt2234.kt +++ b/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/kt2234.kt @@ -8,14 +8,14 @@ fun main(args : Array) { val d : Long = 1 val period : Int? = null if (period != null) Pair(d, period!! : Int) else Pair(d, 1) - if (period != null) Pair(d, period : Int) else Pair(d, 1) + if (period != null) Pair(d, period : Int) else Pair(d, 1) } fun foo() { val x : Int? = 3 if (x != null) { val u = x!! : Int - val y = x : Int + val y = x : Int val z : Int = y } } diff --git a/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/kt244.kt b/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/kt244.kt index 749aae7b9a0..f6780761a46 100644 --- a/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/kt244.kt +++ b/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/kt244.kt @@ -5,18 +5,18 @@ package kt244 fun f(s: String?) { if (s != null) { - s.length //ok - var i = s.length //error: Only safe calls are allowed on a nullable receiver - System.out.println(s.length) //error + s.length //ok + var i = s.length //error: Only safe calls are allowed on a nullable receiver + System.out.println(s.length) //error } } // more tests class A(a: String?) { - val b = if (a != null) a.length else 1 + val b = if (a != null) a.length else 1 { if (a != null) { - val c = a.length + val c = a.length } } @@ -24,7 +24,7 @@ class A(a: String?) { { if (a is String) { - i = a.length + i = a.length } else { i = 3 diff --git a/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/kt362.kt b/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/kt362.kt index 0bea08369bd..d8a3b62411d 100644 --- a/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/kt362.kt +++ b/compiler/testData/diagnostics/tests/nullabilityAndAutoCasts/kt362.kt @@ -7,11 +7,11 @@ fun test() { val p = test.Public() if (p.public is Int) p.public + 1 if (p.protected is Int) p.protected + 1 - if (p.internal is Int) p.internal + 1 + if (p.internal is Int) p.internal + 1 val i = test.Internal() - if (i.public is Int) i.public + 1 - if (i.protected is Int) i.protected + 1 - if (i.internal is Int) i.internal + 1 + if (i.public is Int) i.public + 1 + if (i.protected is Int) i.protected + 1 + if (i.internal is Int) i.internal + 1 } // FILE: other.kt diff --git a/compiler/testData/diagnostics/tests/regressions/Jet169.kt b/compiler/testData/diagnostics/tests/regressions/Jet169.kt index 9761d8ec20f..578ee9e7cc4 100644 --- a/compiler/testData/diagnostics/tests/regressions/Jet169.kt +++ b/compiler/testData/diagnostics/tests/regressions/Jet169.kt @@ -1,8 +1,8 @@ fun set(key : String, value : String) { val a : String? = "" when (a) { - "" -> a.get(0) - is String, is Any -> a.compareTo("") + "" -> a.get(0) + is String, is Any -> a.compareTo("") else -> a.toString() } } diff --git a/compiler/testData/diagnostics/tests/regressions/kt174.kt b/compiler/testData/diagnostics/tests/regressions/kt174.kt index a9804fcc103..6de1bef6546 100644 --- a/compiler/testData/diagnostics/tests/regressions/kt174.kt +++ b/compiler/testData/diagnostics/tests/regressions/kt174.kt @@ -2,6 +2,6 @@ trait Tree {} fun Any?.TreeValue() : Tree { - if (this is Tree) return this + if (this is Tree) return this throw Exception() } diff --git a/compiler/testData/diagnostics/tests/regressions/kt201.kt b/compiler/testData/diagnostics/tests/regressions/kt201.kt index 99e9475c106..132eb66543a 100644 --- a/compiler/testData/diagnostics/tests/regressions/kt201.kt +++ b/compiler/testData/diagnostics/tests/regressions/kt201.kt @@ -1,6 +1,6 @@ // KT-201 Allow to call extension with nullable receiver with a '.' -fun T?.npe() : T = if (this == null) throw NullPointerException() else this +fun T?.npe() : T = if (this == null) throw NullPointerException() else this fun foo() { val i : Int? = 1 diff --git a/compiler/testData/diagnostics/tests/regressions/kt313.kt b/compiler/testData/diagnostics/tests/regressions/kt313.kt index d22f0dc4f2e..adb2f898aa9 100644 --- a/compiler/testData/diagnostics/tests/regressions/kt313.kt +++ b/compiler/testData/diagnostics/tests/regressions/kt313.kt @@ -7,5 +7,5 @@ fun Iterable.join(separator : String?) : String { fun T?.npe() : T { if (this == null) throw NullPointerException() - return this; + return this; } diff --git a/compiler/testData/diagnostics/tests/regressions/kt352.kt b/compiler/testData/diagnostics/tests/regressions/kt352.kt index fb34818a755..f25a639be33 100644 --- a/compiler/testData/diagnostics/tests/regressions/kt352.kt +++ b/compiler/testData/diagnostics/tests/regressions/kt352.kt @@ -22,6 +22,6 @@ fun doSmth(a: String) {} val testIt : (Any) -> Unit = { if (it is String) { - doSmth(it) + doSmth(it) } } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/regressions/kt524.kt b/compiler/testData/diagnostics/tests/regressions/kt524.kt index 39a2ee257cf..1956e977398 100644 --- a/compiler/testData/diagnostics/tests/regressions/kt524.kt +++ b/compiler/testData/diagnostics/tests/regressions/kt524.kt @@ -13,4 +13,4 @@ fun main(args : Array) { val Int.bd : StringBuilder get() = StringBuilder(this.toString()) fun StringBuilder.plus(other : StringBuilder) : StringBuilder = this.append(other).sure1() // !!! -fun T?.sure1() : T { return if (this != null) this else throw NullPointerException() } +fun T?.sure1() : T { return if (this != null) this else throw NullPointerException() } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/regressions/kt597.kt b/compiler/testData/diagnostics/tests/regressions/kt597.kt index a2b361460bb..a82e6228efb 100644 --- a/compiler/testData/diagnostics/tests/regressions/kt597.kt +++ b/compiler/testData/diagnostics/tests/regressions/kt597.kt @@ -2,13 +2,13 @@ fun Array?.get(i: Int) : T { if (this != null) - return this.get(i) // <- inferred type is Any? but &T was excepted + return this.get(i) // <- inferred type is Any? but &T was excepted else throw NullPointerException() } fun Int?.inc() : Int { if (this != null) - return this.inc() + return this.inc() else throw NullPointerException() } diff --git a/compiler/testData/diagnostics/tests/regressions/kt600.kt b/compiler/testData/diagnostics/tests/regressions/kt600.kt index d31c11bba4a..d8ad7a75e44 100644 --- a/compiler/testData/diagnostics/tests/regressions/kt600.kt +++ b/compiler/testData/diagnostics/tests/regressions/kt600.kt @@ -1,6 +1,6 @@ //KT-600 Problem with 'sure' extension function type inference -fun T?._sure() : T { if (this != null) return this else throw NullPointerException() } +fun T?._sure() : T { if (this != null) return this else throw NullPointerException() } fun test() { val i : Int? = 10 diff --git a/compiler/testData/diagnostics/tests/resolve/specialConstructions/elvisAsCall.kt b/compiler/testData/diagnostics/tests/resolve/specialConstructions/elvisAsCall.kt index 81c06080111..0ce1a679500 100644 --- a/compiler/testData/diagnostics/tests/resolve/specialConstructions/elvisAsCall.kt +++ b/compiler/testData/diagnostics/tests/resolve/specialConstructions/elvisAsCall.kt @@ -11,7 +11,7 @@ fun emptyListOfA(): List = throw Exception() fun testElvis(a: Int?, b: Int?) { if (a != null) { - doInt(b ?: a) + doInt(b ?: a) } doList(getList() ?: emptyListOfA()) //should be an error doList(getList() ?: strangeList { doInt(it) }) //lambda was not analyzed @@ -21,12 +21,12 @@ fun testElvis(a: Int?, b: Int?) { fun testDataFlowInfo1(a: Int?, b: Int?) { val c: Int = a ?: b!! doInt(c) - b + 1 + b + 1 } fun testDataFlowInfo2(a: Int?, b: Int?) { doInt(a ?: b!!) - b + 1 + b + 1 } fun testTypeMismatch(a: String?, b: Any) { diff --git a/compiler/testData/diagnostics/tests/resolve/specialConstructions/exclExclAsCall.kt b/compiler/testData/diagnostics/tests/resolve/specialConstructions/exclExclAsCall.kt index f557df0c6e3..0ddc333b530 100644 --- a/compiler/testData/diagnostics/tests/resolve/specialConstructions/exclExclAsCall.kt +++ b/compiler/testData/diagnostics/tests/resolve/specialConstructions/exclExclAsCall.kt @@ -20,7 +20,7 @@ fun testExclExcl() { fun testDataFlowInfoAfterExclExcl(a: Int?) { doInt(a!!) - a + 1 + a + 1 } fun testUnnecessaryExclExcl(a: Int) { diff --git a/compiler/testData/diagnostics/tests/smartCasts/classObjectMember.kt b/compiler/testData/diagnostics/tests/smartCasts/classObjectMember.kt index 53bf09c020e..48a8edbab79 100644 --- a/compiler/testData/diagnostics/tests/smartCasts/classObjectMember.kt +++ b/compiler/testData/diagnostics/tests/smartCasts/classObjectMember.kt @@ -14,7 +14,7 @@ class B { fun test() { if (A.x != null) { - useInt(A.x) + useInt(A.x) useInt(B.x) } } diff --git a/compiler/testData/diagnostics/tests/smartCasts/dataFlowInfoForArguments.kt b/compiler/testData/diagnostics/tests/smartCasts/dataFlowInfoForArguments.kt index 35f4962f420..94cfa70d4b7 100644 --- a/compiler/testData/diagnostics/tests/smartCasts/dataFlowInfoForArguments.kt +++ b/compiler/testData/diagnostics/tests/smartCasts/dataFlowInfoForArguments.kt @@ -3,5 +3,5 @@ package aaa fun bar(a: Int, b: Int) {} fun foo(a: Int?) { - bar(a!!, a) + bar(a!!, a) } diff --git a/compiler/testData/diagnostics/tests/smartCasts/inference/dependentOnPrevArg.kt b/compiler/testData/diagnostics/tests/smartCasts/inference/dependentOnPrevArg.kt index 6a101411a7a..2509dabe575 100644 --- a/compiler/testData/diagnostics/tests/smartCasts/inference/dependentOnPrevArg.kt +++ b/compiler/testData/diagnostics/tests/smartCasts/inference/dependentOnPrevArg.kt @@ -3,5 +3,5 @@ package a fun foo(u: T, v: T): T = u fun test(s: String?) { - val r: String = foo(s!!, s) + val r: String = foo(s!!, s) } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/smartCasts/inference/intersectionTypes.kt b/compiler/testData/diagnostics/tests/smartCasts/inference/intersectionTypes.kt index c61989e1ebf..231a749091e 100644 --- a/compiler/testData/diagnostics/tests/smartCasts/inference/intersectionTypes.kt +++ b/compiler/testData/diagnostics/tests/smartCasts/inference/intersectionTypes.kt @@ -45,7 +45,7 @@ fun testErrorMessages(a: A, ml: MutableList) { fun rr(s: String?) { if (s != null) { - val l = arrayListOf("", s) + val l = arrayListOf("", s) l: MutableList l: MutableList } diff --git a/compiler/testData/diagnostics/tests/smartCasts/inference/kt1355.kt b/compiler/testData/diagnostics/tests/smartCasts/inference/kt1355.kt index a4bd1ee4c63..cc6577dc1f1 100644 --- a/compiler/testData/diagnostics/tests/smartCasts/inference/kt1355.kt +++ b/compiler/testData/diagnostics/tests/smartCasts/inference/kt1355.kt @@ -6,9 +6,9 @@ import java.util.HashMap fun foo(map: MutableMap, value: String?) { if (value != null) { - map.put(1, value) //ok - map.set(1, value) //type inference failed - map[1] = value //type inference failed + map.put(1, value) //ok + map.set(1, value) //type inference failed + map[1] = value //type inference failed } } @@ -26,7 +26,7 @@ public data open class Tag(public var tagName: String) { } else { attributes["id"] = value!! - attributes["id"] = value + attributes["id"] = value } } } diff --git a/compiler/testData/diagnostics/tests/smartCasts/inference/kt2746.kt b/compiler/testData/diagnostics/tests/smartCasts/inference/kt2746.kt index 4bddbccb38c..f49b2a4ef71 100644 --- a/compiler/testData/diagnostics/tests/smartCasts/inference/kt2746.kt +++ b/compiler/testData/diagnostics/tests/smartCasts/inference/kt2746.kt @@ -5,7 +5,7 @@ class C(t :T) fun test1(a: Any) { if (a is String) { - val c: C = C(a) + val c: C = C(a) } } @@ -14,6 +14,6 @@ fun f(t :T): C = C(t) fun test2(a: Any) { if (a is String) { - val c1: C = f(a) + val c1: C = f(a) } } diff --git a/compiler/testData/diagnostics/tests/smartCasts/inference/kt2851.kt b/compiler/testData/diagnostics/tests/smartCasts/inference/kt2851.kt index e6147254056..9d037e036de 100644 --- a/compiler/testData/diagnostics/tests/smartCasts/inference/kt2851.kt +++ b/compiler/testData/diagnostics/tests/smartCasts/inference/kt2851.kt @@ -4,9 +4,9 @@ package a fun main(args: Array) { val value: String? = "" if (value != null) { - foo(Pair("val", value)) + foo(Pair("val", value)) foo(Pair("val", value!!)) - foo(Pair("val", value)) + foo(Pair("val", value)) } } diff --git a/compiler/testData/diagnostics/tests/smartCasts/kt1461.kt b/compiler/testData/diagnostics/tests/smartCasts/kt1461.kt index 585117a5696..9a453904b98 100644 --- a/compiler/testData/diagnostics/tests/smartCasts/kt1461.kt +++ b/compiler/testData/diagnostics/tests/smartCasts/kt1461.kt @@ -7,8 +7,8 @@ class Sub(str : String) : Super(str) {} fun foo(sup : Super, sub : Sub) { if (sup is Sub) { - println("${sup.property}") - println(sup.property) + println("${sup.property}") + println(sup.property) } println("${sub.property}") println(sub.property) diff --git a/compiler/testData/diagnostics/tests/smartCasts/kt2422.kt b/compiler/testData/diagnostics/tests/smartCasts/kt2422.kt index ea3ac5e68fd..8eb162108c7 100644 --- a/compiler/testData/diagnostics/tests/smartCasts/kt2422.kt +++ b/compiler/testData/diagnostics/tests/smartCasts/kt2422.kt @@ -12,10 +12,10 @@ class Test { useInt(foo) } if (this.foo != null) { - useInt(foo) + useInt(foo) } if (foo != null) { - useInt(this.foo) + useInt(this.foo) } } diff --git a/compiler/testData/diagnostics/tests/smartCasts/thisWithLabel.kt b/compiler/testData/diagnostics/tests/smartCasts/thisWithLabel.kt index 618f5b66a69..1249db5f641 100644 --- a/compiler/testData/diagnostics/tests/smartCasts/thisWithLabel.kt +++ b/compiler/testData/diagnostics/tests/smartCasts/thisWithLabel.kt @@ -3,15 +3,15 @@ package foo class A(val i: Int?) { fun test1() { if (this@A.i != null) { - useInt(this.i) - useInt(i) + useInt(this.i) + useInt(i) } } inner class B { fun test2() { if (i != null) { - useInt(this@A.i) + useInt(this@A.i) } } } @@ -19,15 +19,15 @@ class A(val i: Int?) { fun A.foo() { if (this@foo.i != null) { - useInt(this.i) - useInt(i) + useInt(this.i) + useInt(i) } } fun test3() { useFunction { if(i != null) { - useInt(this.i) + useInt(this.i) } } } diff --git a/compiler/testData/diagnostics/tests/smartCasts/thisWithLabelAsReceiverPart.kt b/compiler/testData/diagnostics/tests/smartCasts/thisWithLabelAsReceiverPart.kt index bdbc0aa44f7..9efde90daf4 100644 --- a/compiler/testData/diagnostics/tests/smartCasts/thisWithLabelAsReceiverPart.kt +++ b/compiler/testData/diagnostics/tests/smartCasts/thisWithLabelAsReceiverPart.kt @@ -5,15 +5,15 @@ class C(val i: Int?) {} class A(val c: C) { fun test1() { if (this@A.c.i != null) { - useInt(this.c.i) - useInt(c.i) + useInt(this.c.i) + useInt(c.i) } } inner class B { fun test2() { if (c.i != null) { - useInt(this@A.c.i) + useInt(this@A.c.i) } } } @@ -21,15 +21,15 @@ class A(val c: C) { fun A.foo() { if (this@foo.c.i != null) { - useInt(this.c.i) - useInt(c.i) + useInt(this.c.i) + useInt(c.i) } } fun test3() { useFunction { if(c.i != null) { - useInt(this.c.i) + useInt(this.c.i) } } }