Use FqNameUnsafe instead of FqName in JVM intrinsics
#KT-4777 Fixed
This commit is contained in:
@@ -24,7 +24,7 @@ import org.jetbrains.jet.lang.descriptors.SimpleFunctionDescriptor;
|
|||||||
import org.jetbrains.jet.lang.resolve.CompileTimeConstantUtils;
|
import org.jetbrains.jet.lang.resolve.CompileTimeConstantUtils;
|
||||||
import org.jetbrains.jet.lang.resolve.DescriptorUtils;
|
import org.jetbrains.jet.lang.resolve.DescriptorUtils;
|
||||||
import org.jetbrains.jet.lang.resolve.java.JvmPrimitiveType;
|
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.resolve.name.Name;
|
||||||
import org.jetbrains.jet.lang.types.expressions.OperatorConventions;
|
import org.jetbrains.jet.lang.types.expressions.OperatorConventions;
|
||||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
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 EnumValueOf ENUM_VALUE_OF = new EnumValueOf();
|
||||||
private static final ToString TO_STRING = new ToString();
|
private static final ToString TO_STRING = new ToString();
|
||||||
|
|
||||||
private static final FqName KOTLIN_ANY_FQ_NAME = DescriptorUtils.getFqNameSafe(KotlinBuiltIns.getInstance().getAny());
|
private static final FqNameUnsafe KOTLIN_ANY_FQ_NAME = DescriptorUtils.getFqName(KotlinBuiltIns.getInstance().getAny());
|
||||||
private static final FqName KOTLIN_STRING_FQ_NAME = DescriptorUtils.getFqNameSafe(KotlinBuiltIns.getInstance().getString());
|
private static final FqNameUnsafe KOTLIN_STRING_FQ_NAME = DescriptorUtils.getFqName(KotlinBuiltIns.getInstance().getString());
|
||||||
|
|
||||||
private final Map<String, IntrinsicMethod> namedMethods = new HashMap<String, IntrinsicMethod>();
|
private final Map<String, IntrinsicMethod> namedMethods = new HashMap<String, IntrinsicMethod>();
|
||||||
private static final IntrinsicMethod ARRAY_ITERATOR = new ArrayIterator();
|
private static final IntrinsicMethod ARRAY_ITERATOR = new ArrayIterator();
|
||||||
|
|||||||
@@ -32,11 +32,11 @@ import java.util.Map;
|
|||||||
class IntrinsicsMap {
|
class IntrinsicsMap {
|
||||||
private static final class Key {
|
private static final class Key {
|
||||||
private final FqNameUnsafe owner;
|
private final FqNameUnsafe owner;
|
||||||
private final FqName receiverParameter;
|
private final FqNameUnsafe receiverParameter;
|
||||||
private final String name;
|
private final String name;
|
||||||
private final int valueParameterCount;
|
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.owner = owner;
|
||||||
this.receiverParameter = receiverParameter;
|
this.receiverParameter = receiverParameter;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
@@ -85,7 +85,7 @@ class IntrinsicsMap {
|
|||||||
*/
|
*/
|
||||||
public void registerIntrinsic(
|
public void registerIntrinsic(
|
||||||
@NotNull FqName owner,
|
@NotNull FqName owner,
|
||||||
@Nullable FqName receiverParameter,
|
@Nullable FqNameUnsafe receiverParameter,
|
||||||
@NotNull String name,
|
@NotNull String name,
|
||||||
int valueParameterCount,
|
int valueParameterCount,
|
||||||
@NotNull IntrinsicMethod impl
|
@NotNull IntrinsicMethod impl
|
||||||
@@ -105,13 +105,13 @@ class IntrinsicsMap {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
private static FqName getReceiverParameterFqName(@NotNull CallableMemberDescriptor descriptor) {
|
private static FqNameUnsafe getReceiverParameterFqName(@NotNull CallableMemberDescriptor descriptor) {
|
||||||
ReceiverParameterDescriptor receiverParameter = descriptor.getReceiverParameter();
|
ReceiverParameterDescriptor receiverParameter = descriptor.getReceiverParameter();
|
||||||
if (receiverParameter == null) return null;
|
if (receiverParameter == null) return null;
|
||||||
|
|
||||||
ClassifierDescriptor classifier = receiverParameter.getType().getConstructor().getDeclarationDescriptor();
|
ClassifierDescriptor classifier = receiverParameter.getType().getConstructor().getDeclarationDescriptor();
|
||||||
if (classifier == null) return null;
|
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");
|
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")
|
@TestMetadata("localFunctionInConstructor.kt")
|
||||||
public void testLocalFunctionInConstructor() throws Exception {
|
public void testLocalFunctionInConstructor() throws Exception {
|
||||||
doTest("compiler/testData/codegen/box/functions/localFunctions/localFunctionInConstructor.kt");
|
doTest("compiler/testData/codegen/box/functions/localFunctions/localFunctionInConstructor.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user