Drop unneeded factory methods due to ABI version increase

Either ReflectionFactory or direct creation is now used instead
This commit is contained in:
Alexander Udalov
2014-12-09 01:29:11 +03:00
parent 17c930c84f
commit 245b16dccc
5 changed files with 11 additions and 55 deletions
@@ -1,39 +0,0 @@
/*
* Copyright 2010-2015 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package kotlin.reflect.jvm.internal
import kotlin.reflect.*
// TODO: drop these functions, use ReflectionFactory instead
fun <T> kClass(jClass: Class<T>): KClassImpl<T> =
KClassImpl<T>(jClass, false)
fun kPackage(jClass: Class<*>): KPackageImpl =
KPackageImpl(jClass)
fun topLevelVariable(name: String, owner: KPackageImpl): KTopLevelVariableImpl<Any?> =
KTopLevelVariableImpl<Any?>(name, owner)
fun mutableTopLevelVariable(name: String, owner: KPackageImpl): KMutableTopLevelVariableImpl<Any?> =
KMutableTopLevelVariableImpl<Any?>(name, owner)
fun <T> topLevelExtensionProperty(name: String, owner: KPackageImpl, receiver: Class<T>): KTopLevelExtensionPropertyImpl<T, Any?> =
KTopLevelExtensionPropertyImpl<T, Any?>(name, owner, receiver)
fun <T> mutableTopLevelExtensionProperty(name: String, owner: KPackageImpl, receiver: Class<T>): KMutableTopLevelExtensionPropertyImpl<T, Any?> =
KMutableTopLevelExtensionPropertyImpl<T, Any?>(name, owner, receiver)
@@ -53,13 +53,13 @@ fun <T> foreignKotlinClass(jClass: Class<T>): KClassImpl<T> {
val newArray = arrayOfNulls<WeakReference<KClassImpl<*>>>(size + 1)
// Don't use Arrays.copyOf because it works reflectively
System.arraycopy(cached, 0, newArray, 0, size)
val newKClass = kClass<T>(jClass)
val newKClass = KClassImpl(jClass, false)
newArray[size] = WeakReference(newKClass)
FOREIGN_K_CLASSES = FOREIGN_K_CLASSES.plus(name, newArray)
return newKClass
}
val newKClass = kClass<T>(jClass)
val newKClass = KClassImpl(jClass, false)
FOREIGN_K_CLASSES = FOREIGN_K_CLASSES.plus(name, WeakReference(newKClass))
return newKClass
}
@@ -17,6 +17,7 @@
package kotlin.reflect.jvm
import java.lang.reflect.*
import kotlin.jvm.internal.Reflection
import kotlin.reflect.*
import kotlin.reflect.jvm.internal.*
@@ -58,11 +59,13 @@ public val KMemberProperty<*, *>.javaField: Field?
// Java reflection -> Kotlin reflection
// TODO: getstatic $kotlinClass or go to foreignKClasses
public val <T> Class<T>.kotlin: KClass<T>
get() = kClass(this)
get() = KClassImpl(this, false)
// TODO: getstatic $kotlinPackage
public val Class<*>.kotlinPackage: KPackage
get() = kPackage(this)
get() = KPackageImpl(this)
public val Field.kotlin: KProperty<*>
@@ -73,12 +76,12 @@ public val Field.kotlin: KProperty<*>
val static = Modifier.isStatic(modifiers)
val final = Modifier.isFinal(modifiers)
if (static) {
val kPackage = kPackage(clazz)
return if (final) topLevelVariable(name, kPackage) else mutableTopLevelVariable(name, kPackage)
val kPackage = clazz.kotlinPackage
return if (final) Reflection.topLevelVariable(name, kPackage) else Reflection.mutableTopLevelVariable(name, kPackage)
}
else {
val kClass = kClass(clazz as Class<Any>)
return if (final) kClass.memberProperty(name) else kClass.mutableMemberProperty(name)
val kClass = (clazz as Class<Any>).kotlin
return if (final) Reflection.memberProperty(name, kClass) else Reflection.mutableMemberProperty(name, kClass)
}
}
@@ -16,7 +16,6 @@
package kotlin.jvm.internal;
import kotlin.IntRange;
import kotlin.KotlinNullPointerException;
import java.util.Arrays;
@@ -94,12 +93,6 @@ public class Intrinsics {
return first == null ? second == null : first.equals(second);
}
// This method is not used from generated code anymore but kept for backwards compatibility
@Deprecated
public static IntRange arrayIndices(int length) {
return new IntRange(0, length - 1);
}
private static void throwUndefinedForReified() {
throw new UnsupportedOperationException("You should not use functions with reified parameter without inline");
}
@@ -43,7 +43,6 @@ import org.jetbrains.kotlin.psi.JetTypeReference
import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.serialization.deserialization.AnnotatedCallableKind
import org.jetbrains.kotlin.serialization.ProtoBuf.Callable.CallableKind
import java.util.ArrayList
fun createTopLevelClassStub(classId: ClassId, classProto: ProtoBuf.Class, context: ClsStubBuilderContext): KotlinFileStubImpl {
val fileStub = createFileStub(classId.getPackageFqName())