Use FqNameUnsafe instead of FqName in JVM intrinsics

#KT-4777 Fixed
This commit is contained in:
Alexander Udalov
2014-03-27 22:46:44 +04:00
parent 94084fb8e1
commit ea4daed0ac
4 changed files with 27 additions and 8 deletions
@@ -24,7 +24,7 @@ import org.jetbrains.jet.lang.descriptors.SimpleFunctionDescriptor;
import org.jetbrains.jet.lang.resolve.CompileTimeConstantUtils;
import org.jetbrains.jet.lang.resolve.DescriptorUtils;
import org.jetbrains.jet.lang.resolve.java.JvmPrimitiveType;
import org.jetbrains.jet.lang.resolve.name.FqName;
import org.jetbrains.jet.lang.resolve.name.FqNameUnsafe;
import org.jetbrains.jet.lang.resolve.name.Name;
import org.jetbrains.jet.lang.types.expressions.OperatorConventions;
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
@@ -59,8 +59,8 @@ public class IntrinsicMethods {
private static final EnumValueOf ENUM_VALUE_OF = new EnumValueOf();
private static final ToString TO_STRING = new ToString();
private static final FqName KOTLIN_ANY_FQ_NAME = DescriptorUtils.getFqNameSafe(KotlinBuiltIns.getInstance().getAny());
private static final FqName KOTLIN_STRING_FQ_NAME = DescriptorUtils.getFqNameSafe(KotlinBuiltIns.getInstance().getString());
private static final FqNameUnsafe KOTLIN_ANY_FQ_NAME = DescriptorUtils.getFqName(KotlinBuiltIns.getInstance().getAny());
private static final FqNameUnsafe KOTLIN_STRING_FQ_NAME = DescriptorUtils.getFqName(KotlinBuiltIns.getInstance().getString());
private final Map<String, IntrinsicMethod> namedMethods = new HashMap<String, IntrinsicMethod>();
private static final IntrinsicMethod ARRAY_ITERATOR = new ArrayIterator();
@@ -32,11 +32,11 @@ import java.util.Map;
class IntrinsicsMap {
private static final class Key {
private final FqNameUnsafe owner;
private final FqName receiverParameter;
private final FqNameUnsafe receiverParameter;
private final String name;
private final int valueParameterCount;
private Key(@NotNull FqNameUnsafe owner, @Nullable FqName receiverParameter, @NotNull String name, int valueParameterCount) {
private Key(@NotNull FqNameUnsafe owner, @Nullable FqNameUnsafe receiverParameter, @NotNull String name, int valueParameterCount) {
this.owner = owner;
this.receiverParameter = receiverParameter;
this.name = name;
@@ -85,7 +85,7 @@ class IntrinsicsMap {
*/
public void registerIntrinsic(
@NotNull FqName owner,
@Nullable FqName receiverParameter,
@Nullable FqNameUnsafe receiverParameter,
@NotNull String name,
int valueParameterCount,
@NotNull IntrinsicMethod impl
@@ -105,13 +105,13 @@ class IntrinsicsMap {
}
@Nullable
private static FqName getReceiverParameterFqName(@NotNull CallableMemberDescriptor descriptor) {
private static FqNameUnsafe getReceiverParameterFqName(@NotNull CallableMemberDescriptor descriptor) {
ReceiverParameterDescriptor receiverParameter = descriptor.getReceiverParameter();
if (receiverParameter == null) return null;
ClassifierDescriptor classifier = receiverParameter.getType().getConstructor().getDeclarationDescriptor();
if (classifier == null) return null;
return DescriptorUtils.getFqNameSafe(classifier);
return DescriptorUtils.getFqName(classifier);
}
}
@@ -0,0 +1,14 @@
var result = "Fail"
val p = object : Runnable {
override fun run() {
fun <T : Any> T.id() = this
result = "OK".id()
}
}
fun box(): String {
p.run()
return result
}
@@ -2961,6 +2961,11 @@ public class BlackBoxCodegenTestGenerated extends AbstractBlackBoxCodegenTest {
doTest("compiler/testData/codegen/box/functions/localFunctions/kt4119_2.kt");
}
@TestMetadata("kt4777.kt")
public void testKt4777() throws Exception {
doTest("compiler/testData/codegen/box/functions/localFunctions/kt4777.kt");
}
@TestMetadata("localFunctionInConstructor.kt")
public void testLocalFunctionInConstructor() throws Exception {
doTest("compiler/testData/codegen/box/functions/localFunctions/localFunctionInConstructor.kt");