Merge remote-tracking branch 'origin/master'

This commit is contained in:
svtk
2011-11-10 22:13:57 +04:00
38 changed files with 964 additions and 281 deletions
@@ -1,5 +1,6 @@
trait A {
fun foo() : Int = 1
fun foo2() : Int = 1
fun foo1() : Int = 1
val a : Int
val a1 : Int
@@ -12,7 +13,7 @@ trait A {
abstract class B() : A {
override fun <!RETURN_TYPE_MISMATCH_ON_OVERRIDE!>foo<!>() {
}
override fun foo() : <!RETURN_TYPE_MISMATCH_ON_OVERRIDE!>Unit<!> {
override fun foo2() : <!RETURN_TYPE_MISMATCH_ON_OVERRIDE!>Unit<!> {
}
override val a : <!RETURN_TYPE_MISMATCH_ON_OVERRIDE!>Double<!> = 1.dbl
@@ -10,7 +10,7 @@ fun test2() : Any = @a {return@a 1}
fun test3() : Any { <!RETURN_TYPE_MISMATCH!>return<!> }
fun test4(): fun(): Unit = { <!RETURN_TYPE_MISMATCH, RETURN_NOT_ALLOWED!>return@test4<!> }
fun test5(): Any = @{ return@ }
fun test5(): Any = {<!RETURN_NOT_ALLOWED!>return 1<!>}
fun test6(): Any = {<!RETURN_NOT_ALLOWED!>return 1<!>}
fun bbb() {
return <!TYPE_MISMATCH!>1<!>
@@ -34,7 +34,7 @@ fun intShortInfer() = 1
fun intShort() : Int = 1
//fun intBlockInfer() {1}
fun intBlock() : Int {return 1}
fun intBlock() : Int {<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>1<!>}
fun intBlock1() : Int {<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>1<!>}
fun intString(): Int = <!TYPE_MISMATCH!>"s"<!>
fun intFunctionLiteral(): Int = <!TYPE_MISMATCH!>{ 10 }<!>
@@ -47,70 +47,70 @@ fun blockReturnValueTypeMismatchUnit() : Int {return <!TYPE_MISMATCH!>()<!>}
fun blockAndAndMismatch() : Int {
<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>true && false<!>
}
fun blockAndAndMismatch() : Int {
fun blockAndAndMismatch1() : Int {
return <!TYPE_MISMATCH!>true && false<!>
}
fun blockAndAndMismatch() : Int {
fun blockAndAndMismatch2() : Int {
<!UNREACHABLE_CODE!>(return <!ERROR_COMPILE_TIME_VALUE!>true<!>) && (return <!ERROR_COMPILE_TIME_VALUE!>false<!>)<!>
}
fun blockAndAndMismatch() : Int {
fun blockAndAndMismatch3() : Int {
<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>true || false<!>
}
fun blockAndAndMismatch() : Int {
fun blockAndAndMismatch4() : Int {
return <!TYPE_MISMATCH!>true || false<!>
}
fun blockAndAndMismatch() : Int {
fun blockAndAndMismatch5() : Int {
<!UNREACHABLE_CODE!>(return <!ERROR_COMPILE_TIME_VALUE!>true<!>) || (return <!ERROR_COMPILE_TIME_VALUE!>false<!>)<!>
}
fun blockReturnValueTypeMatch() : Int {
fun blockReturnValueTypeMatch1() : Int {
return if (1 > 2) <!ERROR_COMPILE_TIME_VALUE!>1.0<!> else <!ERROR_COMPILE_TIME_VALUE!>2.0<!>
}
fun blockReturnValueTypeMatch() : Int {
fun blockReturnValueTypeMatch2() : Int {
return <!TYPE_MISMATCH!>if (1 > 2) 1<!>
}
fun blockReturnValueTypeMatch() : Int {
fun blockReturnValueTypeMatch3() : Int {
return <!TYPE_MISMATCH!>if (1 > 2) else 1<!>
}
fun blockReturnValueTypeMatch() : Int {
fun blockReturnValueTypeMatch4() : Int {
if (1 > 2)
return <!ERROR_COMPILE_TIME_VALUE!>1.0<!>
else return <!ERROR_COMPILE_TIME_VALUE!>2.0<!>
}
fun blockReturnValueTypeMatch() : Int {
fun blockReturnValueTypeMatch5() : Int {
if (1 > 2)
return <!ERROR_COMPILE_TIME_VALUE!>1.0<!>
return <!ERROR_COMPILE_TIME_VALUE!>2.0<!>
}
fun blockReturnValueTypeMatch() : Int {
fun blockReturnValueTypeMatch6() : Int {
if (1 > 2)
else return <!ERROR_COMPILE_TIME_VALUE!>1.0<!>
return <!ERROR_COMPILE_TIME_VALUE!>2.0<!>
}
fun blockReturnValueTypeMatch() : Int {
fun blockReturnValueTypeMatch7() : Int {
if (1 > 2)
<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>1.0<!>
else <!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>2.0<!>
}
fun blockReturnValueTypeMatch() : Int {
fun blockReturnValueTypeMatch8() : Int {
if (1 > 2)
1.0
else 2.0
return 1
}
fun blockReturnValueTypeMatch() : Int {
fun blockReturnValueTypeMatch9() : Int {
<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>if (1 > 2)
<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>1.0<!><!>
}
fun blockReturnValueTypeMatch() : Int {
fun blockReturnValueTypeMatch10() : Int {
return <!TYPE_MISMATCH!>if (1 > 2)
1<!>
}
fun blockReturnValueTypeMatch() : Int {
fun blockReturnValueTypeMatch11() : Int {
<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>if (1 > 2)
else <!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>1.0<!><!>
}
fun blockReturnValueTypeMatch() : Int {
fun blockReturnValueTypeMatch12() : Int {
if (1 > 2)
return 1
else return <!ERROR_COMPILE_TIME_VALUE!>1.0<!>
@@ -166,9 +166,9 @@ fun f(): Int {
if (1 < 2) { return 1 } else returnNothing()
}
fun f(): Int = if (1 < 2) 1 else returnNothing()
fun f1(): Int = if (1 < 2) 1 else returnNothing()
public fun <!PUBLIC_MEMBER_SHOULD_SPECIFY_TYPE!>f<!>() = 1
public fun <!PUBLIC_MEMBER_SHOULD_SPECIFY_TYPE!>f2<!>() = 1
class B() {
protected fun <!PUBLIC_MEMBER_SHOULD_SPECIFY_TYPE!>f<!>() = "ss"
}
@@ -17,8 +17,4 @@ fun test(a : java.util.ArrayList<Int>) {
fun test(a : java.lang.Class<Int>) {
}
fun test(a : java.lang.Class<Int>) {
}
@@ -46,7 +46,7 @@ class C() : A() {
}
}
fun f10(a : A?) {
fun f101(a : A?) {
if (a is C) {
a.bar();
}
@@ -0,0 +1,14 @@
// KT-336 Can't infer type parameter for ArrayList in a generic function (Exception in type inference)
// KT-335 Type inference fails on Collections.sort
import java.util.*
import java.lang.Comparable as Comparable
fun <T : java.lang.Comparable<T>> List<T>.sort() {
Collections.sort(this) // Error here
}
fun <T> List<T>.plus(other : List<T>) : List<T> {
val result = ArrayList(this)
return result
}
@@ -0,0 +1,34 @@
// KT-385 type inference does not work properly`
// KT-109 Good code is red: type arguments are not inferred
// KT-441 Exception in type inference when multiple overloads accepting an integer literal are accessible
import java.util.*
fun <T> Iterator<T>.foreach(operation: fun(element: T) : Unit) : Unit = while(hasNext) operation(next())
fun <T> Iterator<T>.foreach(operation: fun(index: Int, element: T) : Unit) : Unit {
var k = 0
while(hasNext)
operation(k++, next())
}
fun <T> Iterable<T>.foreach(operation: fun(element: T) : Unit) : Unit = iterator() foreach operation
fun <T> Iterable<T>.foreach(operation: fun(index: Int, element: T) : Unit) : Unit = iterator() foreach operation
fun box() : String {
return generic_invoker( { () : String => "OK"} )
}
fun <T> generic_invoker(gen : fun () : T) : T {
return gen()
}
fun println(message : Int) { System.out?.println(message) }
fun println(message : Long) { System.out?.println(message) }
inline fun run<T>(body : fun() : T) : T = body()
fun main(args : Array<String>) {
println(run { 1 })
}
@@ -0,0 +1,42 @@
// http://youtrack.jetbrains.net/issue/KT-424
class A {
<!CONFLICTING_OVERLOADS!>fun a(a: Int): Int<!> = 0
<!CONFLICTING_OVERLOADS!>fun a(a: Int)<!> {
}
<!CONFLICTING_OVERLOADS!>fun b()<!> {
}
<!CONFLICTING_OVERLOADS!>fun b()<!> {
}
}
namespace deepSpace {
<!CONFLICTING_OVERLOADS!>fun c(s: String)<!> {
}
<!CONFLICTING_OVERLOADS!>fun c(s: String)<!> {
}
class B {
<!CONFLICTING_OVERLOADS!>fun d(s: String)<!> {
}
<!CONFLICTING_OVERLOADS!>fun d(s: String)<!> {
}
}
}
// check no error in overload in different namespaces
namespace ns1 {
fun e() = 1
}
namespace ns2 {
fun e() = 1
}
@@ -0,0 +1,15 @@
namespace dollar
open class `$$$$$`() {
}
open class `$`() {
}
open class `$$`(`$$$$` : `$$$$$`?) : `$`() {
val `$$$` : `$$$$$`?
{
$`$$$` = `$$$$`
}
open public fun `$$$$$$`() : `$$$$$`? {
return `$$$`
}
}
@@ -0,0 +1,26 @@
// http://youtrack.jetbrains.net/issue/KT-451
// KT-451 Incorrect character literals cause assertion failures
fun ff() {
val b = <!ERROR_COMPILE_TIME_VALUE!>''<!>
val c = <!ERROR_COMPILE_TIME_VALUE!>'23'<!>
val d = <!ERROR_COMPILE_TIME_VALUE!>'a<!>
val e = <!ERROR_COMPILE_TIME_VALUE!>'ab<!>
val f = <!ERROR_COMPILE_TIME_VALUE!>'\'<!>
}
fun test() {
'a'
'\n'
'\t'
'\b'
'\r'
'\"'
'\''
'\\'
'\$'
<!ERROR_COMPILE_TIME_VALUE!>'\x'<!>
<!ERROR_COMPILE_TIME_VALUE!>'\123'<!>
<!ERROR_COMPILE_TIME_VALUE!>'\ra'<!>
<!ERROR_COMPILE_TIME_VALUE!>'\000'<!>
}
@@ -15,7 +15,7 @@ fun test(a : A?) {
a<!UNNECESSARY_SAFE_CALL!>?.<!>buzz() // warning
}
fun A.test() {
fun A.test2() {
foo()
bar()
buzz()
@@ -1,3 +1,8 @@
[`return`] fun `namespace`() {
`class`()
}
class `$`
class `$$`
class ` `
class `1`
+29 -1
View File
@@ -29,4 +29,32 @@ JetFile: QuotedIdentifiers.jet
PsiElement(LPAR)('(')
PsiElement(RPAR)(')')
PsiWhiteSpace('\n')
PsiElement(RBRACE)('}')
PsiElement(RBRACE)('}')
PsiWhiteSpace('\n\n')
CLASS
PsiElement(class)('class')
PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('`$`')
PsiWhiteSpace('\n')
TYPE_PARAMETER_LIST
<empty list>
CLASS
PsiElement(class)('class')
PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('`$$`')
PsiWhiteSpace('\n')
TYPE_PARAMETER_LIST
<empty list>
CLASS
PsiElement(class)('class')
PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('` `')
PsiWhiteSpace('\n')
TYPE_PARAMETER_LIST
<empty list>
CLASS
PsiElement(class)('class')
PsiWhiteSpace(' ')
PsiElement(IDENTIFIER)('`1`')
TYPE_PARAMETER_LIST
<empty list>