Changed priority for default imports + default imports include all built-ins explicitly for java module
#KT-4374 Fixed
This commit is contained in:
+13
-1
@@ -36,8 +36,9 @@ public class JavaToKotlinClassMap extends JavaToKotlinClassMapBuilder implements
|
||||
|
||||
private final Map<FqName, ClassDescriptor> classDescriptorMap = new HashMap<FqName, ClassDescriptor>();
|
||||
private final Map<FqName, ClassDescriptor> classDescriptorMapForCovariantPositions = new HashMap<FqName, ClassDescriptor>();
|
||||
private final Map<String, JetType> primitiveTypesMap = new HashMap<String, JetType>();
|
||||
private final Map<String, JetType> primitiveTypesMap = new LinkedHashMap<String, JetType>();
|
||||
private final Map<FqName, Collection<ClassDescriptor>> packagesWithMappedClasses = new HashMap<FqName, Collection<ClassDescriptor>>();
|
||||
private final Set<ClassDescriptor> allKotlinClasses = new LinkedHashSet<ClassDescriptor>();
|
||||
|
||||
private JavaToKotlinClassMap() {
|
||||
init();
|
||||
@@ -57,6 +58,10 @@ public class JavaToKotlinClassMap extends JavaToKotlinClassMapBuilder implements
|
||||
primitiveTypesMap.put(wrapperFqName.asString(), builtIns.getNullablePrimitiveJetType(primitiveType));
|
||||
}
|
||||
primitiveTypesMap.put("void", KotlinBuiltIns.getInstance().getUnitType());
|
||||
|
||||
for (JetType type : primitiveTypesMap.values()) {
|
||||
allKotlinClasses.add((ClassDescriptor)type.getConstructor().getDeclarationDescriptor());
|
||||
}
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@@ -119,6 +124,8 @@ public class JavaToKotlinClassMap extends JavaToKotlinClassMapBuilder implements
|
||||
packagesWithMappedClasses.put(packageFqName, classesInPackage);
|
||||
}
|
||||
classesInPackage.add(kotlinDescriptor);
|
||||
|
||||
allKotlinClasses.add(kotlinDescriptor);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -155,4 +162,9 @@ public class JavaToKotlinClassMap extends JavaToKotlinClassMapBuilder implements
|
||||
Collection<ClassDescriptor> result = packagesWithMappedClasses.get(fqName.toSafe());
|
||||
return result == null ? Collections.<ClassDescriptor>emptySet() : Collections.unmodifiableCollection(result);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public Set<ClassDescriptor> allKotlinClasses() {
|
||||
return allKotlinClasses;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -135,8 +135,6 @@ public class KotlinBuiltIns {
|
||||
for (PrimitiveType primitive : PrimitiveType.values()) {
|
||||
makePrimitive(primitive);
|
||||
}
|
||||
|
||||
computeNonPhysicalClasses();
|
||||
}
|
||||
|
||||
private void makePrimitive(@NotNull PrimitiveType primitiveType) {
|
||||
@@ -476,57 +474,6 @@ public class KotlinBuiltIns {
|
||||
return getBuiltInClassByName("MutableListIterator");
|
||||
}
|
||||
|
||||
/**
|
||||
* Classes that only exist for the Kotlin compiler: they are erased at runtime.
|
||||
* As a consequence they, for example, shouldn't be referred to by other languages
|
||||
* (e.g. Java).
|
||||
*/
|
||||
@NotNull
|
||||
public Set<ClassDescriptor> getNonPhysicalClasses() {
|
||||
return Collections.unmodifiableSet(nonPhysicalClasses);
|
||||
}
|
||||
|
||||
private void computeNonPhysicalClasses() {
|
||||
nonPhysicalClasses.addAll(Arrays.asList(
|
||||
getAny(),
|
||||
getNothing(),
|
||||
|
||||
getNumber(),
|
||||
getString(),
|
||||
getCharSequence(),
|
||||
getThrowable(),
|
||||
|
||||
getIterator(),
|
||||
getIterable(),
|
||||
getCollection(),
|
||||
getList(),
|
||||
getListIterator(),
|
||||
getSet(),
|
||||
getMap(),
|
||||
getMapEntry(),
|
||||
|
||||
getMutableIterator(),
|
||||
getMutableIterable(),
|
||||
getMutableCollection(),
|
||||
getMutableList(),
|
||||
getMutableListIterator(),
|
||||
getMutableSet(),
|
||||
getMutableMap(),
|
||||
getMutableMapEntry(),
|
||||
|
||||
getDataClassAnnotation(),
|
||||
getAnnotation(),
|
||||
getComparable(),
|
||||
getEnum(),
|
||||
getArray()
|
||||
));
|
||||
|
||||
for (PrimitiveType primitiveType : values()) {
|
||||
nonPhysicalClasses.add(getPrimitiveClassDescriptor(primitiveType));
|
||||
nonPhysicalClasses.add(getPrimitiveArrayClassDescriptor(primitiveType));
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// GET TYPE
|
||||
|
||||
Reference in New Issue
Block a user