Merge remote-tracking branch 'origin/master'
Conflicts: compiler/frontend/src/org/jetbrains/jet/lang/cfg/JetFlowInformationProvider.java
This commit is contained in:
@@ -0,0 +1,29 @@
|
||||
fun escapeChar(c : Char) : String? = when (c) {
|
||||
'\\' => "\\\\"
|
||||
'\n' => "\\n"
|
||||
'"' => "\\\""
|
||||
else => String.valueOf(c)
|
||||
}
|
||||
|
||||
fun String.escape(i : Int = 0, result : String = "") : String =
|
||||
if (i == length) result
|
||||
else escape(i + 1, result + escapeChar(get(i)))
|
||||
|
||||
fun box() : String {
|
||||
val s = " System.out?.println(\"fun escapeChar(c : Char) : String? = when (c) {\");\n System.out?.println(\" '\\\\\\\\' => \\\"\\\\\\\\\\\\\\\\\\\"\");\n System.out?.println(\" '\\\\n' => \\\"\\\\\\\\n\\\"\");\n System.out?.println(\" '\\\"' => \\\"\\\\\\\\\\\\\\\"\\\"\");\n System.out?.println(\" else => String.valueOf(c)\");\n System.out?.println(\"}\");\n System.out?.println();\n System.out?.println(\"fun String.escape(i : Int = 0, result : String = \\\"\\\") : String =\");\n System.out?.println(\" if (i == length) result\");\n System.out?.println(\" else escape(i + 1, result + escapeChar(this.get(i)))\");\n System.out?.println();\n System.out?.println(\"fun main(args : Array<String>) {\");\n System.out?.println(\" val s = \\\"\" + s.escape() + \"\\\";\");\n System.out?.println(s);\n}\n";
|
||||
System.out?.println("fun escapeChar(c : Char) : String? = when (c) {");
|
||||
System.out?.println(" '\\\\' => \"\\\\\\\\\"");
|
||||
System.out?.println(" '\\n' => \"\\\\n\"");
|
||||
System.out?.println(" '\"' => \"\\\\\\\"\"");
|
||||
System.out?.println(" else => String.valueOf(c)");
|
||||
System.out?.println("}");
|
||||
System.out?.println();
|
||||
System.out?.println("fun String.escape(i : Int = 0, result : String = \"\") : String =");
|
||||
System.out?.println(" if (i == length) result");
|
||||
System.out?.println(" else escape(i + 1, result + escapeChar(this.get(i)))");
|
||||
System.out?.println();
|
||||
System.out?.println("fun main(args : Array<String>) {");
|
||||
System.out?.println(" val s = \"" + s.escape() + "\";");
|
||||
System.out?.println(s);
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
namespace demo_range
|
||||
|
||||
fun Int?.rangeTo(other : Int?) : IntRange = this.sure().rangeTo(other.sure())
|
||||
|
||||
fun box() : String {
|
||||
val x : Int? = 10
|
||||
val y : Int? = 12
|
||||
|
||||
for (i in x..y)
|
||||
System.out?.println(i.inv())
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
namespace bitwise_demo
|
||||
|
||||
fun Long?.shl(bits : Int?) : Long = this.sure().shl(bits.sure())
|
||||
|
||||
fun box() : String {
|
||||
val x : Long? = 10
|
||||
val y : Int? = 12
|
||||
|
||||
System.out?.println(x.shl(y))
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
namespace demo_range
|
||||
|
||||
fun Int?.plus() : Int = this.sure().plus()
|
||||
fun Int?.dec() : Int = this.sure().dec()
|
||||
fun Int?.inc() : Int = this.sure().inc()
|
||||
fun Int?.minus() : Int = this.sure().minus()
|
||||
|
||||
fun box() : String {
|
||||
val x : Int? = 10
|
||||
System.out?.println(x?.inv())// * x?.plus() * x?.dec() * x?.minus() as Number)
|
||||
return "OK"
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
namespace demo_long
|
||||
|
||||
fun Long?.inv() : Long = this.sure().inv()
|
||||
|
||||
fun box() : String {
|
||||
val x : Long? = 10
|
||||
System.out?.println(x.inv())
|
||||
return if(x.inv() == -11.lng) "OK" else "fail"
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
// +JDK
|
||||
// KT-689 Allow to put Java and Kotlin files in the same packages
|
||||
|
||||
// This is a stub test. One should not extend Java packages that come from libraries.
|
||||
namespace java
|
||||
|
||||
val c : lang.Class<*>? = null
|
||||
|
||||
val <T> Array<T>?.length : Int get() = if (this != null) this.size else throw NullPointerException()
|
||||
@@ -0,0 +1,13 @@
|
||||
// KT-716 Type inference failed
|
||||
// +JDK
|
||||
|
||||
fun <T> typeinfo.TypeInfo<T>.getJavaClass() : java.lang.Class<T> {
|
||||
val t : java.lang.Object = this <!CAST_NEVER_SUCCEEDS!>as<!> java.lang.Object
|
||||
return <!UNCHECKED_CAST!>t.getClass() as java.lang.Class<T><!> // inferred type is Object but Serializable was expected
|
||||
}
|
||||
|
||||
fun getJavaClass<T>() = typeinfo.typeinfo<T>.getJavaClass()
|
||||
|
||||
fun main(args : Array<String>) {
|
||||
System.out?.println(getJavaClass<String>)
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
namespace test
|
||||
|
||||
class Ramification
|
||||
@@ -0,0 +1,5 @@
|
||||
namespace test
|
||||
|
||||
class River {
|
||||
fun song() = 1
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
namespace test
|
||||
|
||||
fun fff(a: String) = 1
|
||||
@@ -0,0 +1,3 @@
|
||||
namespace test
|
||||
|
||||
fun fff(a: String?) = 1
|
||||
@@ -0,0 +1,3 @@
|
||||
namespace test
|
||||
|
||||
fun f() = 1
|
||||
Reference in New Issue
Block a user