Unit.VALUE -> Unit in testData

This commit is contained in:
Zalim Bashorov
2014-07-12 21:25:00 +04:00
parent 4a8519615a
commit c767ffc3e7
49 changed files with 103 additions and 109 deletions
@@ -1,5 +1,5 @@
fun box(): String { fun box(): String {
val a = if(true) { val a = if(true) {
} }
return if (a.toString() == "Unit.VALUE") "OK" else "fail" return if (a.toString() == "kotlin.Unit") "OK" else "fail"
} }
@@ -1,9 +1,9 @@
fun main(args: Array<String>?) { fun main(args: Array<String>?) {
val y: Unit = Unit.VALUE //do not compile val y: Unit = Unit //do not compile
A<Unit>() //do not compile A<Unit>() //do not compile
C<Unit>(Unit.VALUE) //do not compile C<Unit>(Unit) //do not compile
//do not compile //do not compile
System.out?.println(fff<Unit>(Unit.VALUE)) //do not compile System.out?.println(fff<Unit>(Unit)) //do not compile
System.out?.println(id<Unit>(y)) //do not compile System.out?.println(id<Unit>(y)) //do not compile
System.out?.println(fff<Unit>(id<Unit>(y)) == id<Unit>(foreach(Array<Int>(0,{0}),{(e : Int) : Unit -> }))) //do not compile System.out?.println(fff<Unit>(id<Unit>(y)) == id<Unit>(foreach(Array<Int>(0,{0}),{(e : Int) : Unit -> }))) //do not compile
} }
@@ -14,7 +14,7 @@ val baz: String by StringHandler
val metadatas = IdentityHashMap<PropertyMetadata, Unit>() val metadatas = IdentityHashMap<PropertyMetadata, Unit>()
fun record(p: PropertyMetadata) = metadatas.put(p, Unit.VALUE) fun record(p: PropertyMetadata) = metadatas.put(p, Unit)
object IntHandler { object IntHandler {
fun get(t: Any?, p: PropertyMetadata): Int { record(p); return 42 } fun get(t: Any?, p: PropertyMetadata): Int { record(p); return 42 }
@@ -15,7 +15,7 @@ fun test2(a: A): Int {
} }
fun test3(b: B): Int { fun test3(b: B): Int {
return b[Unit.VALUE, Unit.VALUE] return b[Unit, Unit]
} }
@@ -30,4 +30,4 @@ fun box() : String {
if (result != 2) return "fail3: $result" if (result != 2) return "fail3: $result"
return "OK" return "OK"
} }
@@ -2,10 +2,10 @@ tailRecursive fun foo(x: Int) {
return if (x > 0) { return if (x > 0) {
(foo(x - 1)) (foo(x - 1))
} }
else Unit.VALUE else Unit
} }
fun box(): String { fun box(): String {
foo(1000000) foo(1000000)
return "OK" return "OK"
} }
@@ -3,14 +3,14 @@ class D {
} }
object P { object P {
val u = Unit.VALUE val u = Unit
val v by D() val v by D()
var w = Unit.VALUE var w = Unit
} }
fun box(): String { fun box(): String {
if (P.u != P.v) return "Fail uv" if (P.u != P.v) return "Fail uv"
P.w = Unit.VALUE P.w = Unit
if (P.w != P.u) return "Fail w" if (P.w != P.u) return "Fail w"
return "OK" return "OK"
} }
@@ -1,5 +1,5 @@
fun foo() {} fun foo() {}
fun box(): String { fun box(): String {
return if (foo() == Unit.VALUE) "OK" else "Fail" return if (foo() == Unit) "OK" else "Fail"
} }
+1 -1
View File
@@ -1,4 +1,4 @@
val c = Unit.VALUE val c = Unit
val d = c val d = c
fun box(): String { fun box(): String {
+1 -1
View File
@@ -11,7 +11,7 @@ fun quux(): Unit? = bar()
fun box(): String { fun box(): String {
foo() foo()
if (foo() != Unit.VALUE) return "Fail 1" if (foo() != Unit) return "Fail 1"
if (foo() != bar()) return "Fail 2" if (foo() != bar()) return "Fail 2"
if (bar() != baz()) return "Fail 3" if (bar() != baz()) return "Fail 3"
if (baz() != quux()) return "Fail 4" if (baz() != quux()) return "Fail 4"
@@ -7,7 +7,5 @@ fun box(): String {
if (Unit != Unit) return "Fail Unit != Unit" if (Unit != Unit) return "Fail Unit != Unit"
if (a.VALUE != Unit.VALUE) return "Fail a.VALUE != Unit.VALUE"
return "OK" return "OK"
} }
@@ -1,6 +1,6 @@
data class A(val x: Unit) data class A(val x: Unit)
fun box(): String { fun box(): String {
val a = A(Unit.VALUE) val a = A(Unit)
return if ("$a" == "A(x=Unit.VALUE)") "OK" else "$a" return if ("$a" == "A(x=kotlin.Unit)") "OK" else "$a"
} }
@@ -1,6 +1,6 @@
data class A(val x: Unit) data class A(val x: Unit)
fun box(): String { fun box(): String {
val a = A(Unit.VALUE) val a = A(Unit)
return if (a.component1() is Unit) "OK" else "Fail ${a.component1()}" return if (a.component1() is Unit) "OK" else "Fail ${a.component1()}"
} }
@@ -27,7 +27,7 @@ fun t1() : Boolean {
x = x + "45" + y x = x + "45" + y
x = x.substring(3) x = x.substring(3)
x += "aaa" x += "aaa"
Unit.VALUE Unit
} }
foo() foo()
@@ -43,7 +43,7 @@ fun t2() : Boolean {
x = x + 5 + y x = x + 5 + y
x += 5 x += 5
x++ x++
Unit.VALUE Unit
} }
foo() foo()
x -= 55 x -= 55
@@ -55,7 +55,7 @@ fun t3() : Boolean {
var x = true var x = true
val foo = { val foo = {
x = false x = false
Unit.VALUE Unit
} }
foo() foo()
return !x return !x
@@ -67,7 +67,7 @@ fun t4() : Boolean {
val foo = { val foo = {
x = x + 200.toFloat() + y x = x + 200.toFloat() + y
x += 18 x += 18
Unit.VALUE Unit
} }
foo() foo()
System.out?.println(x) System.out?.println(x)
@@ -80,7 +80,7 @@ fun t5() : Boolean {
val foo = { val foo = {
x = x + 200.toDouble() + y x = x + 200.toDouble() + y
x -= 22 x -= 22
Unit.VALUE Unit
} }
foo() foo()
System.out?.println(x) System.out?.println(x)
@@ -94,7 +94,7 @@ fun t6() : Boolean {
x = (x + 20.toByte() + y).toByte() x = (x + 20.toByte() + y).toByte()
x += 2 x += 2
x-- x--
Unit.VALUE Unit
} }
foo() foo()
System.out?.println(x) System.out?.println(x)
@@ -105,7 +105,7 @@ fun t7() : Boolean {
var x : Char = 'a' var x : Char = 'a'
val foo = { val foo = {
x = 'b' x = 'b'
Unit.VALUE Unit
} }
foo() foo()
System.out?.println(x) System.out?.println(x)
@@ -117,10 +117,10 @@ fun t8() : Boolean {
val foo = { val foo = {
val bar = { val bar = {
x = 30.toShort() x = 30.toShort()
Unit.VALUE Unit
} }
bar() bar()
Unit.VALUE Unit
} }
foo() foo()
return x == 30.toShort() return x == 30.toShort()
+1 -1
View File
@@ -12,5 +12,5 @@ fun test() : Unit {
y <!USELESS_CAST!>as?<!> Int : Int? y <!USELESS_CAST!>as?<!> Int : Int?
x <!USELESS_CAST!>as?<!> Int? : Int? x <!USELESS_CAST!>as?<!> Int? : Int?
y <!USELESS_CAST_STATIC_ASSERT_IS_FINE!>as?<!> Int? : Int? y <!USELESS_CAST_STATIC_ASSERT_IS_FINE!>as?<!> Int? : Int?
Unit.VALUE Unit
} }
@@ -6,7 +6,7 @@ fun unitEmptyInfer() {}
fun unitEmpty() : Unit {} fun unitEmpty() : Unit {}
fun unitEmptyReturn() : Unit {return} fun unitEmptyReturn() : Unit {return}
fun unitIntReturn() : Unit {return <!CONSTANT_EXPECTED_TYPE_MISMATCH!>1<!>} fun unitIntReturn() : Unit {return <!CONSTANT_EXPECTED_TYPE_MISMATCH!>1<!>}
fun unitUnitReturn() : Unit {return Unit.VALUE} fun unitUnitReturn() : Unit {return Unit}
fun test1() : Any = {<!RETURN_NOT_ALLOWED, RETURN_TYPE_MISMATCH!>return<!>} fun test1() : Any = {<!RETURN_NOT_ALLOWED, RETURN_TYPE_MISMATCH!>return<!>}
fun test2() : Any = @a {<!RETURN_NOT_ALLOWED_EXPLICIT_RETURN_TYPE_REQUIRED!>return@a 1<!>} fun test2() : Any = @a {<!RETURN_NOT_ALLOWED_EXPLICIT_RETURN_TYPE_REQUIRED!>return@a 1<!>}
fun test3() : Any { <!RETURN_TYPE_MISMATCH!>return<!> } fun test3() : Any { <!RETURN_TYPE_MISMATCH!>return<!> }
@@ -27,7 +27,7 @@ fun foo(<!UNUSED_PARAMETER!>expr<!>: StringBuilder): Int {
} }
fun unitShort() : Unit = Unit.VALUE fun unitShort() : Unit = Unit
fun unitShortConv() : Unit = <!CONSTANT_EXPECTED_TYPE_MISMATCH!>1<!> fun unitShortConv() : Unit = <!CONSTANT_EXPECTED_TYPE_MISMATCH!>1<!>
fun unitShortNull() : Unit = <!NULL_FOR_NONNULL_TYPE!>null<!> fun unitShortNull() : Unit = <!NULL_FOR_NONNULL_TYPE!>null<!>
@@ -44,7 +44,7 @@ fun intFunctionLiteral(): Int = <!TYPE_MISMATCH!>{ 10 }<!>
fun blockReturnUnitMismatch() : Int {<!RETURN_TYPE_MISMATCH!>return<!>} fun blockReturnUnitMismatch() : Int {<!RETURN_TYPE_MISMATCH!>return<!>}
fun blockReturnValueTypeMismatch() : Int {return <!CONSTANT_EXPECTED_TYPE_MISMATCH!>3.4<!>} fun blockReturnValueTypeMismatch() : Int {return <!CONSTANT_EXPECTED_TYPE_MISMATCH!>3.4<!>}
fun blockReturnValueTypeMatch() : Int {return 1} fun blockReturnValueTypeMatch() : Int {return 1}
fun blockReturnValueTypeMismatchUnit() : Int {return <!TYPE_MISMATCH!>Unit.VALUE<!>} fun blockReturnValueTypeMismatchUnit() : Int {return <!TYPE_MISMATCH!>Unit<!>}
fun blockAndAndMismatch() : Int { fun blockAndAndMismatch() : Int {
true && false true && false
@@ -205,4 +205,4 @@ fun testFunctionLiterals() {
object A {} object A {}
} }
} }
@@ -43,7 +43,7 @@ fun cannotBe() {
<!UNRESOLVED_REFERENCE!>z<!> = 30; <!UNRESOLVED_REFERENCE!>z<!> = 30;
<!VARIABLE_EXPECTED!>""<!> = ""; <!VARIABLE_EXPECTED!>""<!> = "";
<!VARIABLE_EXPECTED!>foo()<!> = Unit.VALUE; <!VARIABLE_EXPECTED!>foo()<!> = Unit;
(<!VARIABLE_EXPECTED!>i <!USELESS_CAST!>as<!> Int<!>) = 34 (<!VARIABLE_EXPECTED!>i <!USELESS_CAST!>as<!> Int<!>) = 34
(<!VARIABLE_EXPECTED!>i is Int<!>) = false (<!VARIABLE_EXPECTED!>i is Int<!>) = false
@@ -39,7 +39,7 @@ fun test() {
<!DEBUG_INFO_AUTOCAST!>out<!>.println(); <!DEBUG_INFO_AUTOCAST!>out<!>.println();
} }
if (out == null || <!DEBUG_INFO_AUTOCAST!>out<!>.println(0) == Unit.VALUE) { if (out == null || <!DEBUG_INFO_AUTOCAST!>out<!>.println(0) == Unit) {
out?.println(1) out?.println(1)
out<!UNSAFE_CALL!>.<!>println(1) out<!UNSAFE_CALL!>.<!>println(1)
} }
@@ -47,21 +47,21 @@ fun test() {
<!DEBUG_INFO_AUTOCAST!>out<!>.println(2) <!DEBUG_INFO_AUTOCAST!>out<!>.println(2)
} }
if (out != null && <!DEBUG_INFO_AUTOCAST!>out<!>.println() == Unit.VALUE) { if (out != null && <!DEBUG_INFO_AUTOCAST!>out<!>.println() == Unit) {
<!DEBUG_INFO_AUTOCAST!>out<!>.println(); <!DEBUG_INFO_AUTOCAST!>out<!>.println();
} }
else { else {
out?.println(); out?.println();
} }
if (out == null || <!DEBUG_INFO_AUTOCAST!>out<!>.println() == Unit.VALUE) { if (out == null || <!DEBUG_INFO_AUTOCAST!>out<!>.println() == Unit) {
out?.println(); out?.println();
} }
else { else {
<!DEBUG_INFO_AUTOCAST!>out<!>.println(); <!DEBUG_INFO_AUTOCAST!>out<!>.println();
} }
if (1 == 2 || out != null && <!DEBUG_INFO_AUTOCAST!>out<!>.println(1) == Unit.VALUE) { if (1 == 2 || out != null && <!DEBUG_INFO_AUTOCAST!>out<!>.println(1) == Unit) {
out?.println(2); out?.println(2);
out<!UNSAFE_CALL!>.<!>println(2); out<!UNSAFE_CALL!>.<!>println(2);
} }
@@ -98,7 +98,7 @@ fun test() {
<!DEBUG_INFO_AUTOCAST!>out<!>.println(); <!DEBUG_INFO_AUTOCAST!>out<!>.println();
} }
if (out == null || <!DEBUG_INFO_AUTOCAST!>out<!>.println(0) == Unit.VALUE) { if (out == null || <!DEBUG_INFO_AUTOCAST!>out<!>.println(0) == Unit) {
out?.println(1) out?.println(1)
out<!UNSAFE_CALL!>.<!>println(1) out<!UNSAFE_CALL!>.<!>println(1)
} }
@@ -106,7 +106,7 @@ fun test() {
<!DEBUG_INFO_AUTOCAST!>out<!>.println(2) <!DEBUG_INFO_AUTOCAST!>out<!>.println(2)
} }
if (out != null && <!DEBUG_INFO_AUTOCAST!>out<!>.println() == Unit.VALUE) { if (out != null && <!DEBUG_INFO_AUTOCAST!>out<!>.println() == Unit) {
<!DEBUG_INFO_AUTOCAST!>out<!>.println(); <!DEBUG_INFO_AUTOCAST!>out<!>.println();
} }
else { else {
@@ -114,7 +114,7 @@ fun test() {
out<!UNSAFE_CALL!>.<!>println(); out<!UNSAFE_CALL!>.<!>println();
} }
if (out == null || <!DEBUG_INFO_AUTOCAST!>out<!>.println() == Unit.VALUE) { if (out == null || <!DEBUG_INFO_AUTOCAST!>out<!>.println() == Unit) {
out?.println(); out?.println();
out<!UNSAFE_CALL!>.<!>println(); out<!UNSAFE_CALL!>.<!>println();
} }
@@ -122,7 +122,7 @@ fun test() {
<!DEBUG_INFO_AUTOCAST!>out<!>.println(); <!DEBUG_INFO_AUTOCAST!>out<!>.println();
} }
if (1 == 2 || out != null && <!DEBUG_INFO_AUTOCAST!>out<!>.println(1) == Unit.VALUE) { if (1 == 2 || out != null && <!DEBUG_INFO_AUTOCAST!>out<!>.println(1) == Unit) {
out?.println(2); out?.println(2);
out<!UNSAFE_CALL!>.<!>println(2); out<!UNSAFE_CALL!>.<!>println(2);
} }
@@ -1,3 +1,3 @@
fun test() { fun test() {
return Unit.VALUE : Unit return Unit : Unit
} }
@@ -17,6 +17,6 @@ fun f3(s: Number?) {
fun f4(s: Int?) { fun f4(s: Int?) {
var u = <!IMPLICIT_CAST_TO_UNIT_OR_ANY!>if (s!! == 42)<!>; var u = <!IMPLICIT_CAST_TO_UNIT_OR_ANY!>if (s!! == 42)<!>;
if (u == Unit.VALUE) u = if (s == 239); if (u == Unit) u = if (s == 239);
return u return u
} }
@@ -2,7 +2,7 @@
package outer package outer
fun Int?.optint() : Unit {} fun Int?.optint() : Unit {}
val Int?.optval : Unit get() = Unit.VALUE val Int?.optval : Unit get() = Unit
fun <T: Any, E> T.foo(<!UNUSED_PARAMETER!>x<!> : E, y : A) : T { fun <T: Any, E> T.foo(<!UNUSED_PARAMETER!>x<!> : E, y : A) : T {
y.plus(1) y.plus(1)
@@ -1,9 +1,9 @@
fun test(a: Int) { fun test(a: Int) {
val x = run @f{ val x = run @f{
if (a > 0) <!RETURN_NOT_ALLOWED_EXPLICIT_RETURN_TYPE_REQUIRED!>return@f<!> if (a > 0) <!RETURN_NOT_ALLOWED_EXPLICIT_RETURN_TYPE_REQUIRED!>return@f<!>
else <!RETURN_NOT_ALLOWED_EXPLICIT_RETURN_TYPE_REQUIRED!>return@f Unit.VALUE<!> else <!RETURN_NOT_ALLOWED_EXPLICIT_RETURN_TYPE_REQUIRED!>return@f Unit<!>
} }
x: Unit x: Unit
} }
fun run<T>(f: () -> T): T { return f() } fun run<T>(f: () -> T): T { return f() }
@@ -20,7 +20,7 @@ fun f9(init : A?) {
a?.<!UNRESOLVED_REFERENCE!>bar<!>() a?.<!UNRESOLVED_REFERENCE!>bar<!>()
a?.foo() a?.foo()
} }
if (!(a is B) || <!DEBUG_INFO_AUTOCAST!>a<!>.bar() == Unit.VALUE) { if (!(a is B) || <!DEBUG_INFO_AUTOCAST!>a<!>.bar() == Unit) {
a?.<!UNRESOLVED_REFERENCE!>bar<!>() a?.<!UNRESOLVED_REFERENCE!>bar<!>()
} }
if (!(a is B)) { if (!(a is B)) {
@@ -102,7 +102,7 @@ fun f13(a : A?) {
} }
a?.foo() a?.foo()
if (a is B && <!DEBUG_INFO_AUTOCAST!>a<!>.foo() == Unit.VALUE) { if (a is B && <!DEBUG_INFO_AUTOCAST!>a<!>.foo() == Unit) {
<!DEBUG_INFO_AUTOCAST!>a<!>.foo() <!DEBUG_INFO_AUTOCAST!>a<!>.foo()
<!DEBUG_INFO_AUTOCAST!>a<!>.bar() <!DEBUG_INFO_AUTOCAST!>a<!>.bar()
} }
@@ -216,4 +216,4 @@ fun foo(aa: Any): Int {
return <!AUTOCAST_IMPOSSIBLE!>a<!> return <!AUTOCAST_IMPOSSIBLE!>a<!>
} }
return 1 return 1
} }
@@ -8,5 +8,5 @@ public abstract class Aaa {
// FILE: bbb.kt // FILE: bbb.kt
class Bbb() : Aaa() { class Bbb() : Aaa() {
override fun foo(vararg args: String?) = Unit.VALUE override fun foo(vararg args: String?) = Unit
} }
@@ -4,12 +4,12 @@ trait Bar
trait A { trait A {
fun <T> foo() fun <T> foo()
where T : Foo, T : Bar where T : Foo, T : Bar
= Unit.VALUE = Unit
} }
class B : A { class B : A {
override fun <T> foo() override fun <T> foo()
where T : Foo, T : Bar where T : Foo, T : Bar
= Unit.VALUE = Unit
} }
@@ -15,8 +15,8 @@ open class MyClass() : MyTrait, MyAbstractClass() {
override fun foo() {} override fun foo() {}
override fun bar() {} override fun bar() {}
override val pr : Unit = Unit.VALUE override val pr : Unit = Unit
override val prr : Unit = Unit.VALUE override val prr : Unit = Unit
} }
class MyChildClass() : MyClass() {} class MyChildClass() : MyClass() {}
@@ -25,14 +25,14 @@ class <!ABSTRACT_MEMBER_NOT_IMPLEMENTED!>MyIllegalClass<!> : MyTrait, MyAbstract
class <!ABSTRACT_MEMBER_NOT_IMPLEMENTED!>MyIllegalClass2<!>() : MyTrait, MyAbstractClass() { class <!ABSTRACT_MEMBER_NOT_IMPLEMENTED!>MyIllegalClass2<!>() : MyTrait, MyAbstractClass() {
override fun foo() {} override fun foo() {}
override val pr : Unit = Unit.VALUE override val pr : Unit = Unit
override val prr : Unit = Unit.VALUE override val prr : Unit = Unit
} }
class <!ABSTRACT_MEMBER_NOT_IMPLEMENTED!>MyIllegalClass3<!>() : MyTrait, MyAbstractClass() { class <!ABSTRACT_MEMBER_NOT_IMPLEMENTED!>MyIllegalClass3<!>() : MyTrait, MyAbstractClass() {
override fun bar() {} override fun bar() {}
override val pr : Unit = Unit.VALUE override val pr : Unit = Unit
override val prr : Unit = Unit.VALUE override val prr : Unit = Unit
} }
class <!ABSTRACT_MEMBER_NOT_IMPLEMENTED!>MyIllegalClass4<!>() : MyTrait, MyAbstractClass() { class <!ABSTRACT_MEMBER_NOT_IMPLEMENTED!>MyIllegalClass4<!>() : MyTrait, MyAbstractClass() {
@@ -44,7 +44,7 @@ class <!ABSTRACT_MEMBER_NOT_IMPLEMENTED!>MyIllegalClass4<!>() : MyTrait, MyAbstr
class MyChildClass1() : MyClass() { class MyChildClass1() : MyClass() {
<!VIRTUAL_MEMBER_HIDDEN!>fun foo()<!> {} <!VIRTUAL_MEMBER_HIDDEN!>fun foo()<!> {}
<!VIRTUAL_MEMBER_HIDDEN!>val pr : Unit<!> = Unit.VALUE <!VIRTUAL_MEMBER_HIDDEN!>val pr : Unit<!> = Unit
override fun bar() {} override fun bar() {}
override val prr : Unit = Unit.VALUE override val prr : Unit = Unit
} }
@@ -20,7 +20,7 @@ fun foo(a: A) {
a.gen() // unit can be inferred a.gen() // unit can be inferred
} }
else { else {
Unit.VALUE Unit
} }
} }
@@ -29,4 +29,4 @@ fun foo(a: A) {
} }
a.<!TYPE_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>gen<!>() // Shouldn't work: no info for inference a.<!TYPE_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>gen<!>() // Shouldn't work: no info for inference
} }
@@ -1,7 +1,7 @@
import kotlin.reflect.* import kotlin.reflect.*
class A { class A {
val foo: Unit = Unit.VALUE val foo: Unit = Unit
var bar: String = "" var bar: String = ""
var self: A var self: A
get() = this get() = this
@@ -1,5 +1,5 @@
package test package test
public open class MethodTypePOneUpperBound() : java.lang.Object() { public open class MethodTypePOneUpperBound() : java.lang.Object() {
public open fun <T : Cloneable?> bar() : Unit = Unit.VALUE public open fun <T : Cloneable?> bar() : Unit = Unit
} }
@@ -1,5 +1,5 @@
package test package test
public class MethodWithTypeP() : java.lang.Object() { public class MethodWithTypeP() : java.lang.Object() {
public fun <P> f() : Unit = Unit.VALUE public fun <P> f() : Unit = Unit
} }
@@ -1,5 +1,5 @@
package test package test
public class MethodWithTypePP() : java.lang.Object() { public class MethodWithTypePP() : java.lang.Object() {
public fun <P, Q : P> f() : Unit = Unit.VALUE public fun <P, Q : P> f() : Unit = Unit
} }
@@ -1,5 +1,5 @@
package test package test
public open class MethodWithTypePRefClassP<P>() : java.lang.Object() { public open class MethodWithTypePRefClassP<P>() : java.lang.Object() {
public fun <Q : P> f() : Unit = Unit.VALUE public fun <Q : P> f() : Unit = Unit
} }
@@ -1,5 +1,5 @@
package test package test
public final class MethosWithPRefTP() : java.lang.Object() { public final class MethosWithPRefTP() : java.lang.Object() {
public fun <P> f(p0: P?) : Unit = Unit.VALUE public fun <P> f(p0: P?) : Unit = Unit
} }
@@ -1,5 +1,5 @@
package test package test
public open class VarargInt() : java.lang.Object() { public open class VarargInt() : java.lang.Object() {
public open fun vararg(vararg p0: Int): Unit = Unit.VALUE public open fun vararg(vararg p0: Int): Unit = Unit
} }
@@ -1,5 +1,5 @@
package test package test
public open class VarargString() : java.lang.Object() { public open class VarargString() : java.lang.Object() {
public open fun vararg(vararg p0: String?): Unit = Unit.VALUE public open fun vararg(vararg p0: String?): Unit = Unit
} }
@@ -5,4 +5,4 @@ trait Bar
fun <T> foo(): Unit fun <T> foo(): Unit
where T : Foo, T : Bar where T : Foo, T : Bar
= Unit.VALUE = Unit
@@ -1,4 +1,4 @@
//ALLOW_AST_ACCESS //ALLOW_AST_ACCESS
package test package test
fun unit() = Unit.VALUE fun unit() = Unit
@@ -1,6 +1,6 @@
package test package test
public open class Super { public open class Super {
public fun String.foo() = Unit.VALUE public fun String.foo() = Unit
public abstract fun String.bar(p: String) public abstract fun String.bar(p: String)
} }
+2 -2
View File
@@ -1,5 +1,5 @@
fun a( fun a(
a : foo = Unit.VALUE, a : foo = Unit,
a : foo = 10, a : foo = 10,
a : foo = 0x10, a : foo = 0x10,
a : foo = '1', a : foo = '1',
@@ -43,4 +43,4 @@ fun a(
continue continue
@la @la
continue @la continue @la
} }
+3 -7
View File
@@ -20,12 +20,8 @@ JetFile: SimpleExpressions.kt
PsiWhiteSpace(' ') PsiWhiteSpace(' ')
PsiElement(EQ)('=') PsiElement(EQ)('=')
PsiWhiteSpace(' ') PsiWhiteSpace(' ')
DOT_QUALIFIED_EXPRESSION REFERENCE_EXPRESSION
REFERENCE_EXPRESSION PsiElement(IDENTIFIER)('Unit')
PsiElement(IDENTIFIER)('Unit')
PsiElement(DOT)('.')
REFERENCE_EXPRESSION
PsiElement(IDENTIFIER)('VALUE')
PsiElement(COMMA)(',') PsiElement(COMMA)(',')
PsiWhiteSpace('\n ') PsiWhiteSpace('\n ')
VALUE_PARAMETER VALUE_PARAMETER
@@ -728,4 +724,4 @@ JetFile: SimpleExpressions.kt
LABEL LABEL
PsiElement(LABEL_IDENTIFIER)('@la') PsiElement(LABEL_IDENTIFIER)('@la')
PsiWhiteSpace('\n') PsiWhiteSpace('\n')
PsiElement(RBRACE)('}') PsiElement(RBRACE)('}')
+2 -2
View File
@@ -12,5 +12,5 @@ fun test() : Unit {
y <warning>as?</warning> Int : Int? y <warning>as?</warning> Int : Int?
x <warning>as?</warning> Int? : Int? x <warning>as?</warning> Int? : Int?
y <warning>as?</warning> Int? : Int? y <warning>as?</warning> Int? : Int?
Unit.VALUE Unit
} }
+1 -1
View File
@@ -1,5 +1,5 @@
fun Int?.optint() : Unit {} fun Int?.optint() : Unit {}
val Int?.optval : Unit get() = Unit.VALUE val Int?.optval : Unit get() = Unit
fun <T: Any, E> T.foo(<warning>x</warning> : E, y : A) : T { fun <T: Any, E> T.foo(<warning>x</warning> : E, y : A) : T {
y.plus(1) y.plus(1)
+3 -3
View File
@@ -4,7 +4,7 @@ fun unitEmptyInfer() {}
fun unitEmpty() : Unit {} fun unitEmpty() : Unit {}
fun unitEmptyReturn() : Unit {return} fun unitEmptyReturn() : Unit {return}
fun unitIntReturn() : Unit {return <error>1</error>} fun unitIntReturn() : Unit {return <error>1</error>}
fun unitUnitReturn() : Unit {return Unit.VALUE} fun unitUnitReturn() : Unit {return Unit}
fun test1() : Any = { <error>return</error> } fun test1() : Any = { <error>return</error> }
fun test2() : Any = @a {<error>return@a 1</error>} fun test2() : Any = @a {<error>return@a 1</error>}
fun test3() : Any { <error>return</error> } fun test3() : Any { <error>return</error> }
@@ -22,7 +22,7 @@ fun foo(<warning>expr</warning>: StringBuilder): Int {
} }
fun unitShort() : Unit = Unit.VALUE fun unitShort() : Unit = Unit
fun unitShortConv() : Unit = <error>1</error> fun unitShortConv() : Unit = <error>1</error>
fun unitShortNull() : Unit = <error>null</error> fun unitShortNull() : Unit = <error>null</error>
@@ -39,7 +39,7 @@ fun intFunctionLiteral(): Int = <error>{ 10 }</error>
fun blockReturnUnitMismatch() : Int {<error>return</error>} fun blockReturnUnitMismatch() : Int {<error>return</error>}
fun blockReturnValueTypeMismatch() : Int {return <error>3.4</error>} fun blockReturnValueTypeMismatch() : Int {return <error>3.4</error>}
fun blockReturnValueTypeMatch() : Int {return 1} fun blockReturnValueTypeMatch() : Int {return 1}
fun blockReturnValueTypeMismatchUnit() : Int {return <error>Unit.VALUE</error>} fun blockReturnValueTypeMismatchUnit() : Int {return <error>Unit</error>}
fun blockAndAndMismatch() : Int { fun blockAndAndMismatch() : Int {
true && false true && false
+8 -8
View File
@@ -38,28 +38,28 @@ fun test() {
out.println(); out.println();
} }
if (out == null || out.println(0) == Unit.VALUE) { if (out == null || out.println(0) == Unit) {
out?.println(1) out?.println(1)
} }
else { else {
out.println(2) out.println(2)
} }
if (out != null && out.println() == Unit.VALUE) { if (out != null && out.println() == Unit) {
out.println(); out.println();
} }
else { else {
out?.println(); out?.println();
} }
if (out == null || out.println() == Unit.VALUE) { if (out == null || out.println() == Unit) {
out?.println(); out?.println();
} }
else { else {
out.println(); out.println();
} }
if (1 == 2 || out != null && out.println(1) == Unit.VALUE) { if (1 == 2 || out != null && out.println(1) == Unit) {
out?.println(2); out?.println(2);
} }
else { else {
@@ -94,28 +94,28 @@ fun test() {
out.println(); out.println();
} }
if (out == null || out.println(0) == Unit.VALUE) { if (out == null || out.println(0) == Unit) {
out?.println(1) out?.println(1)
} }
else { else {
out.println(2) out.println(2)
} }
if (out != null && out.println() == Unit.VALUE) { if (out != null && out.println() == Unit) {
out.println(); out.println();
} }
else { else {
out?.println(); out?.println();
} }
if (out == null || out.println() == Unit.VALUE) { if (out == null || out.println() == Unit) {
out?.println(); out?.println();
} }
else { else {
out.println(); out.println();
} }
if (1 == 2 || out != null && out.println(1) == Unit.VALUE) { if (1 == 2 || out != null && out.println(1) == Unit) {
out?.println(2); out?.println(2);
} }
else { else {
+2 -2
View File
@@ -19,7 +19,7 @@ fun f9(a : A?) {
a<info>?.</info><error descr="[UNRESOLVED_REFERENCE] Unresolved reference: bar">bar</error>() a<info>?.</info><error descr="[UNRESOLVED_REFERENCE] Unresolved reference: bar">bar</error>()
a<info>?.</info>foo() a<info>?.</info>foo()
} }
if (!(a is B) || <info descr="Automatically cast to B">a</info>.bar() == Unit.VALUE) { if (!(a is B) || <info descr="Automatically cast to B">a</info>.bar() == Unit) {
a<info>?.</info><error descr="[UNRESOLVED_REFERENCE] Unresolved reference: bar">bar</error>() a<info>?.</info><error descr="[UNRESOLVED_REFERENCE] Unresolved reference: bar">bar</error>()
} }
if (!(a is B)) { if (!(a is B)) {
@@ -97,7 +97,7 @@ fun f13(a : A?) {
} }
a<info>?.</info>foo() a<info>?.</info>foo()
if (a is B && <info descr="Automatically cast to B">a</info>.foo() == Unit.VALUE) { if (a is B && <info descr="Automatically cast to B">a</info>.foo() == Unit) {
<info descr="Automatically cast to B">a</info>.foo() <info descr="Automatically cast to B">a</info>.foo()
<info descr="Automatically cast to B">a</info>.bar() <info descr="Automatically cast to B">a</info>.bar()
} }
@@ -1,7 +1,7 @@
fun test() { fun test() {
class Test() class Test()
fun Test.invoke(): Unit = Unit.VALUE fun Test.invoke(): Unit = Unit
val test = Test() val test = Test()
test.i<caret>nvoke() test.i<caret>nvoke()
@@ -1,7 +1,7 @@
fun test() { fun test() {
class Test() class Test()
fun Test.invoke(): Unit = Unit.VALUE fun Test.invoke(): Unit = Unit
val test = Test() val test = Test()
test() test()
@@ -1 +1 @@
val x <caret>= Unit.VALUE val x <caret>= Unit
@@ -1 +1 @@
val x: Unit = Unit.VALUE val x: Unit = Unit
@@ -1 +1 @@
fun <caret>test(a : Int = 1) = Unit.VALUE fun <caret>test(a : Int = 1) = Unit