java classes should extend java.lang.Object
#KT-1121 fixed
This commit is contained in:
+29
-4
@@ -356,6 +356,15 @@ public class JavaDescriptorResolver {
|
||||
|
||||
|
||||
|
||||
@Nullable
|
||||
private ClassDescriptor resolveJavaLangObject() {
|
||||
ClassDescriptor clazz = resolveClass(JdkNames.JL_OBJECT.getFqName(), DescriptorSearchRule.IGNORE_IF_FOUND_IN_KOTLIN);
|
||||
if (clazz == null) {
|
||||
// TODO: warning
|
||||
}
|
||||
return clazz;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public ClassDescriptor resolveClass(@NotNull FqName qualifiedName, @NotNull DescriptorSearchRule searchRule) {
|
||||
List<Runnable> tasks = Lists.newArrayList();
|
||||
@@ -466,7 +475,7 @@ public class JavaDescriptorResolver {
|
||||
"class " + psiClass.getQualifiedName());
|
||||
|
||||
// TODO: ugly hack: tests crash if initializeTypeParameters called with class containing proper supertypes
|
||||
supertypes.addAll(getSupertypes(new PsiClassWrapper(psiClass), classData.classDescriptor, classData.getTypeParameters()));
|
||||
supertypes.addAll(getSupertypes(new PsiClassWrapper(psiClass), classData, classData.getTypeParameters()));
|
||||
|
||||
PsiMethod[] psiConstructors = psiClass.getConstructors();
|
||||
|
||||
@@ -599,7 +608,7 @@ public class JavaDescriptorResolver {
|
||||
|
||||
classDescriptorCache.put(fqName, classData);
|
||||
|
||||
classData.classDescriptor.setSupertypes(getSupertypes(new PsiClassWrapper(classObjectPsiClass), classData.classDescriptor, new ArrayList<TypeParameterDescriptor>(0)));
|
||||
classData.classDescriptor.setSupertypes(getSupertypes(new PsiClassWrapper(classObjectPsiClass), classData, new ArrayList<TypeParameterDescriptor>(0)));
|
||||
classData.classDescriptor.setName(JetPsiUtil.NO_NAME_PROVIDED); // TODO
|
||||
classData.classDescriptor.setModality(Modality.FINAL);
|
||||
classData.classDescriptor.setVisibility(containing.getVisibility());
|
||||
@@ -862,7 +871,9 @@ public class JavaDescriptorResolver {
|
||||
}
|
||||
}
|
||||
|
||||
private Collection<JetType> getSupertypes(PsiClassWrapper psiClass, ClassDescriptor classDescriptor, List<TypeParameterDescriptor> typeParameters) {
|
||||
private Collection<JetType> getSupertypes(PsiClassWrapper psiClass, ResolverBinaryClassData classData, List<TypeParameterDescriptor> typeParameters) {
|
||||
ClassDescriptor classDescriptor = classData.classDescriptor;
|
||||
|
||||
final List<JetType> result = new ArrayList<JetType>();
|
||||
|
||||
String context = "class " + psiClass.getQualifiedName();
|
||||
@@ -908,7 +919,21 @@ public class JavaDescriptorResolver {
|
||||
}
|
||||
|
||||
if (result.isEmpty()) {
|
||||
result.add(JetStandardClasses.getAnyType());
|
||||
if (classData.kotlin
|
||||
|| psiClass.getQualifiedName().equals(JdkNames.JL_OBJECT.getFqName().getFqName())
|
||||
// TODO: annotations
|
||||
|| classDescriptor.getKind() == ClassKind.ANNOTATION_CLASS) {
|
||||
result.add(JetStandardClasses.getAnyType());
|
||||
}
|
||||
else {
|
||||
ClassDescriptor object = resolveJavaLangObject();
|
||||
if (object != null) {
|
||||
result.add(object.getDefaultType());
|
||||
}
|
||||
else {
|
||||
result.add(JetStandardClasses.getAnyType());
|
||||
}
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
* Copyright 2010-2012 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;
|
||||
|
||||
/**
|
||||
* @author Stepan Koltsov
|
||||
*/
|
||||
public class JdkNames {
|
||||
|
||||
public static final JvmClassName JL_OBJECT = new JvmClassName("java.lang.Object");
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user