Get rid of JavaBindingContext.IS_DECLARED_IN_JAVA
Create specialized Java descriptor classes instead
This commit is contained in:
@@ -30,10 +30,13 @@ import org.jetbrains.jet.codegen.binding.CalculatedClosure;
|
|||||||
import org.jetbrains.jet.codegen.state.GenerationState;
|
import org.jetbrains.jet.codegen.state.GenerationState;
|
||||||
import org.jetbrains.jet.codegen.state.JetTypeMapper;
|
import org.jetbrains.jet.codegen.state.JetTypeMapper;
|
||||||
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.DescriptorUtils;
|
import org.jetbrains.jet.lang.resolve.DescriptorUtils;
|
||||||
import org.jetbrains.jet.lang.resolve.calls.model.ResolvedCall;
|
import org.jetbrains.jet.lang.resolve.calls.model.ResolvedCall;
|
||||||
import org.jetbrains.jet.lang.resolve.java.*;
|
import org.jetbrains.jet.lang.resolve.java.AsmTypeConstants;
|
||||||
|
import org.jetbrains.jet.lang.resolve.java.JavaVisibilities;
|
||||||
|
import org.jetbrains.jet.lang.resolve.java.JvmAbi;
|
||||||
|
import org.jetbrains.jet.lang.resolve.java.JvmPrimitiveType;
|
||||||
|
import org.jetbrains.jet.lang.resolve.java.descriptor.JavaCallableMemberDescriptor;
|
||||||
import org.jetbrains.jet.lang.types.JetType;
|
import org.jetbrains.jet.lang.types.JetType;
|
||||||
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns;
|
||||||
import org.jetbrains.jet.lexer.JetTokens;
|
import org.jetbrains.jet.lexer.JetTokens;
|
||||||
@@ -531,7 +534,7 @@ public class AsmUtil {
|
|||||||
) {
|
) {
|
||||||
if (!state.isGenerateNotNullAssertions()) return;
|
if (!state.isGenerateNotNullAssertions()) return;
|
||||||
|
|
||||||
if (!isDeclaredInJava(descriptor, state.getBindingContext())) return;
|
if (!isDeclaredInJava(descriptor)) return;
|
||||||
|
|
||||||
JetType type = descriptor.getReturnType();
|
JetType type = descriptor.getReturnType();
|
||||||
if (type == null || isNullableType(type)) return;
|
if (type == null || isNullableType(type)) return;
|
||||||
@@ -545,10 +548,10 @@ public class AsmUtil {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean isDeclaredInJava(@NotNull CallableDescriptor callableDescriptor, @NotNull BindingContext context) {
|
private static boolean isDeclaredInJava(@NotNull CallableDescriptor callableDescriptor) {
|
||||||
CallableDescriptor descriptor = callableDescriptor;
|
CallableDescriptor descriptor = callableDescriptor;
|
||||||
while (true) {
|
while (true) {
|
||||||
if (Boolean.TRUE.equals(context.get(JavaBindingContext.IS_DECLARED_IN_JAVA, descriptor))) {
|
if (descriptor instanceof JavaCallableMemberDescriptor) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
CallableDescriptor original = descriptor.getOriginal();
|
CallableDescriptor original = descriptor.getOriginal();
|
||||||
|
|||||||
+4
-3
@@ -16,7 +16,10 @@
|
|||||||
|
|
||||||
package org.jetbrains.jet.lang.resolve.java;
|
package org.jetbrains.jet.lang.resolve.java;
|
||||||
|
|
||||||
import org.jetbrains.jet.lang.descriptors.*;
|
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor;
|
||||||
|
import org.jetbrains.jet.lang.descriptors.FunctionDescriptor;
|
||||||
|
import org.jetbrains.jet.lang.descriptors.NamespaceDescriptor;
|
||||||
|
import org.jetbrains.jet.lang.descriptors.SimpleFunctionDescriptor;
|
||||||
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.lang.resolve.java.descriptor.ClassDescriptorFromJvmBytecode;
|
||||||
import org.jetbrains.jet.util.slicedmap.BasicWritableSlice;
|
import org.jetbrains.jet.util.slicedmap.BasicWritableSlice;
|
||||||
@@ -39,8 +42,6 @@ public class JavaBindingContext {
|
|||||||
public static final WritableSlice<DeclarationDescriptor, List<String>> LOAD_FROM_JAVA_SIGNATURE_ERRORS =
|
public static final WritableSlice<DeclarationDescriptor, List<String>> LOAD_FROM_JAVA_SIGNATURE_ERRORS =
|
||||||
new BasicWritableSlice<DeclarationDescriptor, List<String>>(Slices.ONLY_REWRITE_TO_EQUAL, true);
|
new BasicWritableSlice<DeclarationDescriptor, List<String>>(Slices.ONLY_REWRITE_TO_EQUAL, true);
|
||||||
|
|
||||||
public static final WritableSlice<CallableDescriptor, Boolean> IS_DECLARED_IN_JAVA = Slices.createSimpleSlice();
|
|
||||||
|
|
||||||
public static final WritableSlice<SimpleFunctionDescriptor, ClassDescriptorFromJvmBytecode> 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();
|
||||||
|
|
||||||
|
|||||||
+22
@@ -0,0 +1,22 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2013 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 org.jetbrains.jet.lang.resolve.java.descriptor;
|
||||||
|
|
||||||
|
import org.jetbrains.jet.lang.descriptors.CallableMemberDescriptor;
|
||||||
|
|
||||||
|
public interface JavaCallableMemberDescriptor extends CallableMemberDescriptor {
|
||||||
|
}
|
||||||
+35
@@ -0,0 +1,35 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2013 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 org.jetbrains.jet.lang.resolve.java.descriptor;
|
||||||
|
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor;
|
||||||
|
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
|
||||||
|
import org.jetbrains.jet.lang.descriptors.impl.SimpleFunctionDescriptorImpl;
|
||||||
|
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class JavaMethodDescriptor extends SimpleFunctionDescriptorImpl implements JavaCallableMemberDescriptor {
|
||||||
|
public JavaMethodDescriptor(
|
||||||
|
@NotNull DeclarationDescriptor containingDeclaration,
|
||||||
|
@NotNull List<AnnotationDescriptor> annotations,
|
||||||
|
@NotNull Name name
|
||||||
|
) {
|
||||||
|
super(containingDeclaration, annotations, name, Kind.DECLARATION);
|
||||||
|
}
|
||||||
|
}
|
||||||
+39
@@ -0,0 +1,39 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2013 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 org.jetbrains.jet.lang.resolve.java.descriptor;
|
||||||
|
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor;
|
||||||
|
import org.jetbrains.jet.lang.descriptors.Modality;
|
||||||
|
import org.jetbrains.jet.lang.descriptors.Visibility;
|
||||||
|
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
|
||||||
|
import org.jetbrains.jet.lang.descriptors.impl.PropertyDescriptorImpl;
|
||||||
|
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class JavaPropertyDescriptor extends PropertyDescriptorImpl implements JavaCallableMemberDescriptor {
|
||||||
|
public JavaPropertyDescriptor(
|
||||||
|
@NotNull DeclarationDescriptor containingDeclaration,
|
||||||
|
@NotNull List<AnnotationDescriptor> annotations,
|
||||||
|
@NotNull Visibility visibility,
|
||||||
|
boolean isVar,
|
||||||
|
@NotNull Name name
|
||||||
|
) {
|
||||||
|
super(containingDeclaration, annotations, Modality.FINAL, visibility, isVar, name, Kind.DECLARATION);
|
||||||
|
}
|
||||||
|
}
|
||||||
+39
@@ -0,0 +1,39 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2013 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 org.jetbrains.jet.lang.resolve.java.descriptor;
|
||||||
|
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.jet.lang.descriptors.ClassDescriptor;
|
||||||
|
import org.jetbrains.jet.lang.descriptors.ClassOrNamespaceDescriptor;
|
||||||
|
import org.jetbrains.jet.lang.descriptors.Visibility;
|
||||||
|
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
|
||||||
|
import org.jetbrains.jet.lang.descriptors.impl.PropertyDescriptorForObjectImpl;
|
||||||
|
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class JavaPropertyDescriptorForObject extends PropertyDescriptorForObjectImpl implements JavaCallableMemberDescriptor {
|
||||||
|
public JavaPropertyDescriptorForObject(
|
||||||
|
@NotNull ClassOrNamespaceDescriptor containingDeclaration,
|
||||||
|
@NotNull List<AnnotationDescriptor> annotations,
|
||||||
|
@NotNull Visibility visibility,
|
||||||
|
@NotNull Name name,
|
||||||
|
@NotNull ClassDescriptor objectClass
|
||||||
|
) {
|
||||||
|
super(containingDeclaration, annotations, visibility, name, objectClass);
|
||||||
|
}
|
||||||
|
}
|
||||||
+3
-7
@@ -34,6 +34,7 @@ import org.jetbrains.jet.lang.resolve.java.DescriptorResolverUtils;
|
|||||||
import org.jetbrains.jet.lang.resolve.java.JavaBindingContext;
|
import org.jetbrains.jet.lang.resolve.java.JavaBindingContext;
|
||||||
import org.jetbrains.jet.lang.resolve.java.TypeUsage;
|
import org.jetbrains.jet.lang.resolve.java.TypeUsage;
|
||||||
import org.jetbrains.jet.lang.resolve.java.descriptor.ClassDescriptorFromJvmBytecode;
|
import org.jetbrains.jet.lang.resolve.java.descriptor.ClassDescriptorFromJvmBytecode;
|
||||||
|
import org.jetbrains.jet.lang.resolve.java.descriptor.JavaMethodDescriptor;
|
||||||
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.kotlinSignature.SignaturesUtil;
|
import org.jetbrains.jet.lang.resolve.java.kotlinSignature.SignaturesUtil;
|
||||||
@@ -113,11 +114,10 @@ public final class JavaFunctionResolver {
|
|||||||
return alreadyResolved;
|
return alreadyResolved;
|
||||||
}
|
}
|
||||||
|
|
||||||
SimpleFunctionDescriptorImpl functionDescriptorImpl = new SimpleFunctionDescriptorImpl(
|
SimpleFunctionDescriptorImpl functionDescriptorImpl = new JavaMethodDescriptor(
|
||||||
ownerDescriptor,
|
ownerDescriptor,
|
||||||
annotationResolver.resolveAnnotations(method),
|
annotationResolver.resolveAnnotations(method),
|
||||||
method.getName(),
|
method.getName()
|
||||||
CallableMemberDescriptor.Kind.DECLARATION
|
|
||||||
);
|
);
|
||||||
|
|
||||||
JavaTypeParameterResolver.Initializer typeParameterInitializer = typeParameterResolver.resolveTypeParameters(functionDescriptorImpl, method);
|
JavaTypeParameterResolver.Initializer typeParameterInitializer = typeParameterResolver.resolveTypeParameters(functionDescriptorImpl, method);
|
||||||
@@ -175,10 +175,6 @@ public final class JavaFunctionResolver {
|
|||||||
BindingContextUtils.recordFunctionDeclarationToDescriptor(trace, method.getPsi(), functionDescriptorImpl);
|
BindingContextUtils.recordFunctionDeclarationToDescriptor(trace, method.getPsi(), functionDescriptorImpl);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (record) {
|
|
||||||
trace.record(JavaBindingContext.IS_DECLARED_IN_JAVA, functionDescriptorImpl);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!RawTypesCheck.hasRawTypesInHierarchicalSignature(method)
|
if (!RawTypesCheck.hasRawTypesInHierarchicalSignature(method)
|
||||||
&& JavaMethodSignatureUtil.isMethodReturnTypeCompatible(method)
|
&& JavaMethodSignatureUtil.isMethodReturnTypeCompatible(method)
|
||||||
&& !containsErrorType(superFunctions, functionDescriptorImpl)) {
|
&& !containsErrorType(superFunctions, functionDescriptorImpl)) {
|
||||||
|
|||||||
+5
-17
@@ -23,7 +23,6 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
import org.jetbrains.jet.lang.descriptors.*;
|
import org.jetbrains.jet.lang.descriptors.*;
|
||||||
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
|
import org.jetbrains.jet.lang.descriptors.annotations.AnnotationDescriptor;
|
||||||
import org.jetbrains.jet.lang.descriptors.impl.ClassDescriptorImpl;
|
import org.jetbrains.jet.lang.descriptors.impl.ClassDescriptorImpl;
|
||||||
import org.jetbrains.jet.lang.descriptors.impl.PropertyDescriptorForObjectImpl;
|
|
||||||
import org.jetbrains.jet.lang.descriptors.impl.PropertyDescriptorImpl;
|
import org.jetbrains.jet.lang.descriptors.impl.PropertyDescriptorImpl;
|
||||||
import org.jetbrains.jet.lang.resolve.AnnotationUtils;
|
import org.jetbrains.jet.lang.resolve.AnnotationUtils;
|
||||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||||
@@ -32,6 +31,8 @@ import org.jetbrains.jet.lang.resolve.DescriptorUtils;
|
|||||||
import org.jetbrains.jet.lang.resolve.constants.CompileTimeConstant;
|
import org.jetbrains.jet.lang.resolve.constants.CompileTimeConstant;
|
||||||
import org.jetbrains.jet.lang.resolve.java.DescriptorResolverUtils;
|
import org.jetbrains.jet.lang.resolve.java.DescriptorResolverUtils;
|
||||||
import org.jetbrains.jet.lang.resolve.java.JavaBindingContext;
|
import org.jetbrains.jet.lang.resolve.java.JavaBindingContext;
|
||||||
|
import org.jetbrains.jet.lang.resolve.java.descriptor.JavaPropertyDescriptor;
|
||||||
|
import org.jetbrains.jet.lang.resolve.java.descriptor.JavaPropertyDescriptorForObject;
|
||||||
import org.jetbrains.jet.lang.resolve.java.kotlinSignature.AlternativeFieldSignatureData;
|
import org.jetbrains.jet.lang.resolve.java.kotlinSignature.AlternativeFieldSignatureData;
|
||||||
import org.jetbrains.jet.lang.resolve.java.scope.NamedMembers;
|
import org.jetbrains.jet.lang.resolve.java.scope.NamedMembers;
|
||||||
import org.jetbrains.jet.lang.resolve.java.structure.JavaField;
|
import org.jetbrains.jet.lang.resolve.java.structure.JavaField;
|
||||||
@@ -120,8 +121,6 @@ public final class JavaPropertyResolver {
|
|||||||
|
|
||||||
trace.record(BindingContext.VARIABLE, field.getPsi(), propertyDescriptor);
|
trace.record(BindingContext.VARIABLE, field.getPsi(), propertyDescriptor);
|
||||||
|
|
||||||
trace.record(JavaBindingContext.IS_DECLARED_IN_JAVA, propertyDescriptor);
|
|
||||||
|
|
||||||
if (AnnotationUtils.isPropertyAcceptableAsAnnotationParameter(propertyDescriptor)) {
|
if (AnnotationUtils.isPropertyAcceptableAsAnnotationParameter(propertyDescriptor)) {
|
||||||
PsiExpression initializer = field.getPsi().getInitializer();
|
PsiExpression initializer = field.getPsi().getInitializer();
|
||||||
if (initializer instanceof PsiLiteralExpression) {
|
if (initializer instanceof PsiLiteralExpression) {
|
||||||
@@ -158,21 +157,10 @@ public final class JavaPropertyResolver {
|
|||||||
Collections.<JetType>emptyList(), JetScope.EMPTY,
|
Collections.<JetType>emptyList(), JetScope.EMPTY,
|
||||||
Collections.<ConstructorDescriptor>emptySet(), null,
|
Collections.<ConstructorDescriptor>emptySet(), null,
|
||||||
false);
|
false);
|
||||||
return new PropertyDescriptorForObjectImpl(
|
return new JavaPropertyDescriptorForObject(owner, annotations, visibility, propertyName, dummyClassDescriptorForEnumEntryObject);
|
||||||
owner,
|
|
||||||
annotations,
|
|
||||||
visibility,
|
|
||||||
propertyName,
|
|
||||||
dummyClassDescriptorForEnumEntryObject);
|
|
||||||
}
|
}
|
||||||
return new PropertyDescriptorImpl(
|
|
||||||
owner,
|
return new JavaPropertyDescriptor(owner, annotations, visibility, isVar, propertyName);
|
||||||
annotations,
|
|
||||||
Modality.FINAL,
|
|
||||||
visibility,
|
|
||||||
isVar,
|
|
||||||
propertyName,
|
|
||||||
CallableMemberDescriptor.Kind.DECLARATION);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
|
|||||||
Reference in New Issue
Block a user