Merge branch 'master' of ssh://git.labs.intellij.net/jet

This commit is contained in:
svtk
2011-11-01 19:12:59 +04:00
72 changed files with 1208 additions and 391 deletions
@@ -0,0 +1,26 @@
// KT-389 Wrong type inference for varargs etc.
import java.util.*
fun foob(vararg a : Byte) : ByteArray = a
fun fooc(vararg a : Char) : CharArray = a
fun foos(vararg a : Short) : ShortArray = a
fun fooi(vararg a : Int) : IntArray = a
fun fool(vararg a : Long) : LongArray = a
fun food(vararg a : Double) : DoubleArray = a
fun foof(vararg a : Float) : FloatArray = a
fun foob(vararg a : Boolean) : BooleanArray = a
fun foos(vararg a : String) : Array<String> = a
fun test() {
Arrays.asList(1, 2, 3)
Arrays.asList<Int>(1, 2, 3)
foob(1, 2, 3)
foos(1, 2, 3)
fooc('1', '2', '3')
fooi(1, 2, 3)
fool(1, 2, 3)
food(1.0, 2.0, 3.0)
foof(1.0.flt, 2.0.flt, 3.0.flt)
}
@@ -10,3 +10,14 @@ namespace b {
}
}
namespace c {
import d.X
val x : X = X()
}
namespace d {
class X() {
}
}
@@ -0,0 +1,15 @@
// KT-127 Support extension functions in when expressions
class Foo() {}
fun Any.equals(other : Any?) : Boolean = true
fun Any?.equals1(other : Any?) : Boolean = true
fun main(args: Array<String>) {
val command : Foo? = null
when (command) {
.equals(null) => 1; // must be resolved
?.equals(null) => 1 // same here
}
}
@@ -0,0 +1,12 @@
// KT-128 Support passing only the last closure if all the other parameters have default values
fun div(c : String = "", f : fun()) {}
fun f() {
div { // Nothing passed, but could have been...
// ...
}
div (c = "foo") { // More things could have been passed
// ...
}
}
@@ -0,0 +1,7 @@
// KT-26 Import namespaces defined in this file
namespace foo {
import bar.* // Must not be an error
}
namespace bar {}
@@ -0,0 +1,10 @@
// KT-26 Import namespaces defined in this file
import html.* // Must not be an error
namespace html {
abstract class Factory<T> {
fun create() : T? = null
}
}
@@ -0,0 +1,18 @@
// KT-282 Nullability in extension functions and in binary calls
class Set {
fun contains(x : Int) : Boolean = true
}
fun Set?.plus(x : Int) : Int = 1
fun Int?.contains(x : Int) : Boolean = false
fun f(): Unit {
var set : Set? = null
val i : Int? = null
i <!UNSAFE_INFIX_CALL!>+<!> 1
set + 1
1 <!UNSAFE_INFIX_CALL!>in<!> set
1 in 2
}
@@ -0,0 +1,4 @@
fun box() : String {
var a = 10
return if(a?.plus(10) == 20) "OK" else "fail"
}
+7 -3
View File
@@ -18,7 +18,8 @@ JetFile: Imports_ERR.jet
PsiWhiteSpace(' ')
REFERENCE_EXPRESSION
PsiErrorElement:Expecting qualified name
PsiElement(SEMICOLON)(';')
<empty list>
PsiElement(SEMICOLON)(';')
PsiWhiteSpace('\n')
IMPORT_DIRECTIVE
PsiElement(import)('import')
@@ -27,7 +28,9 @@ JetFile: Imports_ERR.jet
PsiElement(DOT)('.')
REFERENCE_EXPRESSION
PsiErrorElement:Expecting qualified name
PsiElement(MUL)('*')
<empty list>
PsiErrorElement:Expecting namespace or top level declaration
PsiElement(MUL)('*')
PsiWhiteSpace('\n')
IMPORT_DIRECTIVE
PsiElement(import)('import')
@@ -37,7 +40,8 @@ JetFile: Imports_ERR.jet
PsiWhiteSpace(' ')
REFERENCE_EXPRESSION
PsiErrorElement:Expecting qualified name
PsiElement(SEMICOLON)(';')
<empty list>
PsiElement(SEMICOLON)(';')
PsiWhiteSpace('\n\n')
IMPORT_DIRECTIVE
PsiElement(import)('import')