Drop package facades: get rid of isPackageClassFqName

This commit is contained in:
Dmitry Petrov
2015-10-16 13:20:30 +03:00
parent 12d5aca9d6
commit dc399ac46b
7 changed files with 10 additions and 35 deletions
@@ -25,7 +25,6 @@ import org.jetbrains.kotlin.descriptors.impl.SimpleFunctionDescriptorImpl;
import org.jetbrains.kotlin.fileClasses.JvmFileClassUtil;
import org.jetbrains.kotlin.incremental.components.NoLookupLocation;
import org.jetbrains.kotlin.load.java.descriptors.JavaClassDescriptor;
import org.jetbrains.kotlin.load.kotlin.PackageClassUtils;
import org.jetbrains.kotlin.load.kotlin.PackagePartClassUtils;
import org.jetbrains.kotlin.name.FqName;
import org.jetbrains.kotlin.name.Name;
@@ -1,3 +1,3 @@
public final class VoidReturnKt {
public static final void foo(@org.jetbrains.annotations.NotNull java.lang.String s) { /* compiled code */ }
public static final void foo(@org.jetbrains.annotations.NotNull java.lang.String g) { /* compiled code */ }
}
@@ -123,10 +123,6 @@ public abstract class AbstractLineNumberTest extends TestCaseWithTmpdir {
ClassFileFactory factory = state.getFactory();
List<Integer> actualLineNumbers = Lists.newArrayList();
for (OutputFile outputFile : ClassFileUtilsKt.getClassFiles(factory)) {
if (PackageClassUtils.isPackageClassFqName(new FqName(FileUtil.getNameWithoutExtension(outputFile.getRelativePath())))) {
// Don't test line numbers in *Package facade classes
continue;
}
ClassReader cr = new ClassReader(outputFile.asByteArray());
try {
List<Integer> lineNumbers = testFunInvoke ? readTestFunLineNumbers(cr) : readAllLineNumbers(cr);
@@ -106,11 +106,6 @@ public object InlineTestUtil {
return null
}
val classFqName = JvmClassName.byInternalName(className).getFqNameForClassNameWithoutDollars()
if (PackageClassUtils.isPackageClassFqName(classFqName)) {
return null
}
return object : MethodNode(Opcodes.ASM5, access, name, desc, signature, exceptions) {
public override fun visitMethodInsn(opcode: Int, owner: String, name: String, desc: String, itf: Boolean) {
val methodCall = MethodInfo(owner, name, desc)
@@ -143,10 +138,10 @@ public object InlineTestUtil {
cr.accept(object : ClassVisitorWithName() {
override fun visitMethod(access: Int, name: String, desc: String, signature: String?, exceptions: Array<String>?): MethodVisitor? {
val classFqName = JvmClassName.byInternalName(className).getFqNameForClassNameWithoutDollars()
JvmClassName.byInternalName(className).getFqNameForClassNameWithoutDollars()
val declaration = MethodInfo(className, name, desc)
//do not check anonymous object creation in inline functions and in package facades
if (PackageClassUtils.isPackageClassFqName(classFqName) || declaration in inlinedMethods) {
if (declaration in inlinedMethods) {
return null
}
@@ -33,20 +33,14 @@ public interface AbstractSMAPBaseTest {
private fun extractSMAPFromClasses(outputFiles: Iterable<OutputFile>): List<SMAPAndFile> {
return outputFiles.map { outputFile ->
if (PackageClassUtils.isPackageClassFqName(FqName(FileUtil.getNameWithoutExtension(outputFile.relativePath).replace('/', '.')))) {
// Don't test line numbers in *Package facade classes
null
}
else {
var debugInfo: String? = null
ClassReader(outputFile.asByteArray()).accept(object : ClassVisitor(Opcodes.ASM5) {
override fun visitSource(source: String?, debug: String?) {
debugInfo = debug
}
}, 0)
var debugInfo: String? = null
ClassReader(outputFile.asByteArray()).accept(object : ClassVisitor(Opcodes.ASM5) {
override fun visitSource(source: String?, debug: String?) {
debugInfo = debug
}
}, 0)
SMAPAndFile.SMAPAndFile(debugInfo, outputFile.sourceFiles.single())
}
SMAPAndFile.SMAPAndFile(debugInfo, outputFile.sourceFiles.single())
}.filterNotNull()
}
@@ -57,8 +57,4 @@ public final class PackageClassUtils {
public static String getPackageClassInternalName(@NotNull FqName packageFQN) {
return JvmClassName.byFqNameWithoutInnerClasses(getPackageClassFqName(packageFQN)).getInternalName();
}
public static boolean isPackageClassFqName(@NotNull FqName fqName) {
return !fqName.isRoot() && getPackageClassFqName(fqName.parent()).equals(fqName);
}
}
@@ -30,11 +30,6 @@ public class KotlinSyntheticTypeComponentProvider: SyntheticTypeComponentProvide
val typeName = typeComponent.declaringType().name()
if (!FqNameUnsafe.isValid(typeName)) return false
if (PackageClassUtils.isPackageClassFqName(FqName(typeName))) {
val lineNumber = typeComponent.location().lineNumber()
return lineNumber == 1
}
return false
}
}