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.container.useInstance
|
||||||
import org.jetbrains.kotlin.platform.PlatformToKotlinClassMap
|
import org.jetbrains.kotlin.platform.PlatformToKotlinClassMap
|
||||||
import org.jetbrains.kotlin.resolve.*
|
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.calls.results.TypeSpecificityComparator
|
||||||
import org.jetbrains.kotlin.resolve.checkers.ExpectedActualDeclarationChecker
|
import org.jetbrains.kotlin.resolve.checkers.ExpectedActualDeclarationChecker
|
||||||
import org.jetbrains.kotlin.resolve.lazy.DelegationFilter
|
import org.jetbrains.kotlin.resolve.lazy.DelegationFilter
|
||||||
@@ -32,7 +33,10 @@ import org.jetbrains.kotlin.types.DynamicTypesSettings
|
|||||||
object KonanPlatformConfigurator : PlatformConfigurator(
|
object KonanPlatformConfigurator : PlatformConfigurator(
|
||||||
DynamicTypesSettings(),
|
DynamicTypesSettings(),
|
||||||
additionalDeclarationCheckers = listOf(ExpectedActualDeclarationChecker),
|
additionalDeclarationCheckers = listOf(ExpectedActualDeclarationChecker),
|
||||||
additionalCallCheckers = listOf(),
|
additionalCallCheckers = listOf(
|
||||||
|
org.jetbrains.kotlin.resolve.jvm.checkers.SuperCallWithDefaultArgumentsChecker(),
|
||||||
|
ReifiedTypeParameterSubstitutionChecker()
|
||||||
|
),
|
||||||
additionalTypeCheckers = listOf(),
|
additionalTypeCheckers = listOf(),
|
||||||
additionalClassifierUsageCheckers = listOf(),
|
additionalClassifierUsageCheckers = listOf(),
|
||||||
additionalAnnotationCheckers = 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>
|
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)
|
for (value in values)
|
||||||
result[value.ordinal] = value
|
result[value.ordinal] = value
|
||||||
@Suppress("UNCHECKED_CAST")
|
@Suppress("UNCHECKED_CAST")
|
||||||
|
|||||||
@@ -23,6 +23,7 @@ import konan.internal.InlineConstructor
|
|||||||
public final class Array<T> {
|
public final class Array<T> {
|
||||||
// Constructors are handled with compiler magic.
|
// Constructors are handled with compiler magic.
|
||||||
@InlineConstructor
|
@InlineConstructor
|
||||||
|
@Suppress("TYPE_PARAMETER_AS_REIFIED")
|
||||||
public constructor(size: Int, init: (Int) -> T): this(size) {
|
public constructor(size: Int, init: (Int) -> T): this(size) {
|
||||||
var index = 0
|
var index = 0
|
||||||
while (index < size) {
|
while (index < size) {
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ package kotlin.collections
|
|||||||
@kotlin.internal.InlineExposed
|
@kotlin.internal.InlineExposed
|
||||||
internal fun <E> arrayOfUninitializedElements(size: Int): Array<E> {
|
internal fun <E> arrayOfUninitializedElements(size: Int): Array<E> {
|
||||||
// TODO: special case for size == 0?
|
// TODO: special case for size == 0?
|
||||||
|
@Suppress("TYPE_PARAMETER_AS_REIFIED")
|
||||||
return Array<E>(size)
|
return Array<E>(size)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -51,7 +52,7 @@ fun <E> Array<E>.copyOfNulls(fromIndex: Int, toIndex: Int): Array<E?> {
|
|||||||
if (newSize < 0) {
|
if (newSize < 0) {
|
||||||
throw IllegalArgumentException("$fromIndex > $toIndex")
|
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)
|
copyRangeTo(result, fromIndex, if (toIndex > size) size else toIndex, 0)
|
||||||
return result
|
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 {
|
public fun <T> MutableList<T>.sortWith(comparator: Comparator<in T>): Unit {
|
||||||
if (size > 1) {
|
if (size > 1) {
|
||||||
val it = listIterator()
|
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.next()
|
||||||
it.set(v)
|
it.set(v)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user