Using more specific class.
This commit is contained in:
@@ -1876,11 +1876,11 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> implem
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (funDescriptor instanceof SimpleFunctionDescriptor) {
|
if (funDescriptor instanceof SimpleFunctionDescriptor) {
|
||||||
ClassDescriptor samInterface = bindingContext.get(
|
ClassDescriptorFromJvmBytecode samInterface = bindingContext.get(
|
||||||
JavaBindingContext.SAM_CONSTRUCTOR_TO_INTERFACE, ((SimpleFunctionDescriptor) funDescriptor).getOriginal());
|
JavaBindingContext.SAM_CONSTRUCTOR_TO_INTERFACE, ((SimpleFunctionDescriptor) funDescriptor).getOriginal());
|
||||||
|
|
||||||
if (samInterface != null) {
|
if (samInterface != null) {
|
||||||
return invokeSamConstructor(expression, resolvedCall, (ClassDescriptorFromJvmBytecode) samInterface);
|
return invokeSamConstructor(expression, resolvedCall, samInterface);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-1
@@ -18,6 +18,7 @@ package org.jetbrains.jet.lang.resolve.java;
|
|||||||
|
|
||||||
import org.jetbrains.jet.lang.descriptors.*;
|
import org.jetbrains.jet.lang.descriptors.*;
|
||||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||||
|
import org.jetbrains.jet.lang.resolve.java.descriptor.ClassDescriptorFromJvmBytecode;
|
||||||
import org.jetbrains.jet.util.slicedmap.BasicWritableSlice;
|
import org.jetbrains.jet.util.slicedmap.BasicWritableSlice;
|
||||||
import org.jetbrains.jet.util.slicedmap.Slices;
|
import org.jetbrains.jet.util.slicedmap.Slices;
|
||||||
import org.jetbrains.jet.util.slicedmap.WritableSlice;
|
import org.jetbrains.jet.util.slicedmap.WritableSlice;
|
||||||
@@ -40,7 +41,7 @@ public class JavaBindingContext {
|
|||||||
|
|
||||||
public static final WritableSlice<CallableDescriptor, Boolean> IS_DECLARED_IN_JAVA = Slices.createSimpleSlice();
|
public static final WritableSlice<CallableDescriptor, Boolean> IS_DECLARED_IN_JAVA = Slices.createSimpleSlice();
|
||||||
|
|
||||||
public static final WritableSlice<SimpleFunctionDescriptor, ClassDescriptor> SAM_CONSTRUCTOR_TO_INTERFACE = Slices.createSimpleSlice();
|
public static final WritableSlice<SimpleFunctionDescriptor, ClassDescriptorFromJvmBytecode> SAM_CONSTRUCTOR_TO_INTERFACE = Slices.createSimpleSlice();
|
||||||
public static final WritableSlice<FunctionDescriptor, FunctionDescriptor> SAM_ADAPTER_FUNCTION_TO_ORIGINAL = Slices.createSimpleSlice();
|
public static final WritableSlice<FunctionDescriptor, FunctionDescriptor> SAM_ADAPTER_FUNCTION_TO_ORIGINAL = Slices.createSimpleSlice();
|
||||||
|
|
||||||
private JavaBindingContext() {
|
private JavaBindingContext() {
|
||||||
|
|||||||
+8
-7
@@ -31,6 +31,7 @@ import org.jetbrains.jet.lang.descriptors.impl.NamespaceDescriptorParent;
|
|||||||
import org.jetbrains.jet.lang.descriptors.impl.SimpleFunctionDescriptorImpl;
|
import org.jetbrains.jet.lang.descriptors.impl.SimpleFunctionDescriptorImpl;
|
||||||
import org.jetbrains.jet.lang.resolve.*;
|
import org.jetbrains.jet.lang.resolve.*;
|
||||||
import org.jetbrains.jet.lang.resolve.java.*;
|
import org.jetbrains.jet.lang.resolve.java.*;
|
||||||
|
import org.jetbrains.jet.lang.resolve.java.descriptor.ClassDescriptorFromJvmBytecode;
|
||||||
import org.jetbrains.jet.lang.resolve.java.kotlinSignature.AlternativeMethodSignatureData;
|
import org.jetbrains.jet.lang.resolve.java.kotlinSignature.AlternativeMethodSignatureData;
|
||||||
import org.jetbrains.jet.lang.resolve.java.kotlinSignature.SignaturesPropagationData;
|
import org.jetbrains.jet.lang.resolve.java.kotlinSignature.SignaturesPropagationData;
|
||||||
import org.jetbrains.jet.lang.resolve.java.kt.DescriptorKindUtils;
|
import org.jetbrains.jet.lang.resolve.java.kt.DescriptorKindUtils;
|
||||||
@@ -329,10 +330,10 @@ public final class JavaFunctionResolver {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
private static ClassDescriptor findClassInScope(@NotNull JetScope memberScope, @NotNull Name name) {
|
private static ClassDescriptorFromJvmBytecode findClassInScope(@NotNull JetScope memberScope, @NotNull Name name) {
|
||||||
ClassifierDescriptor classifier = memberScope.getClassifier(name);
|
ClassifierDescriptor classifier = memberScope.getClassifier(name);
|
||||||
if (classifier instanceof ClassDescriptor) {
|
if (classifier instanceof ClassDescriptorFromJvmBytecode) {
|
||||||
return (ClassDescriptor) classifier;
|
return (ClassDescriptorFromJvmBytecode) classifier;
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@@ -344,9 +345,9 @@ public final class JavaFunctionResolver {
|
|||||||
// +-- namespace Bar
|
// +-- namespace Bar
|
||||||
// We need to find class 'Baz' in namespace 'foo.Bar'.
|
// We need to find class 'Baz' in namespace 'foo.Bar'.
|
||||||
@Nullable
|
@Nullable
|
||||||
private static ClassDescriptor findClassInNamespace(@NotNull NamespaceDescriptor namespace, @NotNull Name name) {
|
private static ClassDescriptorFromJvmBytecode findClassInNamespace(@NotNull NamespaceDescriptor namespace, @NotNull Name name) {
|
||||||
// First, try to find in namespace directly
|
// First, try to find in namespace directly
|
||||||
ClassDescriptor found = findClassInScope(namespace.getMemberScope(), name);
|
ClassDescriptorFromJvmBytecode found = findClassInScope(namespace.getMemberScope(), name);
|
||||||
if (found != null) {
|
if (found != null) {
|
||||||
return found;
|
return found;
|
||||||
}
|
}
|
||||||
@@ -373,7 +374,7 @@ public final class JavaFunctionResolver {
|
|||||||
) {
|
) {
|
||||||
PsiClass samInterface = namedMembers.getSamInterface();
|
PsiClass samInterface = namedMembers.getSamInterface();
|
||||||
if (samInterface != null) {
|
if (samInterface != null) {
|
||||||
ClassDescriptor klass = findClassInNamespace(ownerDescriptor, namedMembers.getName());
|
ClassDescriptorFromJvmBytecode klass = findClassInNamespace(ownerDescriptor, namedMembers.getName());
|
||||||
if (klass != null) {
|
if (klass != null) {
|
||||||
return recordSamConstructor(klass, createSamConstructorFunction(ownerDescriptor, klass), trace);
|
return recordSamConstructor(klass, createSamConstructorFunction(ownerDescriptor, klass), trace);
|
||||||
}
|
}
|
||||||
@@ -492,7 +493,7 @@ public final class JavaFunctionResolver {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static SimpleFunctionDescriptor recordSamConstructor(ClassDescriptor klass, SimpleFunctionDescriptor constructorFunction, BindingTrace trace) {
|
private static SimpleFunctionDescriptor recordSamConstructor(ClassDescriptorFromJvmBytecode klass, SimpleFunctionDescriptor constructorFunction, BindingTrace trace) {
|
||||||
trace.record(JavaBindingContext.SAM_CONSTRUCTOR_TO_INTERFACE, constructorFunction, klass);
|
trace.record(JavaBindingContext.SAM_CONSTRUCTOR_TO_INTERFACE, constructorFunction, klass);
|
||||||
trace.record(BindingContext.SOURCE_DESCRIPTOR_FOR_SYNTHESIZED, constructorFunction, klass);
|
trace.record(BindingContext.SOURCE_DESCRIPTOR_FOR_SYNTHESIZED, constructorFunction, klass);
|
||||||
return constructorFunction;
|
return constructorFunction;
|
||||||
|
|||||||
Reference in New Issue
Block a user