Redeclaration diagnostics work properly

This commit is contained in:
Andrey Breslav
2011-09-16 13:30:59 +04:00
parent 0dd2889c55
commit 20427a6e4d
71 changed files with 436 additions and 2553 deletions
@@ -2,15 +2,15 @@ package org.jetbrains.jet.lang.diagnostics;
import com.intellij.openapi.util.TextRange;
import com.intellij.psi.PsiElement;
import com.intellij.psi.PsiFile;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor;
import org.jetbrains.jet.lang.psi.JetNamedDeclaration;
import org.jetbrains.jet.lang.resolve.BindingContext;
/**
* @author abreslav
*/
public class RedeclarationDiagnosticFactory implements DiagnosticFactory {
public class RedeclarationDiagnosticFactory extends AbstractDiagnosticFactory {
public static final RedeclarationDiagnosticFactory INSTANCE = new RedeclarationDiagnosticFactory();
@@ -27,13 +27,14 @@ public class RedeclarationDiagnosticFactory implements DiagnosticFactory {
@NotNull
@Override
public TextRange getTextRange(@NotNull Diagnostic diagnostic) {
throw new UnsupportedOperationException(); // TODO
}
@NotNull
@Override
public PsiFile getPsiFile(@NotNull Diagnostic diagnostic) {
throw new UnsupportedOperationException(); // TODO
PsiElement redeclaration = ((RedeclarationDiagnostic) diagnostic).getPsiElement();
if (redeclaration instanceof JetNamedDeclaration) {
PsiElement nameIdentifier = ((JetNamedDeclaration) redeclaration).getNameIdentifier();
if (nameIdentifier != null) {
return nameIdentifier.getTextRange();
}
}
return redeclaration.getTextRange();
}
@NotNull
@@ -974,7 +974,11 @@ public class JetTypeInferrer {
@Override
public JetType visitParenthesizedExpression(JetParenthesizedExpression expression, TypeInferenceContext context) {
return context.services.checkType(getType(expression.getExpression(), context.replaceScope(context.scope)), expression, context);
JetExpression innerExpression = expression.getExpression();
if (innerExpression == null) {
return null;
}
return context.services.checkType(getType(innerExpression, context.replaceScope(context.scope)), expression, context);
}
@Override
@@ -71,7 +71,7 @@ public class JetPsiChecker implements Annotator {
}
else if (diagnostic instanceof RedeclarationDiagnostic) {
RedeclarationDiagnostic redeclarationDiagnostic = (RedeclarationDiagnostic) diagnostic;
markRedeclaration(redeclarations, redeclarationDiagnostic.getPsiElement(), holder);
annotation = markRedeclaration(redeclarations, redeclarationDiagnostic, holder);
}
else {
annotation = holder.createErrorAnnotation(diagnostic.getFactory().getTextRange(diagnostic), getMessage(diagnostic));
@@ -133,18 +133,10 @@ public class JetPsiChecker implements Annotator {
return diagnostic.getMessage();
}
private void markRedeclaration(Set<PsiElement> redeclarations, @NotNull PsiElement redeclaration, AnnotationHolder holder) {
if (!redeclarations.add(redeclaration)) return;
if (redeclaration instanceof JetNamedDeclaration) {
PsiElement nameIdentifier = ((JetNamedDeclaration) redeclaration).getNameIdentifier();
if (nameIdentifier != null) {
holder.createErrorAnnotation(nameIdentifier, "Redeclaration");
}
}
else {
holder.createErrorAnnotation(redeclaration, "Redeclaration");
}
}
private Annotation markRedeclaration(Set<PsiElement> redeclarations, RedeclarationDiagnostic diagnostic, AnnotationHolder holder) {
if (!redeclarations.add(diagnostic.getPsiElement())) return null;
return holder.createErrorAnnotation(diagnostic.getFactory().getTextRange(diagnostic), getMessage(diagnostic));
}
private void highlightBackingFields(final AnnotationHolder holder, JetFile file, final BindingContext bindingContext) {
@@ -0,0 +1,51 @@
open class NoC
class NoC1 : NoC
class WithC0() : NoC<!NO_CONSTRUCTOR!>()<!>
open class WithC1() : NoC
class NoC2 : <!SUPERTYPE_NOT_INITIALIZED!>WithC1<!>
class NoC3 : WithC1<!PRIMARY_CONSTRUCTOR_MISSING_SUPER_CONSTRUCTOR_CALL!>()<!>
class WithC2() : <!SUPERTYPE_NOT_INITIALIZED!>WithC1<!>
class NoPC {
<!SECONDARY_CONSTRUCTOR_BUT_NO_PRIMARY!>this<!>() {}
}
class WithPC0() {
this(a : Int) : this() {}
}
class WithPC1(a : Int) {
<!SECONDARY_CONSTRUCTOR_NO_INITIALIZER_LIST!>this<!>() {}
this(b : Long) : this("") {}
this(s : String) : this(1) {}
this(b : Char) : <!NONE_APPLICABLE!>this("", 2)<!> {}
this(b : Byte) : this(""), <!MANY_CALLS_TO_THIS!>this(1)<!> {}
}
class Foo() : <!SUPERTYPE_NOT_INITIALIZED, FINAL_SUPERTYPE!>WithPC0<!>, <!MANY_CLASSES_IN_SUPERTYPE_LIST!>this<!>() {
}
class WithCPI_Dup(<!REDECLARATION, REDECLARATION!>x<!> : Int) {
var <!REDECLARATION, REDECLARATION, MUST_BE_INITIALIZED_OR_BE_ABSTRACT!>x<!> : Int
}
class WithCPI(x : Int) {
val a = 1
val b : Int = $a
val xy : Int = x
}
class <!PRIMARY_CONSTRUCTOR_MISSING_STATEFUL_PROPERTY!>NoCPI<!> {
val a = <!PROPERTY_INITIALIZER_NO_PRIMARY_CONSTRUCTOR!>1<!>
var ab = <!PROPERTY_INITIALIZER_NO_BACKING_FIELD!>1<!>
get() = 1
set(v) {}
}
@@ -0,0 +1,16 @@
namespace redeclarations {
object <!REDECLARATION, REDECLARATION!>A<!> {
val x : Int = 0
val A = 1
}
namespace <!REDECLARATION!>A<!> {
class A {}
}
class <!REDECLARATION, REDECLARATION!>A<!> {}
val <!REDECLARATION!>A<!> = 1
}
@@ -0,0 +1,255 @@
open class A() {
fun foo() {}
}
class B() : A() {
fun bar() {}
}
fun f9() {
val a : A?
a?.foo()
a?.<!UNRESOLVED_REFERENCE!>bar<!>()
if (a is B) {
a.bar()
a.foo()
}
a?.foo()
a?.<!UNRESOLVED_REFERENCE!>bar<!>()
if (!(a is B)) {
a?.<!UNRESOLVED_REFERENCE!>bar<!>()
a?.foo()
}
if (!(a is B) || a.bar() == ()) {
a?.<!UNRESOLVED_REFERENCE!>bar<!>()
}
if (!(a is B)) {
return;
}
a.bar()
a.foo()
}
fun f10() {
val a : A?
if (!(a is B)) {
return;
}
if (!(a is B)) {
return;
}
}
class C() : A() {
fun bar() {
}
}
fun f10(a : A?) {
if (a is B) {
if (a is C) {
a.bar();
}
}
}
fun f11(a : A?) {
when (a) {
is B => a.bar()
is A => a.foo()
is Any => a.foo()
is Any? => a.<!UNRESOLVED_REFERENCE!>bar<!>()
else => a?.foo()
}
}
fun f12(a : A?) {
when (a) {
is B => a.bar()
is A => a.foo()
is Any => a.foo();
is Any? => a.<!UNRESOLVED_REFERENCE!>bar<!>()
is val c : <!TYPE_MISMATCH_IN_BINDING_PATTERN!>B<!> => c.foo()
is val c is C => c.bar()
is val c is C => a.bar()
else => a?.foo()
}
if (a is val b) {
a?.<!UNRESOLVED_REFERENCE!>bar<!>()
b?.foo()
}
if (a is val b is B) {
b.foo()
a.bar()
b.bar()
}
}
fun f13(a : A?) {
if (a is val c is B) {
c.foo()
c.bar()
}
else {
a?.foo()
<!UNRESOLVED_REFERENCE!>c<!>.bar()
}
a?.foo()
if (!(a is val c is B)) {
a?.foo()
<!UNRESOLVED_REFERENCE!>c<!>.bar()
}
else {
a.foo()
<!UNRESOLVED_REFERENCE!>c<!>.bar()
}
a?.foo()
if (a is val c is B && a.foo() == () && c.bar() == ()) {
c.foo()
c.bar()
}
else {
a?.foo()
<!UNRESOLVED_REFERENCE!>c<!>.bar()
}
if (!(a is val c is B) || !(a is val x is C)) {
<!UNRESOLVED_REFERENCE!>x<!>
<!UNRESOLVED_REFERENCE!>c<!>
}
else {
<!UNRESOLVED_REFERENCE!>x<!>
<!UNRESOLVED_REFERENCE!>c<!>
}
if (!(a is val c is B) || !(a is val c is C)) {
}
if (!(a is val c is B)) return
a.bar()
<!UNRESOLVED_REFERENCE!>c<!>.foo()
<!UNRESOLVED_REFERENCE!>c<!>.bar()
}
fun f14(a : A?) {
while (!(a is val c is B)) {
}
a.bar()
<!UNRESOLVED_REFERENCE!>c<!>.bar()
}
fun f15(a : A?) {
do {
} while (!(a is val c is B))
a.bar()
<!UNRESOLVED_REFERENCE!>c<!>.bar()
}
fun getStringLength(obj : Any) : Char? {
if (obj !is String)
return null
return obj.get(0) // no cast to String is needed
}
fun toInt(i: Int?): Int = if (i != null) i else 0
fun illegalWhenBody(a: Any): Int = when(a) {
is Int => a
is String => <!TYPE_MISMATCH!>a<!>
}
fun illegalWhenBlock(a: Any): Int {
when(a) {
is Int => return a
is String => return <!TYPE_MISMATCH!>a<!>
}
}
fun declarations(a: Any?) {
if (a is String) {
val p4: (Int, String) = (2, a)
}
if (a is String?) {
if (a != null) {
val s: String = a
}
}
if (a != null) {
if (a is String?) {
val s: String = a
}
}
}
fun vars(a: Any?) {
var b: Int = 0
if (a is Int) {
b = a
}
}
fun tuples(a: Any?) {
if (a != null) {
val s: (Any, String) = (a, <!TYPE_MISMATCH!>a<!>)
}
if (a is String) {
val s: (Any, String) = (a, a)
}
fun illegalTupleReturnType(): (Any, String) = (<!TYPE_MISMATCH!>a<!>, <!TYPE_MISMATCH!>a<!>)
if (a is String) {
fun legalTupleReturnType(): (Any, String) = (a, a)
}
val illegalFunctionLiteral: Function0<Int> = <!TYPE_MISMATCH!>{ <!TYPE_MISMATCH!>a<!> }<!>
val illegalReturnValueInFunctionLiteral: Function0<Int> = { (): Int => <!TYPE_MISMATCH!>a<!> }
if (a is Int) {
val legalFunctionLiteral: Function0<Int> = { a }
val alsoLegalFunctionLiteral: Function0<Int> = { (): Int => a }
}
}
fun returnFunctionLiteralBlock(a: Any?): Function0<Int> {
if (a is Int) return { a }
else return { 1 }
}
fun returnFunctionLiteral(a: Any?): Function0<Int> =
if (a is Int) { (): Int => a }
else { () => 1 }
fun illegalTupleReturnType(a: Any): (Any, String) = (a, <!TYPE_MISMATCH!>a<!>)
fun declarationInsidePattern(x: (Any, Any)): String = when(x) { is (val a is String, *) => a; else => "something" }
fun mergeAutocasts(a: Any?) {
if (a is String || a is Int) {
a.<!UNRESOLVED_REFERENCE!>compareTo<!>("")
a.toString()
}
if (a is Int || a is String) {
a.<!UNRESOLVED_REFERENCE!>compareTo<!>("")
}
when (a) {
is String, is Any => a.<!UNRESOLVED_REFERENCE!>compareTo<!>("")
}
if (a is String && a is Any) {
val i: Int = a.compareTo("")
}
if (a is String && a.compareTo("") == 0) {}
if (a is String || a.<!UNRESOLVED_REFERENCE!>compareTo<!>("") == 0) {}
}
//mutability
fun f(): String {
var a: Any = 11
if (a is String) {
val i: String = <!AUTOCAST_IMPOSSIBLE!>a<!>
<!AUTOCAST_IMPOSSIBLE!>a<!>.compareTo("f")
val f: Function0<String> = { <!AUTOCAST_IMPOSSIBLE!>a<!> }
return <!AUTOCAST_IMPOSSIBLE!>a<!>
}
return ""
}
fun foo(var a: Any): Int {
if (a is Int) {
return <!AUTOCAST_IMPOSSIBLE!>a<!>
}
return 1
}
@@ -0,0 +1,57 @@
abstract class Test() {
abstract val x : Int
abstract val x1 : Int get
abstract val x2 : Int <!ABSTRACT_PROPERTY_WITH_GETTER!>get() = 1<!>
val <!MUST_BE_INITIALIZED_OR_BE_ABSTRACT!>a<!> : Int
val <!MUST_BE_INITIALIZED_OR_BE_ABSTRACT!>b<!> : Int get
val c = 1
val c1 = 1
get
val c2 : Int
get() = 1
val c3 : Int
get() { return 1 }
val c4 : Int
get() = 1
val <!MUST_BE_INITIALIZED!>c5<!> : Int
get() = $c5 + 1
abstract var y : Int
abstract var y1 : Int get
abstract var y2 : Int set
abstract var y3 : Int set get
abstract var y4 : Int set <!ABSTRACT_PROPERTY_WITH_GETTER!>get() = 1<!>
abstract var y5 : Int <!ABSTRACT_PROPERTY_WITH_SETTER!>set(x) {}<!> <!ABSTRACT_PROPERTY_WITH_GETTER!>get() = 1<!>
abstract var y6 : Int <!ABSTRACT_PROPERTY_WITH_SETTER!>set(x) {}<!>
var <!MUST_BE_INITIALIZED_OR_BE_ABSTRACT!>v<!> : Int
var <!MUST_BE_INITIALIZED_OR_BE_ABSTRACT!>v1<!> : Int get
var <!MUST_BE_INITIALIZED_OR_BE_ABSTRACT!>v2<!> : Int get set
var <!MUST_BE_INITIALIZED!>v3<!> : Int get() = 1; set
var v4 : Int get() = 1; set(x){}
var <!MUST_BE_INITIALIZED!>v5<!> : Int get() = 1; set(x){$v5 = x}
var <!MUST_BE_INITIALIZED!>v6<!> : Int get() = $v6 + 1; set(x){}
val v7 : Int abstract get
var v8 : Int abstract get abstract set
var <!MUST_BE_INITIALIZED_OR_BE_ABSTRACT!>v9<!> : Int abstract set
var <!MUST_BE_INITIALIZED_OR_BE_ABSTRACT!>v10<!> : Int abstract get
}
open class Super(i : Int)
class TestPCParameters(w : Int, x : Int, val y : Int, var z : Int) : Super(w) {
val xx = w
{
w + 1
}
fun foo() = x
}
@@ -0,0 +1,4 @@
// JET-11 Redeclaration & Forward reference for classes cause an exception
open class <!REDECLARATION!>NoC<!>
class NoC1 : NoC
open class <!REDECLARATION!>NoC<!>
@@ -1,241 +0,0 @@
namespace abstract
class MyClass() {
//properties
val <!MUST_BE_INITIALIZED_OR_BE_ABSTRACT!>a<!>: Int
val a1: Int = 1
<!ABSTRACT_PROPERTY_IN_NON_ABSTRACT_CLASS!>abstract<!> val a2: Int
<!ABSTRACT_PROPERTY_IN_NON_ABSTRACT_CLASS!>abstract<!> val a3: Int = 1
var <!MUST_BE_INITIALIZED_OR_BE_ABSTRACT!>b<!>: Int private set
var b1: Int = 0; private set
<!ABSTRACT_PROPERTY_IN_NON_ABSTRACT_CLASS!>abstract<!> var b2: Int private set
<!ABSTRACT_PROPERTY_IN_NON_ABSTRACT_CLASS!>abstract<!> var b3: Int = 0; private set
var <!MUST_BE_INITIALIZED!>c<!>: Int set(v: Int) { $c = v }
var c1: Int = 0; set(v: Int) { $c1 = v }
<!ABSTRACT_PROPERTY_IN_NON_ABSTRACT_CLASS!>abstract<!> var c2: Int set(v: Int) { $c2 = v }
<!ABSTRACT_PROPERTY_IN_NON_ABSTRACT_CLASS!>abstract<!> var c3: Int = 0; set(v: Int) { $c3 = v }
val e: Int get() = a
val e1: Int = <!PROPERTY_INITIALIZER_NO_BACKING_FIELD!>0<!>; get() = a
<!ABSTRACT_PROPERTY_IN_NON_ABSTRACT_CLASS!>abstract<!> val e2: Int get() = a
<!ABSTRACT_PROPERTY_IN_NON_ABSTRACT_CLASS!>abstract<!> val e3: Int = 0; get() = a
//methods
fun <!NON_ABSTRACT_FUNCTION_WITH_NO_BODY!>f<!>()
fun g() {}
<!ABSTRACT_FUNCTION_IN_NON_ABSTRACT_CLASS!>abstract<!> fun h()
<!ABSTRACT_FUNCTION_IN_NON_ABSTRACT_CLASS, ABSTRACT_FUNCTION_WITH_BODY!>abstract<!> fun j() {}
//property accessors
var i: Int <!ABSTRACT_FUNCTION_IN_NON_ABSTRACT_CLASS!>abstract<!> get <!ABSTRACT_FUNCTION_IN_NON_ABSTRACT_CLASS!>abstract<!> set
var i1: Int = <!PROPERTY_INITIALIZER_NO_BACKING_FIELD!>0<!>; <!ABSTRACT_FUNCTION_IN_NON_ABSTRACT_CLASS!>abstract<!> get <!ABSTRACT_FUNCTION_IN_NON_ABSTRACT_CLASS!>abstract<!> set
var j: Int get() = i; <!ABSTRACT_FUNCTION_IN_NON_ABSTRACT_CLASS!>abstract<!> set
var j1: Int = <!PROPERTY_INITIALIZER_NO_BACKING_FIELD!>0<!>; get() = i; <!ABSTRACT_FUNCTION_IN_NON_ABSTRACT_CLASS!>abstract<!> set
var <!MUST_BE_INITIALIZED_OR_BE_ABSTRACT!>k<!>: Int <!ABSTRACT_FUNCTION_IN_NON_ABSTRACT_CLASS!>abstract<!> set
var k1: Int = 0; <!ABSTRACT_FUNCTION_IN_NON_ABSTRACT_CLASS!>abstract<!> set
var l: Int <!ABSTRACT_FUNCTION_IN_NON_ABSTRACT_CLASS!>abstract<!> get <!ABSTRACT_FUNCTION_IN_NON_ABSTRACT_CLASS!>abstract<!> set
var l1: Int = <!PROPERTY_INITIALIZER_NO_BACKING_FIELD!>0<!>; <!ABSTRACT_FUNCTION_IN_NON_ABSTRACT_CLASS!>abstract<!> get <!ABSTRACT_FUNCTION_IN_NON_ABSTRACT_CLASS!>abstract<!> set
var n: Int <!ABSTRACT_FUNCTION_IN_NON_ABSTRACT_CLASS!>abstract<!> get <!ABSTRACT_FUNCTION_IN_NON_ABSTRACT_CLASS, ABSTRACT_FUNCTION_WITH_BODY!>abstract<!> set(v: Int) {}
}
abstract class MyAbstractClass() {
//properties
val <!MUST_BE_INITIALIZED_OR_BE_ABSTRACT!>a<!>: Int
val a1: Int = 1
abstract val a2: Int
abstract val a3: Int = <!ABSTRACT_PROPERTY_WITH_INITIALIZER!>1<!>
var <!MUST_BE_INITIALIZED_OR_BE_ABSTRACT!>b<!>: Int private set
var b1: Int = 0; private set
abstract var b2: Int private set
abstract var b3: Int = <!ABSTRACT_PROPERTY_WITH_INITIALIZER!>0<!>; private set
var <!MUST_BE_INITIALIZED!>c<!>: Int set(v: Int) { $c = v }
var c1: Int = 0; set(v: Int) { $c1 = v }
abstract var c2: Int <!ABSTRACT_PROPERTY_WITH_SETTER!>set(v: Int) { $c2 = v }<!>
abstract var c3: Int = <!ABSTRACT_PROPERTY_WITH_INITIALIZER!>0<!>; <!ABSTRACT_PROPERTY_WITH_SETTER!>set(v: Int) { $c3 = v }<!>
val e: Int get() = a
val e1: Int = <!PROPERTY_INITIALIZER_NO_BACKING_FIELD!>0<!>; get() = a
abstract val e2: Int <!ABSTRACT_PROPERTY_WITH_GETTER!>get() = a<!>
abstract val e3: Int = <!ABSTRACT_PROPERTY_WITH_INITIALIZER!>0<!>; <!ABSTRACT_PROPERTY_WITH_GETTER!>get() = a<!>
//methods
fun <!NON_ABSTRACT_FUNCTION_WITH_NO_BODY!>f<!>()
fun g() {}
abstract fun h()
<!ABSTRACT_FUNCTION_WITH_BODY!>abstract<!> fun j() {}
//property accessors
var i: Int abstract get abstract set
var i1: Int = <!PROPERTY_INITIALIZER_NO_BACKING_FIELD!>0<!>; abstract get abstract set
var j: Int get() = i; abstract set
var j1: Int get() = i; abstract set
var <!MUST_BE_INITIALIZED_OR_BE_ABSTRACT!>k<!>: Int abstract set
var k1: Int = 0; abstract set
var l: Int abstract get abstract set
var l1: Int = <!PROPERTY_INITIALIZER_NO_BACKING_FIELD!>0<!>; abstract get abstract set
var n: Int abstract get <!ABSTRACT_FUNCTION_WITH_BODY!>abstract<!> set(v: Int) {}
}
trait MyTrait {
//properties
val a: Int
val a1: Int = <!PROPERTY_INITIALIZER_IN_TRAIT!>1<!>
<!REDUNDANT_ABSTRACT!>abstract<!> val a2: Int
<!REDUNDANT_ABSTRACT!>abstract<!> val a3: Int = <!ABSTRACT_PROPERTY_WITH_INITIALIZER!>1<!>
var b: Int private set
var b1: Int = <!PROPERTY_INITIALIZER_IN_TRAIT!>0<!>; private set
<!REDUNDANT_ABSTRACT!>abstract<!> var b2: Int private set
<!REDUNDANT_ABSTRACT!>abstract<!> var b3: Int = <!ABSTRACT_PROPERTY_WITH_INITIALIZER!>0<!>; private set
var <!BACKING_FIELD_IN_TRAIT!>c<!>: Int set(v: Int) { $c = v }
var <!BACKING_FIELD_IN_TRAIT!>c1<!>: Int = <!PROPERTY_INITIALIZER_IN_TRAIT!>0<!>; set(v: Int) { $c1 = v }
<!REDUNDANT_ABSTRACT!>abstract<!> var c2: Int <!ABSTRACT_PROPERTY_WITH_SETTER!>set(v: Int) { $c2 = v }<!>
<!REDUNDANT_ABSTRACT!>abstract<!> var c3: Int = <!ABSTRACT_PROPERTY_WITH_INITIALIZER!>0<!>; <!ABSTRACT_PROPERTY_WITH_SETTER!>set(v: Int) { $c3 = v }<!>
val e: Int get() = a
val e1: Int = <!PROPERTY_INITIALIZER_IN_TRAIT!>0<!>; get() = a
<!REDUNDANT_ABSTRACT!>abstract<!> val e2: Int <!ABSTRACT_PROPERTY_WITH_GETTER!>get() = a<!>
<!REDUNDANT_ABSTRACT!>abstract<!> val e3: Int = <!ABSTRACT_PROPERTY_WITH_INITIALIZER!>0<!>; <!ABSTRACT_PROPERTY_WITH_GETTER!>get() = a<!>
//methods
fun f()
fun g() {}
<!REDUNDANT_ABSTRACT!>abstract<!> fun h()
<!REDUNDANT_ABSTRACT, ABSTRACT_FUNCTION_WITH_BODY!>abstract<!> fun j() {}
//property accessors
var i: Int abstract get abstract set
var i1: Int = <!PROPERTY_INITIALIZER_IN_TRAIT!>0<!>; abstract get abstract set
var j: Int get() = i; abstract set
var j1: Int = <!PROPERTY_INITIALIZER_IN_TRAIT!>0<!>; get() = i; abstract set
var k: Int abstract set
var k1: Int = <!PROPERTY_INITIALIZER_IN_TRAIT!>0<!>; abstract set
var l: Int abstract get abstract set
var l1: Int = <!PROPERTY_INITIALIZER_IN_TRAIT!>0<!>; abstract get abstract set
var n: Int abstract get <!ABSTRACT_FUNCTION_WITH_BODY!>abstract<!> set(v: Int) {}
}
enum class MyEnum() {
//properties
val <!MUST_BE_INITIALIZED_OR_BE_ABSTRACT!>a<!>: Int
val a1: Int = 1
abstract val a2: Int
abstract val a3: Int = <!ABSTRACT_PROPERTY_WITH_INITIALIZER!>1<!>
var <!MUST_BE_INITIALIZED_OR_BE_ABSTRACT!>b<!>: Int private set
var b1: Int = 0; private set
abstract var b2: Int private set
abstract var b3: Int = <!ABSTRACT_PROPERTY_WITH_INITIALIZER!>0<!>; private set
var <!MUST_BE_INITIALIZED!>c<!>: Int set(v: Int) { $c = v }
var c1: Int = 0; set(v: Int) { $c1 = v }
abstract var c2: Int <!ABSTRACT_PROPERTY_WITH_SETTER!>set(v: Int) { $c2 = v }<!>
abstract var c3: Int = <!ABSTRACT_PROPERTY_WITH_INITIALIZER!>0<!>; <!ABSTRACT_PROPERTY_WITH_SETTER!>set(v: Int) { $c3 = v }<!>
val e: Int get() = a
val e1: Int = <!PROPERTY_INITIALIZER_NO_BACKING_FIELD!>0<!>; get() = a
abstract val e2: Int <!ABSTRACT_PROPERTY_WITH_GETTER!>get() = a<!>
abstract val e3: Int = <!ABSTRACT_PROPERTY_WITH_INITIALIZER!>0<!>; <!ABSTRACT_PROPERTY_WITH_GETTER!>get() = a<!>
//methods
fun <!NON_ABSTRACT_FUNCTION_WITH_NO_BODY!>f<!>()
fun g() {}
abstract fun h()
<!ABSTRACT_FUNCTION_WITH_BODY!>abstract<!> fun j() {}
//property accessors
var i: Int abstract get abstract set
var i1: Int = <!PROPERTY_INITIALIZER_NO_BACKING_FIELD!>0<!>; abstract get abstract set
var j: Int get() = i; abstract set
var j1: Int = <!PROPERTY_INITIALIZER_NO_BACKING_FIELD!>0<!>; get() = i; abstract set
var <!MUST_BE_INITIALIZED_OR_BE_ABSTRACT!>k<!>: Int abstract set
var k1: Int = 0; abstract set
var l: Int abstract get abstract set
var l1: Int = <!PROPERTY_INITIALIZER_NO_BACKING_FIELD!>0<!>; abstract get abstract set
var n: Int abstract get <!ABSTRACT_FUNCTION_WITH_BODY!>abstract<!> set(v: Int) {}
}
abstract enum class MyAbstractEnum() {}
namespace MyNamespace {
//properties
val <!MUST_BE_INITIALIZED!>a<!>: Int
val a1: Int = 1
<!ABSTRACT_PROPERTY_NOT_IN_CLASS!>abstract<!> val a2: Int
<!ABSTRACT_PROPERTY_NOT_IN_CLASS!>abstract<!> val a3: Int = 1
var <!MUST_BE_INITIALIZED!>b<!>: Int private set
var b1: Int = 0; private set
<!ABSTRACT_PROPERTY_NOT_IN_CLASS!>abstract<!> var b2: Int private set
<!ABSTRACT_PROPERTY_NOT_IN_CLASS!>abstract<!> var b3: Int = 0; private set
var <!MUST_BE_INITIALIZED!>c<!>: Int set(v: Int) { $c = v }
var c1: Int = 0; set(v: Int) { $c1 = v }
<!ABSTRACT_PROPERTY_NOT_IN_CLASS!>abstract<!> var c2: Int set(v: Int) { $c2 = v }
<!ABSTRACT_PROPERTY_NOT_IN_CLASS!>abstract<!> var c3: Int = 0; set(v: Int) { $c3 = v }
val e: Int get() = a
val e1: Int = <!PROPERTY_INITIALIZER_NO_BACKING_FIELD!>0<!>; get() = a
<!ABSTRACT_PROPERTY_NOT_IN_CLASS!>abstract<!> val e2: Int get() = a
<!ABSTRACT_PROPERTY_NOT_IN_CLASS!>abstract<!> val e3: Int = 0; get() = a
//methods
fun <!NON_MEMBER_FUNCTION_NO_BODY!>f<!>()
fun g() {}
<!NON_MEMBER_ABSTRACT_FUNCTION!>abstract<!> fun h()
<!NON_MEMBER_ABSTRACT_FUNCTION!>abstract<!> fun j() {}
//property accessors
var i: Int <!NON_MEMBER_ABSTRACT_ACCESSOR!>abstract<!> get <!NON_MEMBER_ABSTRACT_ACCESSOR!>abstract<!> set
var i1: Int = <!PROPERTY_INITIALIZER_NO_BACKING_FIELD!>0<!>; <!NON_MEMBER_ABSTRACT_ACCESSOR!>abstract<!> get <!NON_MEMBER_ABSTRACT_ACCESSOR!>abstract<!> set
var j: Int get() = i; <!NON_MEMBER_ABSTRACT_ACCESSOR!>abstract<!> set
var j1: Int = <!PROPERTY_INITIALIZER_NO_BACKING_FIELD!>0<!>; get() = i; <!NON_MEMBER_ABSTRACT_ACCESSOR!>abstract<!> set
var <!MUST_BE_INITIALIZED!>k<!>: Int <!NON_MEMBER_ABSTRACT_ACCESSOR!>abstract<!> set
var k1: Int = 0; <!NON_MEMBER_ABSTRACT_ACCESSOR!>abstract<!> set
var l: Int <!NON_MEMBER_ABSTRACT_ACCESSOR!>abstract<!> get <!NON_MEMBER_ABSTRACT_ACCESSOR!>abstract<!> set
var l1: Int = <!PROPERTY_INITIALIZER_NO_BACKING_FIELD!>0<!>; <!NON_MEMBER_ABSTRACT_ACCESSOR!>abstract<!> get <!NON_MEMBER_ABSTRACT_ACCESSOR!>abstract<!> set
var n: Int <!NON_MEMBER_ABSTRACT_ACCESSOR!>abstract<!> get <!NON_MEMBER_ABSTRACT_ACCESSOR!>abstract<!> set(v: Int) {}
}
//creating an instance
abstract class B1(
val i: Int,
val s: String
) {
}
class B2() : B1(1, "r") {}
abstract class B3(i: Int) {
this(): this(1)
}
fun foo(a: B3) {
val a = <!CREATING_AN_INSTANCE_OF_ABSTRACT_CLASS!>B3()<!>
val b = <!CREATING_AN_INSTANCE_OF_ABSTRACT_CLASS!>B1(2, "s")<!>
}
@@ -1,34 +0,0 @@
class NoC {
<!ANONYMOUS_INITIALIZER_WITHOUT_CONSTRUCTOR!>{
}<!>
val a : Int get() = 1
<!ANONYMOUS_INITIALIZER_WITHOUT_CONSTRUCTOR!>{
}<!>
}
class WithC() {
val x : Int
{
$x = 1
<!UNRESOLVED_REFERENCE!>$y<!> = 2
val b = x
}
val a : Int get() = 1
{
val z = <!UNRESOLVED_REFERENCE!>b<!>
val zz = x
val zzz = <!NO_BACKING_FIELD!>$a<!>
}
this(a : Int) : this() {
val b = x
}
}
@@ -1,41 +0,0 @@
class A() {
fun equals(a : Any?) : Boolean = false
}
class B() {
fun equals(a : Any?) : Boolean? = false
}
class C() {
fun equals(a : Any?) : Int = 0
}
fun f(): Unit {
var x: Int? = 1
x = 1
x <!UNSAFE_INFIX_CALL!>+<!> 1
x <!UNSAFE_INFIX_CALL!>plus<!> 1
x <!UNSAFE_INFIX_CALL!><<!> 1
x <!UNSAFE_INFIX_CALL!>+=<!> 1
x == 1
x != 1
<!EQUALITY_NOT_APPLICABLE!>A() == 1<!>
B() <!RESULT_TYPE_MISMATCH!>==<!> 1
C() <!RESULT_TYPE_MISMATCH!>==<!> 1
<!EQUALITY_NOT_APPLICABLE!>x === "1"<!>
<!EQUALITY_NOT_APPLICABLE!>x !== "1"<!>
x === 1
x !== 1
x<!UNSAFE_INFIX_CALL!>..<!>2
<!TYPE_MISMATCH!>x<!> in 1..2
val y : Boolean? = true
false || <!TYPE_MISMATCH!>y<!>
<!TYPE_MISMATCH!>y<!> && true
<!TYPE_MISMATCH!>y<!> && <!TYPE_MISMATCH!>1<!>
}
@@ -1,40 +0,0 @@
namespace boundsWithSubstitutors {
open class A<T>
class B<X : A<X>>()
class C : A<C>
val a = B<C>()
val a1 = B<<!UPPER_BOUND_VIOLATED!>Int<!>>()
class X<A, B : A>()
val b = X<Any, X<A<C>, C>>
val b0 = X<Any, <!UPPER_BOUND_VIOLATED!>Any?<!>>
val b1 = X<Any, X<A<C>, <!UPPER_BOUND_VIOLATED!>String<!>>>
}
open class A {}
open class B<T : A>()
abstract class C<T : B<<!UPPER_BOUND_VIOLATED!>Int<!>>, X : fun (B<<!UPPER_BOUND_VIOLATED!>Char<!>>) : (B<<!UPPER_BOUND_VIOLATED!>Any<!>>, B<A>)>() : B<<!UPPER_BOUND_VIOLATED, UPPER_BOUND_VIOLATED!>Any<!>>() { // 2 errors
val a = B<<!UPPER_BOUND_VIOLATED!>Char<!>>() // error
abstract val x : fun (B<<!UPPER_BOUND_VIOLATED!>Char<!>>) : B<<!UPPER_BOUND_VIOLATED!>Any<!>>
}
fun test() {
foo<<!UPPER_BOUND_VIOLATED!>Int?<!>>()
foo<Int>()
bar<Int?>()
bar<Int>()
bar<<!UPPER_BOUND_VIOLATED!>Double?<!>>()
bar<<!UPPER_BOUND_VIOLATED!>Double<!>>()
1.buzz<<!UPPER_BOUND_VIOLATED!>Double<!>>()
}
fun foo<T : Any>() {}
fun bar<T : Int?>() {}
fun <T : <!FINAL_UPPER_BOUND!>Int<!>> Int.buzz() : Unit {}
@@ -1,28 +0,0 @@
class C {
fun f (a : Boolean, b : Boolean) {
@b (while (true)
@a {
<!NOT_A_LOOP_LABEL!>break@f<!>
break
break@b
<!NOT_A_LOOP_LABEL!>break@a<!>
})
<!BREAK_OR_CONTINUE_OUTSIDE_A_LOOP!>continue<!>
@b (while (true)
@a {
<!NOT_A_LOOP_LABEL!>continue@f<!>
continue
continue@b
<!NOT_A_LOOP_LABEL!>continue@a<!>
})
<!BREAK_OR_CONTINUE_OUTSIDE_A_LOOP!>break<!>
<!NOT_A_LOOP_LABEL!>continue@f<!>
<!NOT_A_LOOP_LABEL!>break@f<!>
}
}
@@ -1,121 +0,0 @@
import <!UNRESOLVED_REFERENCE!>java<!>.util.*
namespace html {
abstract class Factory<T> {
abstract fun create() : T
}
abstract class Element
class TextElement(val text : String) : Element
abstract class Tag(val name : String) : Element {
val children = ArrayList<Element>()
val attributes = HashMap<String, String>()
protected fun initTag<T : Element>(init : fun T.() : Unit) : T
where class object T : Factory<T>{
val tag = T.create()
tag.init()
children.add(tag)
return tag
}
}
abstract class TagWithText(name : String) : Tag(name) {
fun String.plus() {
children.add(<!OVERLOAD_RESOLUTION_AMBIGUITY!>TextElement(this)<!>)
}
}
class HTML() : TagWithText("html") {
class object : Factory<HTML> {
override fun create() = <!OVERLOAD_RESOLUTION_AMBIGUITY!>HTML()<!>
}
fun head(init : fun Head.() : Unit) = <!OVERLOAD_RESOLUTION_AMBIGUITY!>initTag<Head>(init)<!>
fun body(init : fun Body.() : Unit) = <!OVERLOAD_RESOLUTION_AMBIGUITY!>initTag<Body>(init)<!>
}
class Head() : TagWithText("head") {
class object : Factory<Head> {
override fun create() = <!OVERLOAD_RESOLUTION_AMBIGUITY!>Head()<!>
}
fun title(init : fun Title.() : Unit) = <!OVERLOAD_RESOLUTION_AMBIGUITY!>initTag<Title>(init)<!>
}
class Title() : TagWithText("title")
abstract class BodyTag(name : String) : TagWithText(name) {
}
class Body() : BodyTag("body") {
class object : Factory<Body> {
override fun create() = <!OVERLOAD_RESOLUTION_AMBIGUITY!>Body()<!>
}
fun b(init : fun B.() : Unit) = <!OVERLOAD_RESOLUTION_AMBIGUITY!>initTag<B>(init)<!>
fun p(init : fun P.() : Unit) = <!OVERLOAD_RESOLUTION_AMBIGUITY!>initTag<P>(init)<!>
fun h1(init : fun H1.() : Unit) = <!OVERLOAD_RESOLUTION_AMBIGUITY!>initTag<H1>(init)<!>
fun a(href : String, init : fun A.() : Unit) {
val a = <!OVERLOAD_RESOLUTION_AMBIGUITY!>initTag<A>(init)<!>
a.href = href
}
}
class B() : BodyTag("b")
class P() : BodyTag("p")
class H1() : BodyTag("h1")
class A() : BodyTag("a") {
var href : String
get() = attributes["href"]
set(value) { attributes["href"] = value }
}
fun Map<String, String>.set(key : String, value : String) = this.put(key, value)
fun html(init : fun HTML.() : Unit) : HTML {
val html = <!OVERLOAD_RESOLUTION_AMBIGUITY!>HTML()<!>
html.init()
return html
}
}
namespace foo {
import html.*
fun result(args : Array<String>) =
<!OVERLOAD_RESOLUTION_AMBIGUITY!>html {
<!OVERLOAD_RESOLUTION_AMBIGUITY!>head {
<!OVERLOAD_RESOLUTION_AMBIGUITY!>title {<!NO_VALUE_FOR_PARAMETER!>+<!>"XML encoding with Groovy"}<!>
}<!>
<!OVERLOAD_RESOLUTION_AMBIGUITY!>body {
<!OVERLOAD_RESOLUTION_AMBIGUITY!>h1 {<!NO_VALUE_FOR_PARAMETER!>+<!>"XML encoding with Groovy"}<!>
<!OVERLOAD_RESOLUTION_AMBIGUITY!>p {<!NO_VALUE_FOR_PARAMETER!>+<!>"this format can be used as an alternative markup to XML"}<!>
// an element with attributes and text content
<!OVERLOAD_RESOLUTION_AMBIGUITY!>a(href = "http://groovy.codehaus.org") {<!NO_VALUE_FOR_PARAMETER!>+<!>"Groovy"}<!>
// mixed content
<!OVERLOAD_RESOLUTION_AMBIGUITY!>p {
<!NO_VALUE_FOR_PARAMETER!>+<!>"This is some"
<!OVERLOAD_RESOLUTION_AMBIGUITY!>b {<!NO_VALUE_FOR_PARAMETER!>+<!>"mixed"}<!>
<!NO_VALUE_FOR_PARAMETER!>+<!>"text. For more see the"
<!OVERLOAD_RESOLUTION_AMBIGUITY!>a(href = "http://groovy.codehaus.org") {<!NO_VALUE_FOR_PARAMETER!>+<!>"Groovy"}<!>
<!NO_VALUE_FOR_PARAMETER!>+<!>"project"
}<!>
<!OVERLOAD_RESOLUTION_AMBIGUITY!>p {<!NO_VALUE_FOR_PARAMETER!>+<!>"some text"}<!>
// content generated by
<!OVERLOAD_RESOLUTION_AMBIGUITY!>p {
for (arg in args)
<!NO_VALUE_FOR_PARAMETER!>+<!>arg
}<!>
}<!>
}<!>
}
@@ -1,16 +0,0 @@
fun test() : Unit {
var x : Int? = 0
var y : Int = 0
x : Int?
y : Int
x as Int : Int
y <!USELESS_CAST!>as<!> Int : Int
x <!USELESS_CAST!>as<!> Int? : Int?
y <!USELESS_CAST_STATIC_ASSERT_IS_FINE!>as<!> Int? : Int?
x as? Int : Int?
y <!USELESS_CAST!>as?<!> Int : Int?
x <!USELESS_CAST!>as?<!> Int? : Int?
y <!USELESS_CAST_STATIC_ASSERT_IS_FINE!>as?<!> Int? : Int?
()
}
@@ -1,30 +0,0 @@
namespace Jet86
class A {
class object {
val x = 1
}
<!MANY_CLASS_OBJECTS!>class object { // error
val x = 1
}<!>
}
class B() {
val x = 12
}
object b {
<!CLASS_OBJECT_NOT_ALLOWED!>class object {
val x = 1
}<!> // error
}
val a = A.x
val c = <!NO_CLASS_OBJECT!>B<!>.x
val d = b.<!UNRESOLVED_REFERENCE!>x<!>
val s = <!UNRESOLVED_REFERENCE!>System<!> // error
fun test() {
<!UNRESOLVED_REFERENCE!>System<!>.out<!UNNECESSARY_SAFE_CALL!>?.<!>println()
<!UNRESOLVED_REFERENCE!>java<!>.lang.System.out<!UNNECESSARY_SAFE_CALL!>?.<!>println()
}
@@ -1,8 +0,0 @@
fun test() {
1 : Byte
1 : Int
<!TYPE_MISMATCH, TYPE_MISMATCH!>1<!> : Double
1 <!USELESS_CAST!>as<!> Byte
1 <!USELESS_CAST!>as<!> Int
<!ERROR_COMPILE_TIME_VALUE!>1<!> <!CAST_NEVER_SUCCEEDS!>as<!> Double
}
@@ -1,30 +0,0 @@
open trait A {
fun foo() {}
}
open trait B : A, <!CYCLIC_INHERITANCE_HIERARCHY!>E<!> {}
open trait C : B {}
open trait D : <!CYCLIC_INHERITANCE_HIERARCHY!>B<!> {}
open trait E : <!CYCLIC_INHERITANCE_HIERARCHY!>F<!> {}
open trait F : <!CYCLIC_INHERITANCE_HIERARCHY!>D<!>, C {}
open trait G : F {}
open trait H : F {}
val a : A? = null
val b : B? = null
val c : C? = null
val d : D? = null
val e : E? = null
val f : F? = null
val g : G? = null
val h : H? = null
fun test() {
a?.foo()
b?.foo()
c?.foo()
d?.foo()
e?.<!UNRESOLVED_REFERENCE!>foo<!>()
f?.foo()
g?.foo()
h?.foo()
}
@@ -1,10 +0,0 @@
enum class List<out T>(val size : Int) {
Nil : List<Nothing>(0) {
val a = 1
}
Cons<out T>(val head : T, val tail : List<T>) : List<T>(tail.size + 1)
}
val foo = List.Nil
val foo1 = foo.a
@@ -1,71 +0,0 @@
fun Int?.optint() : Unit {}
val Int?.optval : Unit = ()
fun <T, E> T.foo(x : E, y : A) : T {
y.plus(1)
y plus 1
y + 1.0
this<!UNNECESSARY_SAFE_CALL!>?.<!>minus<T>(this)
return this
}
class A
fun A.plus(a : Any) {
1.foo()
true.<!NONE_APPLICABLE!>foo()<!>
1
}
fun A.plus(a : Int) {
1
}
fun <T> T.minus(t : T) : Int = 1
fun test() {
val y = 1.abs
}
val Int.abs : Int
get() = if (this > 0) this else -this;
val <T> T.<!MUST_BE_INITIALIZED!>foo<!> : T
fun Int.foo() = this
namespace null_safety {
fun parse(cmd: String): Command? { return null }
class Command() {
// fun equals(other : Any?) : Boolean
val foo : Int = 0
}
fun Any.equals(other : Any?) : Boolean = true
fun Any?.equals1(other : Any?) : Boolean = true
fun Any.equals2(other : Any?) : Boolean = true
fun main(args: Array<String>) {
<!UNRESOLVED_REFERENCE!>System<!>.out<!UNNECESSARY_SAFE_CALL!>?.<!>print(1)
val command = parse("")
command<!UNSAFE_CALL!>.<!>foo
command.equals(null)
command<!UNNECESSARY_SAFE_CALL!>?.<!>equals(null)
command.equals1(null)
command<!UNNECESSARY_SAFE_CALL!>?.<!>equals1(null)
val c = Command()
c<!UNNECESSARY_SAFE_CALL!>?.<!>equals2(null)
if (command == null) 1
}
}
@@ -1,80 +0,0 @@
import <!UNRESOLVED_REFERENCE!>java<!>.util.*;
class NotRange1() {
}
abstract class NotRange2() {
abstract fun iterator() : Unit
}
abstract class ImproperIterator1 {
abstract fun hasNext() : Boolean
}
abstract class NotRange3() {
abstract fun iterator() : ImproperIterator1
}
abstract class ImproperIterator2 {
abstract fun next() : Boolean
}
abstract class NotRange4() {
abstract fun iterator() : ImproperIterator2
}
abstract class ImproperIterator3 {
abstract fun hasNext() : Int
abstract fun next() : Int
}
abstract class NotRange5() {
abstract fun iterator() : ImproperIterator3
}
abstract class AmbiguousHasNextIterator {
abstract fun hasNext() : Boolean
val hasNext : Boolean get() = false
abstract fun next() : Int
}
abstract class NotRange6() {
abstract fun iterator() : AmbiguousHasNextIterator
}
abstract class ImproperIterator4 {
val hasNext : Int get() = 1
abstract fun next() : Int
}
abstract class NotRange7() {
abstract fun iterator() : ImproperIterator3
}
abstract class GoodIterator {
abstract fun hasNext() : Boolean
abstract fun next() : Int
}
abstract class Range0() {
abstract fun iterator() : GoodIterator
}
abstract class Range1() {
abstract fun iterator() : Iterator<Int>
}
fun test(notRange1: NotRange1, notRange2: NotRange2, notRange3: NotRange3, notRange4: NotRange4, notRange5: NotRange5, notRange6: NotRange6, notRange7: NotRange7, range0: Range0, range1: Range1) {
for (i in <!ITERATOR_MISSING!>notRange1<!>);
for (i in <!HAS_NEXT_MISSING, NEXT_MISSING!>notRange2<!>);
for (i in <!NEXT_MISSING!>notRange3<!>);
for (i in <!HAS_NEXT_MISSING!>notRange4<!>);
for (i in <!HAS_NEXT_FUNCTION_TYPE_MISMATCH!>notRange5<!>);
for (i in <!HAS_NEXT_PROPERTY_AND_FUNCTION_AMBIGUITY!>notRange6<!>);
for (i in <!HAS_NEXT_FUNCTION_TYPE_MISMATCH!>notRange7<!>);
for (i in range0);
for (i in range1);
for (i in (ArrayList<Int>() : List<Int>));
}
@@ -1,166 +0,0 @@
fun none() {}
fun unitEmptyInfer() {}
fun unitEmpty() : Unit {}
fun unitEmptyReturn() : Unit {return}
fun unitIntReturn() : Unit {return <!TYPE_MISMATCH!>1<!>}
fun unitUnitReturn() : Unit {return ()}
fun test1() : Any = {<!RETURN_NOT_ALLOWED, RETURN_IN_FUNCTION_WITH_EXPRESSION_BODY!>return<!>}
fun test2() : Any = @a {return@a 1}
fun test3() : Any { <!RETURN_TYPE_MISMATCH!>return<!> }
fun bbb() {
return <!TYPE_MISMATCH!>1<!>
}
fun foo(expr: <!UNRESOLVED_REFERENCE!>StringBuilder<!>): Int {
val c = 'a'
when(c) {
0.chr => throw <!UNRESOLVED_REFERENCE!>Exception<!>("zero")
else => throw <!UNRESOLVED_REFERENCE!>Exception<!>("nonzero" + c)
}
}
fun unitShort() : Unit = ()
fun unitShortConv() : Unit = <!TYPE_MISMATCH!>1<!>
fun unitShortNull() : Unit = <!TYPE_MISMATCH!>null<!>
fun intEmpty() : Int <!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>{}<!>
fun intShortInfer() = 1
fun intShort() : Int = 1
//fun intBlockInfer() {1}
fun intBlock() : Int {return 1}
fun intBlock() : Int {<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>1<!>}
fun intString(): Int = <!TYPE_MISMATCH!>"s"<!>
fun intFunctionLiteral(): Int = <!TYPE_MISMATCH!>{ 10 }<!>
fun blockReturnUnitMismatch() : Int {<!RETURN_TYPE_MISMATCH!>return<!>}
fun blockReturnValueTypeMismatch() : Int {return <!ERROR_COMPILE_TIME_VALUE!>3.4<!>}
fun blockReturnValueTypeMatch() : Int {return 1}
fun blockReturnValueTypeMismatchUnit() : Int {return <!TYPE_MISMATCH!>()<!>}
fun blockAndAndMismatch() : Int {
<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>true && false<!>
}
fun blockAndAndMismatch() : Int {
return <!TYPE_MISMATCH!>true && false<!>
}
fun blockAndAndMismatch() : Int {
<!UNREACHABLE_CODE!>(return <!ERROR_COMPILE_TIME_VALUE!>true<!>) && (return <!ERROR_COMPILE_TIME_VALUE!>false<!>)<!>
}
fun blockAndAndMismatch() : Int {
<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>true || false<!>
}
fun blockAndAndMismatch() : Int {
return <!TYPE_MISMATCH!>true || false<!>
}
fun blockAndAndMismatch() : Int {
<!UNREACHABLE_CODE!>(return <!ERROR_COMPILE_TIME_VALUE!>true<!>) || (return <!ERROR_COMPILE_TIME_VALUE!>false<!>)<!>
}
fun blockReturnValueTypeMatch() : Int {
return if (1 > 2) <!ERROR_COMPILE_TIME_VALUE!>1.0<!> else <!ERROR_COMPILE_TIME_VALUE!>2.0<!>
}
fun blockReturnValueTypeMatch() : Int {
return <!TYPE_MISMATCH!>if (1 > 2) 1<!>
}
fun blockReturnValueTypeMatch() : Int {
return <!TYPE_MISMATCH!>if (1 > 2) else 1<!>
}
fun blockReturnValueTypeMatch() : Int {
if (1 > 2)
return <!ERROR_COMPILE_TIME_VALUE!>1.0<!>
else return <!ERROR_COMPILE_TIME_VALUE!>2.0<!>
}
fun blockReturnValueTypeMatch() : Int {
if (1 > 2)
return <!ERROR_COMPILE_TIME_VALUE!>1.0<!>
return <!ERROR_COMPILE_TIME_VALUE!>2.0<!>
}
fun blockReturnValueTypeMatch() : Int {
if (1 > 2)
else return <!ERROR_COMPILE_TIME_VALUE!>1.0<!>
return <!ERROR_COMPILE_TIME_VALUE!>2.0<!>
}
fun blockReturnValueTypeMatch() : Int {
if (1 > 2)
<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>1.0<!>
else <!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>2.0<!>
}
fun blockReturnValueTypeMatch() : Int {
if (1 > 2)
1.0
else 2.0
return 1
}
fun blockReturnValueTypeMatch() : Int {
<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>if (1 > 2)
<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>1.0<!><!>
}
fun blockReturnValueTypeMatch() : Int {
return <!TYPE_MISMATCH!>if (1 > 2)
1<!>
}
fun blockReturnValueTypeMatch() : Int {
<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>if (1 > 2)
else <!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>1.0<!><!>
}
fun blockReturnValueTypeMatch() : Int {
if (1 > 2)
return 1
else return <!ERROR_COMPILE_TIME_VALUE!>1.0<!>
}
fun blockNoReturnIfValDeclaration(): Int {
<!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>val x = 1<!>
}
fun blockNoReturnIfEmptyIf(): Int {
if (1 < 2) <!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>{}<!> else <!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>{}<!>
}
fun blockNoReturnIfUnitInOneBranch(): Int {
if (1 < 2) {
return 1
} else {
if (3 < 4) <!NO_RETURN_IN_FUNCTION_WITH_BLOCK_BODY!>{
}<!> else {
return 2
}
}
}
fun nonBlockReturnIfEmptyIf(): Int = if (1 < 2) <!TYPE_MISMATCH!>{}<!> else <!TYPE_MISMATCH!>{}<!>
fun nonBlockNoReturnIfUnitInOneBranch(): Int = if (1 < 2) <!TYPE_MISMATCH!>{}<!> else 2
val a = <!RETURN_NOT_ALLOWED!>return 1<!>
class A() {
this(a : Int) : this() {
if (a == 1)
return
return <!TYPE_MISMATCH!>1<!>
}
}
fun illegalConstantBody(): Int = <!TYPE_MISMATCH!>"s"<!>
fun illegalConstantBlock(): String {
return <!ERROR_COMPILE_TIME_VALUE!>1<!>
}
fun illegalIfBody(): Int =
if (1 < 2) <!ERROR_COMPILE_TIME_VALUE!>'a'<!> else { <!ERROR_COMPILE_TIME_VALUE!>1.0<!> }
fun illegalIfBlock(): Boolean {
if (1 < 2)
return false
else { return <!ERROR_COMPILE_TIME_VALUE!>1<!> }
}
fun illegalReturnIf(): Char {
return if (1 < 2) 'a' else { <!ERROR_COMPILE_TIME_VALUE!>1<!> }
}
fun returnNothing(): Nothing {
throw 1
}
fun f(): Int {
if (1 < 2) { return 1 } else returnNothing()
}
fun f(): Int = if (1 < 2) 1 else returnNothing()
@@ -1,42 +0,0 @@
trait A<in T> {}
trait B<T> : A<Int> {}
trait C<T> : <!INCONSISTENT_TYPE_PARAMETER_VALUES!>B<T>, A<T><!> {}
trait C1<T> : B<T>, A<Any> {}
trait D : <!INCONSISTENT_TYPE_PARAMETER_VALUES, INCONSISTENT_TYPE_PARAMETER_VALUES!>C<Boolean>, B<Double><!>{}
trait A1<out T> {}
trait B1 : A1<Int> {}
trait B2 : A1<Any>, B1 {}
trait BA1<T> {}
trait BB1 : BA1<Int> {}
trait BB2 : <!INCONSISTENT_TYPE_PARAMETER_VALUES!>BA1<Any>, BB1<!> {}
namespace x {
trait AA1<out T> {}
trait AB1 : AA1<Int> {}
trait AB3 : AA1<Comparable<Int>> {}
trait AB2 : AA1<Number>, AB1, AB3 {}
}
namespace x2 {
trait AA1<out T> {}
trait AB1 : AA1<Any> {}
trait AB3 : AA1<Comparable<Int>> {}
trait AB2 : <!INCONSISTENT_TYPE_PARAMETER_VALUES!>AA1<Number>, AB1, AB3<!> {}
}
namespace x3 {
trait AA1<in T> {}
trait AB1 : AA1<Any> {}
trait AB3 : AA1<Comparable<Int>> {}
trait AB2 : AA1<Number>, AB1, AB3 {}
}
namespace sx2 {
trait AA1<in T> {}
trait AB1 : AA1<Int> {}
trait AB3 : AA1<Comparable<Int>> {}
trait AB2 : <!INCONSISTENT_TYPE_PARAMETER_VALUES!>AA1<Number>, AB1, AB3<!> {}
}
@@ -1,46 +0,0 @@
class IncDec() {
fun inc() : IncDec = this
fun dec() : IncDec = this
}
fun testIncDec() {
var x = IncDec()
x++
++x
x--
--x
x = x++
x = x--
x = ++x
x = --x
}
class WrongIncDec() {
fun inc() : Int = 1
fun dec() : Int = 1
}
fun testWrongIncDec() {
var x = WrongIncDec()
x<!RESULT_TYPE_MISMATCH!>++<!>
<!RESULT_TYPE_MISMATCH!>++<!>x
x<!RESULT_TYPE_MISMATCH!>--<!>
<!RESULT_TYPE_MISMATCH!>--<!>x
}
class UnitIncDec() {
fun inc() : Unit {}
fun dec() : Unit {}
}
fun testUnitIncDec() {
var x = UnitIncDec()
x++
++x
x--
--x
x = <!TYPE_MISMATCH!>x++<!>
x = <!TYPE_MISMATCH!>x--<!>
x = <!TYPE_MISMATCH!>++x<!>
x = <!TYPE_MISMATCH!>--x<!>
}
@@ -1,7 +0,0 @@
fun test() {
if (1 is Int) {
if (1 is <!INCOMPATIBLE_TYPES!>Boolean<!>) {
}
}
}
@@ -1,72 +0,0 @@
namespace Jet87
open class A() {
fun foo() : Int = 1
}
trait B {
fun bar() : Double = 1.0;
}
class C() : A(), B
class D() {
class object : A(), B {}
}
class Test1<T : A>()
where
T : B,
<!NAME_IN_CONSTRAINT_IS_NOT_A_TYPE_PARAMETER!>B<!> : T, // error
class object T : A,
class object T : B,
class object <!NAME_IN_CONSTRAINT_IS_NOT_A_TYPE_PARAMETER!>B<!> : T
{
fun test(t : T) {
T.foo()
T.bar()
t.foo()
t.bar()
}
}
fun test() {
Test1<<!UPPER_BOUND_VIOLATED!>B<!>>()
Test1<<!UPPER_BOUND_VIOLATED!>A<!>>()
Test1<C>()
}
class Foo() {}
class Bar<T : <!FINAL_UPPER_BOUND!>Foo<!>>
class Buzz<T> where T : <!FINAL_UPPER_BOUND!>Bar<<!UPPER_BOUND_VIOLATED!>Int<!>><!>, T : <!UNRESOLVED_REFERENCE!>nioho<!>
class X<T : <!FINAL_UPPER_BOUND!>Foo<!>>
class Y<<!CONFLICTING_UPPER_BOUNDS!>T<!> : <!FINAL_UPPER_BOUND!>Foo<!>> where T : <!FINAL_UPPER_BOUND!>Bar<Foo><!>
fun <T : A> test2(t : T)
where
T : B,
<!NAME_IN_CONSTRAINT_IS_NOT_A_TYPE_PARAMETER!>B<!> : T,
class object <!NAME_IN_CONSTRAINT_IS_NOT_A_TYPE_PARAMETER!>B<!> : T,
class object T : B,
class object T : A
{
T.foo()
T.bar()
t.foo()
t.bar()
}
val t1 = test2<<!UPPER_BOUND_VIOLATED!>A<!>>(A())
val t2 = test2<<!UPPER_BOUND_VIOLATED!>B<!>>(C())
val t3 = test2<C>(C())
class Test<<!CONFLICTING_CLASS_OBJECT_UPPER_BOUNDS!>T<!>>
where
class object T : <!FINAL_CLASS_OBJECT_UPPER_BOUND!>Foo<!>,
class object T : A {}
val <T, B : T> x : Int = 0
@@ -1,8 +0,0 @@
namespace root
namespace a {
}
val x = <!EXPRESSION_EXPECTED_NAMESPACE_FOUND, UNRESOLVED_REFERENCE!>a<!>
val y2 = <!NAMESPACE_IS_NOT_AN_EXPRESSION!>namespace<!>
@@ -1,63 +0,0 @@
namespace foobar
namespace a {
import <!UNRESOLVED_REFERENCE!>java<!>.*
val a : <!UNRESOLVED_REFERENCE!>util<!>.List<Int>? = null
val a1 : <!UNRESOLVED_REFERENCE!>List<!><Int>? = null
}
abstract class Foo<T>() {
abstract val x : T<Int>
}
namespace a {
import <!UNRESOLVED_REFERENCE!>java<!>.util.*
val b : List<Int>? = a
val b1 : util.List<Int>? = a
}
val x1 = a.a
val y1 = a.b
/////////////////////////////////////////////////////////////////////////
fun done<O>(result : O) : Iteratee<Any?, O> = StrangeIterateeImpl<Any?, O>(result)
abstract class Iteratee<in I, out O> {
abstract fun process(item : I) : Iteratee<I, O>
abstract val isDone : Boolean
abstract val result : O
abstract fun done() : O
}
class StrangeIterateeImpl<in I, out O>(val obj: O) : Iteratee<I, O> {
override fun process(item: I): Iteratee<I, O> = StrangeIterateeImpl<I, O>(obj)
override val isDone = true
override val result = obj
override fun done() = obj
}
abstract class Sum() : Iteratee<Int, Int> {
override fun process(item : Int) : Iteratee<Int, Int> {
return foobar.done<Int>(item);
}
abstract override val isDone : Boolean
abstract override val result : Int
abstract override fun done() : Int
}
abstract class Collection<E> : Iterable<E> {
fun iterate<O>(iteratee : Iteratee<E, O>) : O {
for (x in this) {
val it = iteratee.process(x)
if (it.isDone) return it.result
iteratee = it
}
return iteratee.done()
}
}
@@ -1,280 +0,0 @@
fun test() {
val a : Int? = 0
if (a != null) {
a.plus(1)
}
else {
a?.plus(1)
}
val out : <!UNRESOLVED_REFERENCE!>java<!>.io.PrintStream? = null//= System.out
val ins = <!UNRESOLVED_REFERENCE!>System<!>.`in`
out?.println()
ins<!UNNECESSARY_SAFE_CALL!>?.<!>read()
if (ins != null) {
ins.read()
out?.println()
if (out != null) {
ins.read();
out.println();
}
}
if (out != null && ins != null) {
ins.read();
out.println();
}
if (out == null) {
out?.println()
} else {
out.println()
}
if (out != null && ins != null || out != null) {
ins<!UNNECESSARY_SAFE_CALL!>?.<!>read();
out.println();
}
if (out == null || out.println(0) == ()) {
out?.println(1)
}
else {
out.println(2)
}
if (out != null && out.println() == ()) {
out.println();
}
else {
out?.println();
}
if (out == null || out != null && out.println() == ()) {
out?.println();
}
else {
out.println();
}
if (1 == 2 || out != null && out.println(1) == ()) {
out?.println(2);
}
else {
out?.println(3)
}
out?.println()
ins<!UNNECESSARY_SAFE_CALL!>?.<!>read()
if (ins != null) {
ins.read()
out?.println()
if (out != null) {
ins.read();
out.println();
}
}
if (out != null && ins != null) {
ins.read();
out.println();
}
if (out == null) {
out?.println()
} else {
out.println()
}
if (out != null && ins != null || out != null) {
ins<!UNNECESSARY_SAFE_CALL!>?.<!>read();
out.println();
}
if (out == null || out.println(0) == ()) {
out?.println(1)
}
else {
out.println(2)
}
if (out != null && out.println() == ()) {
out.println();
}
else {
out?.println();
}
if (out == null || out != null && out.println() == ()) {
out?.println();
}
else {
out.println();
}
if (1 == 2 || out != null && out.println(1) == ()) {
out?.println(2);
}
else {
out?.println(3)
}
if (1 > 2) {
if (out == null) return;
out.println();
}
out?.println();
while (out != null) {
out.println();
}
out?.println();
while (out == null) {
out?.println();
}
out.println()
}
fun f(out : String?) {
out?.get(0)
if (out != null) else return;
out.get(0)
}
fun f1(out : String?) {
out?.get(0)
if (out != null) else {
1 + 2
return;
}
out.get(0)
}
fun f2(out : String?) {
out?.get(0)
if (out == null) {
1 + 2
return;
}
out.get(0)
}
fun f3(out : String?) {
out?.get(0)
if (out == null) {
1 + 2
return;
}
else {
1 + 2
}
out.get(0)
}
fun f4(s : String?) {
s?.get(0)
while (1 < 2 && s != null) {
s.get(0)
}
s?.get(0)
while (s == null || 1 < 2) {
s?.get(0)
}
s.get(0)
}
fun f5(s : String?) {
s?.get(0)
while (1 < 2 && s != null) {
s.get(0)
}
s?.get(0)
while (s == null || 1 < 2) {
if (1 > 2) break
s?.get(0)
}
s?.get(0);
}
fun f6(s : String?) {
s?.get(0)
do {
s?.get(0)
if (1 < 2) break;
} while (s == null)
s?.get(0)
do {
s?.get(0)
} while (s == null)
s.get(0)
}
fun f7(s : String?, t : String?) {
s?.get(0)
if (!(s == null)) {
s.get(0)
}
s?.get(0)
if (!(s != null)) {
s?.get(0)
}
else {
s.get(0)
}
s?.get(0)
if (!!(s != null)) {
s.get(0)
}
else {
s?.get(0)
}
s?.get(0)
t?.get(0)
if (!(s == null || t == null)) {
s.get(0)
t.get(0)
}
else {
s?.get(0)
t?.get(0)
}
s?.get(0)
t?.get(0)
if (!(s == null && s == null)) {
s.get(0)
t?.get(0)
}
else {
s?.get(0)
t?.get(0)
}
}
fun f8(b : String?, a : String) {
b?.get(0)
if (b == a) {
b.get(0);
}
b?.get(0)
if (a == b) {
b.get(0)
}
if (a != b) {
b?.get(0)
}
else {
b.get(0)
}
}
fun f9(a : Int?) : Int {
if (a != null)
return a
return 1
}
@@ -1,83 +0,0 @@
namespace toplevelObjectDeclarations {
open class Foo(y : Int) {
open fun foo() : Int = 1
}
class T : <!SUPERTYPE_NOT_INITIALIZED!>Foo<!> {}
object A : <!SUPERTYPE_NOT_INITIALIZED!>Foo<!> {
val x : Int = 2
fun test() : Int {
return x + foo()
}
}
object B : <!UNRESOLVED_REFERENCE!>A<!> {}
val x = A.foo()
val y = object : Foo(x) {
{
x + 12
}
override fun foo() : Int = 1
}
val z = y.foo()
}
namespace nestedObejcts {
object A {
val b = B
val d = A.B.A
object B {
val a = A
val e = B.A
object A {
val a = A
val b = B
val x = nestedObejcts.A.B.A
val y = this<!AMBIGUOUS_LABEL!>@A<!>
}
}
}
object B {
val b = B
val c = A.B
}
val a = A
val b = B
val c = A.B
val d = A.B.A
val e = B.<!UNRESOLVED_REFERENCE!>A<!>.B
}
namespace localObjects {
object A {
val x : Int = 0
}
open class Foo {
fun foo() : Int = 1
}
fun test() {
A.x
val b = object : Foo {
}
b.foo()
object B {
fun foo() {}
}
B.foo()
}
val bb = <!UNRESOLVED_REFERENCE!>B<!>.foo()
}
@@ -1,76 +0,0 @@
namespace override
namespace normal {
trait MyTrait {
fun foo()
}
abstract class MyAbstractClass {
abstract fun bar()
}
open class MyClass : MyTrait, MyAbstractClass {
override fun foo() {}
override fun bar() {}
}
class MyChildClass : MyClass {}
class <!ABSTRACT_METHOD_NOT_IMPLEMENTED!>MyIllegalClass<!> : MyTrait, MyAbstractClass {}
class <!ABSTRACT_METHOD_NOT_IMPLEMENTED!>MyIllegalClass2<!> : MyTrait, MyAbstractClass {
override fun foo() {}
}
class <!ABSTRACT_METHOD_NOT_IMPLEMENTED!>MyIllegalClass3<!> : MyTrait, MyAbstractClass {
override fun bar() {}
}
class <!ABSTRACT_METHOD_NOT_IMPLEMENTED!>MyIllegalClass4<!> : MyTrait, MyAbstractClass {
fun <!VIRTUAL_METHOD_HIDDEN!>foo<!>() {}
<!NOTHING_TO_OVERRIDE!>override<!> fun other() {}
}
class MyChildClass1 : MyClass {
fun <!VIRTUAL_METHOD_HIDDEN!>foo<!>() {}
override fun bar() {}
}
}
namespace generics {
trait MyTrait<T> {
fun foo(t: T) : T
}
abstract class MyAbstractClass<T> {
abstract fun bar(t: T) : T
}
open class MyGenericClass<T> : MyTrait<T>, MyAbstractClass<T> {
override fun foo(t: T) = t
override fun bar(t: T) = t
}
class MyChildClass : MyGenericClass<Int> {}
class MyChildClass1<T> : MyGenericClass<T> {}
class MyChildClass2<T> : MyGenericClass<T> {
fun <!VIRTUAL_METHOD_HIDDEN!>foo<!>(t: T) = t
override fun bar(t: T) = t
}
open class MyClass : MyTrait<Int>, MyAbstractClass<String> {
override fun foo(i: Int) = i
override fun bar(s: String) = s
}
class <!ABSTRACT_METHOD_NOT_IMPLEMENTED!>MyIllegalGenericClass1<!><T> : MyTrait<T>, MyAbstractClass<T> {}
class <!ABSTRACT_METHOD_NOT_IMPLEMENTED!>MyIllegalGenericClass2<!><T, R> : MyTrait<T>, MyAbstractClass<R> {
<!NOTHING_TO_OVERRIDE!>override<!> fun foo(r: R) = r
}
class <!ABSTRACT_METHOD_NOT_IMPLEMENTED!>MyIllegalClass1<!> : MyTrait<Int>, MyAbstractClass<String> {}
class <!ABSTRACT_METHOD_NOT_IMPLEMENTED!>MyIllegalClass2<!><T> : MyTrait<Int>, MyAbstractClass<Int> {
fun foo(t: T) = t
fun bar(t: T) = t
}
}
@@ -1,14 +0,0 @@
class <!PRIMARY_CONSTRUCTOR_MISSING_STATEFUL_PROPERTY!>X<!> {
val <!MUST_BE_INITIALIZED_OR_BE_ABSTRACT!>x<!> : Int
}
open class Y() {
val x : Int = 2
}
class Y1 {
val x : Int get() = 1
}
class Z : Y<!PRIMARY_CONSTRUCTOR_MISSING_SUPER_CONSTRUCTOR_CALL!>()<!> {
}
@@ -1,6 +0,0 @@
trait A<T> {}
trait B<T> {}
trait C<T> {}
trait D<T> {}
trait Test : A<<!PROJECTION_IN_IMMEDIATE_ARGUMENT_TO_SUPERTYPE!>in<!> Int>, B<<!PROJECTION_IN_IMMEDIATE_ARGUMENT_TO_SUPERTYPE!>out<!> Int>, C<<!PROJECTION_IN_IMMEDIATE_ARGUMENT_TO_SUPERTYPE!>*<!>><!NULLABLE_SUPERTYPE!>?<!><!NULLABLE_SUPERTYPE!>?<!><!NULLABLE_SUPERTYPE!>?<!>, D<Int> {}
@@ -1,28 +0,0 @@
var x : Int = 1 + x
get() : Int = 1
set(<!REF_SETTER_PARAMETER!>ref<!> value : <!WRONG_SETTER_PARAMETER_TYPE!>Long<!>) {
$x = value.int
$x = <!TYPE_MISMATCH!>1.lng<!>
}
val xx : Int = <!PROPERTY_INITIALIZER_NO_BACKING_FIELD!>1 + x<!>
get() : Int = 1
<!VAL_WITH_SETTER!>set(value : Long) {}<!>
val p : Int = <!PROPERTY_INITIALIZER_NO_BACKING_FIELD!>1<!>
get() = 1
class Test() {
var a : Int = 111
var b : Int get() = <!UNRESOLVED_REFERENCE!>$a<!>; set(x) {a = x; <!UNRESOLVED_REFERENCE!>$a<!> = x}
this(i : Int) : this() {
<!NO_BACKING_FIELD!>$b<!> = $a
$a = <!NO_BACKING_FIELD!>$b<!>
a = <!NO_BACKING_FIELD!>$b<!>
}
fun f() {
<!UNRESOLVED_REFERENCE!>$b<!> = <!UNRESOLVED_REFERENCE!>$a<!>
a = <!UNRESOLVED_REFERENCE!>$b<!>
}
}
@@ -1,11 +0,0 @@
namespace qualified_expressions
fun test(s: String?) {
val a: Int = <!TYPE_MISMATCH!>s?.length<!>
val b: Int? = s?.length
val c: Int = s?.length ?: -11
val d: Int = s?.length ?: <!TYPE_MISMATCH!>"empty"<!>
val e: String = <!TYPE_MISMATCH!>s?.length<!> ?: "empty"
val f: Int = s?.length ?: b ?: 1
val g: Int? = e? startsWith("s")?.length
}
@@ -1,41 +0,0 @@
class Dup {
fun Dup() : Unit {
this<!AMBIGUOUS_LABEL!>@Dup<!>
}
}
class A() {
fun foo() : Unit {
this@A
this<!UNRESOLVED_REFERENCE!>@a<!>
this
}
val x = this@A.foo()
val y = this.foo()
val z = foo()
}
fun foo1() : Unit {
<!NO_THIS!>this<!>
this<!UNRESOLVED_REFERENCE!>@a<!>
}
namespace closures {
class A(val a:Int) {
class B() {
val x = this@B : B
val y = this@A : A
val z = this : B
val Int.xx = this : Int
fun Char.xx() : Any {
this : Char
val a = {Double.() => this : Double + this@xx : Char}
val b = @a{Double.() => this@a : Double + this@xx : Char}
val c = @a{() => <!NO_THIS!>this@a<!> + this@xx : Char}
return (@a{Double.() => this@a : Double + this@xx : Char})
}
}
}
}
@@ -1,42 +0,0 @@
namespace a {
val foo = <!TYPECHECKER_HAS_RUN_INTO_RECURSIVE_PROBLEM!>bar()<!>
fun bar() = foo
}
namespace b {
fun foo() = <!TYPECHECKER_HAS_RUN_INTO_RECURSIVE_PROBLEM!>bar()<!>
fun bar() = foo()
}
namespace c {
fun bazz() = <!TYPECHECKER_HAS_RUN_INTO_RECURSIVE_PROBLEM!>bar()<!>
fun foo() = bazz()
fun bar() = foo()
}
namespace ok {
namespace a {
val foo = bar()
fun bar() : Int = foo
}
namespace b {
fun foo() : Int = bar()
fun bar() = foo()
}
namespace c {
fun bazz() = bar()
fun foo() : Int = bazz()
fun bar() = foo()
}
}
@@ -1,52 +0,0 @@
import <!UNRESOLVED_REFERENCE!>java<!>.*
import <!UNRESOLVED_REFERENCE!>util<!>.*
import <!UNRESOLVED_REFERENCE!>utils<!>.*
import <!UNRESOLVED_REFERENCE!>java<!>.io.PrintStream
import <!UNRESOLVED_REFERENCE!>java<!>.lang.Comparable as Com
val l : <!UNRESOLVED_REFERENCE!>List<!><in Int> = <!UNRESOLVED_REFERENCE!>ArrayList<!><Int>()
fun test(l : <!UNRESOLVED_REFERENCE!>java<!>.util.List<Int>) {
val x : <!UNRESOLVED_REFERENCE!>java<!>.List
val y : <!UNRESOLVED_REFERENCE!>java<!>.util.List<Int>
val b : <!UNRESOLVED_REFERENCE!>java<!>.lang.Object
val a : <!UNRESOLVED_REFERENCE!>util<!>.List<Int>
val z : <!UNRESOLVED_REFERENCE!>java<!>.utils.List<Int>
val f : <!UNRESOLVED_REFERENCE!>java<!>.io.File? = null
<!UNRESOLVED_REFERENCE!>Collections<!>.emptyList
<!UNRESOLVED_REFERENCE!>Collections<!>.emptyList<Int>
<!UNRESOLVED_REFERENCE!>Collections<!>.emptyList<Int>()
<!UNRESOLVED_REFERENCE!>Collections<!>.emptyList()
<!UNRESOLVED_REFERENCE!>Collections<!>.singleton<Int>(1) : <!UNRESOLVED_REFERENCE!>Set<!><Int>?
<!UNRESOLVED_REFERENCE!>Collections<!>.singleton<Int>(1.0)
<!UNRESOLVED_REFERENCE!>List<!><Int>
val o = "sdf" <!USELESS_CAST!>as<!> <!UNRESOLVED_REFERENCE!>Object<!>
try {
// ...
}
catch(e: <!UNRESOLVED_REFERENCE!>Exception<!>) {
<!UNRESOLVED_REFERENCE!>System<!>.out<!UNNECESSARY_SAFE_CALL!>?.<!>println(e.getMessage())
}
<!UNRESOLVED_REFERENCE!>PrintStream<!>("sdf")
val c : Com<Int>? = null
c : <!UNRESOLVED_REFERENCE!>java<!>.lang.Comparable<Int>?
// Collections.sort<Integer>(ArrayList<Integer>())
xxx.<!UNRESOLVED_REFERENCE!>Class<!>()
}
namespace xxx {
import <!UNRESOLVED_REFERENCE!>java<!>.lang.Class;
}
@@ -1,21 +0,0 @@
fun demo() {
val abc = 1
val a = ""
val asd = 1
val bar = 5
fun map(f : fun () : Any?) : Int = 1
fun buzz(f : fun () : Any?) : Int = 1
val sdf = 1
val foo = 3;
"$abc"
"$"
"$.$.asdf$\t"
"asd\$"
"asd$a<!ILLEGAL_ESCAPE_SEQUENCE!>\x<!>"
"asd$a$asd$ $<!UNRESOLVED_REFERENCE!>xxx<!>"
"fosdfasdo${1 + bar + 100}}sdsdfgdsfsdf"
"foo${bar + map {foo}}sdfsdf"
"foo${bar + map { "foo" }}sdfsdf"
"foo${bar + map {
"foo$sdf${ buzz{}}" }}sdfsdf"
}
@@ -1,50 +0,0 @@
// KT-286 Check supertype lists
/*
In a supertype list:
Same type should not be mentioned twice
Same type should not be indirectly mentioned with incoherent type arguments
Every trait's required dependencies should be satisfied
No final types should appear
Only one class is allowed
*/
class C1()
open class OC1()
open class C2 {}
open class C3 {}
trait T1 {}
trait T2<T> {}
trait Test<!CONSTRUCTOR_IN_TRAIT!>()<!> {
<!CONSTRUCTOR_IN_TRAIT, SECONDARY_CONSTRUCTOR_NO_INITIALIZER_LIST!>this<!>(x : Int) {}
}
trait Test1 : C2<!SUPERTYPE_INITIALIZED_IN_TRAIT!>()<!> {}
trait Test2 : C2 {}
trait Test3 : C2, <!MANY_CLASSES_IN_SUPERTYPE_LIST!>C3<!> {}
trait Test4 : T1 {}
trait Test5 : T1, <!SUPERTYPE_APPEARS_TWICE!>T1<!> {}
trait Test6 : <!FINAL_SUPERTYPE!>C1<!> {}
class CTest1() : OC1() {}
class CTest2 : C2 {}
class CTest3 : C2, <!MANY_CLASSES_IN_SUPERTYPE_LIST!>C3<!> {}
class CTest4 : T1 {}
class CTest5 : T1, <!SUPERTYPE_APPEARS_TWICE!>T1<!> {}
class CTest6 : <!SUPERTYPE_NOT_INITIALIZED, FINAL_SUPERTYPE!>C1<!> {}
@@ -1,11 +0,0 @@
open class bar()
trait Foo<!CONSTRUCTOR_IN_TRAIT!>()<!> : bar<!SUPERTYPE_INITIALIZED_IN_TRAIT!>()<!>, <!MANY_CLASSES_IN_SUPERTYPE_LIST, SUPERTYPE_APPEARS_TWICE!>bar<!>, <!MANY_CLASSES_IN_SUPERTYPE_LIST, SUPERTYPE_APPEARS_TWICE!>bar<!> {
<!CONSTRUCTOR_IN_TRAIT, SECONDARY_CONSTRUCTOR_NO_INITIALIZER_LIST!>this<!>(x : Int) {}
}
trait Foo2 : bar, Foo {
}
open class Foo1() : bar(), <!SUPERTYPE_NOT_INITIALIZED, MANY_CLASSES_IN_SUPERTYPE_LIST, SUPERTYPE_APPEARS_TWICE!>bar<!>, Foo, <!SUPERTYPE_APPEARS_TWICE!>Foo<!><!CONSTRUCTOR_IN_TRAIT!>()<!> {}
open class Foo12 : bar<!PRIMARY_CONSTRUCTOR_MISSING_SUPER_CONSTRUCTOR_CALL!>()<!>, <!SUPERTYPE_NOT_INITIALIZED, MANY_CLASSES_IN_SUPERTYPE_LIST, SUPERTYPE_APPEARS_TWICE!>bar<!> {}
@@ -1,161 +0,0 @@
fun t1() : Int{
return 0
<!UNREACHABLE_CODE!>1<!>
}
fun t1a() : Int {
<!RETURN_TYPE_MISMATCH!>return<!>
<!UNREACHABLE_CODE!>return 1<!>
<!UNREACHABLE_CODE!>1<!>
}
fun t1b() : Int {
return 1
<!UNREACHABLE_CODE!>return 1<!>
<!UNREACHABLE_CODE!>1<!>
}
fun t1c() : Int {
return 1
<!RETURN_TYPE_MISMATCH, UNREACHABLE_CODE!>return<!>
<!UNREACHABLE_CODE!>1<!>
}
fun t2() : Int {
if (1 > 2)
return 1
else return 1
<!UNREACHABLE_CODE!>1<!>
}
fun t2a() : Int {
if (1 > 2) {
return 1
<!UNREACHABLE_CODE!>1<!>
} else { return 1
<!UNREACHABLE_CODE!>2<!>
}
<!UNREACHABLE_CODE!>1<!>
}
fun t3() : Any {
if (1 > 2)
return 2
else return ""
<!UNREACHABLE_CODE!>1<!>
}
fun t4(a : Boolean) : Int {
do {
return 1
}
while (<!UNREACHABLE_CODE!>a<!>)
<!UNREACHABLE_CODE!>1<!>
}
fun t4break(a : Boolean) : Int {
do {
break
}
while (<!UNREACHABLE_CODE!>a<!>)
return 1
}
fun t5() : Int {
do {
return 1
<!UNREACHABLE_CODE!>2<!>
}
while (<!UNREACHABLE_CODE!>1 > 2<!>)
<!UNREACHABLE_CODE!>return 1<!>
}
fun t6() : Int {
while (1 > 2) {
return 1
<!UNREACHABLE_CODE!>2<!>
}
return 1
}
fun t6break() : Int {
while (1 > 2) {
break
<!UNREACHABLE_CODE!>2<!>
}
return 1
}
fun t7(b : Int) : Int {
for (i in 1..b) {
return 1
<!UNREACHABLE_CODE!>2<!>
}
return 1
}
fun t7break(b : Int) : Int {
for (i in 1..b) {
return 1
<!UNREACHABLE_CODE!>2<!>
}
return 1
}
fun t7() : Int {
try {
return 1
<!UNREACHABLE_CODE!>2<!>
}
catch (e : Any) {
2
}
return 1 // this is OK, like in Java
}
fun t8() : Int {
try {
return 1
<!UNREACHABLE_CODE!>2<!>
}
catch (e : Any) {
return 1
<!UNREACHABLE_CODE!>2<!>
}
<!UNREACHABLE_CODE!>return 1<!>
}
fun blockAndAndMismatch() : Boolean {
<!UNREACHABLE_CODE!>(return true) || (return false)<!>
<!UNREACHABLE_CODE!>return true<!>
}
fun tf() : Int {
try {<!UNREACHABLE_CODE!>return 1<!>} finally{return 1}
<!UNREACHABLE_CODE!>return 1<!>
}
fun failtest(a : Int) : Int {
<!UNREACHABLE_BECAUSE_OF_NOTHING!>if (fail() || true) {
}<!>
<!UNREACHABLE_BECAUSE_OF_NOTHING!>return 1<!>
}
fun foo(a : Nothing) : Unit {
1
a
<!UNREACHABLE_BECAUSE_OF_NOTHING!>2<!>
}
fun fail() : Nothing {
throw <!UNRESOLVED_REFERENCE!>java<!>.lang.RuntimeException()
}
fun nullIsNotNothing() : Unit {
val x : Int? = 1
if (x != null) {
return
}
fail()
}
@@ -1,30 +0,0 @@
namespace unresolved
fun testGenericArgumentsCount() {
val p1: Tuple2<!WRONG_NUMBER_OF_TYPE_ARGUMENTS!><Int><!> = (2, 2)
val p2: <!WRONG_NUMBER_OF_TYPE_ARGUMENTS!>Tuple2<!> = (2, 2)
}
fun testUnresolved() {
if (<!UNRESOLVED_REFERENCE!>a<!> is String) {
val s = <!UNRESOLVED_REFERENCE!>a<!>
}
<!UNRESOLVED_REFERENCE!>foo<!>(<!UNRESOLVED_REFERENCE!>a<!>)
val s = "s"
<!UNRESOLVED_REFERENCE!>foo<!>(s)
foo1(<!UNRESOLVED_REFERENCE!>i<!>)
s.<!UNRESOLVED_REFERENCE!>foo<!>()
when(<!UNRESOLVED_REFERENCE!>a<!>) {
is Int => <!UNRESOLVED_REFERENCE!>a<!>
is String => <!UNRESOLVED_REFERENCE!>a<!>
}
//TODO
for (j in <!UNRESOLVED_REFERENCE!>collection<!>) {
val i: Int = j
j += 1
}
}
fun foo1(i: Int) {}
@@ -1,40 +0,0 @@
namespace variance
abstract class Consumer<in T> {}
abstract class Producer<out T> {}
abstract class Usual<T> {}
fun foo(c: Consumer<Int>, p: Producer<Int>, u: Usual<Int>) {
val c1: Consumer<Any> = <!TYPE_MISMATCH!>c<!>
val c2: Consumer<Int> = c1
val p1: Producer<Any> = p
val p2: Producer<Int> = <!TYPE_MISMATCH!>p1<!>
val u1: Usual<Any> = <!TYPE_MISMATCH!>u<!>
val u2: Usual<Int> = <!TYPE_MISMATCH!>u1<!>
}
//Arrays copy example
class Array<T>(val length : Int) {
fun get(index : Int) : T { return null }
fun set(index : Int, value : T) { /* ... */ }
}
fun copy1(from : Array<Any>, to : Array<Any>) {}
fun copy2(from : Array<out Any>, to : Array<in Any>) {}
fun <T> copy3(from : Array<out T>, to : Array<in T>) {}
fun copy4(from : Array<out Number>, to : Array<in Int>) {}
fun f(ints: Array<Int>, any: Array<Any>, numbers: Array<Number>) {
copy1(<!TYPE_MISMATCH!>ints<!>, any)
copy2(ints, any) //ok
copy2(ints, <!TYPE_MISMATCH!>numbers<!>)
copy3<Int>(ints, numbers)
copy4(ints, numbers) //ok
}
@@ -1,61 +0,0 @@
fun foo() : Int {
val s = ""
val x = 1
when (x) {
is * => 1
is <!INCOMPATIBLE_TYPES!>String<!> => 1
!is Int => 1
is Any? => 1
<!INCOMPATIBLE_TYPES!>s<!> => 1
1 => 1
1 + <!UNRESOLVED_REFERENCE!>a<!> => 1
in 1..<!UNRESOLVED_REFERENCE!>a<!> => 1
!in 1..<!UNRESOLVED_REFERENCE!>a<!> => 1
.<!UNRESOLVED_REFERENCE!>a<!> => 1
.equals(1).<!UNRESOLVED_REFERENCE!>a<!> => 1
<!UNNECESSARY_SAFE_CALL!>?.<!>equals(1) => 1
else => 1
}
return when (<!USELESS_ELVIS!>x<!>?:null) {
<!UNSAFE_CALL!>.<!>equals(1) => 1
?.equals(1).equals(2) => 1
}
}
val _type_test : Int = foo() // this is needed to ensure the inferred return type of foo()
fun test() {
val x = 1;
val s = "";
when (x) {
<!INCOMPATIBLE_TYPES!>s<!> => 1
is <!INCOMPATIBLE_TYPES!>""<!> => 1
x => 1
is 1 => 1
is <!TYPE_MISMATCH_IN_TUPLE_PATTERN!>(1, 1)<!> => 1
}
val z = (1, 1)
when (z) {
is (*, *) => 1
is (*, 1) => 1
is (1, 1) => 1
is (1, <!INCOMPATIBLE_TYPES!>"1"<!>) => 1
is <!TYPE_MISMATCH_IN_TUPLE_PATTERN!>(1, "1", *)<!> => 1
is boo @ (1, <!INCOMPATIBLE_TYPES!>"a"<!>, *) => 1
is boo @ <!TYPE_MISMATCH_IN_TUPLE_PATTERN!>(1, *)<!> => 1
}
when (z) {
<!ELSE_MISPLACED_IN_WHEN!>else => 1<!>
(1, 1) => 2
}
when (z) {
else => 1
}
}
val (Int, Int).boo : (Int, Int, Int) = (1, 1, 1)
@@ -1,12 +0,0 @@
// One of the two passes is making a scope and turning vals into functions
// See KT-76
namespace x
val b : Foo = Foo()
val a1 = b.compareTo(2)
class Foo() {
fun compareTo(other : Byte) : Int = 0
fun compareTo(other : Char) : Int = 0
}
@@ -1,6 +0,0 @@
fun test() {
val a : Any? = null
if (a is Any) else a = null;
while (a is Any) a = null
while (true) a = null
}
@@ -1,9 +0,0 @@
fun foo(u : Unit) : Int = 1
fun test() : Int {
foo(<!TYPE_MISMATCH!>1<!>)
val a : fun() : Unit = {
foo(<!TYPE_MISMATCH!>1<!>)
}
return 1
}
@@ -1,66 +0,0 @@
import <!UNRESOLVED_REFERENCE!>java<!>.*
import <!UNRESOLVED_REFERENCE!>util<!>.*
import <!UNRESOLVED_REFERENCE!>java<!>.io.*
fun takeFirst(expr: StringBuilder): Char {
val c = expr.charAt(0)
expr.deleteCharAt(0)
return c
}
fun evaluateArg(expr: AbstractStringBuilder, numbers: ArrayList<Int>): Int {
if (expr.length() == 0) throw Exception("Syntax error: Character expected");
val c = <!OVERLOAD_RESOLUTION_AMBIGUITY!>takeFirst(expr)<!>
if (c <!COMPARE_TO_TYPE_MISMATCH!>>=<!> '0' && c <!COMPARE_TO_TYPE_MISMATCH!><=<!> '9') {
val n = c - '0'
if (!numbers.contains(n)) throw Exception("You used incorrect number: " + n)
numbers.remove(n)
return n
}
throw Exception("Syntax error: Unrecognized character " + c)
}
fun evaluateAdd(expr: StringBuilder, numbers: ArrayList<Int>): Int {
val lhs = <!OVERLOAD_RESOLUTION_AMBIGUITY!>evaluateArg(expr, numbers)<!>
if (expr.length() <!COMPARE_TO_TYPE_MISMATCH!>><!> 0) {
}
return lhs
}
fun evaluate(expr: StringBuilder, numbers: ArrayList<Int>): Int {
val lhs = <!OVERLOAD_RESOLUTION_AMBIGUITY!>evaluateAdd(expr, numbers)<!>
if (expr.length() <!COMPARE_TO_TYPE_MISMATCH!>><!> 0) {
val c = expr.charAt(0)
expr.deleteCharAt(0)
}
return lhs
}
fun main(args: Array<String>) {
System.out<!UNNECESSARY_SAFE_CALL!>?.<!>println("24 game")
val numbers = ArrayList<Int>(4)
val rnd = Random();
val prompt = StringBuilder()
for(val i in 0..3) {
val n = rnd.nextInt(9) + 1
numbers.add(n)
if (i > 0) prompt.append(" ");
prompt.append(n)
}
System.out<!UNNECESSARY_SAFE_CALL!>?.<!>println("Your numbers: " + prompt)
System.out<!UNNECESSARY_SAFE_CALL!>?.<!>println("Enter your expression:")
val reader = BufferedReader(InputStreamReader(System.`in`))
val expr = StringBuilder(reader.readLine())
try {
val result = <!OVERLOAD_RESOLUTION_AMBIGUITY!>evaluate(expr, numbers)<!>
if (result != 24)
System.out<!UNNECESSARY_SAFE_CALL!>?.<!>println("Sorry, that's " + result)
else
System.out<!UNNECESSARY_SAFE_CALL!>?.<!>println("You won!");
}
catch(e: Throwable) {
System.out<!UNNECESSARY_SAFE_CALL!>?.<!>println(e.getMessage())
}
}
@@ -1,14 +0,0 @@
namespace jet121 {
fun box() : String {
val answer = apply("OK") { String.() : Int =>
get(0)
length
}
return if (answer == 2) "OK" else "FAIL"
}
fun apply(arg:String, f : fun String.() : Int) : Int {
return arg.f()
}
}
@@ -1,8 +0,0 @@
fun foo1() : fun (Int) : Int = { (x: Int) => x }
fun foo() {
val h : fun (Int) : Int = foo1();
h(1)
val m : fun (Int) : Int = {(a : Int) => 1}//foo1()
m(1)
}
@@ -1,8 +0,0 @@
fun set(key : String, value : String) {
val a : String? = ""
when (a) {
"" => a<!UNSAFE_CALL!>.<!>get(0)
is String, is Any => a.compareTo("")
else => a.toString()
}
}
@@ -1,6 +0,0 @@
// JET-17 Do not infer property types by the initializer before the containing scope is ready
class WithC() {
val a = 1
val b = $a // error here, but must not be
}
@@ -1,21 +0,0 @@
abstract enum class ProtocolState {
WAITING {
override fun signal() = ProtocolState.TALKING
}
TALKING {
override fun signal() = ProtocolState.WAITING
}
abstract fun signal() : ProtocolState
}
fun box(): String {
val x: ProtocolState = ProtocolState.WAITING
x = x.signal()
if (x != ProtocolState.TALKING) return "fail 1"
x = x.signal()
if (x != ProtocolState.WAITING) return "fail 2"
return "OK"
}
@@ -1,22 +0,0 @@
abstract enum class ProtocolState {
WAITING {
override fun signal() = ProtocolState.TALKING
}
TALKING {
override fun signal() = ProtocolState.WAITING
}
abstract fun signal() : ProtocolState
}
enum class Foo<T> {
<!NO_GENERICS_IN_SUPERTYPE_SPECIFIER!>X<!>
}
fun box() {
val x: ProtocolState = ProtocolState.WAITING
}
@@ -1,4 +0,0 @@
import <!UNRESOLVED_REFERENCE!>java<!>.util.Collections
import <!UNRESOLVED_REFERENCE!>java<!>.util.List
val ab = <!UNRESOLVED_REFERENCE!>Collections<!>.emptyList<Int>() : <!UNRESOLVED_REFERENCE!>List<!><Int>?
@@ -1,4 +0,0 @@
abstract class XXX {
val a : Int abstract get
}
@@ -1,11 +0,0 @@
class Foo()
fun test() {
val f : Foo? = null
if (f == null) {
}
if (f != null) {
}
}
@@ -1,10 +0,0 @@
class Command() {}
fun parse(cmd: String): Command? { return null }
fun Any.equals(other : Any?) : Boolean = this === other
fun main(args: Array<String>) {
val command = parse("")
if (command == null) 1 // error on this line, but must be OK
}
@@ -1,17 +0,0 @@
// JET-72 Type inference doesn't work when iterating over ArrayList
import <!UNRESOLVED_REFERENCE!>java<!>.util.ArrayList
abstract class Item(val room: <!UNRESOLVED_REFERENCE!>Object<!>) {
abstract val name : String
}
val items: <!UNRESOLVED_REFERENCE!>ArrayList<!><Item> = <!UNRESOLVED_REFERENCE!>ArrayList<!><Item>
fun test(room : <!UNRESOLVED_REFERENCE!>Object<!>) {
for(val item: Item in items) {
if (item.room === room) {
<!UNRESOLVED_REFERENCE!>System<!>.out<!UNNECESSARY_SAFE_CALL!>?.<!>println("You see " + item.name)
}
}
}
@@ -1,22 +0,0 @@
// JET-81 Assertion fails when processing self-referring anonymous objects
val y = object {
val a = y;
}
val z = y.a;
object A {
val x = A
}
val a = object {
{
b + 1
}
val x = <!TYPECHECKER_HAS_RUN_INTO_RECURSIVE_PROBLEM!>b<!>
val y = 1
}
val b = a.x
val c = a.y
@@ -1,16 +0,0 @@
fun box() {
val a : C
a.foo()
}
open class A {
open fun foo() {}
}
open class B : A {
override fun foo() {}
}
open class C : B {
override fun foo() {}
}
@@ -1,17 +0,0 @@
class Foo(var bar : Int, barr : Int, val barrr : Int) {
{
bar = 1
barr = 1
barrr = 1
1 : Int
this : Foo
}
this(val bar : Int) : this(1, 1, 1) {
bar = 1
this.bar
1 : Int
val a : Int =1
this : Foo
}
}
@@ -1,9 +0,0 @@
fun Any.equals(other : Any?) : Boolean = true
fun main(args: Array<String>) {
val command : Any = 1
command<!UNNECESSARY_SAFE_CALL!>?.<!>equals(null)
command.equals(null)
}
@@ -1,3 +0,0 @@
class Z() {
this(x : Int) : this() {}
}
@@ -1,9 +0,0 @@
open class Foo {}
open class Bar {}
fun <T : Bar, T1> foo(x : Int) {}
fun <T1, T : Foo> foo(x : Long) {}
fun f(): Unit {
foo<<!UPPER_BOUND_VIOLATED!>Int<!>, Int>(1)
}
@@ -1,33 +0,0 @@
class A() {
var x: Int = 0
get() = <!TYPE_MISMATCH!>"s"<!>
set(value: <!WRONG_SETTER_PARAMETER_TYPE!>String<!>) {
$x = <!TYPE_MISMATCH!>value<!>
}
val y: Int
get(): <!WRONG_GETTER_RETURN_TYPE!>String<!> = "s"
val z: Int
get() {
return <!TYPE_MISMATCH!>"s"<!>
}
var a: Any = 1
set(v: <!WRONG_SETTER_PARAMETER_TYPE!>String<!>) {
$a = v
}
val b: Int
get(): <!WRONG_GETTER_RETURN_TYPE!>Any<!> = "s"
val c: Int
get() {
return 1
}
val d = 1
get() {
return $d
}
val e = 1
get(): <!WRONG_GETTER_RETURN_TYPE!>String<!> {
return <!TYPE_MISMATCH!>$e<!>
}
}
@@ -1,11 +0,0 @@
// KT-303 Stack overflow on a cyclic class hierarchy
open class Foo() : <!CYCLIC_INHERITANCE_HIERARCHY!>Bar<!>() {
val a : Int = 1
}
open class Bar() : <!CYCLIC_INHERITANCE_HIERARCHY!>Foo<!>() {
}
val x : Int = <!TYPE_MISMATCH!>Foo()<!>
@@ -18,7 +18,7 @@ import java.util.List;
public class CheckerTestUtilTest extends JetLiteFixture {
public CheckerTestUtilTest() {
super("checkerTestUtil");
super("checkerWithErrorTypes/checkerTestUtil");
}
protected void doTest(TheTest theTest) throws Exception {
@@ -15,8 +15,10 @@ import org.jetbrains.jet.lang.resolve.BindingContext;
import org.jetbrains.jet.plugin.AnalyzerFacade;
import java.io.File;
import java.io.FileWriter;
import java.io.IOException;
import java.util.List;
import java.util.regex.Pattern;
/**
* @author abreslav
@@ -72,36 +74,36 @@ public class FullJetPsiCheckerTest extends JetTestCaseBase {
return StringUtil.convertLineSeparators(fileText);
}
// 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)>");
// 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();
// }
// }
// }
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 JetTestCaseBase.suiteForDirectory(JetTestCaseBase.getTestDataPathBase(), "/checkerWithErrorTypes/full/", true, new JetTestCaseBase.NamedTestFactory() {