disable +JDK macro in JetDiagnosticsTest and fix (actually hide) revealed bugs

+JDK was not very helpful
This commit is contained in:
Stepan Koltsov
2012-03-12 22:54:24 +04:00
parent 07ff53d456
commit 3748507ac1
84 changed files with 14 additions and 95 deletions
@@ -219,6 +219,7 @@ public class JavaDescriptorResolver {
// First, let's check that this is a real Java class, not a Java's view on a Kotlin class: // First, let's check that this is a real Java class, not a Java's view on a Kotlin class:
ClassDescriptor kotlinClassDescriptor = semanticServices.getKotlinClassDescriptor(qualifiedName); ClassDescriptor kotlinClassDescriptor = semanticServices.getKotlinClassDescriptor(qualifiedName);
if (kotlinClassDescriptor != null) { if (kotlinClassDescriptor != null) {
// TODO: return null, no loops here
return new ResolverSrcClassData(kotlinClassDescriptor); return new ResolverSrcClassData(kotlinClassDescriptor);
} }
@@ -258,6 +259,7 @@ public class JavaDescriptorResolver {
// First, let's check that this is a real Java class, not a Java's view on a Kotlin class: // First, let's check that this is a real Java class, not a Java's view on a Kotlin class:
ClassDescriptor kotlinClassDescriptor = semanticServices.getKotlinClassDescriptor(qualifiedName); ClassDescriptor kotlinClassDescriptor = semanticServices.getKotlinClassDescriptor(qualifiedName);
if (kotlinClassDescriptor != null) { if (kotlinClassDescriptor != null) {
// TODO: return null, no loops here
return kotlinClassDescriptor; return kotlinClassDescriptor;
} }
@@ -29,6 +29,7 @@ import org.jetbrains.jet.lang.descriptors.ClassDescriptor;
import org.jetbrains.jet.lang.descriptors.ClassifierDescriptor; import org.jetbrains.jet.lang.descriptors.ClassifierDescriptor;
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor; import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor;
import org.jetbrains.jet.lang.descriptors.NamespaceDescriptor; import org.jetbrains.jet.lang.descriptors.NamespaceDescriptor;
import org.jetbrains.jet.lang.resolve.DescriptorUtils;
import java.util.Collection; import java.util.Collection;
import java.util.HashSet; import java.util.HashSet;
@@ -68,7 +69,14 @@ public class JavaPackageScope extends JavaClassOrPackageScope {
@Override @Override
public ClassifierDescriptor getClassifier(@NotNull String name) { public ClassifierDescriptor getClassifier(@NotNull String name) {
return semanticServices.getDescriptorResolver().resolveClass(getQualifiedName(packageFQN, name)); ClassDescriptor classDescriptor = semanticServices.getDescriptorResolver().resolveClass(getQualifiedName(packageFQN, name));
if (classDescriptor == null || DescriptorUtils.isObject(classDescriptor)) {
// TODO: this is a big hack against several things that I barely understand myself and cannot explain
// 1. We should not return objects from this method, and maybe JDR.resolveClass should not return too
// 2. JDR should not return classes being analyzed
return null;
}
return classDescriptor;
} }
@Override @Override
@@ -1,5 +1,4 @@
// FILE: a.kt // FILE: a.kt
// +JDK
/** /**
* This is an example of a Type-Safe Groovy-style Builder * This is an example of a Type-Safe Groovy-style Builder
@@ -1,4 +1,3 @@
// +JDK
package Jet86 package Jet86
@@ -1,4 +1,3 @@
// +JDK
trait A { trait A {
fun foo() : Int = 1 fun foo() : Int = 1
@@ -1,4 +1,3 @@
//+JDK
class Foo() { class Foo() {
private val builder = StringBuilder("sdfsd"); private val builder = StringBuilder("sdfsd");
@@ -1,4 +1,3 @@
// +JDK
import java.util.*; import java.util.*;
@@ -1,4 +1,3 @@
// +JDK
fun none() {} fun none() {}
@@ -1,4 +1,3 @@
// +JDK
// KT-689 Allow to put Java and Kotlin files in the same packages // KT-689 Allow to put Java and Kotlin files in the same packages
// This is a stub test. One should not extend Java packages that come from libraries. // This is a stub test. One should not extend Java packages that come from libraries.
@@ -1,4 +1,3 @@
// +JDK
package foo package foo
@@ -1,5 +1,4 @@
// FILE: b.kt // FILE: b.kt
// +JDK
package foobar.a package foobar.a
@@ -1,4 +1,3 @@
// +JDK
fun test() { fun test() {
val a : Int? = 0 val a : Int? = 0
@@ -1,4 +1,3 @@
//+JDK
class X { class X {
val <!MUST_BE_INITIALIZED_OR_BE_ABSTRACT!>x<!> : Int val <!MUST_BE_INITIALIZED_OR_BE_ABSTRACT!>x<!> : Int
@@ -1,4 +1,3 @@
// +JDK
// Fixpoint generic in Java: Enum<T extends Enum<T>> // Fixpoint generic in Java: Enum<T extends Enum<T>>
fun test(<!UNUSED_PARAMETER!>a<!> : annotation.RetentionPolicy) { fun test(<!UNUSED_PARAMETER!>a<!> : annotation.RetentionPolicy) {
@@ -1,5 +1,4 @@
// FILE: f.kt // FILE: f.kt
// +JDK
import java.* import java.*
import java.util.* import java.util.*
@@ -1,4 +1,3 @@
// +JDK
fun t1() : Int{ fun t1() : Int{
return 0 return 0
@@ -1,4 +1,3 @@
// +JDK
class Foo1() : java.util.ArrayList<Int>() class Foo1() : java.util.ArrayList<Int>()
@@ -1,5 +1,4 @@
// KT-389 Wrong type inference for varargs etc. // KT-389 Wrong type inference for varargs etc.
// +JDK
import java.util.* import java.util.*
@@ -1,4 +1,3 @@
// +JDK
package kotlin1 package kotlin1
@@ -1,4 +1,3 @@
// +JDK
package kotlin1 package kotlin1
@@ -1,4 +1,3 @@
// +JDK
package kotlin1 package kotlin1
@@ -1,3 +1,2 @@
// +JDK
annotation [java.lang.Deprecated] class my annotation [java.lang.Deprecated] class my
annotation Deprecated class my1 annotation Deprecated class my1
@@ -1,4 +1,3 @@
// +JDK
import java.lang.Deprecated as deprecated import java.lang.Deprecated as deprecated
@@ -1,4 +1,3 @@
// +JDK
import java.lang.annotation.* import java.lang.annotation.*
annotation [java.lang.annotation.Retention(RetentionPolicy.CLASS)] class my annotation [java.lang.annotation.Retention(RetentionPolicy.CLASS)] class my
@@ -1,4 +1,3 @@
// +JDK
import java.util.List; import java.util.List;
import java.util.Collection; import java.util.Collection;
@@ -1,4 +1,3 @@
// +JDK
import java.util.List; import java.util.List;
import java.util.Collection; import java.util.Collection;
@@ -1,4 +1,3 @@
// +JDK
import java.util.List; import java.util.List;
@@ -1,4 +1,3 @@
// +JDK
import java.util.List; import java.util.List;
@@ -1,4 +1,3 @@
// +JDK
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
@@ -1,4 +1,3 @@
// +JDK
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
@@ -1,4 +1,3 @@
// +JDK
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
@@ -1,4 +1,3 @@
// +JDK
import java.util.List; import java.util.List;
@@ -1,4 +1,3 @@
// +JDK
import java.util.List import java.util.List
@@ -1,4 +1,3 @@
// +JDK
import java.util.List; import java.util.List;
@@ -1,4 +1,3 @@
// +JDK
import java.util.List; import java.util.List;
@@ -1,7 +1,6 @@
//KT-1001 Argument 2 for @NotNull parameter of JetFlowInformationProvider.checkIsInitialized must not be null //KT-1001 Argument 2 for @NotNull parameter of JetFlowInformationProvider.checkIsInitialized must not be null
package kt1001 package kt1001
//+JDK
fun foo(<!UNUSED_PARAMETER!>c<!>: Array<Int>) { fun foo(<!UNUSED_PARAMETER!>c<!>: Array<Int>) {
return return
@@ -1,5 +1,4 @@
//KT-1027 Strange selection of unreachable code //KT-1027 Strange selection of unreachable code
//+JDK
package kt1027 package kt1027
@@ -1,5 +1,4 @@
//KT-1066 false 'Variable cannot be initialized before declaration' //KT-1066 false 'Variable cannot be initialized before declaration'
//+JDK
package kt1066 package kt1066
@@ -1,6 +1,5 @@
//KT-1156 Throwing exception on the right side of elvis operator marks code unreachable //KT-1156 Throwing exception on the right side of elvis operator marks code unreachable
//+JDK
fun foo(maybe: Int?) { fun foo(maybe: Int?) {
val i : Int = maybe ?: throw RuntimeException("No value") val i : Int = maybe ?: throw RuntimeException("No value")
@@ -1,6 +1,5 @@
//KT-1189 StackOverflow in ide //KT-1189 StackOverflow in ide
package kt1189 package kt1189
//+JDK
import java.util.concurrent.locks.ReentrantReadWriteLock import java.util.concurrent.locks.ReentrantReadWriteLock
inline fun <erased T> ReentrantReadWriteLock.write(action: ()->T) : T { inline fun <erased T> ReentrantReadWriteLock.write(action: ()->T) : T {
@@ -1,5 +1,4 @@
//KT-1219 Incorrect 'unused value' error in closures //KT-1219 Incorrect 'unused value' error in closures
//+JDK
package kt1219 package kt1219
@@ -1,6 +1,5 @@
package kt770_351_735 package kt770_351_735
//+JDK
//KT-770 Reference is not resolved to anything, but is not marked unresolved //KT-770 Reference is not resolved to anything, but is not marked unresolved
fun main(args : Array<String>) { fun main(args : Array<String>) {
@@ -1,5 +1,4 @@
//KT-1141 No check that object in 'object expression' implements all abstract members of supertype //KT-1141 No check that object in 'object expression' implements all abstract members of supertype
//+JDK
package kt1141 package kt1141
@@ -1,5 +1,4 @@
// FILE: b.kt // FILE: b.kt
// +JDK
package outer package outer
fun Int?.optint() : Unit {} fun Int?.optint() : Unit {}
@@ -1,4 +1,3 @@
// +JDK
import java.util.Enumeration import java.util.Enumeration
inline fun <T> java.util.Enumeration<T>.iterator() = object: Iterator<T> { inline fun <T> java.util.Enumeration<T>.iterator() = object: Iterator<T> {
@@ -1,5 +1,4 @@
//+JDK
//KT-819 Redeclaration error for extension properties with the same name and different receivers //KT-819 Redeclaration error for extension properties with the same name and different receivers
import java.io.* import java.io.*
@@ -1,5 +1,4 @@
// FILE: aa/A.java // FILE: aa/A.java
// +JDK
package aa; package aa;
public class A { public class A {
@@ -1,5 +1,4 @@
// FILE: a/M.java // FILE: a/M.java
// +JDK
package a; package a;
public class M { public class M {
@@ -1,5 +1,4 @@
//KT-1270 Poor highlighting when trying to dereference a nullable reference //KT-1270 Poor highlighting when trying to dereference a nullable reference
//+JDK
package kt1270 package kt1270
@@ -1,6 +1,5 @@
package kt244 package kt244
//+JDK
// KT-244 Use dataflow info while resolving variable initializers // KT-244 Use dataflow info while resolving variable initializers
@@ -1,7 +1,6 @@
//+JDK
package toplevelObjectDeclarations package toplevelObjectDeclarations
object CObj {} object CObj {}
object DOjb : <!SUPERTYPE_NOT_INITIALIZED_DEFAULT, FINAL_SUPERTYPE!>CObj<!> {} object DOjb : <!UNRESOLVED_REFERENCE!>CObj<!> {}
@@ -1,5 +1,4 @@
//KT-1028 Wrong type checking for plusAssign //KT-1028 Wrong type checking for plusAssign
//+JDK
package kt1028 package kt1028
import java.util.* import java.util.*
@@ -1,4 +1,3 @@
// +JDK
import java.util.* import java.util.*
@@ -1,4 +1,3 @@
// +JDK
import java.util.Collections import java.util.Collections
import java.util.List import java.util.List
@@ -1,5 +1,4 @@
// JET-72 Type inference doesn't work when iterating over ArrayList // JET-72 Type inference doesn't work when iterating over ArrayList
// +JDK
import java.util.ArrayList import java.util.ArrayList
@@ -1,5 +1,4 @@
// KT-174 Nullability info for extension function receivers // KT-174 Nullability info for extension function receivers
// +JDK
trait Tree {} trait Tree {}
fun Any?.TreeValue() : Tree { fun Any?.TreeValue() : Tree {
@@ -1,5 +1,4 @@
// KT-201 Allow to call extension with nullable receiver with a '.' // KT-201 Allow to call extension with nullable receiver with a '.'
// +JDK
fun <T : Any> T?.npe() : T = if (this == null) throw NullPointerException() else this fun <T : Any> T?.npe() : T = if (this == null) throw NullPointerException() else this
@@ -1,5 +1,4 @@
//KT-235 Illegal assignment return type //KT-235 Illegal assignment return type
// +JDK
package kt235 package kt235
@@ -1,5 +1,4 @@
// KT-258 Support equality constraints in type inference // KT-258 Support equality constraints in type inference
// +JDK
import java.util.* import java.util.*
@@ -1,5 +1,4 @@
// KT-287 Infer constructor type arguments // KT-287 Infer constructor type arguments
// +JDK
import java.util.* import java.util.*
@@ -1,5 +1,4 @@
// KT-313 Bug in substitutions in a function returning its type parameter T // KT-313 Bug in substitutions in a function returning its type parameter T
// +JDK
fun <T> Iterable<T>.join(separator : String?) : String { fun <T> Iterable<T>.join(separator : String?) : String {
return separator.npe() return separator.npe()
@@ -1,6 +1,5 @@
// KT-336 Can't infer type parameter for ArrayList in a generic function (Exception in type inference) // 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 // KT-335 Type inference fails on Collections.sort
// +JDK
import java.util.* import java.util.*
import java.lang.Comparable as Comparable import java.lang.Comparable as Comparable
@@ -1,7 +1,6 @@
// KT-385 type inference does not work properly` // KT-385 type inference does not work properly`
// KT-109 Good code is red: type arguments are not inferred // 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 // KT-441 Exception in type inference when multiple overloads accepting an integer literal are accessible
// +JDK
import java.util.* import java.util.*
@@ -1,5 +1,4 @@
// KT-459 Type argument inference fails when class names are fully qualified // KT-459 Type argument inference fails when class names are fully qualified
// +JDK
fun test() { fun test() {
val attributes : java.util.HashMap<String, String> = java.util.HashMap() // failure! val attributes : java.util.HashMap<String, String> = java.util.HashMap() // failure!
@@ -1,4 +1,3 @@
// +JDK
package kt469 package kt469
@@ -1,5 +1,4 @@
// KT-498 Very strange error in the type checker // KT-498 Very strange error in the type checker
// +JDK
class IdUnavailableException() : Exception() {} class IdUnavailableException() : Exception() {}
@@ -1,5 +1,4 @@
// KT-524 sure() returns T // KT-524 sure() returns T
// +JDK
package StringBuilder package StringBuilder
@@ -1,5 +1,4 @@
//KT-549 type inference failed //KT-549 type inference failed
// +JDK
package demo package demo
@@ -1,5 +1,4 @@
//KT-58 Allow finally around definite returns //KT-58 Allow finally around definite returns
// +JDK
package kt58 package kt58
@@ -1,5 +1,4 @@
//KT-580 Type inference failed //KT-580 Type inference failed
// +JDK
package whats.the.difference package whats.the.difference
@@ -1,5 +1,4 @@
// KT-588 Unresolved static method // KT-588 Unresolved static method
// +JDK
class Test() : Thread("Test") { class Test() : Thread("Test") {
class object { class object {
@@ -1,5 +1,4 @@
//KT-597 Type inference failed //KT-597 Type inference failed
// +JDK
fun <T> Array<T>?.get(i: Int) : T { fun <T> Array<T>?.get(i: Int) : T {
if (this != null) if (this != null)
@@ -1,5 +1,4 @@
//KT-600 Problem with 'sure' extension function type inference //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 <T : Any> T?._sure() : T { if (this != null) return this else throw NullPointerException() }
@@ -1,5 +1,4 @@
// KT-702 Type inference failed // KT-702 Type inference failed
// +JDK
fun getJavaClass<T>() : java.lang.Class<T> { return "" <!CAST_NEVER_SUCCEEDS!>as<!> Class<T> } fun getJavaClass<T>() : java.lang.Class<T> { return "" <!CAST_NEVER_SUCCEEDS!>as<!> Class<T> }
public class Throwables() { public class Throwables() {
@@ -1,5 +1,4 @@
// KT-716 Type inference failed // KT-716 Type inference failed
// +JDK
class TypeInfo<T> class TypeInfo<T>
@@ -1,5 +1,4 @@
//KT-743 Wrong type inference //KT-743 Wrong type inference
// +JDK
class List<T>(val head: T, val tail: List<T>? = null) class List<T>(val head: T, val tail: List<T>? = null)
fun <T, Q> List<T>.map(f: (T)-> Q): List<T>? = tail.sure<List<T>>().map(f) fun <T, Q> List<T>.map(f: (T)-> Q): List<T>? = tail.sure<List<T>>().map(f)
@@ -1,4 +1,3 @@
// +JDK
//KT-750 Type inference failed: Constraint violation //KT-750 Type inference failed: Constraint violation
fun main(args : Array<String>) { fun main(args : Array<String>) {
var i : Int? = Integer.valueOf(100) var i : Int? = Integer.valueOf(100)
@@ -1,5 +1,4 @@
// KT-860 ConcurrentModificationException in frontend // KT-860 ConcurrentModificationException in frontend
// +JDK
package kotlin.util package kotlin.util
@@ -1,5 +1,4 @@
//FILE:a.kt //FILE:a.kt
//+JDK
//KT-1080 Don't use previously imported packages while resolving import references //KT-1080 Don't use previously imported packages while resolving import references
package kt1080 package kt1080
@@ -1,4 +1,3 @@
// +JDK
package kt_250_617_10 package kt_250_617_10
@@ -1,6 +1,5 @@
package kt939 package kt939
//+JDK
//KT-939 CommonSupertypes erases scopes associated to types //KT-939 CommonSupertypes erases scopes associated to types
@@ -1,27 +1,23 @@
//FILE:a.kt //FILE:a.kt
//KT-955 Unable to import a Kotlin package into a Kotlin file with no package header //KT-955 Unable to import a Kotlin package into a Kotlin file with no package header
//+JDK
package foo package foo
fun f() {} fun f() {}
//FILE:b.kt //FILE:b.kt
//+JDK
import foo.* import foo.*
val m = f() // unresolved val m = f() // unresolved
//FILE:c.kt //FILE:c.kt
//+JDK
package java.util package java.util
fun bar() {} fun bar() {}
//FILE:d.kt //FILE:d.kt
//+JDK
import java.util.* import java.util.*
@@ -1,4 +1,3 @@
// +JDK
import java.util.ArrayList import java.util.ArrayList
class MyListOfPairs<T> : ArrayList<#(T, T)>() { } class MyListOfPairs<T> : ArrayList<#(T, T)>() { }
@@ -151,8 +151,7 @@ public class JetDiagnosticsTest extends JetLiteFixture {
} }
}); });
boolean importJdk = expectedText.contains("+JDK"); // ModuleConfiguration configuration = JavaBridgeConfiguration.createJavaBridgeConfiguration(getProject());
// ModuleConfiguration configuration = importJdk ? JavaBridgeConfiguration.createJavaBridgeConfiguration(getProject()) : ModuleConfiguration.EMPTY;
if (hasJavaFiles) { if (hasJavaFiles) {
// According to yole@ the only way to import java files is to write them on disk // According to yole@ the only way to import java files is to write them on disk
// -- stepan.koltsov@ 2012-02-29 // -- stepan.koltsov@ 2012-02-29
@@ -166,13 +165,7 @@ public class JetDiagnosticsTest extends JetLiteFixture {
} }
} }
BindingContext bindingContext; BindingContext bindingContext = AnalyzerFacadeForJVM.analyzeFilesWithJavaIntegration(getProject(), jetFiles, Predicates.<PsiFile>alwaysTrue(), JetControlFlowDataTraceFactory.EMPTY);
if (importJdk) {
bindingContext = AnalyzerFacadeForJVM.analyzeFilesWithJavaIntegration(getProject(), jetFiles, Predicates.<PsiFile>alwaysTrue(), JetControlFlowDataTraceFactory.EMPTY);
}
else {
bindingContext = AnalyzingUtils.analyzeFiles(getProject(), ModuleConfiguration.EMPTY, jetFiles, Predicates.<PsiFile>alwaysTrue(), JetControlFlowDataTraceFactory.EMPTY);
}
boolean ok = true; boolean ok = true;