FIR: Do not add alias for variables with explicit type
This commit is contained in:
committed by
TeamCityServer
parent
5317cf3af1
commit
a0a57581ec
@@ -7,7 +7,7 @@ fun foo(arg: Int?) {
|
||||
}
|
||||
val y: Any? = arg
|
||||
if (y != null) {
|
||||
arg.hashCode()
|
||||
arg<!UNSAFE_CALL!>.<!>hashCode()
|
||||
}
|
||||
val yy: Any?
|
||||
yy = arg
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
// SKIP_TXT
|
||||
// FILE: a/A.java
|
||||
package a;
|
||||
public interface A {
|
||||
B b();
|
||||
}
|
||||
|
||||
// FILE: a/B.java
|
||||
package a;
|
||||
public interface B {
|
||||
void bar();
|
||||
}
|
||||
|
||||
// FILE: a/AImpl.java
|
||||
package a;
|
||||
|
||||
public class AImpl implements A {
|
||||
@Override
|
||||
public BImpl b() {
|
||||
return new BImpl();
|
||||
}
|
||||
}
|
||||
|
||||
class BImpl implements B {
|
||||
@Override
|
||||
public void bar() {}
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
import a.A
|
||||
import a.AImpl
|
||||
|
||||
fun test1(a: A) {
|
||||
if (a is AImpl) {
|
||||
(a as A).b().bar() // OK
|
||||
a.b().<!UNRESOLVED_REFERENCE!>bar<!>()
|
||||
}
|
||||
}
|
||||
|
||||
fun test2(aImpl: AImpl) {
|
||||
val a: A = aImpl
|
||||
(a <!USELESS_CAST!>as A<!>).b().bar() // OK
|
||||
a.b().bar() // Works at FE1.0, fails at FIR
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
// SKIP_TXT
|
||||
// FILE: a/A.java
|
||||
package a;
|
||||
public interface A {
|
||||
B b();
|
||||
}
|
||||
|
||||
// FILE: a/B.java
|
||||
package a;
|
||||
public interface B {
|
||||
void bar();
|
||||
}
|
||||
|
||||
// FILE: a/AImpl.java
|
||||
package a;
|
||||
|
||||
public class AImpl implements A {
|
||||
@Override
|
||||
public BImpl b() {
|
||||
return new BImpl();
|
||||
}
|
||||
}
|
||||
|
||||
class BImpl implements B {
|
||||
@Override
|
||||
public void bar() {}
|
||||
}
|
||||
|
||||
// FILE: main.kt
|
||||
import a.A
|
||||
import a.AImpl
|
||||
|
||||
fun test1(a: A) {
|
||||
if (a is AImpl) {
|
||||
(a as A).b().bar() // OK
|
||||
<!INACCESSIBLE_TYPE!><!DEBUG_INFO_SMARTCAST!>a<!>.b()<!>.<!INVISIBLE_MEMBER!>bar<!>()
|
||||
}
|
||||
}
|
||||
|
||||
fun test2(aImpl: AImpl) {
|
||||
val a: A = aImpl
|
||||
(a <!USELESS_CAST!>as A<!>).b().bar() // OK
|
||||
a.b().bar() // Works at FE1.0, fails at FIR
|
||||
}
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@ fun String.next(): String {
|
||||
|
||||
fun list(start: String) {
|
||||
var e: Any? = start
|
||||
if (<!SENSELESS_COMPARISON!>e==null<!>) return
|
||||
if (e==null) return
|
||||
while (e is String) {
|
||||
// Smart cast due to the loop condition
|
||||
if (e.length == 0)
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@ fun foo(arg: Int?) {
|
||||
}
|
||||
val y: Any? = arg
|
||||
if (y != null) {
|
||||
arg.hashCode()
|
||||
arg<!UNSAFE_CALL!>.<!>hashCode()
|
||||
}
|
||||
val yy: Any?
|
||||
yy = arg
|
||||
|
||||
Reference in New Issue
Block a user