Enable missing checkers for frontend:
* Forbid super-calls with default arguments as in JVM; * Forbid passing incorrect types for reified parameters. Also suppress revealed errors with passing non-reified type to array constructor
This commit is contained in:
committed by
SvyatoslavScherbina
parent
7bebb8d960
commit
8d4bedfef6
+5
-1
@@ -22,6 +22,7 @@ import org.jetbrains.kotlin.container.StorageComponentContainer
|
||||
import org.jetbrains.kotlin.container.useInstance
|
||||
import org.jetbrains.kotlin.platform.PlatformToKotlinClassMap
|
||||
import org.jetbrains.kotlin.resolve.*
|
||||
import org.jetbrains.kotlin.resolve.calls.checkers.ReifiedTypeParameterSubstitutionChecker
|
||||
import org.jetbrains.kotlin.resolve.calls.results.TypeSpecificityComparator
|
||||
import org.jetbrains.kotlin.resolve.checkers.ExpectedActualDeclarationChecker
|
||||
import org.jetbrains.kotlin.resolve.lazy.DelegationFilter
|
||||
@@ -32,7 +33,10 @@ import org.jetbrains.kotlin.types.DynamicTypesSettings
|
||||
object KonanPlatformConfigurator : PlatformConfigurator(
|
||||
DynamicTypesSettings(),
|
||||
additionalDeclarationCheckers = listOf(ExpectedActualDeclarationChecker),
|
||||
additionalCallCheckers = listOf(),
|
||||
additionalCallCheckers = listOf(
|
||||
org.jetbrains.kotlin.resolve.jvm.checkers.SuperCallWithDefaultArgumentsChecker(),
|
||||
ReifiedTypeParameterSubstitutionChecker()
|
||||
),
|
||||
additionalTypeCheckers = listOf(),
|
||||
additionalClassifierUsageCheckers = listOf(),
|
||||
additionalAnnotationCheckers = listOf(),
|
||||
|
||||
@@ -102,7 +102,7 @@ fun <T: Enum<T>> valueOfForEnum(name: String, values: Array<T>) : T
|
||||
|
||||
fun <T: Enum<T>> valuesForEnum(values: Array<T>): Array<T>
|
||||
{
|
||||
val result = Array<T?>(values.size)
|
||||
val result = @Suppress("TYPE_PARAMETER_AS_REIFIED") Array<T?>(values.size)
|
||||
for (value in values)
|
||||
result[value.ordinal] = value
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
|
||||
@@ -23,6 +23,7 @@ import konan.internal.InlineConstructor
|
||||
public final class Array<T> {
|
||||
// Constructors are handled with compiler magic.
|
||||
@InlineConstructor
|
||||
@Suppress("TYPE_PARAMETER_AS_REIFIED")
|
||||
public constructor(size: Int, init: (Int) -> T): this(size) {
|
||||
var index = 0
|
||||
while (index < size) {
|
||||
|
||||
@@ -24,6 +24,7 @@ package kotlin.collections
|
||||
@kotlin.internal.InlineExposed
|
||||
internal fun <E> arrayOfUninitializedElements(size: Int): Array<E> {
|
||||
// TODO: special case for size == 0?
|
||||
@Suppress("TYPE_PARAMETER_AS_REIFIED")
|
||||
return Array<E>(size)
|
||||
}
|
||||
|
||||
@@ -51,7 +52,7 @@ fun <E> Array<E>.copyOfNulls(fromIndex: Int, toIndex: Int): Array<E?> {
|
||||
if (newSize < 0) {
|
||||
throw IllegalArgumentException("$fromIndex > $toIndex")
|
||||
}
|
||||
val result = arrayOfNulls<E>(newSize)
|
||||
val result = @Suppress("TYPE_PARAMETER_AS_REIFIED") arrayOfNulls<E>(newSize)
|
||||
copyRangeTo(result, fromIndex, if (toIndex > size) size else toIndex, 0)
|
||||
return result
|
||||
}
|
||||
|
||||
@@ -282,7 +282,8 @@ public fun <T : Comparable<T>> MutableList<T>.sort(): Unit = sortWith(Comparator
|
||||
public fun <T> MutableList<T>.sortWith(comparator: Comparator<in T>): Unit {
|
||||
if (size > 1) {
|
||||
val it = listIterator()
|
||||
for (v in toTypedArray().apply { sortWith(comparator) }) {
|
||||
val sortedArray = @Suppress("TYPE_PARAMETER_AS_REIFIED") toTypedArray().apply { sortWith(comparator) }
|
||||
for (v in sortedArray) {
|
||||
it.next()
|
||||
it.set(v)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user