KT-702 Type inference failed
This commit is contained in:
@@ -4,7 +4,7 @@ fun <T> Array<out T>.safeGet(index : Int) : T? {
|
||||
return if (index < size) this[index] else null
|
||||
}
|
||||
|
||||
val args : Array<String> = Array<String>(1)
|
||||
val args : Array<String> = Array<String>(1, {""})
|
||||
val name : String = <!TYPE_MISMATCH!>args.safeGet<String>(0)<!> // No error, must be type mismatch
|
||||
val name1 : String? = args.safeGet(0)
|
||||
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
// KT-702 Type inference failed
|
||||
// +JDK
|
||||
fun getJavaClass<T>() : java.lang.Class<T> { return "" <!CAST_NEVER_SUCCEEDS!>as<!> Class<T> }
|
||||
|
||||
public class Throwables() {
|
||||
class object {
|
||||
public fun propagateIfInstanceOf<X : Throwable?>(throwable : Throwable?, declaredType : Class<X?>?) {
|
||||
if (((throwable != null) && declaredType?.isInstance(throwable).sure()))
|
||||
{
|
||||
throw declaredType?.cast(throwable)
|
||||
}
|
||||
}
|
||||
public fun propagateIfPossible(throwable : Throwable?) {
|
||||
propagateIfInstanceOf(throwable, getJavaClass<Error?>) //; Type inference failed: Mismatch while expanding constraints
|
||||
propagateIfInstanceOf(throwable, getJavaClass<RuntimeException?>) // Type inference failed: Mismatch while expanding constraints
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user