KT-1293 Kompiler doesn't show error when element of Array<Int?> is assigned to Int
This commit is contained in:
+3
-1
@@ -916,7 +916,9 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
|
||||
|
||||
@Override
|
||||
public JetType visitArrayAccessExpression(JetArrayAccessExpression expression, ExpressionTypingContext context) {
|
||||
return resolveArrayAccessGetMethod(expression, context.replaceExpectedType(NO_EXPECTED_TYPE));
|
||||
JetType type = resolveArrayAccessGetMethod(expression, context.replaceExpectedType(NO_EXPECTED_TYPE));
|
||||
DataFlowUtils.checkType(type, expression, context);
|
||||
return type;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
|
||||
@@ -17,7 +17,6 @@ fun hasDuplicates(a : IntArray) : Boolean {
|
||||
break@loop
|
||||
}
|
||||
}
|
||||
return a[i]
|
||||
}
|
||||
return duplicate
|
||||
}
|
||||
|
||||
@@ -132,10 +132,13 @@ class LI() : BodyTag("li")
|
||||
class P() : BodyTag("p")
|
||||
class H1() : BodyTag("h1")
|
||||
class A() : BodyTag("a") {
|
||||
public var href : String
|
||||
public var href : String?
|
||||
get() = attributes["href"]
|
||||
set(value) {
|
||||
attributes["href"] = value
|
||||
if (value != null) {
|
||||
attributes.put("href", value)
|
||||
// attributes["href"] = value //doesn't work: KT-1355
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
//KT-1293 Kompiler doesn't show error when element of Array<Int?> is assigned to Int
|
||||
|
||||
package kt1293
|
||||
|
||||
fun main(args : Array<String>) {
|
||||
val intArray = Array<Int>(10)
|
||||
val <!UNUSED_VARIABLE!>i<!> : Int = <!TYPE_MISMATCH!>intArray[0]<!>
|
||||
requiresInt(<!TYPE_MISMATCH!>intArray[0]<!>)
|
||||
}
|
||||
|
||||
fun requiresInt(<!UNUSED_PARAMETER!>i<!>: Int) {}
|
||||
Reference in New Issue
Block a user