Check for syntax/diagnostic errors in some tests
This commit is contained in:
@@ -6,7 +6,8 @@ public class BadClass {
|
||||
fun foo() {
|
||||
val x: () -> Int = {
|
||||
bar(ArrayList<Int>())
|
||||
baz<Double, ArrayList<ArrayList>>(ArrayList())
|
||||
baz<Double, ArrayList<Double>>(ArrayList())
|
||||
0
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -4,5 +4,5 @@ trait B {
|
||||
fun foo(kotlinName: Int)
|
||||
}
|
||||
|
||||
class ZAB : A, B
|
||||
class ZBA : B, A
|
||||
abstract class ZAB : A, B
|
||||
abstract class ZBA : B, A
|
||||
|
||||
+2
-2
@@ -10,12 +10,12 @@ internal trait B {
|
||||
internal abstract fun foo(/*0*/ kotlinName: kotlin.Int): kotlin.Unit
|
||||
}
|
||||
|
||||
internal final class ZAB : test.A, test.B {
|
||||
internal abstract class ZAB : test.A, test.B {
|
||||
public constructor ZAB()
|
||||
public abstract override /*2*/ /*fake_override*/ fun foo(/*0*/ kotlinName: kotlin.Int): kotlin.Unit
|
||||
}
|
||||
|
||||
internal final class ZBA : test.B, test.A {
|
||||
internal abstract class ZBA : test.B, test.A {
|
||||
public constructor ZBA()
|
||||
public abstract override /*2*/ /*fake_override*/ fun foo(/*0*/ kotlinName: kotlin.Int): kotlin.Unit
|
||||
}
|
||||
|
||||
+2
-2
@@ -1,5 +1,5 @@
|
||||
package test
|
||||
|
||||
class K1 : J() {
|
||||
override fun foo(l: MutableList<String>): String
|
||||
}
|
||||
override fun foo(l: MutableList<String>): String = ""
|
||||
}
|
||||
|
||||
@@ -193,7 +193,7 @@ public abstract class AbstractLoadJavaTest extends TestCaseWithTmpdir {
|
||||
);
|
||||
JetFile jetFile = JetTestUtils.createFile(kotlinSrc.getPath(), FileUtil.loadFile(kotlinSrc, true), environment.getProject());
|
||||
|
||||
AnalyzeExhaust exhaust = JvmResolveUtil.analyzeFilesWithJavaIntegration(
|
||||
AnalyzeExhaust exhaust = JvmResolveUtil.analyzeFilesWithJavaIntegrationAndCheckForErrors(
|
||||
environment.getProject(), Collections.singleton(jetFile), Predicates.<PsiFile>alwaysTrue()
|
||||
);
|
||||
PackageViewDescriptor packageView = exhaust.getModuleDescriptor().getPackage(TEST_PACKAGE_FQNAME);
|
||||
|
||||
+1
-1
@@ -82,7 +82,7 @@ public class CompileKotlinAgainstCustomBinariesTest extends TestCaseWithTmpdir {
|
||||
private PackageViewDescriptor analyzeFileToPackageView(@NotNull File... extraClassPath) throws IOException {
|
||||
Project project = createEnvironment(Arrays.asList(extraClassPath)).getProject();
|
||||
|
||||
AnalyzeExhaust exhaust = JvmResolveUtil.analyzeOneFileWithJavaIntegration(
|
||||
AnalyzeExhaust exhaust = JvmResolveUtil.analyzeOneFileWithJavaIntegrationAndCheckForErrors(
|
||||
JetTestUtils.loadJetFile(project, getTestDataFileWithExtension("kt"))
|
||||
);
|
||||
|
||||
|
||||
@@ -26,7 +26,6 @@ import com.intellij.util.containers.ContainerUtil;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.ConfigurationKind;
|
||||
import org.jetbrains.jet.JetTestUtils;
|
||||
import org.jetbrains.jet.OutputFileCollection;
|
||||
import org.jetbrains.jet.TestJdkKind;
|
||||
import org.jetbrains.jet.analyzer.AnalyzeExhaust;
|
||||
import org.jetbrains.jet.cli.common.output.outputUtils.OutputUtilsPackage;
|
||||
@@ -68,12 +67,13 @@ public final class LoadDescriptorUtil {
|
||||
@NotNull File outDir,
|
||||
@NotNull Disposable disposable,
|
||||
@NotNull ConfigurationKind configurationKind
|
||||
) throws IOException {
|
||||
) {
|
||||
JetFilesAndExhaust fileAndExhaust = JetFilesAndExhaust.createJetFilesAndAnalyze(kotlinFiles, disposable, configurationKind);
|
||||
GenerationState state = GenerationUtils.compileFilesGetGenerationState(fileAndExhaust.getJetFiles().get(0).getProject(), fileAndExhaust.getExhaust(), fileAndExhaust.getJetFiles());
|
||||
OutputFileCollection outputFiles = state.getFactory();
|
||||
OutputUtilsPackage.writeAllTo(outputFiles, outDir);
|
||||
return fileAndExhaust.getExhaust();
|
||||
AnalyzeExhaust exhaust = fileAndExhaust.getExhaust();
|
||||
List<JetFile> files = fileAndExhaust.getJetFiles();
|
||||
GenerationState state = GenerationUtils.compileFilesGetGenerationState(files.get(0).getProject(), exhaust, files);
|
||||
OutputUtilsPackage.writeAllTo(state.getFactory(), outDir);
|
||||
return exhaust;
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@@ -124,23 +124,20 @@ public final class LoadDescriptorUtil {
|
||||
@NotNull File ktFile,
|
||||
@NotNull Disposable disposable,
|
||||
@NotNull ConfigurationKind configurationKind
|
||||
) throws Exception {
|
||||
) {
|
||||
JetFilesAndExhaust fileAndExhaust = JetFilesAndExhaust.createJetFilesAndAnalyze(Collections.singletonList(ktFile), disposable, configurationKind);
|
||||
PackageViewDescriptor packageView =
|
||||
fileAndExhaust.getExhaust().getModuleDescriptor().getPackage(TEST_PACKAGE_FQNAME);
|
||||
PackageViewDescriptor packageView = fileAndExhaust.getExhaust().getModuleDescriptor().getPackage(TEST_PACKAGE_FQNAME);
|
||||
assert packageView != null: TEST_PACKAGE_FQNAME + " package not found in " + ktFile.getName();
|
||||
return packageView;
|
||||
}
|
||||
|
||||
private static class JetFilesAndExhaust {
|
||||
|
||||
@NotNull
|
||||
public static JetFilesAndExhaust createJetFilesAndAnalyze(
|
||||
@NotNull List<File> kotlinFiles,
|
||||
@NotNull Disposable disposable,
|
||||
@NotNull ConfigurationKind configurationKind
|
||||
)
|
||||
throws IOException {
|
||||
) {
|
||||
final JetCoreEnvironment jetCoreEnvironment = createEnvironmentWithMockJdkAndIdeaAnnotations(disposable, configurationKind);
|
||||
List<JetFile> jetFiles = ContainerUtil.map(kotlinFiles, new Function<File, JetFile>() {
|
||||
@Override
|
||||
@@ -154,18 +151,16 @@ public final class LoadDescriptorUtil {
|
||||
}
|
||||
}
|
||||
});
|
||||
AnalyzeExhaust exhaust = JvmResolveUtil.analyzeFilesWithJavaIntegration(
|
||||
AnalyzeExhaust exhaust = JvmResolveUtil.analyzeFilesWithJavaIntegrationAndCheckForErrors(
|
||||
jetCoreEnvironment.getProject(), jetFiles, Predicates.<PsiFile>alwaysTrue());
|
||||
return new JetFilesAndExhaust(jetFiles, exhaust);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
private final List<JetFile> jetFiles;
|
||||
@NotNull
|
||||
private final AnalyzeExhaust exhaust;
|
||||
|
||||
private JetFilesAndExhaust(@NotNull List<JetFile> files, @NotNull AnalyzeExhaust exhaust) {
|
||||
jetFiles = files;
|
||||
private JetFilesAndExhaust(@NotNull List<JetFile> jetFiles, @NotNull AnalyzeExhaust exhaust) {
|
||||
this.jetFiles = jetFiles;
|
||||
this.exhaust = exhaust;
|
||||
}
|
||||
|
||||
|
||||
@@ -25,7 +25,6 @@ import org.jetbrains.jet.analyzer.AnalyzeExhaust;
|
||||
import org.jetbrains.jet.descriptors.serialization.descriptors.MemberFilter;
|
||||
import org.jetbrains.jet.lang.psi.JetFile;
|
||||
import org.jetbrains.jet.lang.resolve.AnalyzingUtils;
|
||||
import org.jetbrains.jet.lang.resolve.BindingTrace;
|
||||
import org.jetbrains.jet.lang.resolve.BindingTraceContext;
|
||||
import org.jetbrains.jet.lang.resolve.java.AnalyzerFacadeForJVM;
|
||||
|
||||
@@ -34,7 +33,7 @@ import java.util.Collections;
|
||||
|
||||
public class JvmResolveUtil {
|
||||
@NotNull
|
||||
public static AnalyzeExhaust analyzeOneFileWithJavaIntegrationAndCheckForErrors(JetFile file) {
|
||||
public static AnalyzeExhaust analyzeOneFileWithJavaIntegrationAndCheckForErrors(@NotNull JetFile file) {
|
||||
AnalyzingUtils.checkForSyntacticErrors(file);
|
||||
|
||||
AnalyzeExhaust analyzeExhaust = analyzeOneFileWithJavaIntegration(file);
|
||||
@@ -45,23 +44,22 @@ public class JvmResolveUtil {
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static AnalyzeExhaust analyzeOneFileWithJavaIntegration(JetFile file) {
|
||||
public static AnalyzeExhaust analyzeOneFileWithJavaIntegration(@NotNull JetFile file) {
|
||||
return analyzeFilesWithJavaIntegration(file.getProject(), Collections.singleton(file),
|
||||
Predicates.<PsiFile>alwaysTrue());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static AnalyzeExhaust analyzeFilesWithJavaIntegrationAndCheckForErrors(
|
||||
Project project,
|
||||
Collection<JetFile> files,
|
||||
Predicate<PsiFile> filesToAnalyzeCompletely
|
||||
@NotNull Project project,
|
||||
@NotNull Collection<JetFile> files,
|
||||
@NotNull Predicate<PsiFile> filesToAnalyzeCompletely
|
||||
) {
|
||||
for (JetFile file : files) {
|
||||
AnalyzingUtils.checkForSyntacticErrors(file);
|
||||
}
|
||||
|
||||
AnalyzeExhaust analyzeExhaust = analyzeFilesWithJavaIntegration(
|
||||
project, files, filesToAnalyzeCompletely);
|
||||
AnalyzeExhaust analyzeExhaust = analyzeFilesWithJavaIntegration(project, files, filesToAnalyzeCompletely);
|
||||
|
||||
AnalyzingUtils.throwExceptionOnErrors(analyzeExhaust.getBindingContext());
|
||||
|
||||
@@ -70,24 +68,13 @@ public class JvmResolveUtil {
|
||||
|
||||
@NotNull
|
||||
public static AnalyzeExhaust analyzeFilesWithJavaIntegration(
|
||||
Project project,
|
||||
Collection<JetFile> files,
|
||||
Predicate<PsiFile> filesToAnalyzeCompletely
|
||||
@NotNull Project project,
|
||||
@NotNull Collection<JetFile> files,
|
||||
@NotNull Predicate<PsiFile> filesToAnalyzeCompletely
|
||||
) {
|
||||
BindingTraceContext bindingTraceContext = new BindingTraceContext();
|
||||
|
||||
return analyzeFilesWithJavaIntegration(project, files, bindingTraceContext, filesToAnalyzeCompletely
|
||||
);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
public static AnalyzeExhaust analyzeFilesWithJavaIntegration(
|
||||
Project project,
|
||||
Collection<JetFile> files,
|
||||
BindingTrace trace,
|
||||
Predicate<PsiFile> filesToAnalyzeCompletely
|
||||
) {
|
||||
return AnalyzerFacadeForJVM.analyzeFilesWithJavaIntegration(project, files, trace, filesToAnalyzeCompletely,
|
||||
return AnalyzerFacadeForJVM.analyzeFilesWithJavaIntegration(project, files, bindingTraceContext, filesToAnalyzeCompletely,
|
||||
AnalyzerFacadeForJVM.createJavaModule("<module>"),
|
||||
MemberFilter.ALWAYS_TRUE);
|
||||
}
|
||||
|
||||
@@ -49,8 +49,8 @@ public abstract class AbstractResolvedCallsTest() : JetLiteFixture() {
|
||||
val explicitReceiverKind = directives.getExplicitReceiverKind()
|
||||
|
||||
fun analyzeFileAndGetResolvedCallEntries(): Map<JetElement, ResolvedCall<*>> {
|
||||
val psiFile = JetTestUtils.loadJetFile(getProject(), file)
|
||||
val analyzeExhaust = JvmResolveUtil.analyzeOneFileWithJavaIntegration(psiFile)
|
||||
val psiFile = JetTestUtils.loadJetFile(getProject(), file)!!
|
||||
val analyzeExhaust = JvmResolveUtil.analyzeOneFileWithJavaIntegrationAndCheckForErrors(psiFile)
|
||||
val bindingContext = analyzeExhaust.getBindingContext()
|
||||
return bindingContext.getSliceContents(BindingContext.RESOLVED_CALL)
|
||||
}
|
||||
|
||||
+2
-3
@@ -33,7 +33,6 @@ import org.jetbrains.jet.resolve.constraintSystem.AbstractConstraintSystemTest.M
|
||||
import org.jetbrains.jet.resolve.constraintSystem.AbstractConstraintSystemTest.MyConstraint
|
||||
import java.util.ArrayList
|
||||
import java.util.LinkedHashMap
|
||||
import kotlin.properties.Delegates
|
||||
import org.jetbrains.jet.lang.resolve.lazy.JvmResolveUtil
|
||||
|
||||
abstract public class AbstractConstraintSystemTest() : JetLiteFixture() {
|
||||
@@ -74,8 +73,8 @@ abstract public class AbstractConstraintSystemTest() : JetLiteFixture() {
|
||||
private fun analyzeDeclarations(): MyDeclarations {
|
||||
val fileName = "declarations/declarations.kt"
|
||||
|
||||
val psiFile = createPsiFile(null, fileName, loadFile(fileName))
|
||||
val analyzeExhaust = JvmResolveUtil.analyzeOneFileWithJavaIntegration(psiFile)
|
||||
val psiFile = createPsiFile(null, fileName, loadFile(fileName))!!
|
||||
val analyzeExhaust = JvmResolveUtil.analyzeOneFileWithJavaIntegrationAndCheckForErrors(psiFile)
|
||||
val bindingContext = analyzeExhaust.getBindingContext()
|
||||
return MyDeclarations(bindingContext, getProject(), typeResolver)
|
||||
}
|
||||
|
||||
@@ -32,7 +32,6 @@ import org.jetbrains.jet.lang.resolve.DescriptorResolver;
|
||||
import org.jetbrains.jet.lang.resolve.TopDownAnalysisParameters;
|
||||
import org.jetbrains.jet.lang.resolve.calls.autocasts.DataFlowInfo;
|
||||
import org.jetbrains.jet.lang.resolve.lazy.JvmResolveUtil;
|
||||
import org.jetbrains.jet.lang.resolve.name.Name;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.JetScope;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.RedeclarationHandler;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.WritableScope;
|
||||
@@ -44,7 +43,7 @@ import org.jetbrains.jet.storage.LockBasedStorageManager;
|
||||
import java.util.List;
|
||||
|
||||
public class JetDefaultModalityModifiersTest extends JetLiteFixture {
|
||||
private JetDefaultModalityModifiersTestCase tc = new JetDefaultModalityModifiersTestCase();
|
||||
private final JetDefaultModalityModifiersTestCase tc = new JetDefaultModalityModifiersTestCase();
|
||||
|
||||
@Override
|
||||
protected JetCoreEnvironment createEnvironment() {
|
||||
@@ -64,7 +63,7 @@ public class JetDefaultModalityModifiersTest extends JetLiteFixture {
|
||||
}
|
||||
|
||||
public class JetDefaultModalityModifiersTestCase {
|
||||
private ModuleDescriptorImpl root = JetTestUtils.createEmptyModule("<test_root>");
|
||||
private final ModuleDescriptorImpl root = JetTestUtils.createEmptyModule("<test_root>");
|
||||
private DescriptorResolver descriptorResolver;
|
||||
private JetScope scope;
|
||||
|
||||
@@ -84,8 +83,7 @@ public class JetDefaultModalityModifiersTest extends JetLiteFixture {
|
||||
List<JetDeclaration> declarations = file.getDeclarations();
|
||||
JetDeclaration aClass = declarations.get(0);
|
||||
assert aClass instanceof JetClass;
|
||||
AnalyzeExhaust bindingContext = JvmResolveUtil.analyzeOneFileWithJavaIntegration(file
|
||||
);
|
||||
AnalyzeExhaust bindingContext = JvmResolveUtil.analyzeOneFileWithJavaIntegrationAndCheckForErrors(file);
|
||||
DeclarationDescriptor classDescriptor = bindingContext.getBindingContext().get(BindingContext.DECLARATION_TO_DESCRIPTOR, aClass);
|
||||
WritableScopeImpl scope = new WritableScopeImpl(
|
||||
libraryScope, root, RedeclarationHandler.DO_NOTHING, "JetDefaultModalityModifiersTest");
|
||||
@@ -96,7 +94,7 @@ public class JetDefaultModalityModifiersTest extends JetLiteFixture {
|
||||
}
|
||||
|
||||
private ClassDescriptorWithResolutionScopes createClassDescriptor(ClassKind kind, JetClass aClass) {
|
||||
MutableClassDescriptor classDescriptor = new MutableClassDescriptor(root, scope, kind, false, Name.identifier(aClass.getName()));
|
||||
MutableClassDescriptor classDescriptor = new MutableClassDescriptor(root, scope, kind, false, aClass.getNameAsSafeName());
|
||||
TopDownAnalysisParameters parameters = TopDownAnalysisParameters.create(
|
||||
LockBasedStorageManager.NO_LOCKS, new ExceptionTracker(), Predicates.<PsiFile>alwaysTrue(), false, false
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user