From d41e8ed4ada725b74fad2abc913fc1ebe6cb4d74 Mon Sep 17 00:00:00 2001 From: Ilya Gorbunov Date: Thu, 18 Jun 2020 20:11:29 +0300 Subject: [PATCH] Annotate KTypeProjection factory methods with JvmStatic #KT-30084 Fixed --- libraries/stdlib/api/js-v1/kotlin.reflect.kt | 6 ++++++ libraries/stdlib/api/js/kotlin.reflect.kt | 3 +++ libraries/stdlib/src/kotlin/reflect/KType.kt | 7 ++++++- .../reference-public-api/kotlin-stdlib-runtime-merged.txt | 3 +++ 4 files changed, 18 insertions(+), 1 deletion(-) diff --git a/libraries/stdlib/api/js-v1/kotlin.reflect.kt b/libraries/stdlib/api/js-v1/kotlin.reflect.kt index 3375ab2005c..6f1ec4eec04 100644 --- a/libraries/stdlib/api/js-v1/kotlin.reflect.kt +++ b/libraries/stdlib/api/js-v1/kotlin.reflect.kt @@ -141,10 +141,13 @@ public final data class KTypeProjection { public companion object of KTypeProjection { public final val STAR: kotlin.reflect.KTypeProjection { get; } + @kotlin.jvm.JvmStatic public final fun contravariant(type: kotlin.reflect.KType): kotlin.reflect.KTypeProjection + @kotlin.jvm.JvmStatic public final fun covariant(type: kotlin.reflect.KType): kotlin.reflect.KTypeProjection + @kotlin.jvm.JvmStatic public final fun invariant(type: kotlin.reflect.KType): kotlin.reflect.KTypeProjection } } @@ -172,10 +175,13 @@ public final data class KTypeProjection { /*∆*/ public companion object of KTypeProjection { /*∆*/ public final val STAR: kotlin.reflect.KTypeProjection { get; } /*∆*/ +/*∆*/ @kotlin.jvm.JvmStatic /*∆*/ public final fun contravariant(type: kotlin.reflect.KType): kotlin.reflect.KTypeProjection /*∆*/ +/*∆*/ @kotlin.jvm.JvmStatic /*∆*/ public final fun covariant(type: kotlin.reflect.KType): kotlin.reflect.KTypeProjection /*∆*/ +/*∆*/ @kotlin.jvm.JvmStatic /*∆*/ public final fun invariant(type: kotlin.reflect.KType): kotlin.reflect.KTypeProjection /*∆*/ } /*∆*/ } diff --git a/libraries/stdlib/api/js/kotlin.reflect.kt b/libraries/stdlib/api/js/kotlin.reflect.kt index 7394f16eeb5..68d99c9bcc1 100644 --- a/libraries/stdlib/api/js/kotlin.reflect.kt +++ b/libraries/stdlib/api/js/kotlin.reflect.kt @@ -126,10 +126,13 @@ public final data class KTypeProjection { public companion object of KTypeProjection { public final val STAR: kotlin.reflect.KTypeProjection { get; } + @kotlin.jvm.JvmStatic public final fun contravariant(type: kotlin.reflect.KType): kotlin.reflect.KTypeProjection + @kotlin.jvm.JvmStatic public final fun covariant(type: kotlin.reflect.KType): kotlin.reflect.KTypeProjection + @kotlin.jvm.JvmStatic public final fun invariant(type: kotlin.reflect.KType): kotlin.reflect.KTypeProjection } } diff --git a/libraries/stdlib/src/kotlin/reflect/KType.kt b/libraries/stdlib/src/kotlin/reflect/KType.kt index 85e5d0bac10..d941a62fc86 100644 --- a/libraries/stdlib/src/kotlin/reflect/KType.kt +++ b/libraries/stdlib/src/kotlin/reflect/KType.kt @@ -1,10 +1,12 @@ /* - * Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors. + * Copyright 2010-2020 JetBrains s.r.o. and Kotlin Programming Language contributors. * Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file. */ package kotlin.reflect +import kotlin.jvm.JvmStatic + /** * Represents a type. Type is usually either a class with optional type arguments, * or a type parameter of some declaration, plus nullability. @@ -92,6 +94,7 @@ public data class KTypeProjection constructor( * without any use-site variance modifiers applied to it. * For example, in the type `Set`, `String` is an invariant projection of the type represented by the class `String`. */ + @JvmStatic public fun invariant(type: KType): KTypeProjection = KTypeProjection(KVariance.INVARIANT, type) @@ -99,6 +102,7 @@ public data class KTypeProjection constructor( * Creates a contravariant projection of a given type, denoted by the `in` modifier applied to a type. * For example, in the type `MutableList`, `in Number` is a contravariant projection of the type of class `Number`. */ + @JvmStatic public fun contravariant(type: KType): KTypeProjection = KTypeProjection(KVariance.IN, type) @@ -106,6 +110,7 @@ public data class KTypeProjection constructor( * Creates a covariant projection of a given type, denoted by the `out` modifier applied to a type. * For example, in the type `Array`, `out Number` is a covariant projection of the type of class `Number`. */ + @JvmStatic public fun covariant(type: KType): KTypeProjection = KTypeProjection(KVariance.OUT, type) } diff --git a/libraries/tools/binary-compatibility-validator/reference-public-api/kotlin-stdlib-runtime-merged.txt b/libraries/tools/binary-compatibility-validator/reference-public-api/kotlin-stdlib-runtime-merged.txt index f31e5586abb..1ed69390ddb 100644 --- a/libraries/tools/binary-compatibility-validator/reference-public-api/kotlin-stdlib-runtime-merged.txt +++ b/libraries/tools/binary-compatibility-validator/reference-public-api/kotlin-stdlib-runtime-merged.txt @@ -4777,12 +4777,15 @@ public final class kotlin/reflect/KTypeProjection { public fun (Lkotlin/reflect/KVariance;Lkotlin/reflect/KType;)V public final fun component1 ()Lkotlin/reflect/KVariance; public final fun component2 ()Lkotlin/reflect/KType; + public static final fun contravariant (Lkotlin/reflect/KType;)Lkotlin/reflect/KTypeProjection; public final fun copy (Lkotlin/reflect/KVariance;Lkotlin/reflect/KType;)Lkotlin/reflect/KTypeProjection; public static synthetic fun copy$default (Lkotlin/reflect/KTypeProjection;Lkotlin/reflect/KVariance;Lkotlin/reflect/KType;ILjava/lang/Object;)Lkotlin/reflect/KTypeProjection; + public static final fun covariant (Lkotlin/reflect/KType;)Lkotlin/reflect/KTypeProjection; public fun equals (Ljava/lang/Object;)Z public final fun getType ()Lkotlin/reflect/KType; public final fun getVariance ()Lkotlin/reflect/KVariance; public fun hashCode ()I + public static final fun invariant (Lkotlin/reflect/KType;)Lkotlin/reflect/KTypeProjection; public fun toString ()Ljava/lang/String; }