Fix overload resolution ambiguity for types intersection

There are two different forms of types intestion:
1. Type parameters with multiple bounds
2. Smart casts

The problem was that when member scope of type intersection contained
effective duplicates and that lead to overload resolution ambiguity in
strange cases like `x.hashCode()`

For first type we do effectively the same thing as when building member
scope for class extending several interfaces: group all descriptors by
both-way-overridability relation and then choose most-specific in each
group.

For smart casts we do basically the same thing but with special
treatments:
1. From all descriptors that _equal_ to most specific we choose
   the one that works without smartcast if possible (i.e. we choose first from candidates list)
2. If smart-cast value seems to be unstable we use only member scope
   of receiver type + all descriptors from smart cast possible types
   that has incompatible signature. If we'd include all of them and
   choose one as more specific, and it would lead to false
   SMART_CAST_IMPOSIBLE (see test unstableSmartCast.kt)

 #KT-3996 Fixed
 #KT-10315 Fixed
This commit is contained in:
Denis Zharkov
2015-12-15 12:55:40 +03:00
parent 8d0c3281cd
commit b4bb92d136
75 changed files with 1226 additions and 105 deletions
@@ -42,7 +42,7 @@ import org.jetbrains.kotlin.resolve.scopes.receivers.*
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue.NO_RECEIVER
import org.jetbrains.kotlin.resolve.scopes.utils.getImplicitReceiversHierarchy
import org.jetbrains.kotlin.resolve.scopes.utils.memberScopeAsImportingScope
import org.jetbrains.kotlin.resolve.validation.InfixValidator
import org.jetbrains.kotlin.resolve.selectMostSpecificInEachOverridableGroup
import org.jetbrains.kotlin.storage.StorageManager
import org.jetbrains.kotlin.types.ErrorUtils
import org.jetbrains.kotlin.types.KotlinType
@@ -251,6 +251,11 @@ public class TaskPrioritizer(
c.context.call
)
}
if (explicitReceiver.types.size > 1) {
members.retainAll( members.selectMostSpecificInEachOverridableGroup { descriptor } )
}
members
}
}
@@ -25,7 +25,11 @@ import org.jetbrains.kotlin.resolve.descriptorUtil.hasClassValueDescriptor
import org.jetbrains.kotlin.resolve.scopes.ImportingScope
import org.jetbrains.kotlin.resolve.scopes.LexicalScope
import org.jetbrains.kotlin.resolve.scopes.ResolutionScope
import org.jetbrains.kotlin.resolve.scopes.receivers.*
import org.jetbrains.kotlin.resolve.scopes.receivers.CastImplicitClassReceiver
import org.jetbrains.kotlin.resolve.scopes.receivers.ImplicitClassReceiver
import org.jetbrains.kotlin.resolve.scopes.receivers.QualifierReceiver
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue
import org.jetbrains.kotlin.resolve.selectMostSpecificInEachOverridableGroup
import org.jetbrains.kotlin.types.ErrorUtils
import org.jetbrains.kotlin.types.KotlinType
import org.jetbrains.kotlin.types.isDynamic
@@ -71,7 +75,7 @@ internal class ReceiverScopeTowerLevel(
val dispatchReceiver: ReceiverValue
): AbstractScopeTowerLevel(scopeTower) {
private fun <D: CallableDescriptor> collectMembers(
private fun <D : CallableDescriptor> collectMembers(
getMembers: ResolutionScope.(KotlinType?) -> Collection<D>
): Collection<CandidateWithBoundDispatchReceiver<D>> {
val result = ArrayList<CandidateWithBoundDispatchReceiver<D>>(0)
@@ -81,13 +85,23 @@ internal class ReceiverScopeTowerLevel(
val smartCastPossibleTypes = scopeTower.dataFlowInfo.getSmartCastTypes(dispatchReceiver)
val unstableError = if (scopeTower.dataFlowInfo.isStableReceiver(dispatchReceiver)) null else UnstableSmartCastDiagnostic
val unstableCandidates = if (unstableError != null) ArrayList<CandidateWithBoundDispatchReceiver<D>>(0) else null
for (possibleType in smartCastPossibleTypes) {
possibleType.memberScope.getMembers(possibleType).mapTo(result) {
possibleType.memberScope.getMembers(possibleType).mapTo(unstableCandidates ?: result) {
createCandidateDescriptor(it, dispatchReceiver.smartCastReceiver(possibleType), unstableError, dispatchReceiverSmartCastType = possibleType)
}
}
if (smartCastPossibleTypes.isNotEmpty()) {
if (unstableCandidates == null) {
result.retainAll(result.selectMostSpecificInEachOverridableGroup { descriptor })
}
else {
result.addAll(unstableCandidates.selectMostSpecificInEachOverridableGroup { descriptor })
}
}
if (dispatchReceiver.type.isDynamic()) {
scopeTower.dynamicScope.getMembers(null).mapTo(result) {
createCandidateDescriptor(it, dispatchReceiver, DynamicDescriptorDiagnostic)
@@ -29,6 +29,7 @@ import org.jetbrains.kotlin.resolve.calls.inference.ConstraintSystem;
import org.jetbrains.kotlin.resolve.calls.inference.ConstraintSystemBuilderImpl;
import org.jetbrains.kotlin.resolve.scopes.ChainedScope;
import org.jetbrains.kotlin.resolve.scopes.MemberScope;
import org.jetbrains.kotlin.resolve.scopes.TypeIntersectionScope;
import org.jetbrains.kotlin.types.checker.KotlinTypeChecker;
import java.util.*;
@@ -124,19 +125,12 @@ public class TypeIntersector {
TypeConstructor constructor = new IntersectionTypeConstructor(Annotations.Companion.getEMPTY(), resultingTypes);
MemberScope[] scopes = new MemberScope[resultingTypes.size()];
int i = 0;
for (KotlinType type : resultingTypes) {
scopes[i] = type.getMemberScope();
i++;
}
return KotlinTypeImpl.create(
Annotations.Companion.getEMPTY(),
constructor,
allNullable,
Collections.<TypeProjection>emptyList(),
new ChainedScope("member scope for intersection type " + constructor, scopes)
TypeIntersectionScope.create("member scope for intersection type " + constructor, resultingTypes)
);
}
@@ -0,0 +1,22 @@
interface A {
fun foo(): Any?
fun bar(): String
}
interface B {
fun foo(): String
}
fun <T> bar(x: T): String where T : A, T : B {
if (x.foo().length != 2 || x.foo() != "OK") return "fail 1"
if (x.bar() != "ok") return "fail 2"
return "OK"
}
class C : A, B {
override fun foo() = "OK"
override fun bar() = "ok"
}
fun box(): String = bar(C())
@@ -0,0 +1,27 @@
interface A {
fun foo(): Any?
}
interface B {
fun foo(): String
}
fun bar(x: Any?): String {
if (x is A) {
val k = x.foo()
if (k != "OK") return "fail 1"
}
if (x is B) {
val k = x.foo()
if (k.length != 2) return "fail 2"
}
if (x is A && x is B) {
return x.foo()
}
return "fail 4"
}
fun box(): String = bar(object : A, B { override fun foo() = "OK" })
+3 -3
View File
@@ -10,6 +10,6 @@ open class SuperFoo {
class Foo : SuperFoo()
// 0 INVOKEVIRTUAL SuperFoo.baz
// 1 CHECKCAST Foo
// 1 INVOKEVIRTUAL Foo.baz
// 1 INVOKEVIRTUAL SuperFoo.baz
// 0 CHECKCAST Foo
// 0 INVOKEVIRTUAL Foo.baz
@@ -10,7 +10,7 @@ class C() {
fun test(a : Any?) {
if (a is B) {
if (a is C) {
a.<!OVERLOAD_RESOLUTION_AMBIGUITY!>bar<!>();
<!DEBUG_INFO_SMARTCAST!>a<!>.bar();
}
}
}
@@ -0,0 +1,13 @@
// !CHECK_TYPE
interface A {
fun foo(): CharSequence
}
interface B {
fun foo(): String?
}
fun <T> test(x: T) where T : B, T : A {
x.<!OVERLOAD_RESOLUTION_AMBIGUITY!>foo<!>()
}
@@ -0,0 +1,17 @@
package
public fun </*0*/ T : B> test(/*0*/ x: T): kotlin.Unit where T : A
public interface A {
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public abstract fun foo(): kotlin.CharSequence
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public interface B {
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public abstract fun foo(): kotlin.String?
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
@@ -0,0 +1,19 @@
// !CHECK_TYPE
// FILE: A.java
public interface A {
String foo();
}
// FILE: main.kt
interface B {
fun foo(): String?
}
interface C {
fun foo(): String
}
fun <T> test(x: T) where T : B, T : A, T : C {
x.foo().checkType { _<String>() }
}
@@ -0,0 +1,25 @@
package
public /*synthesized*/ fun A(/*0*/ function: () -> kotlin.String!): A
public fun </*0*/ T : B> test(/*0*/ x: T): kotlin.Unit where T : A, T : C
public interface A {
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public abstract fun foo(): kotlin.String!
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public interface B {
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public abstract fun foo(): kotlin.String?
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public interface C {
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public abstract fun foo(): kotlin.String
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
@@ -0,0 +1,13 @@
// !CHECK_TYPE
interface A {
fun foo(): CharSequence?
}
interface B {
fun foo(): String
}
fun <T> test(x: T) where T : B, T : A {
x.foo().checkType { _<String>() }
}
@@ -0,0 +1,17 @@
package
public fun </*0*/ T : B> test(/*0*/ x: T): kotlin.Unit where T : A
public interface A {
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public abstract fun foo(): kotlin.CharSequence?
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public interface B {
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public abstract fun foo(): kotlin.String
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
@@ -0,0 +1,19 @@
// !CHECK_TYPE
interface A {
val foo: Any?
}
interface C: A {
override val foo: String?
}
interface B: A {
override var foo: String
}
fun <T> test(a: T) where T : B, T : C {
a.foo = ""
a.foo = <!NULL_FOR_NONNULL_TYPE!>null<!>
a.foo.checkType { _<String>() }
}
@@ -0,0 +1,24 @@
package
public fun </*0*/ T : B> test(/*0*/ a: T): kotlin.Unit where T : C
public interface A {
public abstract val foo: kotlin.Any?
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public interface B : A {
public abstract override /*1*/ var foo: kotlin.String
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public interface C : A {
public abstract override /*1*/ val foo: kotlin.String?
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
@@ -0,0 +1,19 @@
// !CHECK_TYPE
interface A {
val foo: Any?
}
interface C: A {
override val foo: String
}
interface B: A {
override var foo: String?
}
fun <T> test(a: T) where T : B, T : C {
a.<!OVERLOAD_RESOLUTION_AMBIGUITY!>foo<!> = ""
a.<!OVERLOAD_RESOLUTION_AMBIGUITY!>foo<!> = null
a.<!OVERLOAD_RESOLUTION_AMBIGUITY!>foo<!>.<!DEBUG_INFO_ELEMENT_WITH_ERROR_TYPE!>checkType<!> { <!UNRESOLVED_REFERENCE!>_<!><String>() }
}
@@ -0,0 +1,24 @@
package
public fun </*0*/ T : B> test(/*0*/ a: T): kotlin.Unit where T : C
public interface A {
public abstract val foo: kotlin.Any?
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public interface B : A {
public abstract override /*1*/ var foo: kotlin.String?
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public interface C : A {
public abstract override /*1*/ val foo: kotlin.String
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
@@ -0,0 +1,13 @@
interface A {
fun foo()
}
interface C: A
interface B: A
fun <T> test(x: T) where T : C?, T : B? {
x?.foo()
if (x != null) {
<!DEBUG_INFO_SMARTCAST!>x<!>.foo()
}
}
@@ -0,0 +1,24 @@
package
public fun </*0*/ T : C?> test(/*0*/ x: T): kotlin.Unit where T : B?
public interface A {
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public abstract fun foo(): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public interface B : A {
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public abstract override /*1*/ /*fake_override*/ fun foo(): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public interface C : A {
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public abstract override /*1*/ /*fake_override*/ fun foo(): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
@@ -0,0 +1,13 @@
// !CHECK_TYPE
interface A {
fun <T, E> foo(): E
}
interface B {
fun <Q, W> foo(): W
}
fun <T> test(x: T) where T : B, T : A {
x.foo<String, Int>().checkType { _<Int>() }
}
@@ -0,0 +1,17 @@
package
public fun </*0*/ T : B> test(/*0*/ x: T): kotlin.Unit where T : A
public interface A {
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public abstract fun </*0*/ T, /*1*/ E> foo(): E
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public interface B {
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public abstract fun </*0*/ Q, /*1*/ W> foo(): W
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
@@ -27,7 +27,7 @@ fun <T : CharSequence?> foo(x: T) {
if (x is String) {
<!DEBUG_INFO_SMARTCAST!>x<!>.length
<!DEBUG_INFO_SMARTCAST!>x<!><!UNNECESSARY_SAFE_CALL!>?.<!>length
x<!UNNECESSARY_SAFE_CALL!>?.<!>length
<!DEBUG_INFO_SMARTCAST!>x<!>.bar1()
x.bar2()
@@ -31,6 +31,6 @@ import p.*
fun test(b: B<String>?) {
if (b is C) {
<!DEBUG_INFO_SMARTCAST!>b<!>?.foo("")
b?.foo("")
}
}
}
@@ -33,6 +33,6 @@ import p.*
fun test(b: B<Tr>?) {
if (b is C) {
<!DEBUG_INFO_SMARTCAST!>b<!>?.foo(null)
b?.foo(null)
}
}
}
@@ -31,6 +31,6 @@ import p.*
fun <Y> test(b: B<Y>?, y: Y) {
if (b is C) {
<!DEBUG_INFO_SMARTCAST!>b<!>?.foo(y)
b?.foo(y)
}
}
}
@@ -31,6 +31,6 @@ import p.*
fun test(b: B<String>?) {
if (b is C) {
<!DEBUG_INFO_SMARTCAST!>b<!>?.foo()
b?.foo()
}
}
}
@@ -31,6 +31,6 @@ import p.*
fun test(b: B?) {
if (b is C) {
b?.<!OVERLOAD_RESOLUTION_AMBIGUITY!>getParent<!>()
<!DEBUG_INFO_SMARTCAST!>b<!>?.getParent()
}
}
}
@@ -31,6 +31,6 @@ import p.*
fun test(b: B?) {
if (b is C) {
<!DEBUG_INFO_SMARTCAST!>b<!>?.foo(1, "")
b?.foo(1, "")
}
}
}
@@ -31,6 +31,6 @@ import p.*
fun B.test() {
if (this is C) {
"".<!DEBUG_INFO_IMPLICIT_RECEIVER_SMARTCAST!>getParent<!>()
"".getParent()
}
}
}
@@ -31,12 +31,12 @@ import p.*
fun test(b: B?) {
if (b is C) {
<!DEBUG_INFO_SMARTCAST!>b<!>?.foo<String>("")
b?.foo<String>("")
}
}
fun test1(b: B?) {
if (b is C) {
<!DEBUG_INFO_SMARTCAST!>b<!>?.foo("")
b?.foo("")
}
}
}
@@ -31,10 +31,10 @@ import p.*
fun test(b: B?) {
if (b !is C) return
<!DEBUG_INFO_SMARTCAST!>b<!>?.foo("")
b?.foo("")
}
fun test1(b: B?) {
if (b !is C) return
<!DEBUG_INFO_SMARTCAST!>b<!>?.foo<String>("")
}
b?.foo<String>("")
}
@@ -35,10 +35,10 @@ import p.*
fun test(b: B?) {
if (b !is C) return
<!DEBUG_INFO_SMARTCAST!>b<!>?.foo("")
b?.foo("")
}
fun test1(b: B?) {
if (b !is C) return
<!DEBUG_INFO_SMARTCAST!>b<!>?.foo<String>("")
b?.foo<String>("")
}
@@ -31,10 +31,10 @@ import p.*
fun test(b: B?) {
if (b !is C) return
<!DEBUG_INFO_SMARTCAST!>b<!>?.foo("")
b?.foo("")
}
fun test1(b: B?) {
if (b !is C) return
<!DEBUG_INFO_SMARTCAST!>b<!>?.foo<String>("")
}
b?.foo<String>("")
}
@@ -30,6 +30,6 @@ import p.*
fun test(b: B?) {
if (b is C) {
<!DEBUG_INFO_SMARTCAST!>b<!>?.foo(1, "")
b?.foo(1, "")
}
}
}
@@ -31,6 +31,6 @@ import p.*
fun test(b: B?) {
if (b is C) {
<!DEBUG_INFO_SMARTCAST!>b<!>?.getParent()
b?.getParent()
}
}
}
@@ -38,6 +38,6 @@ import p.*
fun test(b: B?, a: G1<Int>, b1: G2<B, String>) {
if (b is C) {
<!DEBUG_INFO_SMARTCAST!>b<!>?.foo(a, b1)
b?.foo(a, b1)
}
}
}
@@ -33,6 +33,6 @@ import p.*
fun test(b: B?) {
if (b is C && b is D) {
b<!UNNECESSARY_SAFE_CALL!>?.<!><!OVERLOAD_RESOLUTION_AMBIGUITY!>getParent<!>()
b<!UNNECESSARY_SAFE_CALL!>?.<!>getParent()
}
}
}
@@ -29,6 +29,6 @@ import p.*
fun test(b: B?) {
if (b is C) {
b<!UNNECESSARY_SAFE_CALL!>?.<!><!OVERLOAD_RESOLUTION_AMBIGUITY!>foo<!>("")
b<!UNNECESSARY_SAFE_CALL!>?.<!>foo("")
}
}
}
@@ -12,7 +12,7 @@ class C() {
fun test(a : Any?) {
if (a is B) {
if (a is C) {
a.<!OVERLOAD_RESOLUTION_AMBIGUITY!>bar<!>();
<!DEBUG_INFO_SMARTCAST!>a<!>.bar();
}
}
}
@@ -1,7 +1,7 @@
open class A {
open fun foo() = "FAIL"
fun bar() = if (this is C) <!DEBUG_INFO_IMPLICIT_RECEIVER_SMARTCAST!>foo<!>() else "FAIL"
fun bar() = if (this is C) foo() else "FAIL"
}
open class B : A()
@@ -0,0 +1,13 @@
interface A {
fun <T, E> foo(): E
}
interface B {
fun <Q, W> foo(): Q
}
fun test(c: Any) {
if (c is B && c is A) {
c.<!OVERLOAD_RESOLUTION_AMBIGUITY!>foo<!><String, Int>()
}
}
@@ -0,0 +1,17 @@
package
public fun test(/*0*/ c: kotlin.Any): kotlin.Unit
public interface A {
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public abstract fun </*0*/ T, /*1*/ E> foo(): E
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public interface B {
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public abstract fun </*0*/ Q, /*1*/ W> foo(): Q
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
@@ -0,0 +1,15 @@
// !CHECK_TYPE
interface A {
fun foo(): CharSequence
}
interface B {
fun foo(): String?
}
fun test(c: Any) {
if (c is B && c is A) {
c.<!OVERLOAD_RESOLUTION_AMBIGUITY!>foo<!>()
}
}
@@ -0,0 +1,17 @@
package
public fun test(/*0*/ c: kotlin.Any): kotlin.Unit
public interface A {
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public abstract fun foo(): kotlin.CharSequence
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public interface B {
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public abstract fun foo(): kotlin.String?
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
@@ -0,0 +1,52 @@
// !CHECK_TYPE
// FILE: A.java
public interface A {
String foo();
}
// FILE: main.kt
interface B {
fun foo(): String?
}
interface C {
fun foo(): String
}
fun foo(x: Any?) {
if (x is A && x is B) {
<!DEBUG_INFO_SMARTCAST!>x<!>.foo().checkType { <!TYPE_MISMATCH!>_<!><String>() }
<!DEBUG_INFO_SMARTCAST!>x<!>.foo().checkType { _<String?>() }
}
if (x is B && x is A) {
<!DEBUG_INFO_SMARTCAST!>x<!>.foo().checkType { <!TYPE_MISMATCH!>_<!><String>() }
<!DEBUG_INFO_SMARTCAST!>x<!>.foo().checkType { _<String?>() }
}
if (x is A && x is C) {
<!DEBUG_INFO_SMARTCAST!>x<!>.foo().checkType { _<String>() }
<!DEBUG_INFO_SMARTCAST!>x<!>.foo().checkType { <!TYPE_MISMATCH!>_<!><String?>() }
}
if (x is C && x is A) {
<!DEBUG_INFO_SMARTCAST!>x<!>.foo().checkType { _<String>() }
<!DEBUG_INFO_SMARTCAST!>x<!>.foo().checkType { <!TYPE_MISMATCH!>_<!><String?>() }
}
if (x is A && x is B && x is C) {
<!DEBUG_INFO_SMARTCAST!>x<!>.foo().checkType { _<String>() }
<!DEBUG_INFO_SMARTCAST!>x<!>.foo().checkType { <!TYPE_MISMATCH!>_<!><String?>() }
}
if (x is B && x is A && x is C) {
<!DEBUG_INFO_SMARTCAST!>x<!>.foo().checkType { _<String>() }
<!DEBUG_INFO_SMARTCAST!>x<!>.foo().checkType { <!TYPE_MISMATCH!>_<!><String?>() }
}
if (x is B && x is C && x is A) {
<!DEBUG_INFO_SMARTCAST!>x<!>.foo().checkType { _<String>() }
<!DEBUG_INFO_SMARTCAST!>x<!>.foo().checkType { <!TYPE_MISMATCH!>_<!><String?>() }
}
}
@@ -0,0 +1,25 @@
package
public /*synthesized*/ fun A(/*0*/ function: () -> kotlin.String!): A
public fun foo(/*0*/ x: kotlin.Any?): kotlin.Unit
public interface A {
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public abstract fun foo(): kotlin.String!
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public interface B {
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public abstract fun foo(): kotlin.String?
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public interface C {
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public abstract fun foo(): kotlin.String
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
@@ -0,0 +1,19 @@
// !CHECK_TYPE
interface Common {
fun foo(): CharSequence?
}
interface A : Common {
override fun foo(): CharSequence
}
interface B : Common {
override fun foo(): String
}
fun test(c: Common) {
if (c is B && c is A) {
<!DEBUG_INFO_SMARTCAST!>c<!>.foo().checkType { _<String>() }
}
}
@@ -0,0 +1,24 @@
package
public fun test(/*0*/ c: Common): kotlin.Unit
public interface A : Common {
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public abstract override /*1*/ fun foo(): kotlin.CharSequence
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public interface B : Common {
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public abstract override /*1*/ fun foo(): kotlin.String
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public interface Common {
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public abstract fun foo(): kotlin.CharSequence?
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
@@ -0,0 +1,15 @@
// !CHECK_TYPE
interface A {
fun foo(): CharSequence?
}
interface B {
fun foo(): String
}
fun test(c: Any) {
if (c is B && c is A) {
<!DEBUG_INFO_SMARTCAST!>c<!>.foo().checkType { _<String>() }
}
}
@@ -0,0 +1,17 @@
package
public fun test(/*0*/ c: kotlin.Any): kotlin.Unit
public interface A {
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public abstract fun foo(): kotlin.CharSequence?
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public interface B {
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public abstract fun foo(): kotlin.String
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
@@ -0,0 +1,21 @@
// !CHECK_TYPE
interface A {
val foo: Any?
}
interface C: A {
override val foo: String?
}
interface B: A {
override var foo: String
}
fun test(a: A) {
if (a is B && a is C) {
<!DEBUG_INFO_SMARTCAST!>a<!>.foo = ""
<!DEBUG_INFO_SMARTCAST!>a<!>.foo = <!NULL_FOR_NONNULL_TYPE!>null<!>
<!DEBUG_INFO_SMARTCAST!>a<!>.foo.checkType { _<String>() }
}
}
@@ -0,0 +1,24 @@
package
public fun test(/*0*/ a: A): kotlin.Unit
public interface A {
public abstract val foo: kotlin.Any?
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public interface B : A {
public abstract override /*1*/ var foo: kotlin.String
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public interface C : A {
public abstract override /*1*/ val foo: kotlin.String?
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
@@ -0,0 +1,20 @@
// !CHECK_TYPE
interface A {
val foo: Any?
}
interface C: A {
override val foo: String
}
interface B: A {
override var foo: String?
}
fun test(a: A) {
if (a is B && a is C) {
a.<!OVERLOAD_RESOLUTION_AMBIGUITY!>foo<!> = ""
a.<!OVERLOAD_RESOLUTION_AMBIGUITY!>foo<!> = null
a.<!OVERLOAD_RESOLUTION_AMBIGUITY!>foo<!>
}
}
@@ -0,0 +1,24 @@
package
public fun test(/*0*/ a: A): kotlin.Unit
public interface A {
public abstract val foo: kotlin.Any?
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public interface B : A {
public abstract override /*1*/ var foo: kotlin.String?
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public interface C : A {
public abstract override /*1*/ val foo: kotlin.String
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
@@ -0,0 +1,16 @@
// !CHECK_TYPE
interface A {
fun foo(): CharSequence?
}
interface B : A {
override fun foo(): String
}
fun test(a: A) {
if (a is B) {
<!DEBUG_INFO_SMARTCAST!>a<!>.foo()
<!DEBUG_INFO_SMARTCAST!>a<!>.foo().checkType { _<String>() }
}
}
@@ -0,0 +1,17 @@
package
public fun test(/*0*/ a: A): kotlin.Unit
public interface A {
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public abstract fun foo(): kotlin.CharSequence?
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public interface B : A {
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public abstract override /*1*/ fun foo(): kotlin.String
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
@@ -0,0 +1,12 @@
interface A {
fun foo()
}
interface C: A
interface B: A
fun test(c: C) {
if (c is B) {
c.foo() // OVERLOAD_RESOLUTION_AMBIGUITY: B.foo() and C.foo()
}
}
@@ -0,0 +1,24 @@
package
public fun test(/*0*/ c: C): kotlin.Unit
public interface A {
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public abstract fun foo(): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public interface B : A {
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public abstract override /*1*/ /*fake_override*/ fun foo(): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public interface C : A {
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public abstract override /*1*/ /*fake_override*/ fun foo(): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
@@ -0,0 +1,37 @@
// !CHECK_TYPE
interface A {
fun foo(): CharSequence?
fun baz(x: Any) {}
}
interface B {
fun foo(): String
fun baz(x: Int): String =""
fun baz(x: Int, y: Int) {}
fun foobar(): CharSequence?
}
interface C {
fun foo(): String
fun baz(x: Int): String =""
fun baz(x: Int, y: Int) {}
fun foobar(): String
}
var x: A = null!!
fun test() {
x.foo().checkType { _<CharSequence?>() }
if (x is B && x is C) {
x.foo().checkType { _<CharSequence?>() }
x.baz("")
x.baz(1).checkType { _<Unit>() }
<!SMARTCAST_IMPOSSIBLE!>x<!>.baz(1, 2)
<!SMARTCAST_IMPOSSIBLE!>x<!>.foobar().checkType { _<String>() }
}
}
@@ -0,0 +1,32 @@
package
public var x: A
public fun test(): kotlin.Unit
public interface A {
public open fun baz(/*0*/ x: kotlin.Any): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public abstract fun foo(): kotlin.CharSequence?
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public interface B {
public open fun baz(/*0*/ x: kotlin.Int): kotlin.String
public open fun baz(/*0*/ x: kotlin.Int, /*1*/ y: kotlin.Int): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public abstract fun foo(): kotlin.String
public abstract fun foobar(): kotlin.CharSequence?
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public interface C {
public open fun baz(/*0*/ x: kotlin.Int): kotlin.String
public open fun baz(/*0*/ x: kotlin.Int, /*1*/ y: kotlin.Int): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public abstract fun foo(): kotlin.String
public abstract fun foobar(): kotlin.String
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
@@ -0,0 +1,15 @@
// !CHECK_TYPE
interface A {
fun <T, E> foo(): E
}
interface B {
fun <Q, W> foo(): W
}
fun test(c: Any) {
if (c is B && c is A) {
<!DEBUG_INFO_SMARTCAST!>c<!>.foo<String, Int>().checkType { _<Int>() }
}
}
@@ -0,0 +1,17 @@
package
public fun test(/*0*/ c: kotlin.Any): kotlin.Unit
public interface A {
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public abstract fun </*0*/ T, /*1*/ E> foo(): E
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public interface B {
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public abstract fun </*0*/ Q, /*1*/ W> foo(): W
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
@@ -0,0 +1,15 @@
// !CHECK_TYPE
interface A {
fun <T, E> foo(): E
}
interface B : A {
override fun <Q, W> foo(): W
}
fun test(a: A) {
if (a is B) {
a.foo<String, Int>().checkType { _<Int>() }
}
}
@@ -0,0 +1,17 @@
package
public fun test(/*0*/ a: A): kotlin.Unit
public interface A {
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public abstract fun </*0*/ T, /*1*/ E> foo(): E
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public interface B : A {
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public abstract override /*1*/ fun </*0*/ Q, /*1*/ W> foo(): W
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
+2 -2
View File
@@ -4,5 +4,5 @@ fun test(c : Class<*>) {
val sc = <!UNCHECKED_CAST!>c as Class<String><!>
// No ambiguous overload
c.getAnnotations();
sc.getAnnotations();
}
sc.getAnnotations();
}
@@ -12,7 +12,7 @@ fun foo(): Int {
override fun run() = Unit
}
// Unnecessary but not important smart cast
<!DEBUG_INFO_SMARTCAST!>k<!>.run()
k.run()
return <!DEBUG_INFO_SMARTCAST!>c<!> + d
}
else return -1
@@ -14,10 +14,10 @@ fun foo(): Boolean {
var v: A
v = B()
// No smart cast needed, but not a problem if ever
if (<!DEBUG_INFO_SMARTCAST!>v<!>.ok()) {
if (v.ok()) {
v = C()
}
// No smart cast needed, and no smart cast possible!
// We cannot choose between B and C
return v.ok()
}
}
@@ -6909,6 +6909,57 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest {
}
}
@TestMetadata("compiler/testData/diagnostics/tests/generics/multipleBoundsMemberScope")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class MultipleBoundsMemberScope extends AbstractDiagnosticsTest {
public void testAllFilesPresentInMultipleBoundsMemberScope() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/diagnostics/tests/generics/multipleBoundsMemberScope"), Pattern.compile("^(.+)\\.kt$"), true);
}
@TestMetadata("conflictingReturnType.kt")
public void testConflictingReturnType() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/generics/multipleBoundsMemberScope/conflictingReturnType.kt");
doTest(fileName);
}
@TestMetadata("flexibleTypes.kt")
public void testFlexibleTypes() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/generics/multipleBoundsMemberScope/flexibleTypes.kt");
doTest(fileName);
}
@TestMetadata("mostSpecific.kt")
public void testMostSpecific() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/generics/multipleBoundsMemberScope/mostSpecific.kt");
doTest(fileName);
}
@TestMetadata("properties.kt")
public void testProperties() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/generics/multipleBoundsMemberScope/properties.kt");
doTest(fileName);
}
@TestMetadata("propertiesConflict.kt")
public void testPropertiesConflict() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/generics/multipleBoundsMemberScope/propertiesConflict.kt");
doTest(fileName);
}
@TestMetadata("simple.kt")
public void testSimple() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/generics/multipleBoundsMemberScope/simple.kt");
doTest(fileName);
}
@TestMetadata("validTypeParameters.kt")
public void testValidTypeParameters() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/generics/multipleBoundsMemberScope/validTypeParameters.kt");
doTest(fileName);
}
}
@TestMetadata("compiler/testData/diagnostics/tests/generics/nullability")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
@@ -15474,6 +15525,87 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest {
}
}
@TestMetadata("compiler/testData/diagnostics/tests/smartCasts/intersectionScope")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
public static class IntersectionScope extends AbstractDiagnosticsTest {
public void testAllFilesPresentInIntersectionScope() throws Exception {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/diagnostics/tests/smartCasts/intersectionScope"), Pattern.compile("^(.+)\\.kt$"), true);
}
@TestMetadata("conflictTypeParameters.kt")
public void testConflictTypeParameters() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/smartCasts/intersectionScope/conflictTypeParameters.kt");
doTest(fileName);
}
@TestMetadata("conflictingReturnType.kt")
public void testConflictingReturnType() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/smartCasts/intersectionScope/conflictingReturnType.kt");
doTest(fileName);
}
@TestMetadata("flexibleTypes.kt")
public void testFlexibleTypes() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/smartCasts/intersectionScope/flexibleTypes.kt");
doTest(fileName);
}
@TestMetadata("mostSpecific.kt")
public void testMostSpecific() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/smartCasts/intersectionScope/mostSpecific.kt");
doTest(fileName);
}
@TestMetadata("mostSpecificIrrelevant.kt")
public void testMostSpecificIrrelevant() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/smartCasts/intersectionScope/mostSpecificIrrelevant.kt");
doTest(fileName);
}
@TestMetadata("properties.kt")
public void testProperties() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/smartCasts/intersectionScope/properties.kt");
doTest(fileName);
}
@TestMetadata("propertiesConflict.kt")
public void testPropertiesConflict() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/smartCasts/intersectionScope/propertiesConflict.kt");
doTest(fileName);
}
@TestMetadata("refineReturnType.kt")
public void testRefineReturnType() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/smartCasts/intersectionScope/refineReturnType.kt");
doTest(fileName);
}
@TestMetadata("simple.kt")
public void testSimple() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/smartCasts/intersectionScope/simple.kt");
doTest(fileName);
}
@TestMetadata("unstableSmartCast.kt")
public void testUnstableSmartCast() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/smartCasts/intersectionScope/unstableSmartCast.kt");
doTest(fileName);
}
@TestMetadata("validTypeParameters.kt")
public void testValidTypeParameters() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/smartCasts/intersectionScope/validTypeParameters.kt");
doTest(fileName);
}
@TestMetadata("validTypeParametersNoSmartCast.kt")
public void testValidTypeParametersNoSmartCast() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/smartCasts/intersectionScope/validTypeParametersNoSmartCast.kt");
doTest(fileName);
}
}
@TestMetadata("compiler/testData/diagnostics/tests/smartCasts/loops")
@TestDataPath("$PROJECT_ROOT")
@RunWith(JUnit3RunnerWithInners.class)
@@ -928,6 +928,18 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
doTest(fileName);
}
@TestMetadata("intersectionTypeMultipleBounds.kt")
public void testIntersectionTypeMultipleBounds() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/casts/intersectionTypeMultipleBounds.kt");
doTest(fileName);
}
@TestMetadata("intersectionTypeSmartcast.kt")
public void testIntersectionTypeSmartcast() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/casts/intersectionTypeSmartcast.kt");
doTest(fileName);
}
@TestMetadata("is.kt")
public void testIs() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/codegen/box/casts/is.kt");