merge FullJetPsiCheckerTest into QuickJetPsiCheckerTest
This commit is contained in:
@@ -1,4 +0,0 @@
|
||||
import java.util.Collections
|
||||
import java.util.List
|
||||
|
||||
val ab = Collections.emptyList<Int>() : List<Int>?
|
||||
+3
-1
@@ -1,3 +1,5 @@
|
||||
// +JDK
|
||||
|
||||
namespace abstract
|
||||
|
||||
class MyClass() {
|
||||
@@ -238,4 +240,4 @@ abstract class B3(i: Int) {
|
||||
fun foo(a: B3) {
|
||||
val <!UNUSED_VARIABLE!>a<!> = <!CREATING_AN_INSTANCE_OF_ABSTRACT_CLASS!>B3()<!>
|
||||
val <!UNUSED_VARIABLE!>b<!> = <!CREATING_AN_INSTANCE_OF_ABSTRACT_CLASS!>B1(2, "s")<!>
|
||||
}
|
||||
}
|
||||
@@ -88,4 +88,4 @@ open class C {
|
||||
t = <!UNUSED_VALUE!>this@C<!>
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
@@ -1,3 +1,5 @@
|
||||
// +JDK
|
||||
|
||||
import java.util.*
|
||||
|
||||
namespace html {
|
||||
+3
-1
@@ -1,3 +1,5 @@
|
||||
// +JDK
|
||||
|
||||
namespace Jet86
|
||||
|
||||
class A {
|
||||
@@ -27,4 +29,4 @@ val s = <!NO_CLASS_OBJECT!>System<!> // error
|
||||
fun test() {
|
||||
System.out?.println()
|
||||
java.lang.System.out?.println()
|
||||
}
|
||||
}
|
||||
+2
@@ -1,3 +1,5 @@
|
||||
// +JDK
|
||||
|
||||
trait A {
|
||||
fun foo() : Int = 1
|
||||
fun foo2() : Int = 1
|
||||
+3
-1
@@ -1,3 +1,5 @@
|
||||
// +JDK
|
||||
|
||||
fun Int?.optint() : Unit {}
|
||||
val Int?.optval : Unit = ()
|
||||
|
||||
@@ -68,4 +70,4 @@ namespace null_safety {
|
||||
if (command == null) 1
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
+2
@@ -1,3 +1,5 @@
|
||||
// +JDK
|
||||
|
||||
import java.util.*;
|
||||
|
||||
class NotRange1() {
|
||||
+3
-1
@@ -1,3 +1,5 @@
|
||||
// +JDK
|
||||
|
||||
fun none() {}
|
||||
|
||||
fun unitEmptyInfer() {}
|
||||
@@ -209,4 +211,4 @@ fun testFunctionLiterals() {
|
||||
object A {}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
+2
@@ -1,3 +1,5 @@
|
||||
// +JDK
|
||||
|
||||
namespace foo
|
||||
|
||||
class X {}
|
||||
+3
-1
@@ -1,3 +1,5 @@
|
||||
// +JDK
|
||||
|
||||
namespace foobar
|
||||
|
||||
namespace a {
|
||||
@@ -60,4 +62,4 @@ abstract class Collection<E> : Iterable<E> {
|
||||
}
|
||||
return iteratee.done()
|
||||
}
|
||||
}
|
||||
}
|
||||
+3
-1
@@ -1,3 +1,5 @@
|
||||
// +JDK
|
||||
|
||||
fun test() {
|
||||
val a : Int? = 0
|
||||
if (a != null) {
|
||||
@@ -277,4 +279,4 @@ fun f9(a : Int?) : Int {
|
||||
if (a != null)
|
||||
return a
|
||||
return 1
|
||||
}
|
||||
}
|
||||
+3
-1
@@ -1,3 +1,5 @@
|
||||
// +JDK
|
||||
|
||||
// Fixpoint generic in Java: Enum<T extends Enum<T>>
|
||||
fun test(a : annotation.RetentionPolicy) {
|
||||
|
||||
@@ -17,4 +19,4 @@ fun test(a : java.util.ArrayList<Int>) {
|
||||
|
||||
fun test(a : java.lang.Class<Int>) {
|
||||
|
||||
}
|
||||
}
|
||||
+3
-1
@@ -1,3 +1,5 @@
|
||||
// +JDK
|
||||
|
||||
import java.*
|
||||
import util.*
|
||||
import <!UNRESOLVED_REFERENCE!>utils<!>.*
|
||||
@@ -49,4 +51,4 @@ fun test(l : java.util.List<Int>) {
|
||||
|
||||
namespace xxx {
|
||||
import java.lang.Class;
|
||||
}
|
||||
}
|
||||
+2
@@ -1,3 +1,5 @@
|
||||
// +JDK
|
||||
|
||||
fun t1() : Int{
|
||||
return 0
|
||||
<!UNREACHABLE_CODE!>1<!>
|
||||
+2
@@ -1,3 +1,5 @@
|
||||
// +JDK
|
||||
|
||||
class Foo1() : java.util.ArrayList<Int>()
|
||||
|
||||
open class Bar() {
|
||||
+2
-1
@@ -1,4 +1,5 @@
|
||||
// KT-389 Wrong type inference for varargs etc.
|
||||
// +JDK
|
||||
|
||||
import java.util.*
|
||||
|
||||
@@ -23,4 +24,4 @@ fun test() {
|
||||
fool(1, 2, 3)
|
||||
food(1.0, 2.0, 3.0)
|
||||
foof(1.0.flt, 2.0.flt, 3.0.flt)
|
||||
}
|
||||
}
|
||||
+2
@@ -1,3 +1,5 @@
|
||||
// +JDK
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Collection;
|
||||
|
||||
+2
@@ -1,3 +1,5 @@
|
||||
// +JDK
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Collection;
|
||||
|
||||
+2
@@ -1,3 +1,5 @@
|
||||
// +JDK
|
||||
|
||||
import java.util.List;
|
||||
|
||||
fun ff(l: Any) = l as List<*>
|
||||
+2
@@ -1,3 +1,5 @@
|
||||
// +JDK
|
||||
|
||||
import java.util.List;
|
||||
|
||||
fun ff(a: Any) = <!UNCHECKED_CAST!>a as List<String><!>
|
||||
+2
@@ -1,3 +1,5 @@
|
||||
// +JDK
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
+2
@@ -1,3 +1,5 @@
|
||||
// +JDK
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
+2
@@ -1,3 +1,5 @@
|
||||
// +JDK
|
||||
|
||||
import java.util.List;
|
||||
|
||||
fun ff(l: Any) = l is <!CANNOT_CHECK_FOR_ERASED!>List<String><!>
|
||||
+2
@@ -1,3 +1,5 @@
|
||||
// +JDK
|
||||
|
||||
import java.util.List;
|
||||
|
||||
fun ff(l: Any) = l is List<*>
|
||||
+2
@@ -1,3 +1,5 @@
|
||||
// +JDK
|
||||
|
||||
import java.util.List;
|
||||
|
||||
fun ff(l: Any) = when(l) {
|
||||
+2
-1
@@ -1,8 +1,9 @@
|
||||
//KT-600 Problem with 'sure' extension function type inference
|
||||
// +JDK
|
||||
|
||||
fun <T : Any> T?.sure() : T { if (this != null) return this else throw NullPointerException() }
|
||||
|
||||
fun test() {
|
||||
val i : Int? = 10
|
||||
val <!UNUSED_VARIABLE!>i2<!> : Int = i.sure() // inferred type is Int? but Int was excepted
|
||||
}
|
||||
}
|
||||
+3
-1
@@ -1,3 +1,5 @@
|
||||
// +JDK
|
||||
|
||||
import java.*
|
||||
import util.*
|
||||
|
||||
@@ -63,4 +65,4 @@ fun main(args: Array<String>) {
|
||||
catch(e: Throwable) {
|
||||
System.out?.println(e.getMessage())
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
// +JDK
|
||||
|
||||
import java.util.Collections
|
||||
import java.util.List
|
||||
|
||||
val ab = Collections.emptyList<Int>() : List<Int>?
|
||||
+1
@@ -1,4 +1,5 @@
|
||||
// JET-72 Type inference doesn't work when iterating over ArrayList
|
||||
// +JDK
|
||||
|
||||
import java.util.ArrayList
|
||||
|
||||
+1
@@ -1,4 +1,5 @@
|
||||
// KT-258 Support equality constraints in type inference
|
||||
// +JDK
|
||||
|
||||
import java.util.*
|
||||
|
||||
+2
@@ -1,4 +1,6 @@
|
||||
// KT-287 Infer constructor type arguments
|
||||
// +JDK
|
||||
|
||||
import java.util.*
|
||||
|
||||
fun attributes() : Map<String, String> = HashMap() // Should be inferred;
|
||||
+1
@@ -1,4 +1,5 @@
|
||||
// KT-313 Bug in substitutions in a function returning its type parameter T
|
||||
// +JDK
|
||||
|
||||
fun <T> Iterable<T>.join(separator : String?) : String {
|
||||
return separator.npe()
|
||||
+1
@@ -1,5 +1,6 @@
|
||||
// KT-336 Can't infer type parameter for ArrayList in a generic function (Exception in type inference)
|
||||
// KT-335 Type inference fails on Collections.sort
|
||||
// +JDK
|
||||
|
||||
import java.util.*
|
||||
import java.lang.Comparable as Comparable
|
||||
+2
-1
@@ -1,6 +1,7 @@
|
||||
// KT-385 type inference does not work properly`
|
||||
// KT-109 Good code is red: type arguments are not inferred
|
||||
// KT-441 Exception in type inference when multiple overloads accepting an integer literal are accessible
|
||||
// +JDK
|
||||
|
||||
import java.util.*
|
||||
|
||||
@@ -31,4 +32,4 @@ inline fun run<T>(body : fun() : T) : T = body()
|
||||
fun main(args : Array<String>) {
|
||||
|
||||
println(run { 1 })
|
||||
}
|
||||
}
|
||||
+2
-1
@@ -1,8 +1,9 @@
|
||||
// KT-459 Type argument inference fails when class names are fully qualified
|
||||
// +JDK
|
||||
|
||||
fun test() {
|
||||
val attributes : java.util.HashMap<String, String> = java.util.HashMap() // failure!
|
||||
attributes["href"] = "1" // inference fails, but it shouldn't
|
||||
}
|
||||
|
||||
fun <K, V> java.util.Map<K, V>.set(key : K, value : V) {}//= this.put(key, value)
|
||||
fun <K, V> java.util.Map<K, V>.set(key : K, value : V) {}//= this.put(key, value)
|
||||
+2
@@ -1,3 +1,5 @@
|
||||
// +JDK
|
||||
|
||||
namespace kt469
|
||||
|
||||
//KT-512 plusAssign() : Unit does not work properly
|
||||
+2
@@ -1,4 +1,6 @@
|
||||
//KT-549 type inference failed
|
||||
// +JDK
|
||||
|
||||
namespace demo
|
||||
|
||||
fun filter<T>(list : Array<T>, filter : fun (T) : Boolean) : java.util.List<T> {
|
||||
+2
-1
@@ -1,4 +1,5 @@
|
||||
//KT-58 Allow finally around definite returns
|
||||
// +JDK
|
||||
|
||||
namespace kt58
|
||||
|
||||
@@ -88,4 +89,4 @@ fun t7() : Int {
|
||||
}
|
||||
|
||||
fun doSmth(i: Int) {
|
||||
}
|
||||
}
|
||||
+3
-1
@@ -1,4 +1,6 @@
|
||||
//KT-580 Type inference failed
|
||||
// +JDK
|
||||
|
||||
namespace whats.the.difference
|
||||
|
||||
import java.util.*
|
||||
@@ -17,4 +19,4 @@ fun main(vals : IntArray) {
|
||||
}
|
||||
|
||||
fun <T> Array<T>.lastIndex() = size - 1
|
||||
val <T> Array<T>.lastIndex : Int get() = size - 1
|
||||
val <T> Array<T>.lastIndex : Int get() = size - 1
|
||||
+3
-1
@@ -1,4 +1,6 @@
|
||||
// KT-588 Unresolved static method
|
||||
// +JDK
|
||||
|
||||
class Test() : Thread("Test") {
|
||||
class object {
|
||||
fun init2() {
|
||||
@@ -9,4 +11,4 @@ class Test() : Thread("Test") {
|
||||
init2() // unresolved
|
||||
Test.init2() // ok
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,5 @@
|
||||
//KT-235 Illegal assignment return type
|
||||
// +JDK
|
||||
|
||||
namespace kt235
|
||||
|
||||
@@ -46,4 +47,4 @@ class MyArray1() {
|
||||
|
||||
class MyNumber() {
|
||||
fun inc(): MyNumber = MyNumber()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,119 +0,0 @@
|
||||
package org.jetbrains.jet.checkers;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import junit.framework.Test;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.JetLiteFixture;
|
||||
import org.jetbrains.jet.JetTestCaseBuilder;
|
||||
import org.jetbrains.jet.lang.diagnostics.DiagnosticUtils;
|
||||
import org.jetbrains.jet.lang.resolve.AnalyzingUtils;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||
import org.jetbrains.jet.lang.resolve.ImportingStrategy;
|
||||
import org.jetbrains.jet.lang.resolve.java.AnalyzerFacade;
|
||||
import org.jetbrains.jet.lang.resolve.java.JavaDefaultImports;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author abreslav
|
||||
*/
|
||||
public class FullJetPsiCheckerTest extends JetLiteFixture {
|
||||
private final String myDataPath;
|
||||
private String myName;
|
||||
|
||||
public FullJetPsiCheckerTest(@NonNls String dataPath, String name) {
|
||||
myDataPath = dataPath;
|
||||
myName = name;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "test" + myName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void runTest() throws Exception {
|
||||
String fileName = myName + ".jet";
|
||||
String fullPath = myDataPath + "/" + fileName;
|
||||
|
||||
|
||||
String expectedText = loadFile(fullPath);
|
||||
|
||||
List<CheckerTestUtil.DiagnosedRange> diagnosedRanges = Lists.newArrayList();
|
||||
String clearText = CheckerTestUtil.parseDiagnosedRanges(expectedText, diagnosedRanges);
|
||||
|
||||
myFile = createPsiFile(myName, clearText);
|
||||
|
||||
boolean importJdk = !expectedText.contains("-JDK");
|
||||
ImportingStrategy importingStrategy = importJdk ? JavaDefaultImports.JAVA_DEFAULT_IMPORTS : ImportingStrategy.NONE;
|
||||
|
||||
BindingContext bindingContext = AnalyzerFacade.analyzeFileWithCache(AnalyzingUtils.getInstance(importingStrategy), myFile, AnalyzerFacade.SINGLE_DECLARATION_PROVIDER);
|
||||
|
||||
CheckerTestUtil.diagnosticsDiff(diagnosedRanges, bindingContext.getDiagnostics(), new CheckerTestUtil.DiagnosticDiffCallbacks() {
|
||||
@Override
|
||||
public void missingDiagnostic(String type, int expectedStart, int expectedEnd) {
|
||||
String message = "Missing " + type + DiagnosticUtils.atLocation(myFile, new TextRange(expectedStart, expectedEnd));
|
||||
System.err.println(message);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unexpectedDiagnostic(String type, int actualStart, int actualEnd) {
|
||||
String message = "Unexpected " + type + DiagnosticUtils.atLocation(myFile, new TextRange(actualStart, actualEnd));
|
||||
System.err.println(message);
|
||||
}
|
||||
});
|
||||
|
||||
String actualText = CheckerTestUtil.addDiagnosticMarkersToText(myFile, bindingContext).toString();
|
||||
|
||||
assertEquals(expectedText, actualText);
|
||||
|
||||
// String myFullDataPath = getTestDataPath() + getDataPath();
|
||||
// System.out.println("myFullDataPath = " + myFullDataPath);
|
||||
// convert(new File(myFullDataPath + "/../../checker/"), new File(myFullDataPath));
|
||||
}
|
||||
|
||||
/*
|
||||
private void convert(File src, File dest) throws IOException {
|
||||
File[] files = src.listFiles();
|
||||
for (File file : files) {
|
||||
try {
|
||||
if (file.isDirectory()) {
|
||||
File destDir = new File(dest, file.getName());
|
||||
destDir.mkdir();
|
||||
convert(file, destDir);
|
||||
continue;
|
||||
}
|
||||
if (!file.getName().endsWith(".jet")) continue;
|
||||
String text = loadFile(file.getAbsolutePath());
|
||||
Pattern pattern = Pattern.compile("</?(error|warning|info( descr=\"[\\w ]+\")?)>");
|
||||
String clearText = pattern.matcher(text).replaceAll("");
|
||||
|
||||
configureFromFileText(file.getName(), clearText);
|
||||
|
||||
BindingContext bindingContext = AnalyzerFacade.analyzeFileWithCache((JetFile) myFile);
|
||||
String expectedText = CheckerTestUtil.addDiagnosticMarkersToText(myFile, bindingContext).toString();
|
||||
|
||||
File destFile = new File(dest, file.getName());
|
||||
FileWriter fileWriter = new FileWriter(destFile);
|
||||
fileWriter.write(expectedText);
|
||||
fileWriter.close();
|
||||
}
|
||||
catch (RuntimeException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
public static Test suite() {
|
||||
return JetTestCaseBuilder.suiteForDirectory(JetTestCaseBuilder.getTestDataPathBase(), "/checkerWithErrorTypes/full/", true, new JetTestCaseBuilder.NamedTestFactory() {
|
||||
@NotNull
|
||||
@Override
|
||||
public Test createTest(@NotNull String dataPath, @NotNull String name) {
|
||||
return new FullJetPsiCheckerTest(dataPath, name);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user