deprecating types after colon
This commit is contained in:
@@ -569,7 +569,7 @@ public interface Errors {
|
|||||||
DiagnosticFactory1<JetElement, JetType> CANNOT_CHECK_FOR_ERASED = DiagnosticFactory1.create(ERROR);
|
DiagnosticFactory1<JetElement, JetType> CANNOT_CHECK_FOR_ERASED = DiagnosticFactory1.create(ERROR);
|
||||||
DiagnosticFactory2<JetBinaryExpressionWithTypeRHS, JetType, JetType> UNCHECKED_CAST = DiagnosticFactory2.create(WARNING);
|
DiagnosticFactory2<JetBinaryExpressionWithTypeRHS, JetType, JetType> UNCHECKED_CAST = DiagnosticFactory2.create(WARNING);
|
||||||
|
|
||||||
DiagnosticFactory0<JetBinaryExpressionWithTypeRHS> USELESS_CAST_STATIC_ASSERT_IS_FINE = DiagnosticFactory0.create(WARNING, AS_TYPE);
|
DiagnosticFactory0<JetBinaryExpressionWithTypeRHS> DEPRECATED_STATIC_ASSERT = DiagnosticFactory0.create(WARNING, AS_TYPE);
|
||||||
DiagnosticFactory0<JetBinaryExpressionWithTypeRHS> USELESS_CAST = DiagnosticFactory0.create(WARNING, AS_TYPE);
|
DiagnosticFactory0<JetBinaryExpressionWithTypeRHS> USELESS_CAST = DiagnosticFactory0.create(WARNING, AS_TYPE);
|
||||||
DiagnosticFactory0<JetSimpleNameExpression> CAST_NEVER_SUCCEEDS = DiagnosticFactory0.create(WARNING);
|
DiagnosticFactory0<JetSimpleNameExpression> CAST_NEVER_SUCCEEDS = DiagnosticFactory0.create(WARNING);
|
||||||
DiagnosticFactory0<JetTypeReference> DYNAMIC_NOT_ALLOWED = DiagnosticFactory0.create(ERROR);
|
DiagnosticFactory0<JetTypeReference> DYNAMIC_NOT_ALLOWED = DiagnosticFactory0.create(ERROR);
|
||||||
@@ -673,7 +673,7 @@ public interface Errors {
|
|||||||
INVISIBLE_MEMBER, INVISIBLE_MEMBER_FROM_INLINE, INVISIBLE_REFERENCE, INVISIBLE_SETTER);
|
INVISIBLE_MEMBER, INVISIBLE_MEMBER_FROM_INLINE, INVISIBLE_REFERENCE, INVISIBLE_SETTER);
|
||||||
ImmutableSet<? extends DiagnosticFactory<?>> UNUSED_ELEMENT_DIAGNOSTICS = ImmutableSet.of(
|
ImmutableSet<? extends DiagnosticFactory<?>> UNUSED_ELEMENT_DIAGNOSTICS = ImmutableSet.of(
|
||||||
UNUSED_VARIABLE, UNUSED_PARAMETER, ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE, VARIABLE_WITH_REDUNDANT_INITIALIZER,
|
UNUSED_VARIABLE, UNUSED_PARAMETER, ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE, VARIABLE_WITH_REDUNDANT_INITIALIZER,
|
||||||
UNUSED_FUNCTION_LITERAL, USELESS_CAST, USELESS_CAST_STATIC_ASSERT_IS_FINE);
|
UNUSED_FUNCTION_LITERAL, USELESS_CAST);
|
||||||
ImmutableSet<? extends DiagnosticFactory<?>> TYPE_INFERENCE_ERRORS = ImmutableSet.of(
|
ImmutableSet<? extends DiagnosticFactory<?>> TYPE_INFERENCE_ERRORS = ImmutableSet.of(
|
||||||
TYPE_INFERENCE_NO_INFORMATION_FOR_PARAMETER, TYPE_INFERENCE_CONFLICTING_SUBSTITUTIONS, TYPE_INFERENCE_TYPE_CONSTRUCTOR_MISMATCH,
|
TYPE_INFERENCE_NO_INFORMATION_FOR_PARAMETER, TYPE_INFERENCE_CONFLICTING_SUBSTITUTIONS, TYPE_INFERENCE_TYPE_CONSTRUCTOR_MISMATCH,
|
||||||
TYPE_INFERENCE_UPPER_BOUND_VIOLATED, TYPE_INFERENCE_EXPECTED_TYPE_MISMATCH);
|
TYPE_INFERENCE_UPPER_BOUND_VIOLATED, TYPE_INFERENCE_EXPECTED_TYPE_MISMATCH);
|
||||||
|
|||||||
+1
-1
@@ -291,7 +291,7 @@ public class DefaultErrorMessages {
|
|||||||
MAP.put(ABSTRACT_SUPER_CALL, "Abstract member cannot be accessed directly");
|
MAP.put(ABSTRACT_SUPER_CALL, "Abstract member cannot be accessed directly");
|
||||||
MAP.put(NOT_A_SUPERTYPE, "Not a supertype");
|
MAP.put(NOT_A_SUPERTYPE, "Not a supertype");
|
||||||
MAP.put(TYPE_ARGUMENTS_REDUNDANT_IN_SUPER_QUALIFIER, "Type arguments do not need to be specified in a 'super' qualifier");
|
MAP.put(TYPE_ARGUMENTS_REDUNDANT_IN_SUPER_QUALIFIER, "Type arguments do not need to be specified in a 'super' qualifier");
|
||||||
MAP.put(USELESS_CAST_STATIC_ASSERT_IS_FINE, "No cast needed. You can use ':' if you need a cast to a super type");
|
MAP.put(DEPRECATED_STATIC_ASSERT, "Static type assertions are deprecated, consider using a cast instead");
|
||||||
MAP.put(USELESS_CAST, "No cast needed");
|
MAP.put(USELESS_CAST, "No cast needed");
|
||||||
MAP.put(CAST_NEVER_SUCCEEDS, "This cast can never succeed");
|
MAP.put(CAST_NEVER_SUCCEEDS, "This cast can never succeed");
|
||||||
MAP.put(DYNAMIC_NOT_ALLOWED, "Dynamic types are not allowed in this position");
|
MAP.put(DYNAMIC_NOT_ALLOWED, "Dynamic types are not allowed in this position");
|
||||||
|
|||||||
+2
-1
@@ -212,6 +212,7 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
|
|||||||
JetSimpleNameExpression operationSign = expression.getOperationReference();
|
JetSimpleNameExpression operationSign = expression.getOperationReference();
|
||||||
IElementType operationType = operationSign.getReferencedNameElementType();
|
IElementType operationType = operationSign.getReferencedNameElementType();
|
||||||
if (operationType == JetTokens.COLON) {
|
if (operationType == JetTokens.COLON) {
|
||||||
|
context.trace.report(DEPRECATED_STATIC_ASSERT.on(expression));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (operationType != JetTokens.AS_KEYWORD && operationType != JetTokens.AS_SAFE) {
|
if (operationType != JetTokens.AS_KEYWORD && operationType != JetTokens.AS_SAFE) {
|
||||||
@@ -250,7 +251,7 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
|
|||||||
expression.getLeft(), context.dataFlowInfo, actualType, context);
|
expression.getLeft(), context.dataFlowInfo, actualType, context);
|
||||||
for (JetType possibleType : possibleTypes) {
|
for (JetType possibleType : possibleTypes) {
|
||||||
if (typeChecker.isSubtypeOf(possibleType, targetType)) {
|
if (typeChecker.isSubtypeOf(possibleType, targetType)) {
|
||||||
context.trace.report(USELESS_CAST_STATIC_ASSERT_IS_FINE.on(expression));
|
context.trace.report(USELESS_CAST.on(expression));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,16 +1,18 @@
|
|||||||
|
// !CHECK_TYPE
|
||||||
|
|
||||||
fun test() : Unit {
|
fun test() : Unit {
|
||||||
var x : Int? = 0
|
var x : Int? = 0
|
||||||
var y : Int = 0
|
var y : Int = 0
|
||||||
|
|
||||||
x : Int?
|
checkSubtype<Int?>(x)
|
||||||
y : Int
|
checkSubtype<Int>(y)
|
||||||
x as Int : Int
|
checkSubtype<Int>(x as Int)
|
||||||
y <!USELESS_CAST!>as Int<!> : Int
|
checkSubtype<Int>(y <!USELESS_CAST!>as Int<!>)
|
||||||
x <!USELESS_CAST!>as Int?<!> : Int?
|
checkSubtype<Int?>(x <!USELESS_CAST!>as Int?<!>)
|
||||||
y <!USELESS_CAST_STATIC_ASSERT_IS_FINE!>as Int?<!> : Int?
|
checkSubtype<Int?>(y <!USELESS_CAST!>as Int?<!>)
|
||||||
x <!USELESS_CAST_STATIC_ASSERT_IS_FINE!>as? Int<!> : Int?
|
checkSubtype<Int?>(x <!USELESS_CAST!>as? Int<!>)
|
||||||
y <!USELESS_CAST!>as? Int<!> : Int?
|
checkSubtype<Int?>(y <!USELESS_CAST!>as? Int<!>)
|
||||||
x <!USELESS_CAST!>as? Int?<!> : Int?
|
checkSubtype<Int?>(x <!USELESS_CAST!>as? Int?<!>)
|
||||||
y <!USELESS_CAST_STATIC_ASSERT_IS_FINE!>as? Int?<!> : Int?
|
checkSubtype<Int?>(y <!USELESS_CAST!>as? Int?<!>)
|
||||||
Unit
|
Unit
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
// !CHECK_TYPE
|
||||||
|
|
||||||
fun varargByte(vararg v: Byte) = v
|
fun varargByte(vararg v: Byte) = v
|
||||||
|
|
||||||
fun varargShort(vararg v: Short) = v
|
fun varargShort(vararg v: Short) = v
|
||||||
@@ -13,29 +15,29 @@ fun varargDouble(vararg v: Double) = v
|
|||||||
fun <T> testFun(<!UNUSED_PARAMETER!>p<!>: T) {}
|
fun <T> testFun(<!UNUSED_PARAMETER!>p<!>: T) {}
|
||||||
|
|
||||||
fun test() {
|
fun test() {
|
||||||
1: Byte
|
checkSubtype<Byte>(1)
|
||||||
1: Short
|
checkSubtype<Short>(1)
|
||||||
1: Int
|
checkSubtype<Int>(1)
|
||||||
1: Long
|
checkSubtype<Long>(1)
|
||||||
|
|
||||||
0x001: Long
|
checkSubtype<Long>(0x001)
|
||||||
0b001: Int
|
checkSubtype<Int>(0b001)
|
||||||
|
|
||||||
0.1: Double
|
checkSubtype<Double>(0.1)
|
||||||
0.1.toFloat(): Float
|
checkSubtype<Float>(0.1.toFloat())
|
||||||
|
|
||||||
1e5: Double
|
checkSubtype<Double>(1e5)
|
||||||
1e-5.toFloat(): Float
|
checkSubtype<Float>(1e-5.toFloat())
|
||||||
|
|
||||||
<!CONSTANT_EXPECTED_TYPE_MISMATCH!>1<!>: Double
|
checkSubtype<Double>(<!CONSTANT_EXPECTED_TYPE_MISMATCH!>1<!>)
|
||||||
<!CONSTANT_EXPECTED_TYPE_MISMATCH!>1<!>: Float
|
checkSubtype<Float>(<!CONSTANT_EXPECTED_TYPE_MISMATCH!>1<!>)
|
||||||
|
|
||||||
1 <!CAST_NEVER_SUCCEEDS!>as<!> Byte
|
1 <!CAST_NEVER_SUCCEEDS!>as<!> Byte
|
||||||
1 <!USELESS_CAST!>as Int<!>
|
1 <!USELESS_CAST!>as Int<!>
|
||||||
0xff <!CAST_NEVER_SUCCEEDS!>as<!> Long
|
0xff <!CAST_NEVER_SUCCEEDS!>as<!> Long
|
||||||
|
|
||||||
1.1 <!CAST_NEVER_SUCCEEDS!>as<!> Int
|
1.1 <!CAST_NEVER_SUCCEEDS!>as<!> Int
|
||||||
<!CONSTANT_EXPECTED_TYPE_MISMATCH!>1.1<!>: Int
|
checkSubtype<Int>(<!CONSTANT_EXPECTED_TYPE_MISMATCH!>1.1<!>)
|
||||||
|
|
||||||
varargByte(0x77, 1, 3, <!CONSTANT_EXPECTED_TYPE_MISMATCH!>200<!>, 0b111)
|
varargByte(0x77, 1, 3, <!CONSTANT_EXPECTED_TYPE_MISMATCH!>200<!>, 0b111)
|
||||||
varargShort(0x777, 1, 2, 3, <!CONSTANT_EXPECTED_TYPE_MISMATCH!>200000<!>, 0b111)
|
varargShort(0x777, 1, 2, 3, <!CONSTANT_EXPECTED_TYPE_MISMATCH!>200000<!>, 0b111)
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
// !CHECK_TYPE
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
class NotRange1() {
|
class NotRange1() {
|
||||||
@@ -87,5 +89,5 @@ fun test(notRange1: NotRange1, notRange2: NotRange2, notRange3: NotRange3, notRa
|
|||||||
for (i in range0);
|
for (i in range0);
|
||||||
for (i in range1);
|
for (i in range1);
|
||||||
|
|
||||||
for (i in (ArrayList<Int>() : List<Int>));
|
for (i in (checkSubtype<List<Int>>(ArrayList<Int>())));
|
||||||
}
|
}
|
||||||
@@ -1,3 +1,5 @@
|
|||||||
|
// !CHECK_TYPE
|
||||||
|
|
||||||
package foo
|
package foo
|
||||||
|
|
||||||
fun Any.foo() : () -> Unit {
|
fun Any.foo() : () -> Unit {
|
||||||
@@ -38,10 +40,10 @@ fun main(args : Array<String>) {
|
|||||||
foo2()({<!EXPECTED_PARAMETERS_NUMBER_MISMATCH, CANNOT_INFER_PARAMETER_TYPE!>x<!> -> })
|
foo2()({<!EXPECTED_PARAMETERS_NUMBER_MISMATCH, CANNOT_INFER_PARAMETER_TYPE!>x<!> -> })
|
||||||
|
|
||||||
val a = fooT1(1)()
|
val a = fooT1(1)()
|
||||||
a : Int
|
checkSubtype<Int>(a)
|
||||||
|
|
||||||
val b = fooT2<Int>()(1)
|
val b = fooT2<Int>()(1)
|
||||||
b : Int
|
checkSubtype<Int>(b)
|
||||||
<!TYPE_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>fooT2<!>()(1) // : Any?
|
<!TYPE_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>fooT2<!>()(1) // : Any?
|
||||||
|
|
||||||
<!FUNCTION_EXPECTED!>1<!>()
|
<!FUNCTION_EXPECTED!>1<!>()
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
|
// !CHECK_TYPE
|
||||||
|
|
||||||
// A generic funciton is always less specific than a non-generic one
|
// A generic funciton is always less specific than a non-generic one
|
||||||
fun foo<T>(<!UNUSED_PARAMETER!>t<!> : T) : Unit {}
|
fun foo<T>(<!UNUSED_PARAMETER!>t<!> : T) : Unit {}
|
||||||
fun foo(<!UNUSED_PARAMETER!>i<!> : Int) : Int = 1
|
fun foo(<!UNUSED_PARAMETER!>i<!> : Int) : Int = 1
|
||||||
|
|
||||||
fun test() {
|
fun test() {
|
||||||
foo(1) : Int
|
checkSubtype<Int>(foo(1))
|
||||||
foo("s") : Unit
|
checkSubtype<Unit>(foo("s"))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,11 +53,9 @@ fun cannotBe() {
|
|||||||
|
|
||||||
fun canBe(i0: Int, j: Int) {
|
fun canBe(i0: Int, j: Int) {
|
||||||
var <!ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE!>i<!> = i0
|
var <!ASSIGNED_BUT_NEVER_ACCESSED_VARIABLE!>i<!> = i0
|
||||||
(i: Int) = <!UNUSED_VALUE!>36<!>
|
|
||||||
(label@ i) = <!UNUSED_VALUE!>34<!>
|
(label@ i) = <!UNUSED_VALUE!>34<!>
|
||||||
|
|
||||||
(<!VAL_REASSIGNMENT!>j<!>: Int) = <!UNUSED_VALUE!>36<!>
|
(label@ <!VAL_REASSIGNMENT!>j<!>) = <!UNUSED_VALUE!>34<!> //repeat for j
|
||||||
(label@ j) = <!UNUSED_VALUE!>34<!> //repeat for j
|
|
||||||
|
|
||||||
val a = A()
|
val a = A()
|
||||||
(l@ a.a) = 3894
|
(l@ a.a) = 3894
|
||||||
@@ -74,20 +72,16 @@ class A() {
|
|||||||
class Test() {
|
class Test() {
|
||||||
fun testIllegalValues() {
|
fun testIllegalValues() {
|
||||||
<!VARIABLE_EXPECTED!>1<!> += 23
|
<!VARIABLE_EXPECTED!>1<!> += 23
|
||||||
(<!VARIABLE_EXPECTED!>1<!> : Int) += 43
|
|
||||||
(l@ <!VARIABLE_EXPECTED!>1<!>) += 23
|
(l@ <!VARIABLE_EXPECTED!>1<!>) += 23
|
||||||
|
|
||||||
<!VARIABLE_EXPECTED!>getInt()<!> += 343
|
<!VARIABLE_EXPECTED!>getInt()<!> += 343
|
||||||
(f@ <!VARIABLE_EXPECTED!>getInt()<!>) += 343
|
(f@ <!VARIABLE_EXPECTED!>getInt()<!>) += 343
|
||||||
(<!VARIABLE_EXPECTED!>getInt()<!> : Int) += 343
|
|
||||||
|
|
||||||
<!VARIABLE_EXPECTED!>1<!>++
|
<!VARIABLE_EXPECTED!>1<!>++
|
||||||
(r@ <!VARIABLE_EXPECTED!>1<!>)++
|
(r@ <!VARIABLE_EXPECTED!>1<!>)++
|
||||||
(<!VARIABLE_EXPECTED!>1<!> : Int)++
|
|
||||||
|
|
||||||
<!VARIABLE_EXPECTED!>getInt()<!>++
|
<!VARIABLE_EXPECTED!>getInt()<!>++
|
||||||
(m@ <!VARIABLE_EXPECTED!>getInt()<!>)++
|
(m@ <!VARIABLE_EXPECTED!>getInt()<!>)++
|
||||||
(<!VARIABLE_EXPECTED!>getInt()<!> : Int)++
|
|
||||||
|
|
||||||
this<!UNRESOLVED_REFERENCE!>++<!>
|
this<!UNRESOLVED_REFERENCE!>++<!>
|
||||||
|
|
||||||
@@ -103,13 +97,11 @@ class Test() {
|
|||||||
|
|
||||||
a += 34
|
a += 34
|
||||||
(l@ a) += 34
|
(l@ a) += 34
|
||||||
(a : Int) += 34
|
|
||||||
|
|
||||||
<!VAL_REASSIGNMENT!>b<!> += 34
|
<!VAL_REASSIGNMENT!>b<!> += 34
|
||||||
|
|
||||||
a++
|
a++
|
||||||
(l@ a)++
|
(l@ a)++
|
||||||
(a : Int)++
|
|
||||||
<!UNUSED_CHANGED_VALUE!>(a)++<!>
|
<!UNUSED_CHANGED_VALUE!>(a)++<!>
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -118,7 +110,6 @@ class Test() {
|
|||||||
|
|
||||||
(l@ <!VAL_REASSIGNMENT!>b<!>) += 34
|
(l@ <!VAL_REASSIGNMENT!>b<!>) += 34
|
||||||
//repeat for b
|
//repeat for b
|
||||||
(b : Int) += 34
|
|
||||||
(b) += 3
|
(b) += 3
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -131,8 +122,6 @@ class Test() {
|
|||||||
ab.getArray()[54]++
|
ab.getArray()[54]++
|
||||||
|
|
||||||
(f@ a)[3] = 4
|
(f@ a)[3] = 4
|
||||||
(a : Array<Int>)[4]++
|
|
||||||
(ab.getArray() : Array<Int>)[54] += 43
|
|
||||||
|
|
||||||
this<!NO_SET_METHOD!><!UNRESOLVED_REFERENCE!>[<!>54<!UNRESOLVED_REFERENCE!>]<!><!> = 34
|
this<!NO_SET_METHOD!><!UNRESOLVED_REFERENCE!>[<!>54<!UNRESOLVED_REFERENCE!>]<!><!> = 34
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
// !CHECK_TYPE
|
||||||
|
|
||||||
// FILE: f.kt
|
// FILE: f.kt
|
||||||
|
|
||||||
import java.*
|
import java.*
|
||||||
@@ -24,7 +26,7 @@ fun test(<!UNUSED_PARAMETER!>l<!> : <!PLATFORM_CLASS_MAPPED_TO_KOTLIN!>java.util
|
|||||||
Collections.emptyList<Int>()
|
Collections.emptyList<Int>()
|
||||||
Collections.<!TYPE_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>emptyList<!>()
|
Collections.<!TYPE_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>emptyList<!>()
|
||||||
|
|
||||||
Collections.singleton<Int>(1) : Set<Int>?
|
checkSubtype<Set<Int>?>(Collections.singleton<Int>(1))
|
||||||
Collections.singleton<Int>(<!CONSTANT_EXPECTED_TYPE_MISMATCH!>1.0<!>)
|
Collections.singleton<Int>(<!CONSTANT_EXPECTED_TYPE_MISMATCH!>1.0<!>)
|
||||||
|
|
||||||
<!UNRESOLVED_REFERENCE!>List<!><Int>
|
<!UNRESOLVED_REFERENCE!>List<!><Int>
|
||||||
@@ -43,7 +45,7 @@ fun test(<!UNUSED_PARAMETER!>l<!> : <!PLATFORM_CLASS_MAPPED_TO_KOTLIN!>java.util
|
|||||||
|
|
||||||
val c : <!PLATFORM_CLASS_MAPPED_TO_KOTLIN!>Com<Int><!>? = null
|
val c : <!PLATFORM_CLASS_MAPPED_TO_KOTLIN!>Com<Int><!>? = null
|
||||||
|
|
||||||
c : <!PLATFORM_CLASS_MAPPED_TO_KOTLIN!>java.lang.Comparable<Int><!>?
|
checkSubtype<<!PLATFORM_CLASS_MAPPED_TO_KOTLIN!>java.lang.Comparable<Int><!>?>(c)
|
||||||
|
|
||||||
// Collections.sort<Integer>(ArrayList<Integer>())
|
// Collections.sort<Integer>(ArrayList<Integer>())
|
||||||
xxx.<!UNRESOLVED_REFERENCE!>Class<!>()
|
xxx.<!UNRESOLVED_REFERENCE!>Class<!>()
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
// !CHECK_TYPE
|
||||||
|
|
||||||
fun test() {
|
fun test() {
|
||||||
return Unit : Unit
|
return checkSubtype<Unit>(Unit)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ fun foo(<!UNRESOLVED_REFERENCE!>varargs<!> <!UNUSED_PARAMETER!>f<!> : Int) {}
|
|||||||
var bar : Int = 1
|
var bar : Int = 1
|
||||||
set(<!UNRESOLVED_REFERENCE!>varargs<!> v) {}
|
set(<!UNRESOLVED_REFERENCE!>varargs<!> v) {}
|
||||||
|
|
||||||
val x : (Int) -> Int = {[<!UNRESOLVED_REFERENCE!>varargs<!>] <!TYPE_MISMATCH!>x<!> : Int <!SYNTAX!>-> x<!>}
|
val x : (Int) -> Int = {[<!UNRESOLVED_REFERENCE!>varargs<!>] <!TYPE_MISMATCH!>x<!> <!DEPRECATED_STATIC_ASSERT!>: Int<!> <!SYNTAX!>-> x<!>}
|
||||||
|
|
||||||
class Hello(<!UNRESOLVED_REFERENCE!>varargs<!> <!UNUSED_PARAMETER!>args<!>: Any) {
|
class Hello(<!UNRESOLVED_REFERENCE!>varargs<!> <!UNUSED_PARAMETER!>args<!>: Any) {
|
||||||
}
|
}
|
||||||
@@ -5,7 +5,7 @@ fun foo(test <!UNUSED_PARAMETER!>f<!> : Int) {}
|
|||||||
var bar : Int = 1
|
var bar : Int = 1
|
||||||
set(test v) {}
|
set(test v) {}
|
||||||
|
|
||||||
val x : (Int) -> Int = {[test] <!TYPE_MISMATCH!>x<!> : Int <!SYNTAX!>-> x<!>} // todo fix parser annotation on lambda parameter
|
val x : (Int) -> Int = {[test] <!TYPE_MISMATCH!>x<!> <!DEPRECATED_STATIC_ASSERT!>: Int<!> <!SYNTAX!>-> x<!>} // todo fix parser annotation on lambda parameter
|
||||||
|
|
||||||
class Hello(test <!UNUSED_PARAMETER!>args<!>: Any) {
|
class Hello(test <!UNUSED_PARAMETER!>args<!>: Any) {
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
|
// !CHECK_TYPE
|
||||||
|
|
||||||
trait Tr<T>
|
trait Tr<T>
|
||||||
trait G<T> : Tr<T>
|
trait G<T> : Tr<T>
|
||||||
|
|
||||||
fun test(tr: Tr<String>) {
|
fun test(tr: Tr<String>) {
|
||||||
val v = tr as G?
|
val v = tr as G?
|
||||||
// If v is not nullable, there will be a warning on this line:
|
// If v is not nullable, there will be a warning on this line:
|
||||||
v!!: G<String>
|
checkSubtype<G<String>>(v!!)
|
||||||
}
|
}
|
||||||
@@ -1,8 +1,10 @@
|
|||||||
|
// !CHECK_TYPE
|
||||||
|
|
||||||
trait Tr
|
trait Tr
|
||||||
trait G<T>
|
trait G<T>
|
||||||
|
|
||||||
fun test(tr: Tr) {
|
fun test(tr: Tr) {
|
||||||
val v = tr as <!NO_TYPE_ARGUMENTS_ON_RHS!>G?<!>
|
val v = tr as <!NO_TYPE_ARGUMENTS_ON_RHS!>G?<!>
|
||||||
// If v is not nullable, there will be a warning on this line:
|
// If v is not nullable, there will be a warning on this line:
|
||||||
v!!: G<*>
|
checkSubtype<G<*>>(v!!)
|
||||||
}
|
}
|
||||||
@@ -1,3 +1,5 @@
|
|||||||
|
// !CHECK_TYPE
|
||||||
|
|
||||||
trait Either<out A, out B>
|
trait Either<out A, out B>
|
||||||
trait Left<out A>: Either<A, Nothing>
|
trait Left<out A>: Either<A, Nothing>
|
||||||
trait Right<out B>: Either<Nothing, B>
|
trait Right<out B>: Either<Nothing, B>
|
||||||
@@ -7,10 +9,10 @@ class C2(val v2: Int)
|
|||||||
|
|
||||||
fun _as_left(e: Either<C1, C2>): Any {
|
fun _as_left(e: Either<C1, C2>): Any {
|
||||||
val v = e as Left
|
val v = e as Left
|
||||||
return v: Left<C1>
|
return checkSubtype<Left<C1>>(v)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun _as_right(e: Either<C1, C2>): Any {
|
fun _as_right(e: Either<C1, C2>): Any {
|
||||||
val v = e as Right
|
val v = e as Right
|
||||||
return v: Right<C2>
|
return checkSubtype<Right<C2>>(v)
|
||||||
}
|
}
|
||||||
@@ -1,3 +1,5 @@
|
|||||||
|
// !CHECK_TYPE
|
||||||
|
|
||||||
trait Either<out A, out B>
|
trait Either<out A, out B>
|
||||||
trait Left<out A>: Either<A, Nothing>
|
trait Left<out A>: Either<A, Nothing>
|
||||||
trait Right<out B>: Either<Nothing, B>
|
trait Right<out B>: Either<Nothing, B>
|
||||||
@@ -7,10 +9,10 @@ class C2(val v2: Int)
|
|||||||
|
|
||||||
fun _as_left(e: Either<C1, C2>): Any? {
|
fun _as_left(e: Either<C1, C2>): Any? {
|
||||||
val v = e as? Left
|
val v = e as? Left
|
||||||
return v: Left<C1>?
|
return checkSubtype<Left<C1>?>(v)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun _as_right(e: Either<C1, C2>): Any? {
|
fun _as_right(e: Either<C1, C2>): Any? {
|
||||||
val v = e as? Right
|
val v = e as? Right
|
||||||
return v: Right<C2>?
|
return checkSubtype<Right<C2>?>(v)
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,9 @@
|
|||||||
|
// !CHECK_TYPE
|
||||||
|
|
||||||
trait B<T>
|
trait B<T>
|
||||||
trait G<T>: B<T>
|
trait G<T>: B<T>
|
||||||
|
|
||||||
fun f(p: B<<!UNRESOLVED_REFERENCE!>Foo<!>>): Any {
|
fun f(p: B<<!UNRESOLVED_REFERENCE!>Foo<!>>): Any {
|
||||||
val v = <!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>p<!> as G
|
val v = <!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>p<!> as G
|
||||||
return <!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>v<!>: G<*>
|
return checkSubtype<G<*>>(<!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>v<!>)
|
||||||
}
|
}
|
||||||
@@ -1,6 +1,8 @@
|
|||||||
|
// !CHECK_TYPE
|
||||||
|
|
||||||
class G<T>
|
class G<T>
|
||||||
|
|
||||||
fun foo(p: <!UNRESOLVED_REFERENCE!>P<!>) {
|
fun foo(p: <!UNRESOLVED_REFERENCE!>P<!>) {
|
||||||
val v = <!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>p<!> <!USELESS_CAST_STATIC_ASSERT_IS_FINE!>as <!NO_TYPE_ARGUMENTS_ON_RHS!>G?<!><!>
|
val v = <!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>p<!> <!USELESS_CAST!>as <!NO_TYPE_ARGUMENTS_ON_RHS!>G?<!><!>
|
||||||
v!!: G<*>
|
checkSubtype<G<*>>(v!!)
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,9 @@
|
|||||||
|
// !CHECK_TYPE
|
||||||
|
|
||||||
trait Tr<T>
|
trait Tr<T>
|
||||||
trait G<T> : Tr<T>
|
trait G<T> : Tr<T>
|
||||||
|
|
||||||
fun test(tr: Tr<String>?) {
|
fun test(tr: Tr<String>?) {
|
||||||
val v = tr as G
|
val v = tr as G
|
||||||
v: G<String>
|
checkSubtype<G<String>>(v)
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,9 @@
|
|||||||
|
// !CHECK_TYPE
|
||||||
|
|
||||||
trait Tr
|
trait Tr
|
||||||
trait G<T>
|
trait G<T>
|
||||||
|
|
||||||
fun test(tr: Tr?) {
|
fun test(tr: Tr?) {
|
||||||
val v = tr as <!NO_TYPE_ARGUMENTS_ON_RHS!>G<!>
|
val v = tr as <!NO_TYPE_ARGUMENTS_ON_RHS!>G<!>
|
||||||
v: G<*>
|
checkSubtype<G<*>>(v)
|
||||||
}
|
}
|
||||||
@@ -1,8 +1,10 @@
|
|||||||
|
// !CHECK_TYPE
|
||||||
|
|
||||||
trait Tr<T>
|
trait Tr<T>
|
||||||
trait G<T> : Tr<T>
|
trait G<T> : Tr<T>
|
||||||
|
|
||||||
fun test(tr: Tr<String>?) {
|
fun test(tr: Tr<String>?) {
|
||||||
val v = tr as G?
|
val v = tr as G?
|
||||||
// If v is not nullable, there will be a warning on this line:
|
// If v is not nullable, there will be a warning on this line:
|
||||||
v!!: G<String>
|
checkSubtype<G<String>>(v!!)
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,9 @@
|
|||||||
|
// !CHECK_TYPE
|
||||||
|
|
||||||
trait Tr
|
trait Tr
|
||||||
trait G<T>
|
trait G<T>
|
||||||
|
|
||||||
fun test(tr: Tr?) {
|
fun test(tr: Tr?) {
|
||||||
val v = tr as <!NO_TYPE_ARGUMENTS_ON_RHS!>G?<!>
|
val v = tr as <!NO_TYPE_ARGUMENTS_ON_RHS!>G?<!>
|
||||||
v!!: G<*>
|
checkSubtype<G<*>>(v!!)
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,9 @@
|
|||||||
|
// !CHECK_TYPE
|
||||||
|
|
||||||
trait Tr
|
trait Tr
|
||||||
trait G<T>
|
trait G<T>
|
||||||
|
|
||||||
fun test(tr: Tr) {
|
fun test(tr: Tr) {
|
||||||
val v = tr as <!NO_TYPE_ARGUMENTS_ON_RHS!>G<!>
|
val v = tr as <!NO_TYPE_ARGUMENTS_ON_RHS!>G<!>
|
||||||
v: G<*>
|
checkSubtype<G<*>>(v)
|
||||||
}
|
}
|
||||||
@@ -1,4 +1,6 @@
|
|||||||
|
// !CHECK_TYPE
|
||||||
|
|
||||||
trait Tr
|
trait Tr
|
||||||
trait G<T>
|
trait G<T>
|
||||||
|
|
||||||
fun test(tr: Tr) = tr: <!WRONG_NUMBER_OF_TYPE_ARGUMENTS!>G<!>
|
fun test(tr: Tr) = checkSubtype<<!WRONG_NUMBER_OF_TYPE_ARGUMENTS!>G<!>>(tr)
|
||||||
@@ -1,3 +1,5 @@
|
|||||||
|
// !CHECK_TYPE
|
||||||
|
|
||||||
fun <T> array1(vararg a : T) = a
|
fun <T> array1(vararg a : T) = a
|
||||||
|
|
||||||
fun main(args : Array<String>) {
|
fun main(args : Array<String>) {
|
||||||
@@ -52,23 +54,23 @@ fun main(args : Array<String>) {
|
|||||||
joinG(a = *a, x = 1)
|
joinG(a = *a, x = 1)
|
||||||
|
|
||||||
val x1 = joinT(1, "2")
|
val x1 = joinT(1, "2")
|
||||||
x1 : String?
|
checkSubtype<String?>(x1)
|
||||||
val x2 = joinT(<!NON_VARARG_SPREAD!>*<!>1, "2")
|
val x2 = joinT(<!NON_VARARG_SPREAD!>*<!>1, "2")
|
||||||
x2 : String?
|
checkSubtype<String?>(x2)
|
||||||
val x6 = joinT(1, *a)
|
val x6 = joinT(1, *a)
|
||||||
x6 : String?
|
checkSubtype<String?>(x6)
|
||||||
val x7 = joinT(1, *a, "3")
|
val x7 = joinT(1, *a, "3")
|
||||||
x7 : String?
|
checkSubtype<String?>(x7)
|
||||||
val x8 = joinT(1, "4", *a, "3")
|
val x8 = joinT(1, "4", *a, "3")
|
||||||
x8 : String?
|
checkSubtype<String?>(x8)
|
||||||
val x9 = joinT(1, "4", *a)
|
val x9 = joinT(1, "4", *a)
|
||||||
x9 : String?
|
checkSubtype<String?>(x9)
|
||||||
val x10 = joinT(1, "4", *a, *a, "3")
|
val x10 = joinT(1, "4", *a, *a, "3")
|
||||||
x10 : String?
|
checkSubtype<String?>(x10)
|
||||||
val x11 = joinT(a = *a, x = 1)
|
val x11 = joinT(a = *a, x = 1)
|
||||||
x11 : String?
|
checkSubtype<String?>(x11)
|
||||||
val x12 = joinT(x = 1, a = *a)
|
val x12 = joinT(x = 1, a = *a)
|
||||||
x12 : String?
|
checkSubtype<String?>(x12)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun join(x : Int, vararg a : String) : String {
|
fun join(x : Int, vararg a : String) : String {
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ trait B : A
|
|||||||
trait C : B
|
trait C : B
|
||||||
|
|
||||||
fun test(b: B) {
|
fun test(b: B) {
|
||||||
b checkType { it : _<B> }
|
b checkType { _<B>() }
|
||||||
b checkType { <!TYPE_MISMATCH!>it<!> : _<A> }
|
b checkType { <!TYPE_MISMATCH!>_<!><A>() }
|
||||||
b checkType { <!TYPE_MISMATCH!>it<!> : _<C> }
|
b checkType { <!TYPE_MISMATCH!>_<!><C>() }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ fun bar() {
|
|||||||
val x = X
|
val x = X
|
||||||
x.foo()
|
x.foo()
|
||||||
X.foo()
|
X.foo()
|
||||||
(X : C).foo()
|
(X <!USELESS_CAST!>as C<!>).foo()
|
||||||
(X <!USELESS_CAST_STATIC_ASSERT_IS_FINE!>as C<!>).foo()
|
((if (1<2) X else Y) <!USELESS_CAST!>as C<!>).foo()
|
||||||
((if (1<2) X else Y) : C).foo()
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,10 +11,10 @@ fun <T: Any> exclExcl(t: T?): T = t!!
|
|||||||
|
|
||||||
fun test11() {
|
fun test11() {
|
||||||
// not 'String!'
|
// not 'String!'
|
||||||
exclExcl(A.foo()) checkType { it : _<String> }
|
exclExcl(A.foo()) checkType { _<String>() }
|
||||||
exclExcl(A.foo()) checkType { <!TYPE_MISMATCH!>it<!> : _<String?> }
|
exclExcl(A.foo()) checkType { <!TYPE_MISMATCH!>_<!><String?>() }
|
||||||
|
|
||||||
// not 'String!'
|
// not 'String!'
|
||||||
A.foo()!! checkType { it : _<String> }
|
A.foo()!! checkType { _<String>() }
|
||||||
A.foo()!! checkType { <!TYPE_MISMATCH!>it<!> : _<String?> }
|
A.foo()!! checkType { <!TYPE_MISMATCH!>_<!><String?>() }
|
||||||
}
|
}
|
||||||
@@ -1,3 +1,5 @@
|
|||||||
|
// !CHECK_TYPE
|
||||||
|
|
||||||
open data class A(private val x: Int)
|
open data class A(private val x: Int)
|
||||||
|
|
||||||
class B : A(1) {
|
class B : A(1) {
|
||||||
@@ -6,6 +8,6 @@ class B : A(1) {
|
|||||||
|
|
||||||
fun foo() {
|
fun foo() {
|
||||||
val b = B()
|
val b = B()
|
||||||
b.component1() : String
|
checkSubtype<String>(b.component1())
|
||||||
(b : A).<!INVISIBLE_MEMBER!>component1<!>() : Int
|
checkSubtype<Int>((checkSubtype<A>(b)).<!INVISIBLE_MEMBER!>component1<!>())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
|
// !CHECK_TYPE
|
||||||
|
|
||||||
data class A(val x: Int, <!UNUSED_PARAMETER!>y<!>: String)
|
data class A(val x: Int, <!UNUSED_PARAMETER!>y<!>: String)
|
||||||
|
|
||||||
fun foo(a: A) {
|
fun foo(a: A) {
|
||||||
a.component1() : Int
|
checkSubtype<Int>(a.component1())
|
||||||
a.<!UNRESOLVED_REFERENCE!>component2<!>()
|
a.<!UNRESOLVED_REFERENCE!>component2<!>()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
|
// !CHECK_TYPE
|
||||||
|
|
||||||
data class A(var x: Int, <!UNUSED_PARAMETER!>y<!>: String)
|
data class A(var x: Int, <!UNUSED_PARAMETER!>y<!>: String)
|
||||||
|
|
||||||
fun foo(a: A) {
|
fun foo(a: A) {
|
||||||
a.component1() : Int
|
checkSubtype<Int>(a.component1())
|
||||||
a.<!UNRESOLVED_REFERENCE!>component2<!>()
|
a.<!UNRESOLVED_REFERENCE!>component2<!>()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
|
// !CHECK_TYPE
|
||||||
|
|
||||||
data class A(val x: Int, val y: String)
|
data class A(val x: Int, val y: String)
|
||||||
|
|
||||||
fun foo(a: A) {
|
fun foo(a: A) {
|
||||||
val (b, c) = a
|
val (b, c) = a
|
||||||
b : Int
|
checkSubtype<Int>(b)
|
||||||
c : String
|
checkSubtype<String>(c)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,10 @@
|
|||||||
|
// !CHECK_TYPE
|
||||||
|
|
||||||
data class A(val x: Int, val y: String)
|
data class A(val x: Int, val y: String)
|
||||||
|
|
||||||
fun foo(arr: Array<A>) {
|
fun foo(arr: Array<A>) {
|
||||||
for ((b, c) in arr) {
|
for ((b, c) in arr) {
|
||||||
b : Int
|
checkSubtype<Int>(b)
|
||||||
c : String
|
checkSubtype<String>(c)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
|
// !CHECK_TYPE
|
||||||
|
|
||||||
data class A(val x: Int)
|
data class A(val x: Int)
|
||||||
|
|
||||||
fun foo(a: A) {
|
fun foo(a: A) {
|
||||||
a.component1() : Int
|
checkSubtype<Int>(a.component1())
|
||||||
a.<!UNRESOLVED_REFERENCE!>component2<!>()
|
a.<!UNRESOLVED_REFERENCE!>component2<!>()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
|
// !CHECK_TYPE
|
||||||
|
|
||||||
data class A(<!UNUSED_PARAMETER!>x<!>: Int, val y: String)
|
data class A(<!UNUSED_PARAMETER!>x<!>: Int, val y: String)
|
||||||
|
|
||||||
fun foo(a: A) {
|
fun foo(a: A) {
|
||||||
a.component1() : String
|
checkSubtype<String>(a.component1())
|
||||||
a.<!UNRESOLVED_REFERENCE!>component2<!>()
|
a.<!UNRESOLVED_REFERENCE!>component2<!>()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
|
// !CHECK_TYPE
|
||||||
|
|
||||||
data class A(<!UNUSED_PARAMETER!>x<!>: Int, var y: String)
|
data class A(<!UNUSED_PARAMETER!>x<!>: Int, var y: String)
|
||||||
|
|
||||||
fun foo(a: A) {
|
fun foo(a: A) {
|
||||||
a.component1() : String
|
checkSubtype<String>(a.component1())
|
||||||
a.<!UNRESOLVED_REFERENCE!>component2<!>()
|
a.<!UNRESOLVED_REFERENCE!>component2<!>()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
|
// !CHECK_TYPE
|
||||||
|
|
||||||
data class A(val x: Int, val y: String)
|
data class A(val x: Int, val y: String)
|
||||||
|
|
||||||
fun foo(a: A) {
|
fun foo(a: A) {
|
||||||
a.component1() : Int
|
checkSubtype<Int>(a.component1())
|
||||||
a.component2() : String
|
checkSubtype<String>(a.component2())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
|
// !CHECK_TYPE
|
||||||
|
|
||||||
data class A(var x: Int, var y: String)
|
data class A(var x: Int, var y: String)
|
||||||
|
|
||||||
fun foo(a: A) {
|
fun foo(a: A) {
|
||||||
a.component1() : Int
|
checkSubtype<Int>(a.component1())
|
||||||
a.component2() : String
|
checkSubtype<String>(a.component2())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,18 +1,20 @@
|
|||||||
|
// !CHECK_TYPE
|
||||||
|
|
||||||
fun f1(s: String?) {
|
fun f1(s: String?) {
|
||||||
if (s!! == "");
|
if (s!! == "");
|
||||||
<!DEBUG_INFO_SMARTCAST!>s<!> : String
|
checkSubtype<String>(<!DEBUG_INFO_SMARTCAST!>s<!>)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun f2(s: Number?) {
|
fun f2(s: Number?) {
|
||||||
if (s is Int);
|
if (s is Int);
|
||||||
<!TYPE_MISMATCH!>s<!> : Int
|
checkSubtype<Int>(<!TYPE_MISMATCH!>s<!>)
|
||||||
if (s as Int == 42);
|
if (s as Int == 42);
|
||||||
<!DEBUG_INFO_SMARTCAST!>s<!> : Int
|
checkSubtype<Int>(<!DEBUG_INFO_SMARTCAST!>s<!>)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun f3(s: Number?) {
|
fun f3(s: Number?) {
|
||||||
if (s is Int && s <!USELESS_CAST_STATIC_ASSERT_IS_FINE!>as Int<!> == 42);
|
if (s is Int && s <!USELESS_CAST!>as Int<!> == 42);
|
||||||
<!TYPE_MISMATCH!>s<!> : Int
|
checkSubtype<Int>(<!TYPE_MISMATCH!>s<!>)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun f4(s: Int?) {
|
fun f4(s: Int?) {
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
fun foo(o: Any) {
|
fun foo(o: Any) {
|
||||||
if (o is String) {
|
if (o is String) {
|
||||||
val s = o <!USELESS_CAST_STATIC_ASSERT_IS_FINE!>as String<!>
|
val s = o <!USELESS_CAST!>as String<!>
|
||||||
s.length()
|
s.length()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
|
// !CHECK_TYPE
|
||||||
|
|
||||||
fun foo(arr: Array<out Number>): Int {
|
fun foo(arr: Array<out Number>): Int {
|
||||||
val result = (arr as Array<Int>)[0]
|
val result = (arr as Array<Int>)[0]
|
||||||
<!DEBUG_INFO_SMARTCAST!>arr<!> : Array<Int>
|
checkSubtype<Array<Int>>(<!DEBUG_INFO_SMARTCAST!>arr<!>)
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
// !CHECK_TYPE
|
||||||
|
|
||||||
trait G {
|
trait G {
|
||||||
fun get(x: Int, y: Int): Int = x + y
|
fun get(x: Int, y: Int): Int = x + y
|
||||||
fun set(x: Int, y: Int, value: Int) {}
|
fun set(x: Int, y: Int, value: Int) {}
|
||||||
@@ -5,22 +7,22 @@ trait G {
|
|||||||
|
|
||||||
fun foo1(a: Int?, b: G) {
|
fun foo1(a: Int?, b: G) {
|
||||||
b[a!!, a<!UNNECESSARY_NOT_NULL_ASSERTION!>!!<!>] = <!DEBUG_INFO_SMARTCAST!>a<!>
|
b[a!!, a<!UNNECESSARY_NOT_NULL_ASSERTION!>!!<!>] = <!DEBUG_INFO_SMARTCAST!>a<!>
|
||||||
<!DEBUG_INFO_SMARTCAST!>a<!> : Int
|
checkSubtype<Int>(<!DEBUG_INFO_SMARTCAST!>a<!>)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun foo2(a: Int?, b: G) {
|
fun foo2(a: Int?, b: G) {
|
||||||
b[0, a!!] = <!DEBUG_INFO_SMARTCAST!>a<!>
|
b[0, a!!] = <!DEBUG_INFO_SMARTCAST!>a<!>
|
||||||
<!DEBUG_INFO_SMARTCAST!>a<!> : Int
|
checkSubtype<Int>(<!DEBUG_INFO_SMARTCAST!>a<!>)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun foo3(a: Int?, b: G) {
|
fun foo3(a: Int?, b: G) {
|
||||||
val r = b[a!!, <!DEBUG_INFO_SMARTCAST!>a<!>]
|
val r = b[a!!, <!DEBUG_INFO_SMARTCAST!>a<!>]
|
||||||
<!DEBUG_INFO_SMARTCAST!>a<!> : Int
|
checkSubtype<Int>(<!DEBUG_INFO_SMARTCAST!>a<!>)
|
||||||
r : Int
|
checkSubtype<Int>(r)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun foo4(a: Int?, b: G) {
|
fun foo4(a: Int?, b: G) {
|
||||||
val r = b[0, a!!]
|
val r = b[0, a!!]
|
||||||
<!DEBUG_INFO_SMARTCAST!>a<!> : Int
|
checkSubtype<Int>(<!DEBUG_INFO_SMARTCAST!>a<!>)
|
||||||
r : Int
|
checkSubtype<Int>(r)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
|
// !CHECK_TYPE
|
||||||
|
|
||||||
fun foo1(a: Int?, b: Array<Array<Int>>) {
|
fun foo1(a: Int?, b: Array<Array<Int>>) {
|
||||||
b[a!!][a<!UNNECESSARY_NOT_NULL_ASSERTION!>!!<!>] = <!DEBUG_INFO_SMARTCAST!>a<!>
|
b[a!!][a<!UNNECESSARY_NOT_NULL_ASSERTION!>!!<!>] = <!DEBUG_INFO_SMARTCAST!>a<!>
|
||||||
<!DEBUG_INFO_SMARTCAST!>a<!> : Int
|
checkSubtype<Int>(<!DEBUG_INFO_SMARTCAST!>a<!>)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun foo2(a: Int?, b: Array<Array<Int>>) {
|
fun foo2(a: Int?, b: Array<Array<Int>>) {
|
||||||
b[0][a!!] = <!DEBUG_INFO_SMARTCAST!>a<!>
|
b[0][a!!] = <!DEBUG_INFO_SMARTCAST!>a<!>
|
||||||
<!DEBUG_INFO_SMARTCAST!>a<!> : Int
|
checkSubtype<Int>(<!DEBUG_INFO_SMARTCAST!>a<!>)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,15 +1,17 @@
|
|||||||
|
// !CHECK_TYPE
|
||||||
|
|
||||||
fun bar1(x: Number, y: Int) {
|
fun bar1(x: Number, y: Int) {
|
||||||
var yy = y
|
var yy = y
|
||||||
yy += x as Int
|
yy += x as Int
|
||||||
<!DEBUG_INFO_SMARTCAST!>x<!> : Int
|
checkSubtype<Int>(<!DEBUG_INFO_SMARTCAST!>x<!>)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun bar2(x: Number) {
|
fun bar2(x: Number) {
|
||||||
<!UNRESOLVED_REFERENCE!>y<!> <!UNRESOLVED_REFERENCE!>+=<!> x as Int
|
<!UNRESOLVED_REFERENCE!>y<!> <!UNRESOLVED_REFERENCE!>+=<!> x as Int
|
||||||
<!DEBUG_INFO_SMARTCAST!>x<!> : Int
|
checkSubtype<Int>(<!DEBUG_INFO_SMARTCAST!>x<!>)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun bar3(x: Number, y: Array<Int>) {
|
fun bar3(x: Number, y: Array<Int>) {
|
||||||
y[0] += x as Int
|
y[0] += x as Int
|
||||||
<!DEBUG_INFO_SMARTCAST!>x<!> : Int
|
checkSubtype<Int>(<!DEBUG_INFO_SMARTCAST!>x<!>)
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-2
@@ -1,10 +1,12 @@
|
|||||||
|
// !CHECK_TYPE
|
||||||
|
|
||||||
fun arrayAccessRHS(a: Int?, b: Array<Int>) {
|
fun arrayAccessRHS(a: Int?, b: Array<Int>) {
|
||||||
b[0] = a!!
|
b[0] = a!!
|
||||||
<!DEBUG_INFO_SMARTCAST!>a<!> : Int
|
checkSubtype<Int>(<!DEBUG_INFO_SMARTCAST!>a<!>)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun arrayAccessLHS(a: Int?, b: Array<Int>) {
|
fun arrayAccessLHS(a: Int?, b: Array<Int>) {
|
||||||
b[a!!] = <!DEBUG_INFO_SMARTCAST!>a<!>
|
b[a!!] = <!DEBUG_INFO_SMARTCAST!>a<!>
|
||||||
<!DEBUG_INFO_SMARTCAST!>a<!> : Int
|
checkSubtype<Int>(<!DEBUG_INFO_SMARTCAST!>a<!>)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+6
-4
@@ -1,23 +1,25 @@
|
|||||||
|
// !CHECK_TYPE
|
||||||
|
|
||||||
fun foo1(x: Number, cond: Boolean): Boolean {
|
fun foo1(x: Number, cond: Boolean): Boolean {
|
||||||
val result = cond && ((x as Int) == 42)
|
val result = cond && ((x as Int) == 42)
|
||||||
<!TYPE_MISMATCH!>x<!> : Int
|
checkSubtype<Int>(<!TYPE_MISMATCH!>x<!>)
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
fun foo2(x: Number, cond: Boolean): Boolean {
|
fun foo2(x: Number, cond: Boolean): Boolean {
|
||||||
val result = ((x as Int) == 42) && cond
|
val result = ((x as Int) == 42) && cond
|
||||||
<!DEBUG_INFO_SMARTCAST!>x<!> : Int
|
checkSubtype<Int>(<!DEBUG_INFO_SMARTCAST!>x<!>)
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
fun foo3(x: Number, cond: Boolean): Boolean {
|
fun foo3(x: Number, cond: Boolean): Boolean {
|
||||||
val result = cond || ((x as Int) == 42)
|
val result = cond || ((x as Int) == 42)
|
||||||
<!TYPE_MISMATCH!>x<!> : Int
|
checkSubtype<Int>(<!TYPE_MISMATCH!>x<!>)
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
fun foo4(x: Number, cond: Boolean): Boolean {
|
fun foo4(x: Number, cond: Boolean): Boolean {
|
||||||
val result = ((x as Int) == 42) || cond
|
val result = ((x as Int) == 42) || cond
|
||||||
<!DEBUG_INFO_SMARTCAST!>x<!> : Int
|
checkSubtype<Int>(<!DEBUG_INFO_SMARTCAST!>x<!>)
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-2
@@ -1,3 +1,5 @@
|
|||||||
|
// !CHECK_TYPE
|
||||||
|
|
||||||
trait A
|
trait A
|
||||||
|
|
||||||
trait B : A
|
trait B : A
|
||||||
@@ -5,12 +7,12 @@ fun B.compareTo(b: B) = if (this == b) 0 else 1
|
|||||||
|
|
||||||
fun foo(a: A): Boolean {
|
fun foo(a: A): Boolean {
|
||||||
val result = (a as B) < <!DEBUG_INFO_SMARTCAST!>a<!>
|
val result = (a as B) < <!DEBUG_INFO_SMARTCAST!>a<!>
|
||||||
<!DEBUG_INFO_SMARTCAST!>a<!> : B
|
checkSubtype<B>(<!DEBUG_INFO_SMARTCAST!>a<!>)
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
fun bar(a: A, b: B): Boolean {
|
fun bar(a: A, b: B): Boolean {
|
||||||
val result = b < (a as B)
|
val result = b < (a as B)
|
||||||
<!DEBUG_INFO_SMARTCAST!>a<!> : B
|
checkSubtype<B>(<!DEBUG_INFO_SMARTCAST!>a<!>)
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-1
@@ -1,5 +1,7 @@
|
|||||||
|
// !CHECK_TYPE
|
||||||
|
|
||||||
fun foo(x: Number): Boolean {
|
fun foo(x: Number): Boolean {
|
||||||
val result = (x as Int) in 1..5
|
val result = (x as Int) in 1..5
|
||||||
<!DEBUG_INFO_SMARTCAST!>x<!> : Int
|
checkSubtype<Int>(<!DEBUG_INFO_SMARTCAST!>x<!>)
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,14 +1,16 @@
|
|||||||
|
// !CHECK_TYPE
|
||||||
|
|
||||||
fun foo(x: Int?): Int = x!!
|
fun foo(x: Int?): Int = x!!
|
||||||
|
|
||||||
fun elvis(x: Number?): Int {
|
fun elvis(x: Number?): Int {
|
||||||
val result = (x as Int?) ?: foo(<!DEBUG_INFO_SMARTCAST!>x<!>)
|
val result = (x as Int?) ?: foo(<!DEBUG_INFO_SMARTCAST!>x<!>)
|
||||||
<!DEBUG_INFO_SMARTCAST!>x<!> : Int?
|
checkSubtype<Int?>(<!DEBUG_INFO_SMARTCAST!>x<!>)
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
fun elvisWithRHSTypeInfo(x: Number?): Any? {
|
fun elvisWithRHSTypeInfo(x: Number?): Any? {
|
||||||
val result = x ?: x!!
|
val result = x ?: x!!
|
||||||
<!TYPE_MISMATCH!>x<!> : Int?
|
checkSubtype<Int?>(<!TYPE_MISMATCH!>x<!>)
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-2
@@ -1,14 +1,16 @@
|
|||||||
|
// !CHECK_TYPE
|
||||||
|
|
||||||
trait A
|
trait A
|
||||||
trait B : A
|
trait B : A
|
||||||
|
|
||||||
fun foo1(a: A, b: B): Boolean {
|
fun foo1(a: A, b: B): Boolean {
|
||||||
val result = (a as B) == b
|
val result = (a as B) == b
|
||||||
<!DEBUG_INFO_SMARTCAST!>a<!> : B
|
checkSubtype<B>(<!DEBUG_INFO_SMARTCAST!>a<!>)
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
fun foo2(a: A, b: B): Boolean {
|
fun foo2(a: A, b: B): Boolean {
|
||||||
val result = b == (a as B)
|
val result = b == (a as B)
|
||||||
<!DEBUG_INFO_SMARTCAST!>a<!> : B
|
checkSubtype<B>(<!DEBUG_INFO_SMARTCAST!>a<!>)
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-2
@@ -1,11 +1,13 @@
|
|||||||
|
// !CHECK_TYPE
|
||||||
|
|
||||||
fun foo(a: Number): Int {
|
fun foo(a: Number): Int {
|
||||||
val result = (a as Int) compareTo <!DEBUG_INFO_SMARTCAST!>a<!>
|
val result = (a as Int) compareTo <!DEBUG_INFO_SMARTCAST!>a<!>
|
||||||
<!DEBUG_INFO_SMARTCAST!>a<!> : Int
|
checkSubtype<Int>(<!DEBUG_INFO_SMARTCAST!>a<!>)
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
fun bar(a: Number): Int {
|
fun bar(a: Number): Int {
|
||||||
val result = 42 compareTo (a as Int)
|
val result = 42 compareTo (a as Int)
|
||||||
<!DEBUG_INFO_SMARTCAST!>a<!> : Int
|
checkSubtype<Int>(<!DEBUG_INFO_SMARTCAST!>a<!>)
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-2
@@ -1,3 +1,5 @@
|
|||||||
|
// !CHECK_TYPE
|
||||||
|
|
||||||
trait A
|
trait A
|
||||||
|
|
||||||
trait B : A
|
trait B : A
|
||||||
@@ -5,12 +7,12 @@ fun B.plus(b: B) = if (this == b) b else this
|
|||||||
|
|
||||||
fun foo(a: A): B {
|
fun foo(a: A): B {
|
||||||
val result = (a as B) + <!DEBUG_INFO_SMARTCAST!>a<!>
|
val result = (a as B) + <!DEBUG_INFO_SMARTCAST!>a<!>
|
||||||
<!DEBUG_INFO_SMARTCAST!>a<!> : B
|
checkSubtype<B>(<!DEBUG_INFO_SMARTCAST!>a<!>)
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|
||||||
fun bar(a: A, b: B): B {
|
fun bar(a: A, b: B): B {
|
||||||
val result = b + (a as B)
|
val result = b + (a as B)
|
||||||
<!DEBUG_INFO_SMARTCAST!>a<!> : B
|
checkSubtype<B>(<!DEBUG_INFO_SMARTCAST!>a<!>)
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
|
// !CHECK_TYPE
|
||||||
|
|
||||||
fun foo(x: Int?): Boolean {
|
fun foo(x: Int?): Boolean {
|
||||||
val result = ((x!! == 0) && ((<!DEBUG_INFO_SMARTCAST!>x<!> : Int) == 0))
|
val result = ((x!! == 0) && (checkSubtype<Int>(<!DEBUG_INFO_SMARTCAST!>x<!>) == 0))
|
||||||
<!DEBUG_INFO_SMARTCAST!>x<!> : Int
|
checkSubtype<Int>(<!DEBUG_INFO_SMARTCAST!>x<!>)
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,13 @@
|
|||||||
|
// !CHECK_TYPE
|
||||||
|
|
||||||
fun whileLoop(x: Int?) {
|
fun whileLoop(x: Int?) {
|
||||||
outer@ while (x != 0) {
|
outer@ while (x != 0) {
|
||||||
while (x != 1) {
|
while (x != 1) {
|
||||||
if (x == 2) continue@outer
|
if (x == 2) continue@outer
|
||||||
}
|
}
|
||||||
<!TYPE_MISMATCH!>x<!> : Int
|
checkSubtype<Int>(<!TYPE_MISMATCH!>x<!>)
|
||||||
}
|
}
|
||||||
<!DEBUG_INFO_SMARTCAST!>x<!> : Int
|
checkSubtype<Int>(<!DEBUG_INFO_SMARTCAST!>x<!>)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun doWhileLoop(x: Int?) {
|
fun doWhileLoop(x: Int?) {
|
||||||
@@ -13,9 +15,9 @@ fun doWhileLoop(x: Int?) {
|
|||||||
do {
|
do {
|
||||||
if (x == 2) continue@outer
|
if (x == 2) continue@outer
|
||||||
} while (x == null)
|
} while (x == null)
|
||||||
<!TYPE_MISMATCH!>x<!> : Int
|
checkSubtype<Int>(<!TYPE_MISMATCH!>x<!>)
|
||||||
}
|
}
|
||||||
<!DEBUG_INFO_SMARTCAST!>x<!> : Int
|
checkSubtype<Int>(<!DEBUG_INFO_SMARTCAST!>x<!>)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun whileLoopContinueInnerOuter(x: Int?) {
|
fun whileLoopContinueInnerOuter(x: Int?) {
|
||||||
@@ -24,9 +26,9 @@ fun whileLoopContinueInnerOuter(x: Int?) {
|
|||||||
while (x != 2) {
|
while (x != 2) {
|
||||||
if (x == 3) continue@inner
|
if (x == 3) continue@inner
|
||||||
}
|
}
|
||||||
<!TYPE_MISMATCH!>x<!> : Int
|
checkSubtype<Int>(<!TYPE_MISMATCH!>x<!>)
|
||||||
}
|
}
|
||||||
<!DEBUG_INFO_SMARTCAST!>x<!> : Int
|
checkSubtype<Int>(<!DEBUG_INFO_SMARTCAST!>x<!>)
|
||||||
}
|
}
|
||||||
<!DEBUG_INFO_SMARTCAST!>x<!> : Int
|
checkSubtype<Int>(<!DEBUG_INFO_SMARTCAST!>x<!>)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,18 +1,20 @@
|
|||||||
|
// !CHECK_TYPE
|
||||||
|
|
||||||
fun simpleDoWhile(x: Int?, y0: Int) {
|
fun simpleDoWhile(x: Int?, y0: Int) {
|
||||||
var y = y0
|
var y = y0
|
||||||
do {
|
do {
|
||||||
x : Int?
|
checkSubtype<Int?>(x)
|
||||||
y++
|
y++
|
||||||
} while (x!! == y)
|
} while (x!! == y)
|
||||||
<!DEBUG_INFO_SMARTCAST!>x<!> : Int
|
checkSubtype<Int>(<!DEBUG_INFO_SMARTCAST!>x<!>)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun doWhileWithBreak(x: Int?, y0: Int) {
|
fun doWhileWithBreak(x: Int?, y0: Int) {
|
||||||
var y = y0
|
var y = y0
|
||||||
do {
|
do {
|
||||||
x : Int?
|
checkSubtype<Int?>(x)
|
||||||
y++
|
y++
|
||||||
if (y > 0) break
|
if (y > 0) break
|
||||||
} while (x!! == y)
|
} while (x!! == y)
|
||||||
<!TYPE_MISMATCH!>x<!> : Int
|
checkSubtype<Int>(<!TYPE_MISMATCH!>x<!>)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
|
// !CHECK_TYPE
|
||||||
|
|
||||||
fun foo(arr: Array<Int>?) {
|
fun foo(arr: Array<Int>?) {
|
||||||
for (x in arr!!) {
|
for (x in arr!!) {
|
||||||
<!DEBUG_INFO_SMARTCAST!>arr<!> : Array<Int>
|
checkSubtype<Array<Int>>(<!DEBUG_INFO_SMARTCAST!>arr<!>)
|
||||||
}
|
}
|
||||||
<!DEBUG_INFO_SMARTCAST!>arr<!> : Array<Int>
|
checkSubtype<Array<Int>>(<!DEBUG_INFO_SMARTCAST!>arr<!>)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,29 +1,31 @@
|
|||||||
|
// !CHECK_TYPE
|
||||||
|
|
||||||
fun ifThen(x: Int?) {
|
fun ifThen(x: Int?) {
|
||||||
if (x!! == 0) {
|
if (x!! == 0) {
|
||||||
<!DEBUG_INFO_SMARTCAST!>x<!> : Int
|
checkSubtype<Int>(<!DEBUG_INFO_SMARTCAST!>x<!>)
|
||||||
}
|
}
|
||||||
<!DEBUG_INFO_SMARTCAST!>x<!> : Int
|
checkSubtype<Int>(<!DEBUG_INFO_SMARTCAST!>x<!>)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun ifElse(x: Int?) {
|
fun ifElse(x: Int?) {
|
||||||
if (x!! == 0) else {
|
if (x!! == 0) else {
|
||||||
<!DEBUG_INFO_SMARTCAST!>x<!> : Int
|
checkSubtype<Int>(<!DEBUG_INFO_SMARTCAST!>x<!>)
|
||||||
}
|
}
|
||||||
<!DEBUG_INFO_SMARTCAST!>x<!> : Int
|
checkSubtype<Int>(<!DEBUG_INFO_SMARTCAST!>x<!>)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun ifThenElse(x: Int?) {
|
fun ifThenElse(x: Int?) {
|
||||||
if (x!! == 0) {
|
if (x!! == 0) {
|
||||||
<!DEBUG_INFO_SMARTCAST!>x<!> : Int
|
checkSubtype<Int>(<!DEBUG_INFO_SMARTCAST!>x<!>)
|
||||||
} else {
|
} else {
|
||||||
<!DEBUG_INFO_SMARTCAST!>x<!> : Int
|
checkSubtype<Int>(<!DEBUG_INFO_SMARTCAST!>x<!>)
|
||||||
}
|
}
|
||||||
<!DEBUG_INFO_SMARTCAST!>x<!> : Int
|
checkSubtype<Int>(<!DEBUG_INFO_SMARTCAST!>x<!>)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun ifIs(x: Int?, cond: Boolean) {
|
fun ifIs(x: Int?, cond: Boolean) {
|
||||||
if ((x is Int) == cond) {
|
if ((x is Int) == cond) {
|
||||||
<!TYPE_MISMATCH!>x<!> : Int
|
checkSubtype<Int>(<!TYPE_MISMATCH!>x<!>)
|
||||||
}
|
}
|
||||||
<!TYPE_MISMATCH!>x<!> : Int
|
checkSubtype<Int>(<!TYPE_MISMATCH!>x<!>)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
|
// !CHECK_TYPE
|
||||||
|
|
||||||
fun foo(x: Number) {
|
fun foo(x: Number) {
|
||||||
if ((x as Int) is Int) {
|
if ((x as Int) is Int) {
|
||||||
<!DEBUG_INFO_SMARTCAST!>x<!> : Int
|
checkSubtype<Int>(<!DEBUG_INFO_SMARTCAST!>x<!>)
|
||||||
}
|
}
|
||||||
<!DEBUG_INFO_SMARTCAST!>x<!> : Int
|
checkSubtype<Int>(<!DEBUG_INFO_SMARTCAST!>x<!>)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
// !CHECK_TYPE
|
||||||
|
|
||||||
fun noUselessDataFlowInfoCreation(x: Number) {
|
fun noUselessDataFlowInfoCreation(x: Number) {
|
||||||
if (x is Int) { if (x is Int) { if (x is Int) { if (x is Int) { if (x is Int) {
|
if (x is Int) { if (x is Int) { if (x is Int) { if (x is Int) { if (x is Int) {
|
||||||
if (x is Int) { if (x is Int) { if (x is Int) { if (x is Int) { if (x is Int) {
|
if (x is Int) { if (x is Int) { if (x is Int) { if (x is Int) { if (x is Int) {
|
||||||
@@ -14,7 +16,7 @@ fun dataFlowInfoAnd(a: Array<Number>) {
|
|||||||
if (a[15] is Int) { if (a[16] is Int) { if (a[17] is Int) { if (a[18] is Int) { if (a[19] is Int) {
|
if (a[15] is Int) { if (a[16] is Int) { if (a[17] is Int) { if (a[18] is Int) { if (a[19] is Int) {
|
||||||
if (a[20] is Int) { if (a[21] is Int) { if (a[22] is Int) { if (a[23] is Int) { if (a[24] is Int) {
|
if (a[20] is Int) { if (a[21] is Int) { if (a[22] is Int) { if (a[23] is Int) { if (a[24] is Int) {
|
||||||
if (a[25] is Int) { if (a[26] is Int) { if (a[27] is Int) { if (a[28] is Int) { if (a[29] is Int) {
|
if (a[25] is Int) { if (a[26] is Int) { if (a[27] is Int) { if (a[28] is Int) { if (a[29] is Int) {
|
||||||
<!TYPE_MISMATCH!>a[0]<!> : Int
|
checkSubtype<Int>(<!TYPE_MISMATCH!>a[0]<!>)
|
||||||
} } } } } } } } } } } } } } } } } } } } } } } } } } } } } }
|
} } } } } } } } } } } } } } } } } } } } } } } } } } } } } }
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -25,6 +27,6 @@ fun dataFlowInfoOr(a: Array<Number>) {
|
|||||||
a[30] is Int || a[31] is Int || a[32] is Int || a[33] is Int || a[34] is Int || a[35] is Int || a[36] is Int || a[37] is Int || a[38] is Int || a[39] is Int ||
|
a[30] is Int || a[31] is Int || a[32] is Int || a[33] is Int || a[34] is Int || a[35] is Int || a[36] is Int || a[37] is Int || a[38] is Int || a[39] is Int ||
|
||||||
a[40] is Int || a[41] is Int || a[42] is Int || a[43] is Int || a[44] is Int || a[45] is Int || a[46] is Int || a[47] is Int || a[48] is Int || a[49] is Int ||
|
a[40] is Int || a[41] is Int || a[42] is Int || a[43] is Int || a[44] is Int || a[45] is Int || a[46] is Int || a[47] is Int || a[48] is Int || a[49] is Int ||
|
||||||
a[50] is Int || a[51] is Int || a[52] is Int || a[53] is Int || a[54] is Int || a[55] is Int || a[56] is Int || a[57] is Int || a[58] is Int || a[59] is Int) {
|
a[50] is Int || a[51] is Int || a[52] is Int || a[53] is Int || a[54] is Int || a[55] is Int || a[56] is Int || a[57] is Int || a[58] is Int || a[59] is Int) {
|
||||||
<!TYPE_MISMATCH!>a[0]<!> : Int
|
checkSubtype<Int>(<!TYPE_MISMATCH!>a[0]<!>)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
|
// !CHECK_TYPE
|
||||||
|
|
||||||
fun Int.component1() = "a"
|
fun Int.component1() = "a"
|
||||||
|
|
||||||
fun foo(a: Number) {
|
fun foo(a: Number) {
|
||||||
val (x) = a as Int
|
val (x) = a as Int
|
||||||
<!DEBUG_INFO_SMARTCAST!>a<!> : Int
|
checkSubtype<Int>(<!DEBUG_INFO_SMARTCAST!>a<!>)
|
||||||
x : String
|
checkSubtype<String>(x)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
|
// !CHECK_TYPE
|
||||||
|
|
||||||
fun foo(x: Number, y: String?): String {
|
fun foo(x: Number, y: String?): String {
|
||||||
val result = "abcde $x ${x as Int} ${y!!} $x $y"
|
val result = "abcde $x ${x as Int} ${y!!} $x $y"
|
||||||
<!DEBUG_INFO_SMARTCAST!>x<!> : Int
|
checkSubtype<Int>(<!DEBUG_INFO_SMARTCAST!>x<!>)
|
||||||
<!DEBUG_INFO_SMARTCAST!>y<!> : String
|
checkSubtype<String>(<!DEBUG_INFO_SMARTCAST!>y<!>)
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
|
// !CHECK_TYPE
|
||||||
|
|
||||||
fun tryFinally(x: Int?) {
|
fun tryFinally(x: Int?) {
|
||||||
try {
|
try {
|
||||||
} finally {
|
} finally {
|
||||||
x!!
|
x!!
|
||||||
}
|
}
|
||||||
<!DEBUG_INFO_SMARTCAST!>x<!> : Int
|
checkSubtype<Int>(<!DEBUG_INFO_SMARTCAST!>x<!>)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun tryCatchFinally(x: Int?) {
|
fun tryCatchFinally(x: Int?) {
|
||||||
@@ -12,8 +14,8 @@ fun tryCatchFinally(x: Int?) {
|
|||||||
} catch (e: Exception) {
|
} catch (e: Exception) {
|
||||||
x!!
|
x!!
|
||||||
} finally {
|
} finally {
|
||||||
<!TYPE_MISMATCH!>x<!> : Int
|
checkSubtype<Int>(<!TYPE_MISMATCH!>x<!>)
|
||||||
x!!
|
x!!
|
||||||
}
|
}
|
||||||
<!DEBUG_INFO_SMARTCAST!>x<!> : Int
|
checkSubtype<Int>(<!DEBUG_INFO_SMARTCAST!>x<!>)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,24 +1,26 @@
|
|||||||
|
// !CHECK_TYPE
|
||||||
|
|
||||||
fun foo(x: Number, y: Int) {
|
fun foo(x: Number, y: Int) {
|
||||||
when (x) {
|
when (x) {
|
||||||
x as Int -> <!DEBUG_INFO_SMARTCAST!>x<!> : Int
|
x as Int -> checkSubtype<Int>(<!DEBUG_INFO_SMARTCAST!>x<!>)
|
||||||
y -> {}
|
y -> {}
|
||||||
else -> {}
|
else -> {}
|
||||||
}
|
}
|
||||||
<!DEBUG_INFO_SMARTCAST!>x<!> : Int
|
checkSubtype<Int>(<!DEBUG_INFO_SMARTCAST!>x<!>)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun bar(x: Number) {
|
fun bar(x: Number) {
|
||||||
when (x) {
|
when (x) {
|
||||||
x as Int -> <!DEBUG_INFO_SMARTCAST!>x<!> : Int
|
x as Int -> checkSubtype<Int>(<!DEBUG_INFO_SMARTCAST!>x<!>)
|
||||||
else -> {}
|
else -> {}
|
||||||
}
|
}
|
||||||
<!DEBUG_INFO_SMARTCAST!>x<!> : Int
|
checkSubtype<Int>(<!DEBUG_INFO_SMARTCAST!>x<!>)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun whenWithoutSubject(x: Number) {
|
fun whenWithoutSubject(x: Number) {
|
||||||
when {
|
when {
|
||||||
(x as Int) == 42 -> <!DEBUG_INFO_SMARTCAST!>x<!> : Int
|
(x as Int) == 42 -> checkSubtype<Int>(<!DEBUG_INFO_SMARTCAST!>x<!>)
|
||||||
else -> {}
|
else -> {}
|
||||||
}
|
}
|
||||||
<!DEBUG_INFO_SMARTCAST!>x<!> : Int
|
checkSubtype<Int>(<!DEBUG_INFO_SMARTCAST!>x<!>)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,24 +1,26 @@
|
|||||||
|
// !CHECK_TYPE
|
||||||
|
|
||||||
fun foo(x: Number, y: Int) {
|
fun foo(x: Number, y: Int) {
|
||||||
when (x) {
|
when (x) {
|
||||||
is Int -> <!DEBUG_INFO_SMARTCAST!>x<!> : Int
|
is Int -> checkSubtype<Int>(<!DEBUG_INFO_SMARTCAST!>x<!>)
|
||||||
y -> {}
|
y -> {}
|
||||||
else -> {}
|
else -> {}
|
||||||
}
|
}
|
||||||
<!TYPE_MISMATCH!>x<!> : Int
|
checkSubtype<Int>(<!TYPE_MISMATCH!>x<!>)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun bar(x: Number) {
|
fun bar(x: Number) {
|
||||||
when (x) {
|
when (x) {
|
||||||
is Int -> <!DEBUG_INFO_SMARTCAST!>x<!> : Int
|
is Int -> checkSubtype<Int>(<!DEBUG_INFO_SMARTCAST!>x<!>)
|
||||||
else -> {}
|
else -> {}
|
||||||
}
|
}
|
||||||
<!TYPE_MISMATCH!>x<!> : Int
|
checkSubtype<Int>(<!TYPE_MISMATCH!>x<!>)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun whenWithoutSubject(x: Number) {
|
fun whenWithoutSubject(x: Number) {
|
||||||
when {
|
when {
|
||||||
(x is Int) -> <!DEBUG_INFO_SMARTCAST!>x<!> : Int
|
(x is Int) -> checkSubtype<Int>(<!DEBUG_INFO_SMARTCAST!>x<!>)
|
||||||
else -> {}
|
else -> {}
|
||||||
}
|
}
|
||||||
<!TYPE_MISMATCH!>x<!> : Int
|
checkSubtype<Int>(<!TYPE_MISMATCH!>x<!>)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,13 +1,15 @@
|
|||||||
|
// !CHECK_TYPE
|
||||||
|
|
||||||
fun foo(x: Int, list: List<Int>?) {
|
fun foo(x: Int, list: List<Int>?) {
|
||||||
when (x) {
|
when (x) {
|
||||||
in list!! -> <!DEBUG_INFO_SMARTCAST!>list<!> : List<Int>
|
in list!! -> checkSubtype<List<Int>>(<!DEBUG_INFO_SMARTCAST!>list<!>)
|
||||||
else -> {}
|
else -> {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fun whenWithoutSubject(x: Int, list: List<Int>?) {
|
fun whenWithoutSubject(x: Int, list: List<Int>?) {
|
||||||
when {
|
when {
|
||||||
x in list!! -> <!DEBUG_INFO_SMARTCAST!>list<!> : List<Int>
|
x in list!! -> checkSubtype<List<Int>>(<!DEBUG_INFO_SMARTCAST!>list<!>)
|
||||||
else -> {}
|
else -> {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
|
// !CHECK_TYPE
|
||||||
|
|
||||||
fun foo(x: Number) {
|
fun foo(x: Number) {
|
||||||
when (x as Int) {
|
when (x as Int) {
|
||||||
else -> <!DEBUG_INFO_SMARTCAST!>x<!> : Int
|
else -> checkSubtype<Int>(<!DEBUG_INFO_SMARTCAST!>x<!>)
|
||||||
}
|
}
|
||||||
<!DEBUG_INFO_SMARTCAST!>x<!> : Int
|
checkSubtype<Int>(<!DEBUG_INFO_SMARTCAST!>x<!>)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,24 +1,26 @@
|
|||||||
|
// !CHECK_TYPE
|
||||||
|
|
||||||
fun simpleWhile(x: Int?, y0: Int) {
|
fun simpleWhile(x: Int?, y0: Int) {
|
||||||
var y = y0
|
var y = y0
|
||||||
while (x!! == y) {
|
while (x!! == y) {
|
||||||
<!DEBUG_INFO_SMARTCAST!>x<!> : Int
|
checkSubtype<Int>(<!DEBUG_INFO_SMARTCAST!>x<!>)
|
||||||
y++
|
y++
|
||||||
}
|
}
|
||||||
<!DEBUG_INFO_SMARTCAST!>x<!> : Int
|
checkSubtype<Int>(<!DEBUG_INFO_SMARTCAST!>x<!>)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun whileWithBreak(x: Int?, y0: Int) {
|
fun whileWithBreak(x: Int?, y0: Int) {
|
||||||
var y = y0
|
var y = y0
|
||||||
while (x!! == y) {
|
while (x!! == y) {
|
||||||
<!DEBUG_INFO_SMARTCAST!>x<!> : Int
|
checkSubtype<Int>(<!DEBUG_INFO_SMARTCAST!>x<!>)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
<!DEBUG_INFO_SMARTCAST!>x<!> : Int
|
checkSubtype<Int>(<!DEBUG_INFO_SMARTCAST!>x<!>)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun whileWithNoCondition(x: Int?) {
|
fun whileWithNoCondition(x: Int?) {
|
||||||
while (<!SYNTAX!><!>) {
|
while (<!SYNTAX!><!>) {
|
||||||
x!!
|
x!!
|
||||||
}
|
}
|
||||||
<!TYPE_MISMATCH!>x<!> : Int
|
checkSubtype<Int>(<!TYPE_MISMATCH!>x<!>)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
// !CHECK_TYPE
|
||||||
|
|
||||||
//KT-2631 Check multiple assignment
|
//KT-2631 Check multiple assignment
|
||||||
package a
|
package a
|
||||||
|
|
||||||
@@ -12,14 +14,14 @@ fun MyClass2.component1() = 1.2
|
|||||||
|
|
||||||
fun test(mc1: MyClass, mc2: MyClass2) {
|
fun test(mc1: MyClass, mc2: MyClass2) {
|
||||||
val (a, b) = mc1
|
val (a, b) = mc1
|
||||||
a : Int
|
checkSubtype<Int>(a)
|
||||||
b : String
|
checkSubtype<String>(b)
|
||||||
|
|
||||||
val (c) = mc2
|
val (c) = mc2
|
||||||
c : Double
|
checkSubtype<Double>(c)
|
||||||
|
|
||||||
//check no error types
|
//check no error types
|
||||||
<!TYPE_MISMATCH!>a<!> : Boolean
|
checkSubtype<Boolean>(<!TYPE_MISMATCH!>a<!>)
|
||||||
<!TYPE_MISMATCH!>b<!> : Boolean
|
checkSubtype<Boolean>(<!TYPE_MISMATCH!>b<!>)
|
||||||
<!TYPE_MISMATCH!>c<!> : Boolean
|
checkSubtype<Boolean>(<!TYPE_MISMATCH!>c<!>)
|
||||||
}
|
}
|
||||||
+3
-1
@@ -1,8 +1,10 @@
|
|||||||
|
// !CHECK_TYPE
|
||||||
|
|
||||||
class A {
|
class A {
|
||||||
val a by MyProperty()
|
val a by MyProperty()
|
||||||
|
|
||||||
fun test() {
|
fun test() {
|
||||||
a: Int
|
checkSubtype<Int>(a)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
// !CHECK_TYPE
|
||||||
|
|
||||||
package m
|
package m
|
||||||
|
|
||||||
fun test(i: Int?) {
|
fun test(i: Int?) {
|
||||||
@@ -10,14 +12,14 @@ fun test(i: Int?) {
|
|||||||
|
|
||||||
val a: Int = l4@ <!TYPE_MISMATCH!>""<!>
|
val a: Int = l4@ <!TYPE_MISMATCH!>""<!>
|
||||||
val b: Int = (<!TYPE_MISMATCH!>""<!>)
|
val b: Int = (<!TYPE_MISMATCH!>""<!>)
|
||||||
val c: Int = <!TYPE_MISMATCH!>""<!>: Int
|
val c: Int = checkSubtype<Int>(<!TYPE_MISMATCH!>""<!>)
|
||||||
val d: Int = <!TYPE_MISMATCH!><!TYPE_MISMATCH!>""<!>: Long<!>
|
val d: Int = <!TYPE_MISMATCH!>checkSubtype<Long>(<!TYPE_MISMATCH!>""<!>)<!>
|
||||||
|
|
||||||
|
|
||||||
foo(l4@ <!TYPE_MISMATCH!>""<!>)
|
foo(l4@ <!TYPE_MISMATCH!>""<!>)
|
||||||
foo((<!TYPE_MISMATCH!>""<!>))
|
foo((<!TYPE_MISMATCH!>""<!>))
|
||||||
foo(<!TYPE_MISMATCH!>""<!>: Int)
|
foo(checkSubtype<Int>(<!TYPE_MISMATCH!>""<!>))
|
||||||
foo(<!TYPE_MISMATCH!><!TYPE_MISMATCH!>""<!>: Long<!>)
|
foo(<!TYPE_MISMATCH!>checkSubtype<Long>(<!TYPE_MISMATCH!>""<!>)<!>)
|
||||||
|
|
||||||
use(a, b, c, d)
|
use(a, b, c, d)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
// !CHECK_TYPE
|
||||||
// FILE: A.java
|
// FILE: A.java
|
||||||
public enum A {
|
public enum A {
|
||||||
ENTRY;
|
ENTRY;
|
||||||
@@ -5,5 +6,5 @@ public enum A {
|
|||||||
|
|
||||||
// FILE: test.kt
|
// FILE: test.kt
|
||||||
fun main() {
|
fun main() {
|
||||||
A.valueOf("ENTRY"): A
|
checkSubtype<A>(A.valueOf("ENTRY"))
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
// !CHECK_TYPE
|
||||||
// FILE: A.java
|
// FILE: A.java
|
||||||
public enum A {
|
public enum A {
|
||||||
ENTRY,
|
ENTRY,
|
||||||
@@ -6,5 +7,5 @@ public enum A {
|
|||||||
|
|
||||||
// FILE: test.kt
|
// FILE: test.kt
|
||||||
fun main() {
|
fun main() {
|
||||||
A.values(): Array<A>
|
checkSubtype<Array<A>>(A.values())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
// !CHECK_TYPE
|
||||||
// FILE: A.java
|
// FILE: A.java
|
||||||
public enum A {
|
public enum A {
|
||||||
|
|
||||||
@@ -11,5 +12,5 @@ public enum A {
|
|||||||
|
|
||||||
// FILE: test.kt
|
// FILE: test.kt
|
||||||
fun main() {
|
fun main() {
|
||||||
A.ENTRY.s(): String?
|
checkSubtype<String?>(A.ENTRY.s())
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
// !CHECK_TYPE
|
||||||
|
|
||||||
import java.util.Enumeration
|
import java.util.Enumeration
|
||||||
|
|
||||||
fun <T> java.util.Enumeration<T>.iterator() = object : Iterator<T> {
|
fun <T> java.util.Enumeration<T>.iterator() = object : Iterator<T> {
|
||||||
@@ -8,6 +10,6 @@ fun <T> java.util.Enumeration<T>.iterator() = object : Iterator<T> {
|
|||||||
|
|
||||||
fun a(e : java.util.Enumeration<Int>) {
|
fun a(e : java.util.Enumeration<Int>) {
|
||||||
for (i in e) {
|
for (i in e) {
|
||||||
i : Int
|
checkSubtype<Int>(i)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
// !CHECK_TYPE
|
||||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||||
|
|
||||||
annotation class ann(val name: String)
|
annotation class ann(val name: String)
|
||||||
@@ -16,5 +17,5 @@ val withExpression = fun() = 5
|
|||||||
val funfun = fun() = fun() = 5
|
val funfun = fun() = fun() = 5
|
||||||
|
|
||||||
val parentesized = (fun () {})
|
val parentesized = (fun () {})
|
||||||
val parentesizedWithType = (fun () {}) : () -> Unit
|
val parentesizedWithType = checkSubtype<() -> Unit>((fun () {}))
|
||||||
val withType = (fun () {}) : () -> Unit
|
val withType = checkSubtype<() -> Unit>((fun () {}))
|
||||||
|
|||||||
@@ -4,7 +4,7 @@
|
|||||||
fun testReturnType(foo: String) {
|
fun testReturnType(foo: String) {
|
||||||
val bar = fun () = foo
|
val bar = fun () = foo
|
||||||
|
|
||||||
bar.checkType { it : _<() -> String> }
|
bar.checkType { _<() -> String>() }
|
||||||
|
|
||||||
val bas: () -> String = fun () = foo
|
val bas: () -> String = fun () = foo
|
||||||
|
|
||||||
@@ -14,7 +14,7 @@ fun testReturnType(foo: String) {
|
|||||||
fun testParamType() {
|
fun testParamType() {
|
||||||
val bar = fun (bal: String){}
|
val bar = fun (bal: String){}
|
||||||
|
|
||||||
bar.checkType { it : _<(String) -> Unit> }
|
bar.checkType { _<(String) -> Unit>() }
|
||||||
|
|
||||||
val bas: (String) -> Unit = fun (param: String) {}
|
val bas: (String) -> Unit = fun (param: String) {}
|
||||||
val bag: (Int) -> Unit = <!TYPE_MISMATCH!>fun (<!EXPECTED_PARAMETER_TYPE_MISMATCH!>param: String<!>) {}<!>
|
val bag: (Int) -> Unit = <!TYPE_MISMATCH!>fun (<!EXPECTED_PARAMETER_TYPE_MISMATCH!>param: String<!>) {}<!>
|
||||||
@@ -23,7 +23,7 @@ fun testParamType() {
|
|||||||
fun testReceiverType() {
|
fun testReceiverType() {
|
||||||
val bar = fun String.() {}
|
val bar = fun String.() {}
|
||||||
|
|
||||||
bar.checkType { it : _<String.() -> Unit> }
|
bar.checkType { _<String.() -> Unit>() }
|
||||||
|
|
||||||
val bas: String.() -> Unit = fun String.() {}
|
val bas: String.() -> Unit = fun String.() {}
|
||||||
|
|
||||||
|
|||||||
+3
-2
@@ -1,3 +1,4 @@
|
|||||||
|
// !CHECK_TYPE
|
||||||
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE
|
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE
|
||||||
fun listOf<T>(): List<T> = null!!
|
fun listOf<T>(): List<T> = null!!
|
||||||
|
|
||||||
@@ -6,13 +7,13 @@ fun test(a: (Int) -> Int) {
|
|||||||
|
|
||||||
test(fun (x) = x)
|
test(fun (x) = x)
|
||||||
|
|
||||||
test(fun (x): Int { x: Int; return 4 })
|
test(fun (x): Int { checkSubtype<Int>(x); return 4 })
|
||||||
}
|
}
|
||||||
|
|
||||||
fun test2(a: () -> List<Int>) {
|
fun test2(a: () -> List<Int>) {
|
||||||
test2(fun () = <!TYPE_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>listOf<!>())
|
test2(fun () = <!TYPE_INFERENCE_NO_INFORMATION_FOR_PARAMETER!>listOf<!>())
|
||||||
}
|
}
|
||||||
|
|
||||||
val a: (Int) -> Unit = fun(x) { x: Int }
|
val a: (Int) -> Unit = fun(x) { checkSubtype<Int>(x) }
|
||||||
|
|
||||||
val b: (Int) -> Unit = <!TYPE_MISMATCH!>fun(<!EXPECTED_PARAMETER_TYPE_MISMATCH!>x: String<!>) {}<!>
|
val b: (Int) -> Unit = <!TYPE_MISMATCH!>fun(<!EXPECTED_PARAMETER_TYPE_MISMATCH!>x: String<!>) {}<!>
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
// !CHECK_TYPE
|
||||||
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE
|
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE
|
||||||
|
|
||||||
val a = fun (<!CANNOT_INFER_PARAMETER_TYPE!>x<!>) = <!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>x<!>
|
val a = fun (<!CANNOT_INFER_PARAMETER_TYPE!>x<!>) = <!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>x<!>
|
||||||
@@ -13,7 +14,7 @@ val e: (Int, String) -> Int = <!TYPE_MISMATCH!>fun <!EXPECTED_PARAMETERS_NUMBER_
|
|||||||
val f: (Int) -> Int = <!TYPE_MISMATCH!>fun (<!EXPECTED_PARAMETER_TYPE_MISMATCH!>x: String<!>) = 3<!>
|
val f: (Int) -> Int = <!TYPE_MISMATCH!>fun (<!EXPECTED_PARAMETER_TYPE_MISMATCH!>x: String<!>) = 3<!>
|
||||||
|
|
||||||
fun test1(a: (Int) -> Unit) {
|
fun test1(a: (Int) -> Unit) {
|
||||||
test1(fun (x) { x : Int})
|
test1(fun (x) { checkSubtype<Int>(x)})
|
||||||
}
|
}
|
||||||
|
|
||||||
fun test2(a: (Int) -> Unit) {
|
fun test2(a: (Int) -> Unit) {
|
||||||
|
|||||||
@@ -1,16 +1,18 @@
|
|||||||
|
// !CHECK_TYPE
|
||||||
|
|
||||||
fun test(bal: Array<Int>) {
|
fun test(bal: Array<Int>) {
|
||||||
var bar = 4
|
var bar = 4
|
||||||
|
|
||||||
val a = { bar += 4 }
|
val a = { bar += 4 }
|
||||||
a : () -> Unit
|
checkSubtype<() -> Unit>(a)
|
||||||
|
|
||||||
val b = { bar = 4 }
|
val b = { bar = 4 }
|
||||||
b : () -> Unit
|
checkSubtype<() -> Unit>(b)
|
||||||
|
|
||||||
val c = { bal[2] = 3 }
|
val c = { bal[2] = 3 }
|
||||||
c : () -> Unit
|
checkSubtype<() -> Unit>(c)
|
||||||
|
|
||||||
val d = run { bar += 4 }
|
val d = run { bar += 4 }
|
||||||
d : Unit
|
checkSubtype<Unit>(d)
|
||||||
}
|
}
|
||||||
fun <T> run(f: () -> T): T = f()
|
fun <T> run(f: () -> T): T = f()
|
||||||
@@ -6,5 +6,5 @@ fun test() {
|
|||||||
} else {
|
} else {
|
||||||
{ 2 }
|
{ 2 }
|
||||||
}
|
}
|
||||||
a checkType { it : _<() -> Int> }
|
a checkType { _<() -> Int>() }
|
||||||
}
|
}
|
||||||
+1
-1
@@ -3,5 +3,5 @@ fun <T> id(t: T) = t
|
|||||||
|
|
||||||
fun foo() {
|
fun foo() {
|
||||||
val i = id { 22 } //type inference error: no information for parameter
|
val i = id { 22 } //type inference error: no information for parameter
|
||||||
i checkType { it : _<()->Int> }
|
i checkType { _<()->Int>() }
|
||||||
}
|
}
|
||||||
|
|||||||
+3
-1
@@ -1,9 +1,11 @@
|
|||||||
|
// !CHECK_TYPE
|
||||||
|
|
||||||
fun test2(a: Int) {
|
fun test2(a: Int) {
|
||||||
val x = run f@{
|
val x = run f@{
|
||||||
if (a > 0) <!RETURN_NOT_ALLOWED!>return<!>
|
if (a > 0) <!RETURN_NOT_ALLOWED!>return<!>
|
||||||
return@f 1
|
return@f 1
|
||||||
}
|
}
|
||||||
x: Int
|
checkSubtype<Int>(x)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun run<T>(f: () -> T): T { return f() }
|
fun run<T>(f: () -> T): T { return f() }
|
||||||
+3
-1
@@ -1,6 +1,8 @@
|
|||||||
|
// !CHECK_TYPE
|
||||||
|
|
||||||
fun test2() {
|
fun test2() {
|
||||||
val x = run f@{return@f 1}
|
val x = run f@{return@f 1}
|
||||||
x: Int
|
checkSubtype<Int>(x)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun run<T>(f: () -> T): T { return f() }
|
fun run<T>(f: () -> T): T { return f() }
|
||||||
+4
-2
@@ -1,12 +1,14 @@
|
|||||||
|
// !CHECK_TYPE
|
||||||
|
|
||||||
fun test() {
|
fun test() {
|
||||||
val x = run(f@{return@f 1})
|
val x = run(f@{return@f 1})
|
||||||
x: Int
|
checkSubtype<Int>(x)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
fun test1() {
|
fun test1() {
|
||||||
val x = run(l@{return@l 1})
|
val x = run(l@{return@l 1})
|
||||||
x: Int
|
checkSubtype<Int>(x)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun run<T>(f: () -> T): T { return f() }
|
fun run<T>(f: () -> T): T { return f() }
|
||||||
+3
-1
@@ -1,6 +1,8 @@
|
|||||||
|
// !CHECK_TYPE
|
||||||
|
|
||||||
fun test() {
|
fun test() {
|
||||||
run1 f@{
|
run1 f@{
|
||||||
(return@f 1)<!UNREACHABLE_CODE!>: Nothing<!>
|
<!UNREACHABLE_CODE!>checkSubtype<Nothing>(<!>return@f 1<!UNREACHABLE_CODE!>)<!>
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+3
-1
@@ -1,3 +1,5 @@
|
|||||||
|
// !CHECK_TYPE
|
||||||
|
|
||||||
fun test() {
|
fun test() {
|
||||||
val x = run f@{
|
val x = run f@{
|
||||||
fun local(a: Int): String {
|
fun local(a: Int): String {
|
||||||
@@ -6,7 +8,7 @@ fun test() {
|
|||||||
}
|
}
|
||||||
return@f 1
|
return@f 1
|
||||||
}
|
}
|
||||||
x: Int
|
checkSubtype<Int>(x)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun run<T>(f: () -> T): T { return f() }
|
fun run<T>(f: () -> T): T { return f() }
|
||||||
+3
-1
@@ -1,3 +1,5 @@
|
|||||||
|
// !CHECK_TYPE
|
||||||
|
|
||||||
fun test() {
|
fun test() {
|
||||||
val x = run f@{
|
val x = run f@{
|
||||||
run ff@ {
|
run ff@ {
|
||||||
@@ -5,7 +7,7 @@ fun test() {
|
|||||||
}
|
}
|
||||||
return@f 1
|
return@f 1
|
||||||
}
|
}
|
||||||
x: Int
|
checkSubtype<Int>(x)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun run<T>(f: () -> T): T { return f() }
|
fun run<T>(f: () -> T): T { return f() }
|
||||||
@@ -1,9 +1,11 @@
|
|||||||
|
// !CHECK_TYPE
|
||||||
|
|
||||||
fun test(a: Int) {
|
fun test(a: Int) {
|
||||||
val x = run f@{
|
val x = run f@{
|
||||||
if (a > 0) return@f
|
if (a > 0) return@f
|
||||||
else return@f Unit
|
else return@f Unit
|
||||||
}
|
}
|
||||||
x: Unit
|
checkSubtype<Unit>(x)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun run<T>(f: () -> T): T { return f() }
|
fun run<T>(f: () -> T): T { return f() }
|
||||||
+3
-1
@@ -1,3 +1,5 @@
|
|||||||
|
// !CHECK_TYPE
|
||||||
|
|
||||||
trait A
|
trait A
|
||||||
trait B: A
|
trait B: A
|
||||||
trait C: A
|
trait C: A
|
||||||
@@ -8,7 +10,7 @@ fun test(a: C, b: B) {
|
|||||||
if (a != b) return@f a
|
if (a != b) return@f a
|
||||||
b
|
b
|
||||||
}
|
}
|
||||||
x: A
|
checkSubtype<A>(x)
|
||||||
}
|
}
|
||||||
|
|
||||||
fun run<T>(f: () -> T): T { return f() }
|
fun run<T>(f: () -> T): T { return f() }
|
||||||
@@ -1,3 +1,5 @@
|
|||||||
|
// !CHECK_TYPE
|
||||||
|
|
||||||
class In<in T>() {
|
class In<in T>() {
|
||||||
fun f(<!UNUSED_PARAMETER!>t<!> : T) : Unit {}
|
fun f(<!UNUSED_PARAMETER!>t<!> : T) : Unit {}
|
||||||
fun f(<!UNUSED_PARAMETER!>t<!> : Int) : Int = 1
|
fun f(<!UNUSED_PARAMETER!>t<!> : Int) : Int = 1
|
||||||
@@ -43,7 +45,7 @@ fun testInOut() {
|
|||||||
(null <!CAST_NEVER_SUCCEEDS!>as<!> Inv<*>).<!UNRESOLVED_REFERENCE!>inf<!>(1) // !!
|
(null <!CAST_NEVER_SUCCEEDS!>as<!> Inv<*>).<!UNRESOLVED_REFERENCE!>inf<!>(1) // !!
|
||||||
|
|
||||||
Inv<Int>().outf()
|
Inv<Int>().outf()
|
||||||
<!TYPE_MISMATCH!>(null <!CAST_NEVER_SUCCEEDS!>as<!> Inv<in Int>).outf()<!> : Int // Type mismatch
|
checkSubtype<Int>(<!TYPE_MISMATCH!>(null <!CAST_NEVER_SUCCEEDS!>as<!> Inv<in Int>).outf()<!>) // Type mismatch
|
||||||
(null <!CAST_NEVER_SUCCEEDS!>as<!> Inv<out Int>).outf()
|
(null <!CAST_NEVER_SUCCEEDS!>as<!> Inv<out Int>).outf()
|
||||||
(null <!CAST_NEVER_SUCCEEDS!>as<!> Inv<*>).outf()
|
(null <!CAST_NEVER_SUCCEEDS!>as<!> Inv<*>).outf()
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -5,5 +5,5 @@ trait Tr<T> {
|
|||||||
|
|
||||||
fun test(t: Tr<*>) {
|
fun test(t: Tr<*>) {
|
||||||
t.v = t
|
t.v = t
|
||||||
t.v checkType { it : _<Tr<*>> }
|
t.v checkType { _<Tr<*>>() }
|
||||||
}
|
}
|
||||||
+1
-1
@@ -7,5 +7,5 @@ trait Tr<T> {
|
|||||||
|
|
||||||
fun test(t: Tr<*>) {
|
fun test(t: Tr<*>) {
|
||||||
t.<!SETTER_PROJECTED_OUT!>v<!> = null!!
|
t.<!SETTER_PROJECTED_OUT!>v<!> = null!!
|
||||||
t.v checkType { it : _<Any?> }
|
t.v checkType { _<Any?>() }
|
||||||
}
|
}
|
||||||
+2
-2
@@ -6,7 +6,7 @@ fun <T: Any> bar(a: Array<T>): Array<T?> = null!!
|
|||||||
fun test1(a: Array<out Int>) {
|
fun test1(a: Array<out Int>) {
|
||||||
val r: Array<out Int?> = bar(a)
|
val r: Array<out Int?> = bar(a)
|
||||||
val t = bar(a)
|
val t = bar(a)
|
||||||
t checkType { it : _<Array<out Int?>> }
|
t checkType { _<Array<out Int?>>() }
|
||||||
}
|
}
|
||||||
|
|
||||||
fun <T: Any> foo(l: Array<T>): Array<Array<T?>> = null!!
|
fun <T: Any> foo(l: Array<T>): Array<Array<T?>> = null!!
|
||||||
@@ -14,5 +14,5 @@ fun <T: Any> foo(l: Array<T>): Array<Array<T?>> = null!!
|
|||||||
fun test2(a: Array<out Int>) {
|
fun test2(a: Array<out Int>) {
|
||||||
val r: Array<out Array<out Int?>> = foo(a)
|
val r: Array<out Array<out Int?>> = foo(a)
|
||||||
val t = foo(a)
|
val t = foo(a)
|
||||||
t checkType { it : _<Array<out Array<out Int?>>> }
|
t checkType { _<Array<out Array<out Int?>>>() }
|
||||||
}
|
}
|
||||||
+4
-4
@@ -15,15 +15,15 @@ public class A {
|
|||||||
fun test1(clazz: Class<out Int>) {
|
fun test1(clazz: Class<out Int>) {
|
||||||
val foo0: Class<out Int> = A.foo(clazz)
|
val foo0: Class<out Int> = A.foo(clazz)
|
||||||
val foo1 = A.foo(clazz)
|
val foo1 = A.foo(clazz)
|
||||||
foo1 checkType { it: _< Class<out Int> > }
|
foo1 checkType { _< Class<out Int> >() }
|
||||||
// should be ok
|
// should be ok
|
||||||
foo1 checkType { <!TYPE_MISMATCH!>it<!>: _< Class<out Int?> > }
|
foo1 checkType { <!TYPE_MISMATCH!>_<!>< Class<out Int?> >() }
|
||||||
}
|
}
|
||||||
|
|
||||||
fun tes2t(clazz: Class<in Int>) {
|
fun tes2t(clazz: Class<in Int>) {
|
||||||
val foo0: Class<out Class<in Int>> = A.bar(clazz)
|
val foo0: Class<out Class<in Int>> = A.bar(clazz)
|
||||||
val foo1 = A.bar(clazz)
|
val foo1 = A.bar(clazz)
|
||||||
foo1 checkType { it: _< Class<out Class<in Int>> > }
|
foo1 checkType { _< Class<out Class<in Int>> >() }
|
||||||
// should be ok
|
// should be ok
|
||||||
foo1 checkType { <!TYPE_MISMATCH!>it<!>: _< Class<out Class<in Int?>> > }
|
foo1 checkType { <!TYPE_MISMATCH!>_<!>< Class<out Class<in Int?>> >() }
|
||||||
}
|
}
|
||||||
+2
-2
@@ -4,10 +4,10 @@ fun <T : Any> Array<T?>.filterNotNull(): List<T> = throw Exception()
|
|||||||
|
|
||||||
fun test1(a: Array<out Int?>) {
|
fun test1(a: Array<out Int?>) {
|
||||||
val list = a.filterNotNull()
|
val list = a.filterNotNull()
|
||||||
list checkType { it : _<List<Int>> }
|
list checkType { _<List<Int>>() }
|
||||||
}
|
}
|
||||||
|
|
||||||
fun test2(vararg a: Int?) {
|
fun test2(vararg a: Int?) {
|
||||||
val list = a.filterNotNull()
|
val list = a.filterNotNull()
|
||||||
list checkType { it : _<List<Int>> }
|
list checkType { _<List<Int>>() }
|
||||||
}
|
}
|
||||||
@@ -6,11 +6,11 @@ fun <T> foo(array: Array<T>): Array<T> = array
|
|||||||
fun test1(a1: Array<out Int>) {
|
fun test1(a1: Array<out Int>) {
|
||||||
val b1: Array<out Int> = foo(a1)
|
val b1: Array<out Int> = foo(a1)
|
||||||
val c1 = foo(a1)
|
val c1 = foo(a1)
|
||||||
c1 checkType { it : _<Array<out Int>> }
|
c1 checkType { _<Array<out Int>>() }
|
||||||
}
|
}
|
||||||
|
|
||||||
fun test2(a2: Array<in Int>) {
|
fun test2(a2: Array<in Int>) {
|
||||||
val b2: Array<in Int> = foo(a2)
|
val b2: Array<in Int> = foo(a2)
|
||||||
val c2 = foo(a2)
|
val c2 = foo(a2)
|
||||||
c2 checkType { it : _<Array<in Int>> }
|
c2 checkType { _<Array<in Int>>() }
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -6,11 +6,11 @@ fun <T> foo(a: Array<T>): Array<Array<T>> = throw Exception()
|
|||||||
fun test1(a1: Array<out Int>) {
|
fun test1(a1: Array<out Int>) {
|
||||||
val b1: Array<out Array<out Int>> = foo(a1)
|
val b1: Array<out Array<out Int>> = foo(a1)
|
||||||
val c1 = foo(a1)
|
val c1 = foo(a1)
|
||||||
c1 checkType { it : _<Array<out Array<out Int>>> }
|
c1 checkType { _<Array<out Array<out Int>>>() }
|
||||||
}
|
}
|
||||||
|
|
||||||
fun test2(a2: Array<in Int>) {
|
fun test2(a2: Array<in Int>) {
|
||||||
val b2: Array<out Array<in Int>> = foo(a2)
|
val b2: Array<out Array<in Int>> = foo(a2)
|
||||||
val c2 = foo(a2)
|
val c2 = foo(a2)
|
||||||
c2 checkType { it : _<Array<out Array<in Int>>> }
|
c2 checkType { _<Array<out Array<in Int>>>() }
|
||||||
}
|
}
|
||||||
+2
-2
@@ -4,11 +4,11 @@
|
|||||||
fun <T> foo1(a1: Array<in T>, a2: Array<T>): T = null!!
|
fun <T> foo1(a1: Array<in T>, a2: Array<T>): T = null!!
|
||||||
|
|
||||||
fun test1(a1: Array<Int>, a2: Array<out Int>) {
|
fun test1(a1: Array<Int>, a2: Array<out Int>) {
|
||||||
foo1(a1, a2) checkType { it : _<Int> }
|
foo1(a1, a2) checkType { _<Int>() }
|
||||||
}
|
}
|
||||||
|
|
||||||
fun <T> foo2(a1: Array<T>, a2: Array<out T>): T = null!!
|
fun <T> foo2(a1: Array<T>, a2: Array<out T>): T = null!!
|
||||||
|
|
||||||
fun test2(a1: Array<in Int>, a2: Array<Int>) {
|
fun test2(a1: Array<in Int>, a2: Array<Int>) {
|
||||||
foo2(a1, a2) checkType { it : _<Any?>}
|
foo2(a1, a2) checkType { _<Any?>() }
|
||||||
}
|
}
|
||||||
@@ -5,5 +5,5 @@ fun <T> foo(l: MutableList<T>): MutableList<T> = l
|
|||||||
fun test(l: MutableList<out Int>) {
|
fun test(l: MutableList<out Int>) {
|
||||||
val a: MutableList<out Int> = foo(l)
|
val a: MutableList<out Int> = foo(l)
|
||||||
val b = foo(l)
|
val b = foo(l)
|
||||||
b checkType { it: _< MutableList<out Int> > }
|
b checkType { _< MutableList<out Int> >() }
|
||||||
}
|
}
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user