Merge branch 'master' of ssh://git.labs.intellij.net/jet
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
/*
|
||||
* @author max
|
||||
* @author alex.tkachman
|
||||
*/
|
||||
package org.jetbrains.jet.codegen;
|
||||
|
||||
@@ -16,9 +17,7 @@ import org.objectweb.asm.commons.Method;
|
||||
import org.objectweb.asm.signature.SignatureWriter;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.objectweb.asm.Opcodes.*;
|
||||
|
||||
@@ -152,6 +151,9 @@ public class ClosureCodegen extends FunctionOrClosureCodegen {
|
||||
final Method bridge = erasedInvokeSignature(funDescriptor);
|
||||
final Method delegate = invokeSignature(funDescriptor);
|
||||
|
||||
if(bridge.getDescriptor().equals(delegate.getDescriptor()))
|
||||
return;
|
||||
|
||||
final MethodVisitor mv = cv.visitMethod(ACC_PUBLIC, "invoke", bridge.getDescriptor(), state.getTypeMapper().genericSignature(funDescriptor), new String[0]);
|
||||
mv.visitCode();
|
||||
|
||||
@@ -212,7 +214,8 @@ public class ClosureCodegen extends FunctionOrClosureCodegen {
|
||||
ExpressionCodegen expressionCodegen = new ExpressionCodegen(mv, null, Type.VOID_TYPE, context, state);
|
||||
|
||||
iv.load(0, Type.getObjectType(funClass));
|
||||
expressionCodegen.generateTypeInfo(new ProjectionErasingJetType(returnType));
|
||||
// expressionCodegen.generateTypeInfo(new ProjectionErasingJetType(returnType));
|
||||
iv.aconst(null); // @todo
|
||||
iv.invokespecial(funClass, "<init>", "(Ljet/typeinfo/TypeInfo;)V");
|
||||
|
||||
i = 1;
|
||||
|
||||
@@ -313,10 +313,6 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
||||
myContinueTargets.pop();
|
||||
}
|
||||
|
||||
private DeclarationDescriptor contextType() {
|
||||
return context.getContextClass();
|
||||
}
|
||||
|
||||
private OwnerKind contextKind() {
|
||||
return context.getContextKind();
|
||||
}
|
||||
@@ -874,7 +870,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
||||
String owner;
|
||||
|
||||
boolean isInterface;
|
||||
boolean isInsideClass = containingDeclaration == contextType();
|
||||
boolean isInsideClass = containingDeclaration == context.getContextClass();
|
||||
if (isInsideClass || isStatic) {
|
||||
owner = typeMapper.getOwner(functionDescriptor, contextKind());
|
||||
isInterface = false;
|
||||
@@ -904,7 +900,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
||||
DeclarationDescriptor containingDeclaration = propertyDescriptor.getContainingDeclaration();
|
||||
boolean isStatic = containingDeclaration instanceof NamespaceDescriptorImpl;
|
||||
propertyDescriptor = propertyDescriptor.getOriginal();
|
||||
boolean isInsideClass = !forceInterface && containingDeclaration == contextType();
|
||||
boolean isInsideClass = !forceInterface && containingDeclaration == context.getContextClass();
|
||||
Method getter;
|
||||
Method setter;
|
||||
if (forceField) {
|
||||
@@ -1024,10 +1020,6 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
||||
return funDescriptor;
|
||||
}
|
||||
|
||||
public void invokeMethodWithArguments(CallableMethod callableMethod, JetCallElement expression) {
|
||||
invokeMethodWithArguments(callableMethod, expression, StackValue.none());
|
||||
}
|
||||
|
||||
public void invokeMethodWithArguments(CallableMethod callableMethod, JetCallElement expression, StackValue receiver) {
|
||||
final Type calleeType = callableMethod.getGenerateCalleeType();
|
||||
if (calleeType != null && expression instanceof JetCallExpression) {
|
||||
@@ -1053,7 +1045,11 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
||||
}
|
||||
else {
|
||||
if (callableMethod.isNeedsReceiver()) {
|
||||
receiver.put(JetTypeMapper.TYPE_OBJECT, v);
|
||||
if (receiver == StackValue.none()) {
|
||||
v.load(0, JetTypeMapper.TYPE_OBJECT);
|
||||
}
|
||||
else
|
||||
receiver.put(JetTypeMapper.TYPE_OBJECT, v);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1812,7 +1808,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
||||
}
|
||||
|
||||
CallableMethod method = typeMapper.mapToCallableMethod((ConstructorDescriptor) constructorDescriptor, OwnerKind.IMPLEMENTATION);
|
||||
invokeMethodWithArguments(method, expression);
|
||||
invokeMethodWithArguments(method, expression, StackValue.none());
|
||||
}
|
||||
}
|
||||
else {
|
||||
@@ -1849,7 +1845,7 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
||||
v.anew(type);
|
||||
v.dup();
|
||||
final CallableMethod callableMethod = typeMapper.mapToCallableMethod(constructor);
|
||||
invokeMethodWithArguments(callableMethod, expression);
|
||||
invokeMethodWithArguments(callableMethod, expression, StackValue.none());
|
||||
return type;
|
||||
}
|
||||
|
||||
@@ -1867,20 +1863,22 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
||||
throw new CompilationException("primitive array constructor requires one argument");
|
||||
}
|
||||
}
|
||||
gen(args.get(0).getArgumentExpression(), Type.INT_TYPE);
|
||||
|
||||
if(isArray) {
|
||||
JetType elementType = typeMapper.getGenericsElementType(arrayType);
|
||||
if(elementType != null) {
|
||||
generateTypeInfo(elementType);
|
||||
v.invokestatic("jet/typeinfo/TypeInfo", "newArray", "(ILjet/typeinfo/TypeInfo;)[Ljava/lang/Object;");
|
||||
gen(args.get(0).getArgumentExpression(), Type.INT_TYPE);
|
||||
v.invokevirtual("jet/typeinfo/TypeInfo", "newArray", "(I)[Ljava/lang/Object;");
|
||||
}
|
||||
else {
|
||||
gen(args.get(0).getArgumentExpression(), Type.INT_TYPE);
|
||||
v.newarray(JetTypeMapper.boxType(typeMapper.mapType(arrayType.getArguments().get(0).getType())));
|
||||
}
|
||||
}
|
||||
else {
|
||||
Type type = typeMapper.mapType(arrayType, OwnerKind.IMPLEMENTATION);
|
||||
gen(args.get(0).getArgumentExpression(), Type.INT_TYPE);
|
||||
v.newarray(type.getElementType());
|
||||
}
|
||||
|
||||
@@ -2311,12 +2309,12 @@ public class ExpressionCodegen extends JetVisitor<StackValue, StackValue> {
|
||||
return;
|
||||
}
|
||||
DeclarationDescriptor containingDeclaration = typeParameterDescriptor.getContainingDeclaration();
|
||||
if (contextType() instanceof ClassDescriptor) {
|
||||
ClassDescriptor descriptor = (ClassDescriptor) contextType();
|
||||
if (context.getContextClass() instanceof ClassDescriptor) {
|
||||
ClassDescriptor descriptor = (ClassDescriptor) context.getContextClass();
|
||||
JetType defaultType = ((ClassDescriptor)containingDeclaration).getDefaultType();
|
||||
Type ownerType = typeMapper.mapType(defaultType);
|
||||
ownerType = JetTypeMapper.boxType(ownerType);
|
||||
if (containingDeclaration == contextType()) {
|
||||
if (containingDeclaration == context.getContextClass()) {
|
||||
if(!CodegenUtil.isInterface(descriptor)) {
|
||||
if (CodegenUtil.hasTypeInfoField(defaultType)) {
|
||||
v.load(0, JetTypeMapper.TYPE_OBJECT);
|
||||
|
||||
@@ -461,7 +461,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
}
|
||||
|
||||
CallableMethod method = state.getTypeMapper().mapToCallableMethod(constructorDescriptor, kind);
|
||||
codegen.invokeMethodWithArguments(method, constructorCall);
|
||||
codegen.invokeMethodWithArguments(method, constructorCall, StackValue.none());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -513,7 +513,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen {
|
||||
final JetDelegatorToSuperCall superCall = (JetDelegatorToSuperCall) specifier;
|
||||
ConstructorDescriptor constructorDescriptor = (ConstructorDescriptor) state.getBindingContext().get(BindingContext.REFERENCE_TARGET, superCall.getCalleeExpression().getConstructorReferenceExpression());
|
||||
CallableMethod method = state.getTypeMapper().mapToCallableMethod(constructorDescriptor, OwnerKind.IMPLEMENTATION);
|
||||
codegen.invokeMethodWithArguments(method, superCall);
|
||||
codegen.invokeMethodWithArguments(method, superCall, StackValue.none());
|
||||
}
|
||||
else {
|
||||
throw new UnsupportedOperationException("unsupported type of enum constant initializer: " + specifier);
|
||||
|
||||
@@ -75,6 +75,7 @@ public class IntrinsicMethods {
|
||||
|
||||
declareOverload(myStdLib.getLibraryScope().getFunctions("toString"), 0, new ToString());
|
||||
declareOverload(myStdLib.getLibraryScope().getFunctions("equals"), 1, new Equals());
|
||||
declareOverload(myStdLib.getLibraryScope().getFunctions("plus"), 1, new StringPlus());
|
||||
|
||||
// declareIntrinsicFunction("Any", "equals", 1, new Equals());
|
||||
//
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
package org.jetbrains.jet.codegen.intrinsics;
|
||||
|
||||
import com.intellij.psi.PsiElement;
|
||||
import org.jetbrains.jet.codegen.ExpressionCodegen;
|
||||
import org.jetbrains.jet.codegen.JetTypeMapper;
|
||||
import org.jetbrains.jet.codegen.StackValue;
|
||||
import org.jetbrains.jet.lang.psi.JetCallExpression;
|
||||
import org.jetbrains.jet.lang.psi.JetExpression;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||
import org.jetbrains.jet.lang.types.JetType;
|
||||
import org.jetbrains.jet.lexer.JetTokens;
|
||||
import org.objectweb.asm.Type;
|
||||
import org.objectweb.asm.commons.InstructionAdapter;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author alex.tkachman
|
||||
*/
|
||||
public class StringPlus implements IntrinsicMethod {
|
||||
@Override
|
||||
public StackValue generate(ExpressionCodegen codegen, InstructionAdapter v, Type expectedType, PsiElement element, List<JetExpression> arguments, StackValue receiver) {
|
||||
codegen.gen(arguments.get(0)).put(JetTypeMapper.JL_STRING_TYPE, v);
|
||||
codegen.gen(arguments.get(1)).put(JetTypeMapper.TYPE_OBJECT, v);
|
||||
v.invokestatic("jet/runtime/Intrinsics", "stringPlus", "(Ljava/lang/String;Ljava/lang/Object;)Ljava/lang/String;");
|
||||
return StackValue.onStack(JetTypeMapper.JL_STRING_TYPE);
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,8 @@
|
||||
package org.jetbrains.jet.cli;
|
||||
|
||||
import com.google.common.collect.*;
|
||||
import com.google.common.collect.LinkedHashMultimap;
|
||||
import com.google.common.collect.Lists;
|
||||
import com.google.common.collect.Multimap;
|
||||
import com.intellij.core.JavaCoreEnvironment;
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.project.Project;
|
||||
@@ -10,6 +12,7 @@ import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.PsiManager;
|
||||
import com.sampullara.cli.Args;
|
||||
import com.sampullara.cli.Argument;
|
||||
import org.jetbrains.jet.JetCoreEnvironment;
|
||||
import org.jetbrains.jet.codegen.ClassFileFactory;
|
||||
import org.jetbrains.jet.codegen.GenerationState;
|
||||
import org.jetbrains.jet.lang.cfg.pseudocode.JetControlFlowDataTraceFactory;
|
||||
@@ -17,13 +20,11 @@ import org.jetbrains.jet.lang.diagnostics.Diagnostic;
|
||||
import org.jetbrains.jet.lang.diagnostics.DiagnosticUtils;
|
||||
import org.jetbrains.jet.lang.diagnostics.DiagnosticWithTextRange;
|
||||
import org.jetbrains.jet.lang.diagnostics.Severity;
|
||||
import org.jetbrains.jet.lang.parsing.JetParserDefinition;
|
||||
import org.jetbrains.jet.lang.psi.JetFile;
|
||||
import org.jetbrains.jet.lang.psi.JetNamespace;
|
||||
import org.jetbrains.jet.lang.resolve.AnalyzingUtils;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||
import org.jetbrains.jet.lang.resolve.java.JavaDefaultImports;
|
||||
import org.jetbrains.jet.plugin.JetFileType;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@@ -61,17 +62,13 @@ public class KotlinCompiler {
|
||||
public void dispose() {
|
||||
}
|
||||
};
|
||||
JavaCoreEnvironment environment = new JavaCoreEnvironment(root);
|
||||
JetCoreEnvironment environment = new JetCoreEnvironment(root);
|
||||
|
||||
File rtJar = initJdk();
|
||||
if (rtJar == null) return;
|
||||
|
||||
environment.addToClasspath(rtJar);
|
||||
|
||||
environment.registerFileType(JetFileType.INSTANCE, "kt");
|
||||
environment.registerFileType(JetFileType.INSTANCE, "jet");
|
||||
environment.registerParserDefinition(new JetParserDefinition());
|
||||
|
||||
VirtualFile vFile = environment.getLocalFileSystem().findFileByPath(arguments.src);
|
||||
if (vFile == null) {
|
||||
System.out.print("File/directory not found: " + arguments.src);
|
||||
|
||||
+1
-1
@@ -168,7 +168,7 @@ public class JavaDescriptorResolver {
|
||||
private DeclarationDescriptor resolveParentDescriptor(PsiClass psiClass) {
|
||||
PsiClass containingClass = psiClass.getContainingClass();
|
||||
if (containingClass != null) {
|
||||
return resolveClass(psiClass);
|
||||
return resolveClass(containingClass);
|
||||
}
|
||||
|
||||
PsiJavaFile containingFile = (PsiJavaFile) psiClass.getContainingFile();
|
||||
|
||||
@@ -40,6 +40,8 @@ fun Any?.equals(other : Any?) : Boolean// = this === other
|
||||
// Returns "null" for null
|
||||
fun Any?.toString() : String// = this === other
|
||||
|
||||
fun String?.plus(other: Any?) : String
|
||||
|
||||
trait Iterator<out T> {
|
||||
fun next() : T
|
||||
val hasNext : Boolean
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
package org.jetbrains.jet;
|
||||
|
||||
import com.intellij.core.JavaCoreEnvironment;
|
||||
import com.intellij.openapi.Disposable;
|
||||
import org.jetbrains.jet.lang.parsing.JetParserDefinition;
|
||||
import org.jetbrains.jet.plugin.JetFileType;
|
||||
|
||||
/**
|
||||
* @author yole
|
||||
*/
|
||||
public class JetCoreEnvironment extends JavaCoreEnvironment {
|
||||
public JetCoreEnvironment(Disposable parentDisposable) {
|
||||
super(parentDisposable);
|
||||
registerFileType(JetFileType.INSTANCE, "kt");
|
||||
registerFileType(JetFileType.INSTANCE, "kts");
|
||||
registerFileType(JetFileType.INSTANCE, "ktm");
|
||||
registerFileType(JetFileType.INSTANCE, "jet");
|
||||
registerParserDefinition(new JetParserDefinition());
|
||||
}
|
||||
}
|
||||
@@ -1,166 +0,0 @@
|
||||
namespace abstract
|
||||
|
||||
class MyClass() {
|
||||
//properties
|
||||
val <error>a</error>: Int
|
||||
val a1: Int = 1
|
||||
<error>abstract</error> val a2: Int
|
||||
<error>abstract</error> val a3: Int = 1
|
||||
|
||||
var <error>b</error>: Int private set
|
||||
var b1: Int = 0; private set
|
||||
<error>abstract</error> var b2: Int private set
|
||||
<error>abstract</error> var b3: Int = 0; private set
|
||||
|
||||
var <error>c</error>: Int set(v: Int) { $c = v }
|
||||
var c1: Int = 0; set(v: Int) { $c1 = v }
|
||||
<error>abstract</error> var c2: Int set(v: Int) { $c2 = v }
|
||||
<error>abstract</error> var c3: Int = 0; set(v: Int) { $c3 = v }
|
||||
|
||||
val e: Int get() = a
|
||||
val e1: Int = <error>0</error>; get() = a
|
||||
<error>abstract</error> val e2: Int get() = a
|
||||
<error>abstract</error> val e3: Int = 0; get() = a
|
||||
|
||||
//methods
|
||||
fun <error>f</error>()
|
||||
fun g() {}
|
||||
<error>abstract</error> fun h()
|
||||
<error><error>abstract</error></error> fun j() {}
|
||||
}
|
||||
|
||||
abstract class MyAbstractClass() {
|
||||
//properties
|
||||
val <error>a</error>: Int
|
||||
val a1: Int = 1
|
||||
abstract val a2: Int
|
||||
abstract val a3: Int = <error>1</error>
|
||||
|
||||
var <error>b</error>: Int private set
|
||||
var b1: Int = 0; private set
|
||||
abstract var b2: Int private set
|
||||
abstract var b3: Int = <error>0</error>; private set
|
||||
|
||||
var <error>c</error>: Int set(v: Int) { $c = v }
|
||||
var c1: Int = 0; set(v: Int) { $c1 = v }
|
||||
abstract var c2: Int <error>set(v: Int) { $c2 = v }</error>
|
||||
abstract var c3: Int = <error>0</error>; <error>set(v: Int) { $c3 = v }</error>
|
||||
|
||||
val e: Int get() = a
|
||||
val e1: Int = <error>0</error>; get() = a
|
||||
abstract val e2: Int <error>get() = a</error>
|
||||
abstract val e3: Int = <error>0</error>; <error>get() = a</error>
|
||||
|
||||
//methods
|
||||
fun <error>f</error>()
|
||||
fun g() {}
|
||||
abstract fun h()
|
||||
<error>abstract</error> fun j() {}
|
||||
}
|
||||
|
||||
trait MyTrait {
|
||||
//properties
|
||||
val a: Int
|
||||
val a1: Int = <error>1</error>
|
||||
<warning>abstract</warning> val a2: Int
|
||||
<warning>abstract</warning> val a3: Int = <error>1</error>
|
||||
|
||||
var b: Int private set
|
||||
var b1: Int = <error>0</error>; private set
|
||||
<warning>abstract</warning> var b2: Int private set
|
||||
<warning>abstract</warning> var b3: Int = <error>0</error>; private set
|
||||
|
||||
var <error>c</error>: Int set(v: Int) { $c = v }
|
||||
var <error>c1</error>: Int = <error>0</error>; set(v: Int) { $c1 = v }
|
||||
<warning>abstract</warning> var c2: Int <error>set(v: Int) { $c2 = v }</error>
|
||||
<warning>abstract</warning> var c3: Int = <error>0</error>; <error>set(v: Int) { $c3 = v }</error>
|
||||
|
||||
val e: Int get() = a
|
||||
val e1: Int = <error>0</error>; get() = a
|
||||
<warning>abstract</warning> val e2: Int <error>get() = a</error>
|
||||
<warning>abstract</warning> val e3: Int = <error>0</error>; <error>get() = a</error>
|
||||
|
||||
//methods
|
||||
fun f()
|
||||
fun g() {}
|
||||
<warning>abstract</warning> fun h()
|
||||
<error>abstract</error> fun j() {}
|
||||
}
|
||||
|
||||
enum class MyEnum() {
|
||||
//properties
|
||||
val <error>a</error>: Int
|
||||
val a1: Int = 1
|
||||
abstract val a2: Int
|
||||
abstract val a3: Int = <error>1</error>
|
||||
|
||||
var <error>b</error>: Int private set
|
||||
var b1: Int = 0; private set
|
||||
abstract var b2: Int private set
|
||||
abstract var b3: Int = <error>0</error>; private set
|
||||
|
||||
var <error>c</error>: Int set(v: Int) { $c = v }
|
||||
var c1: Int = 0; set(v: Int) { $c1 = v }
|
||||
abstract var c2: Int <error>set(v: Int) { $c2 = v }</error>
|
||||
abstract var c3: Int = <error>0</error>; <error>set(v: Int) { $c3 = v }</error>
|
||||
|
||||
val e: Int get() = a
|
||||
val e1: Int = <error>0</error>; get() = a
|
||||
abstract val e2: Int <error>get() = a</error>
|
||||
abstract val e3: Int = <error>0</error>; <error>get() = a</error>
|
||||
|
||||
//methods
|
||||
fun <error>f</error>()
|
||||
fun g() {}
|
||||
abstract fun h()
|
||||
<error>abstract</error> fun j() {}
|
||||
}
|
||||
|
||||
abstract enum class MyAbstractEnum() {}
|
||||
|
||||
namespace MyNamespace {
|
||||
//properties
|
||||
val <error>a</error>: Int
|
||||
val a1: Int = 1
|
||||
<error>abstract</error> val a2: Int
|
||||
<error>abstract</error> val a3: Int = 1
|
||||
|
||||
var <error>b</error>: Int private set
|
||||
var b1: Int = 0; private set
|
||||
<error>abstract</error> var b2: Int private set
|
||||
<error>abstract</error> var b3: Int = 0; private set
|
||||
|
||||
var <error>c</error>: Int set(v: Int) { $c = v }
|
||||
var c1: Int = 0; set(v: Int) { $c1 = v }
|
||||
<error>abstract</error> var c2: Int set(v: Int) { $c2 = v }
|
||||
<error>abstract</error> var c3: Int = 0; set(v: Int) { $c3 = v }
|
||||
|
||||
val e: Int get() = a
|
||||
val e1: Int = <error>0</error>; get() = a
|
||||
<error>abstract</error> val e2: Int get() = a
|
||||
<error>abstract</error> val e3: Int = 0; get() = a
|
||||
|
||||
//methods
|
||||
fun <error>f</error>()
|
||||
fun g() {}
|
||||
<error>abstract</error> fun h()
|
||||
<error>abstract</error> fun j() {}
|
||||
}
|
||||
|
||||
//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 = <error>B3()</error>
|
||||
val b = <error>B1(2, "s")</error>
|
||||
}
|
||||
@@ -1,34 +0,0 @@
|
||||
class NoC {
|
||||
<error>{
|
||||
|
||||
}</error>
|
||||
|
||||
val a : Int get() = 1
|
||||
|
||||
<error>{
|
||||
|
||||
}</error>
|
||||
}
|
||||
|
||||
class WithC() {
|
||||
val x : Int
|
||||
{
|
||||
$x = 1
|
||||
<error>$y</error> = 2
|
||||
val b = x
|
||||
|
||||
}
|
||||
|
||||
val a : Int get() = 1
|
||||
|
||||
{
|
||||
val z = <error>b</error>
|
||||
val zz = x
|
||||
val zzz = <error>$a</error>
|
||||
}
|
||||
|
||||
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 <error>+</error> 1
|
||||
x <error>plus</error> 1
|
||||
x <error><</error> 1
|
||||
x <error>+=</error> 1
|
||||
|
||||
x == 1
|
||||
x != 1
|
||||
|
||||
<error>A() == 1</error>
|
||||
B() <error>==</error> 1
|
||||
C() <error>==</error> 1
|
||||
|
||||
<error>x === "1"</error>
|
||||
<error>x !== "1"</error>
|
||||
|
||||
x === 1
|
||||
x !== 1
|
||||
|
||||
x<error>..</error>2
|
||||
<error>x</error> in 1..2
|
||||
|
||||
val y : Boolean? = true
|
||||
false || <error>y</error>
|
||||
<error>y</error> && true
|
||||
<error>y</error> && <error>1</error>
|
||||
}
|
||||
@@ -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<<error>Int</error>>()
|
||||
|
||||
class X<A, B : A>()
|
||||
|
||||
val b = X<Any, X<A<C>, C>>
|
||||
val b0 = X<Any, <error>Any?</error>>
|
||||
val b1 = X<Any, X<A<C>, <error>String</error>>>
|
||||
|
||||
}
|
||||
|
||||
open class A {}
|
||||
open class B<T : A>()
|
||||
|
||||
abstract class C<T : B<<error>Int</error>>, X : fun (B<<error>Char</error>>) : (B<<error>Any</error>>, B<A>)>() : B<<error>Any</error>>() { // 2 errors
|
||||
val a = B<<error>Char</error>>() // error
|
||||
|
||||
abstract val x : fun (B<<error>Char</error>>) : B<<error>Any</error>>
|
||||
}
|
||||
|
||||
|
||||
fun test() {
|
||||
foo<<error>Int?</error>>()
|
||||
foo<Int>()
|
||||
bar<Int?>()
|
||||
bar<Int>()
|
||||
bar<<error>Double?</error>>()
|
||||
bar<<error>Double</error>>()
|
||||
1.buzz<<error>Double</error>>()
|
||||
}
|
||||
|
||||
fun foo<T : Any>() {}
|
||||
fun bar<T : Int?>() {}
|
||||
fun <T : <warning>Int</warning>> Int.buzz() : Unit {}
|
||||
@@ -1,28 +0,0 @@
|
||||
class C {
|
||||
|
||||
fun f (a : Boolean, b : Boolean) {
|
||||
@b (while (true)
|
||||
@a {
|
||||
<error>break@f</error>
|
||||
break
|
||||
break@b
|
||||
<error>break@a</error>
|
||||
})
|
||||
|
||||
<error>continue</error>
|
||||
|
||||
@b (while (true)
|
||||
@a {
|
||||
<error>continue@f</error>
|
||||
continue
|
||||
continue@b
|
||||
<error>continue@a</error>
|
||||
})
|
||||
|
||||
<error>break</error>
|
||||
|
||||
<error>continue@f</error>
|
||||
<error>break@f</error>
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,121 +0,0 @@
|
||||
import 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(TextElement(this))
|
||||
}
|
||||
}
|
||||
|
||||
class HTML() : TagWithText("html") {
|
||||
class object : Factory<HTML> {
|
||||
override fun create() = HTML()
|
||||
}
|
||||
|
||||
fun head(init : fun Head.() : Unit) = initTag<Head>(init)
|
||||
|
||||
fun body(init : fun Body.() : Unit) = initTag<Body>(init)
|
||||
}
|
||||
|
||||
class Head() : TagWithText("head") {
|
||||
class object : Factory<Head> {
|
||||
override fun create() = Head()
|
||||
}
|
||||
|
||||
fun title(init : fun Title.() : Unit) = 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() = Body()
|
||||
}
|
||||
|
||||
fun b(init : fun B.() : Unit) = initTag<B>(init)
|
||||
fun p(init : fun P.() : Unit) = initTag<P>(init)
|
||||
fun h1(init : fun H1.() : Unit) = initTag<H1>(init)
|
||||
fun a(href : String, init : fun A.() : Unit) {
|
||||
val a = 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 = HTML()
|
||||
html.init()
|
||||
return html
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
namespace foo {
|
||||
|
||||
import html.*
|
||||
|
||||
fun result(args : Array<String>) =
|
||||
html {
|
||||
head {
|
||||
title {+"XML encoding with Groovy"}
|
||||
}
|
||||
body {
|
||||
h1 {+"XML encoding with Groovy"}
|
||||
p {+"this format can be used as an alternative markup to XML"}
|
||||
|
||||
// an element with attributes and text content
|
||||
a(href = "http://groovy.codehaus.org") {+"Groovy"}
|
||||
|
||||
// mixed content
|
||||
p {
|
||||
+"This is some"
|
||||
b {+"mixed"}
|
||||
+"text. For more see the"
|
||||
a(href = "http://groovy.codehaus.org") {+"Groovy"}
|
||||
+"project"
|
||||
}
|
||||
p {+"some text"}
|
||||
|
||||
// content generated by
|
||||
p {
|
||||
for (arg in args)
|
||||
+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 <warning>as</warning> Int : Int
|
||||
x <warning>as</warning> Int? : Int?
|
||||
y <warning>as</warning> Int? : Int?
|
||||
x as? Int : Int?
|
||||
y <warning>as?</warning> Int : Int?
|
||||
x <warning>as?</warning> Int? : Int?
|
||||
y <warning>as?</warning> Int? : Int?
|
||||
()
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
namespace Jet86
|
||||
|
||||
class A {
|
||||
class object {
|
||||
val x = 1
|
||||
}
|
||||
<error>class object { // error
|
||||
val x = 1
|
||||
}</error>
|
||||
}
|
||||
|
||||
class B() {
|
||||
val x = 12
|
||||
}
|
||||
|
||||
object b {
|
||||
<error>class object {
|
||||
val x = 1
|
||||
}</error> // error
|
||||
}
|
||||
|
||||
val a = A.x
|
||||
val c = <error>B</error>.x
|
||||
val d = b.<error>x</error>
|
||||
|
||||
val s = <error>System</error> // error
|
||||
fun test() {
|
||||
System.out?.println()
|
||||
java.lang.System.out?.println()
|
||||
}
|
||||
@@ -1,8 +0,0 @@
|
||||
fun test() {
|
||||
1 : Byte
|
||||
1 : Int
|
||||
<error>1</error> : Double
|
||||
1 <warning>as</warning> Byte
|
||||
1 <warning>as</warning> Int
|
||||
<error>1</error> <warning>as</warning> Double
|
||||
}
|
||||
@@ -1,51 +0,0 @@
|
||||
|
||||
open class NoC
|
||||
class NoC1 : NoC
|
||||
|
||||
class WithC0() : NoC<error>()</error>
|
||||
open class WithC1() : NoC
|
||||
class NoC2 : <error>WithC1</error>
|
||||
class NoC3 : WithC1<error>()</error>
|
||||
class WithC2() : <error>WithC1</error>
|
||||
|
||||
class NoPC {
|
||||
<error>this</error>() {}
|
||||
}
|
||||
|
||||
class WithPC0() {
|
||||
this(a : Int) : this() {}
|
||||
}
|
||||
|
||||
class WithPC1(a : Int) {
|
||||
<error>this</error>() {}
|
||||
|
||||
this(b : Long) : this("") {}
|
||||
|
||||
this(s : String) : this(1) {}
|
||||
|
||||
this(b : Char) : <error>this</error>("", 2) {}
|
||||
|
||||
this(b : Byte) : this(""), <error>this(1)</error> {}
|
||||
}
|
||||
|
||||
|
||||
class Foo() : <error>WithPC0</error>, <error>this</error>() {
|
||||
|
||||
}
|
||||
|
||||
class WithCPI_Dup(x : Int) {
|
||||
var <error>x</error> : Int
|
||||
}
|
||||
|
||||
class WithCPI(x : Int) {
|
||||
val a = 1
|
||||
val b : Int = $a
|
||||
val xy : Int = x
|
||||
}
|
||||
|
||||
class <error>NoCPI</error> {
|
||||
val a = <error>1</error>
|
||||
var ab = <error>1</error>
|
||||
get() = 1
|
||||
set(v) {}
|
||||
}
|
||||
@@ -1,30 +0,0 @@
|
||||
trait A {
|
||||
fun foo() {}
|
||||
}
|
||||
trait B : A, <error>E</error> {}
|
||||
trait C : B {}
|
||||
trait D : <error>B</error> {}
|
||||
trait E : <error>F</error> {}
|
||||
trait F : <error>D</error>, C {}
|
||||
trait G : F {}
|
||||
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?.<error>foo</error>()
|
||||
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<warning>?.</warning>minus<T>(this)
|
||||
|
||||
return this
|
||||
}
|
||||
|
||||
class A
|
||||
|
||||
fun A.plus(a : Any) {
|
||||
|
||||
1.foo()
|
||||
true.<error>foo</error>()
|
||||
|
||||
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.<error>foo</error> : 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>) {
|
||||
|
||||
System.out?.print(1)
|
||||
|
||||
val command = parse("")
|
||||
|
||||
command.foo
|
||||
|
||||
command.equals(null)
|
||||
command?.equals(null)
|
||||
command.equals1(null)
|
||||
command<warning>?.</warning>equals1(null)
|
||||
|
||||
val c = Command()
|
||||
c<warning>?.</warning>equals2(null)
|
||||
|
||||
if (command == null) 1
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,81 +0,0 @@
|
||||
import 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 <error>notRange1</error>);
|
||||
for (i in <error>notRange2</error>);
|
||||
for (i in <error>notRange3</error>);
|
||||
for (i in <error>notRange4</error>);
|
||||
for (i in <error>notRange5</error>);
|
||||
for (i in <error>notRange6</error>);
|
||||
for (i in <error>notRange7</error>);
|
||||
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 <error>1</error>}
|
||||
fun unitUnitReturn() : Unit {return ()}
|
||||
fun test1() : Any = {<error>return</error>}
|
||||
fun test2() : Any = @a {return@a 1}
|
||||
fun test3() : Any { <error>return</error> }
|
||||
|
||||
fun bbb() {
|
||||
return <error>1</error>
|
||||
}
|
||||
|
||||
fun foo(expr: StringBuilder): Int {
|
||||
val c = 'a'
|
||||
when(c) {
|
||||
0.chr => throw Exception("zero")
|
||||
else => throw Exception("nonzero" + c)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
fun unitShort() : Unit = ()
|
||||
fun unitShortConv() : Unit = <error>1</error>
|
||||
fun unitShortNull() : Unit = <error>null</error>
|
||||
|
||||
fun intEmpty() : Int <error>{}</error>
|
||||
fun intShortInfer() = 1
|
||||
fun intShort() : Int = 1
|
||||
//fun intBlockInfer() {1}
|
||||
fun intBlock() : Int {return 1}
|
||||
fun intBlock() : Int {<error>1</error>}
|
||||
|
||||
fun intString(): Int = <error>"s"</error>
|
||||
fun intFunctionLiteral(): Int = <error>{ 10 }</error>
|
||||
|
||||
fun blockReturnUnitMismatch() : Int {<error>return</error>}
|
||||
fun blockReturnValueTypeMismatch() : Int {return <error>3.4</error>}
|
||||
fun blockReturnValueTypeMatch() : Int {return 1}
|
||||
fun blockReturnValueTypeMismatchUnit() : Int {return <error>()</error>}
|
||||
|
||||
fun blockAndAndMismatch() : Int {
|
||||
<error>true && false</error>
|
||||
}
|
||||
fun blockAndAndMismatch() : Int {
|
||||
return <error>true && false</error>
|
||||
}
|
||||
fun blockAndAndMismatch() : Int {
|
||||
<error>(return <error>true</error>) && (return <error>false</error>)</error>
|
||||
}
|
||||
|
||||
fun blockAndAndMismatch() : Int {
|
||||
<error>true || false</error>
|
||||
}
|
||||
fun blockAndAndMismatch() : Int {
|
||||
return <error>true || false</error>
|
||||
}
|
||||
fun blockAndAndMismatch() : Int {
|
||||
<error>(return <error>true</error>) || (return <error>false</error>)</error>
|
||||
}
|
||||
fun blockReturnValueTypeMatch() : Int {
|
||||
return if (1 > 2) <error>1.0</error> else <error>2.0</error>
|
||||
}
|
||||
fun blockReturnValueTypeMatch() : Int {
|
||||
return <error>if (1 > 2) 1</error>
|
||||
}
|
||||
fun blockReturnValueTypeMatch() : Int {
|
||||
return <error>if (1 > 2) else 1</error>
|
||||
}
|
||||
fun blockReturnValueTypeMatch() : Int {
|
||||
if (1 > 2)
|
||||
return <error>1.0</error>
|
||||
else return <error>2.0</error>
|
||||
}
|
||||
fun blockReturnValueTypeMatch() : Int {
|
||||
if (1 > 2)
|
||||
return <error>1.0</error>
|
||||
return <error>2.0</error>
|
||||
}
|
||||
fun blockReturnValueTypeMatch() : Int {
|
||||
if (1 > 2)
|
||||
else return <error>1.0</error>
|
||||
return <error>2.0</error>
|
||||
}
|
||||
fun blockReturnValueTypeMatch() : Int {
|
||||
if (1 > 2)
|
||||
<error>1.0</error>
|
||||
else <error>2.0</error>
|
||||
}
|
||||
fun blockReturnValueTypeMatch() : Int {
|
||||
if (1 > 2)
|
||||
1.0
|
||||
else 2.0
|
||||
return 1
|
||||
}
|
||||
fun blockReturnValueTypeMatch() : Int {
|
||||
<error>if (1 > 2)
|
||||
<error>1.0</error></error>
|
||||
}
|
||||
fun blockReturnValueTypeMatch() : Int {
|
||||
return <error>if (1 > 2)
|
||||
1</error>
|
||||
}
|
||||
fun blockReturnValueTypeMatch() : Int {
|
||||
<error>if (1 > 2)
|
||||
else <error>1.0</error></error>
|
||||
}
|
||||
fun blockReturnValueTypeMatch() : Int {
|
||||
if (1 > 2)
|
||||
return 1
|
||||
else return <error>1.0</error>
|
||||
}
|
||||
fun blockNoReturnIfValDeclaration(): Int {
|
||||
<error>val x = 1</error>
|
||||
}
|
||||
fun blockNoReturnIfEmptyIf(): Int {
|
||||
if (1 < 2) <error>{}</error> else <error>{}</error>
|
||||
}
|
||||
fun blockNoReturnIfUnitInOneBranch(): Int {
|
||||
if (1 < 2) {
|
||||
return 1
|
||||
} else {
|
||||
if (3 < 4) <error>{
|
||||
}</error> else {
|
||||
return 2
|
||||
}
|
||||
}
|
||||
}
|
||||
fun nonBlockReturnIfEmptyIf(): Int = if (1 < 2) <error>{}</error> else <error>{}</error>
|
||||
fun nonBlockNoReturnIfUnitInOneBranch(): Int = if (1 < 2) <error>{}</error> else 2
|
||||
|
||||
val a = <error>return 1</error>
|
||||
|
||||
class A() {
|
||||
this(a : Int) : this() {
|
||||
if (a == 1)
|
||||
return
|
||||
return <error>1</error>
|
||||
}
|
||||
|
||||
}
|
||||
fun illegalConstantBody(): Int = <error>"s"</error>
|
||||
fun illegalConstantBlock(): String {
|
||||
return <error>1</error>
|
||||
}
|
||||
fun illegalIfBody(): Int =
|
||||
if (1 < 2) <error>'a'</error> else { <error>1.0</error> }
|
||||
fun illegalIfBlock(): Boolean {
|
||||
if (1 < 2)
|
||||
return false
|
||||
else { return <error>1</error> }
|
||||
}
|
||||
fun illegalReturnIf(): Char {
|
||||
return if (1 < 2) 'a' else { <error>1</error> }
|
||||
}
|
||||
|
||||
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> : <error>B<T>, A<T></error> {}
|
||||
trait C1<T> : B<T>, A<Any> {}
|
||||
trait D : <error>C<Boolean>, B<Double></error>{}
|
||||
|
||||
trait A1<out T> {}
|
||||
trait B1 : A1<Int> {}
|
||||
trait B2 : A1<Any>, B1 {}
|
||||
|
||||
trait BA1<T> {}
|
||||
trait BB1 : BA1<Int> {}
|
||||
trait BB2 : <error>BA1<Any>, BB1</error> {}
|
||||
|
||||
|
||||
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 : <error>AA1<Number>, AB1, AB3</error> {}
|
||||
}
|
||||
|
||||
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 : <error>AA1<Number>, AB1, AB3</error> {}
|
||||
}
|
||||
@@ -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<error>++</error>
|
||||
<error>++</error>x
|
||||
x<error>--</error>
|
||||
<error>--</error>x
|
||||
}
|
||||
|
||||
class UnitIncDec() {
|
||||
fun inc() : Unit {}
|
||||
fun dec() : Unit {}
|
||||
}
|
||||
|
||||
fun testUnitIncDec() {
|
||||
var x = UnitIncDec()
|
||||
x++
|
||||
++x
|
||||
x--
|
||||
--x
|
||||
x = <error>x++</error>
|
||||
x = <error>x--</error>
|
||||
x = <error>++x</error>
|
||||
x = <error>--x</error>
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
fun test() {
|
||||
if (1 is Int) {
|
||||
if (1 is <error>Boolean</error>) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -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,
|
||||
<error>B</error> : T, // error
|
||||
class object T : A,
|
||||
class object T : B,
|
||||
class object <error>B</error> : T
|
||||
{
|
||||
|
||||
fun test(t : T) {
|
||||
T.foo()
|
||||
T.bar()
|
||||
t.foo()
|
||||
t.bar()
|
||||
}
|
||||
}
|
||||
|
||||
fun test() {
|
||||
Test1<<error>B</error>>()
|
||||
Test1<<error>A</error>>()
|
||||
Test1<C>()
|
||||
}
|
||||
|
||||
class Foo() {}
|
||||
|
||||
class Bar<T : <warning>Foo</warning>>
|
||||
|
||||
class Buzz<T> where T : <warning>Bar<<error>Int</error>></warning>, T : <error>nioho</error>
|
||||
|
||||
class X<T : <warning>Foo</warning>>
|
||||
class Y<<error>T</error> : <warning>Foo</warning>> where T : <warning>Bar<Foo></warning>
|
||||
|
||||
fun <T : A> test2(t : T)
|
||||
where
|
||||
T : B,
|
||||
<error>B</error> : T,
|
||||
class object <error>B</error> : T,
|
||||
class object T : B,
|
||||
class object T : A
|
||||
{
|
||||
T.foo()
|
||||
T.bar()
|
||||
t.foo()
|
||||
t.bar()
|
||||
}
|
||||
|
||||
val t1 = test2<<error>A</error>>(A())
|
||||
val t2 = test2<<error>B</error>>(C())
|
||||
val t3 = test2<C>(C())
|
||||
|
||||
class Test<<error>T</error>>
|
||||
where
|
||||
class object T : <error>Foo</error>,
|
||||
class object T : A {}
|
||||
|
||||
val <T, B : T> x : Int = 0
|
||||
@@ -1,8 +0,0 @@
|
||||
namespace root
|
||||
|
||||
namespace a {
|
||||
|
||||
}
|
||||
|
||||
val x = <error>a</error>
|
||||
val y2 = <error>namespace</error>
|
||||
@@ -1,63 +0,0 @@
|
||||
namespace foobar
|
||||
|
||||
namespace a {
|
||||
import java.*
|
||||
|
||||
val a : util.List<Int>? = null
|
||||
val a1 : <error>List</error><Int>? = null
|
||||
|
||||
}
|
||||
|
||||
abstract class Foo<T>() {
|
||||
abstract val x : T<Int>
|
||||
}
|
||||
|
||||
namespace a {
|
||||
import java.util.*
|
||||
|
||||
val b : List<Int>? = a
|
||||
val b1 : <error>util</error>.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>(var 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 : java.io.PrintStream? = null//= System.out
|
||||
val ins = System.`in`
|
||||
|
||||
out?.println()
|
||||
ins?.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?.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?.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?.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 : <error>Foo</error> {}
|
||||
|
||||
object A : <error>Foo</error> {
|
||||
val x : Int = 2
|
||||
|
||||
fun test() : Int {
|
||||
return x + foo()
|
||||
}
|
||||
}
|
||||
|
||||
object B : <error>A</error> {}
|
||||
|
||||
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<error>@A</error>
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
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.<error>A</error>.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 = <error>B</error>.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 <error>MyIllegalClass</error> : MyTrait, MyAbstractClass {}
|
||||
|
||||
class <error>MyIllegalClass2</error> : MyTrait, MyAbstractClass {
|
||||
override fun foo() {}
|
||||
}
|
||||
|
||||
class <error>MyIllegalClass3</error> : MyTrait, MyAbstractClass {
|
||||
override fun bar() {}
|
||||
}
|
||||
|
||||
class <error>MyIllegalClass4</error> : MyTrait, MyAbstractClass {
|
||||
fun <error>foo</error>() {}
|
||||
<error>override</error> fun other() {}
|
||||
}
|
||||
|
||||
class MyChildClass1 : MyClass {
|
||||
fun <error>foo</error>() {}
|
||||
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 <error>foo</error>(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 <error>MyIllegalGenericClass1</error><T> : MyTrait<T>, MyAbstractClass<T> {}
|
||||
class <error>MyIllegalGenericClass2</error><T, R> : MyTrait<T>, MyAbstractClass<R> {
|
||||
<error>override</error> fun foo(r: R) = r
|
||||
}
|
||||
class <error>MyIllegalClass1</error> : MyTrait<Int>, MyAbstractClass<String> {}
|
||||
|
||||
class <error>MyIllegalClass2</error><T> : MyTrait<Int>, MyAbstractClass<Int> {
|
||||
fun foo(t: T) = t
|
||||
fun bar(t: T) = t
|
||||
}
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
class <error>X</error> {
|
||||
val <error>x</error> : Int
|
||||
}
|
||||
|
||||
open class Y() {
|
||||
val x : Int = 2
|
||||
}
|
||||
|
||||
class Y1 {
|
||||
val x : Int get() = 1
|
||||
}
|
||||
|
||||
class Z : Y<error>()</error> {
|
||||
}
|
||||
@@ -1,6 +0,0 @@
|
||||
trait A<T> {}
|
||||
trait B<T> {}
|
||||
trait C<T> {}
|
||||
trait D<T> {}
|
||||
|
||||
trait Test : A<<error>in</error> Int>, B<<error>out</error> Int>, C<<error>*</error>><error>?</error><error>?</error><error>?</error>, D<Int> {}
|
||||
@@ -1,28 +0,0 @@
|
||||
var x : Int = 1 + x
|
||||
get() : Int = 1
|
||||
set(<error>ref</error> value : <error>Long</error>) {
|
||||
$x = value.int
|
||||
$x = <error>1.lng</error>
|
||||
}
|
||||
|
||||
val xx : Int = <error>1 + x</error>
|
||||
get() : Int = 1
|
||||
<error>set(value : Long) {}</error>
|
||||
|
||||
val p : Int = <error>1</error>
|
||||
get() = 1
|
||||
|
||||
class Test() {
|
||||
var a : Int = 111
|
||||
var b : Int get() = <error>$a</error>; set(x) {a = x; <error>$a</error> = x}
|
||||
|
||||
this(i : Int) : this() {
|
||||
<error>$b</error> = $a
|
||||
$a = <error>$b</error>
|
||||
a = <error>$b</error>
|
||||
}
|
||||
fun f() {
|
||||
<error>$b</error> = <error>$a</error>
|
||||
a = <error>$b</error>
|
||||
}
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
namespace qualified_expressions
|
||||
|
||||
fun test(s: String?) {
|
||||
val a: Int = <error>s?.length</error>
|
||||
val b: Int? = s?.length
|
||||
val c: Int = s?.length ?: -11
|
||||
val d: Int = s?.length ?: <error>"empty"</error>
|
||||
val e: String = <error>s?.length</error> ?: "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<error>@Dup</error>
|
||||
}
|
||||
}
|
||||
|
||||
class A() {
|
||||
fun foo() : Unit {
|
||||
this@A
|
||||
this<error>@a</error>
|
||||
this
|
||||
}
|
||||
|
||||
val x = this@A.foo()
|
||||
val y = this.foo()
|
||||
val z = foo()
|
||||
}
|
||||
|
||||
fun foo1() : Unit {
|
||||
<error>this</error>
|
||||
this<error>@a</error>
|
||||
}
|
||||
|
||||
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{() => <error>this@a</error> + this@xx : Char}
|
||||
return (@a{Double.() => this@a : Double + this@xx : Char})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
namespace a {
|
||||
val foo = <error>bar()</error>
|
||||
|
||||
fun bar() = foo
|
||||
}
|
||||
|
||||
namespace b {
|
||||
fun foo() = <error>bar()</error>
|
||||
|
||||
fun bar() = foo()
|
||||
}
|
||||
|
||||
namespace c {
|
||||
fun bazz() = <error>bar()</error>
|
||||
|
||||
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,16 +0,0 @@
|
||||
namespace redeclarations {
|
||||
object <error>A</error> {
|
||||
val x : Int = 0
|
||||
|
||||
val A = 1
|
||||
}
|
||||
|
||||
namespace <error>A</error> {
|
||||
class A {}
|
||||
}
|
||||
|
||||
class <error>A</error> {}
|
||||
|
||||
val <error>A</error> = 1
|
||||
|
||||
}
|
||||
@@ -1,52 +0,0 @@
|
||||
import java.*
|
||||
import util.*
|
||||
import <error>utils</error>.*
|
||||
|
||||
import java.io.PrintStream
|
||||
import java.lang.Comparable as Com
|
||||
|
||||
val l : List<in Int> = ArrayList<Int>()
|
||||
|
||||
fun test(l : java.util.List<Int>) {
|
||||
val x : java.<error>List</error>
|
||||
val y : java.util.List<Int>
|
||||
val b : java.lang.Object
|
||||
val a : util.List<Int>
|
||||
val z : java.<error>utils</error>.List<Int>
|
||||
|
||||
val f : java.io.File? = null
|
||||
|
||||
Collections.<error>emptyList</error>
|
||||
Collections.emptyList<Int>
|
||||
Collections.emptyList<Int>()
|
||||
Collections.emptyList()
|
||||
|
||||
Collections.singleton<Int>(1) : Set<Int>?
|
||||
Collections.singleton<Int>(<error>1.0</error>)
|
||||
|
||||
<error>List</error><Int>
|
||||
|
||||
|
||||
val o = "sdf" <warning>as</warning> Object
|
||||
|
||||
try {
|
||||
// ...
|
||||
}
|
||||
catch(e: Exception) {
|
||||
System.out?.println(e.getMessage())
|
||||
}
|
||||
|
||||
PrintStream("sdf")
|
||||
|
||||
val c : Com<Int>? = null
|
||||
|
||||
c : java.lang.Comparable<Int>?
|
||||
|
||||
// Collections.sort<Integer>(ArrayList<Integer>())
|
||||
xxx.<error>Class</error>()
|
||||
}
|
||||
|
||||
|
||||
namespace xxx {
|
||||
import 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<error>\x</error>"
|
||||
"asd$a$asd$ $<error>xxx</error>"
|
||||
"fosdfasdo${1 + bar + 100}}sdsdfgdsfsdf"
|
||||
"foo${bar + map {foo}}sdfsdf"
|
||||
"foo${bar + map { "foo" }}sdfsdf"
|
||||
"foo${bar + map {
|
||||
"foo$sdf${ buzz{}}" }}sdfsdf"
|
||||
}
|
||||
@@ -1,51 +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<error>()</error> {
|
||||
<error>this</error>(x : Int) {}
|
||||
}
|
||||
|
||||
trait Test1 : C2<error>()</error> {}
|
||||
|
||||
trait Test2 : C2 {}
|
||||
|
||||
trait Test3 : C2, <error>C3</error> {}
|
||||
|
||||
trait Test4 : T1 {}
|
||||
|
||||
trait Test5 : T1, <error>T1</error> {}
|
||||
|
||||
trait Test6 : <error>C1</error> {}
|
||||
|
||||
class CTest1() : OC1() {}
|
||||
|
||||
class CTest2 : C2 {}
|
||||
|
||||
class CTest3 : C2, <error>C3</error> {}
|
||||
|
||||
class CTest4 : T1 {}
|
||||
|
||||
class CTest5 : T1, <error>T1</error> {}
|
||||
|
||||
class CTest6 : <error>C1</error> {}
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
open class bar()
|
||||
|
||||
trait Foo<error>()</error> : bar<error>()</error>, <error>bar</error>, <error>bar</error> {
|
||||
<error>this</error>(x : Int) {}
|
||||
}
|
||||
|
||||
trait Foo2 : bar, Foo {
|
||||
}
|
||||
|
||||
open class Foo1() : bar(), <error>bar</error>, Foo, <error>Foo</error><error>()</error> {}
|
||||
open class Foo12 : bar<error>()</error>, <error>bar</error> {}
|
||||
@@ -1,161 +0,0 @@
|
||||
fun t1() : Int{
|
||||
return 0
|
||||
<error>1</error>
|
||||
}
|
||||
|
||||
fun t1a() : Int {
|
||||
<error>return</error>
|
||||
<error>return 1</error>
|
||||
<error>1</error>
|
||||
}
|
||||
|
||||
fun t1b() : Int {
|
||||
return 1
|
||||
<error>return 1</error>
|
||||
<error>1</error>
|
||||
}
|
||||
|
||||
fun t1c() : Int {
|
||||
return 1
|
||||
<error>return</error>
|
||||
<error>1</error>
|
||||
}
|
||||
|
||||
fun t2() : Int {
|
||||
if (1 > 2)
|
||||
return 1
|
||||
else return 1
|
||||
<error>1</error>
|
||||
}
|
||||
|
||||
fun t2a() : Int {
|
||||
if (1 > 2) {
|
||||
return 1
|
||||
<error>1</error>
|
||||
} else { return 1
|
||||
<error>2</error>
|
||||
}
|
||||
<error>1</error>
|
||||
}
|
||||
|
||||
fun t3() : Any {
|
||||
if (1 > 2)
|
||||
return 2
|
||||
else return ""
|
||||
<error>1</error>
|
||||
}
|
||||
|
||||
fun t4(a : Boolean) : Int {
|
||||
do {
|
||||
return 1
|
||||
}
|
||||
while (<error>a</error>)
|
||||
<error>1</error>
|
||||
}
|
||||
|
||||
fun t4break(a : Boolean) : Int {
|
||||
do {
|
||||
break
|
||||
}
|
||||
while (<error>a</error>)
|
||||
return 1
|
||||
}
|
||||
|
||||
fun t5() : Int {
|
||||
do {
|
||||
return 1
|
||||
<error>2</error>
|
||||
}
|
||||
while (<error>1 > 2</error>)
|
||||
<error>return 1</error>
|
||||
}
|
||||
|
||||
fun t6() : Int {
|
||||
while (1 > 2) {
|
||||
return 1
|
||||
<error>2</error>
|
||||
}
|
||||
return 1
|
||||
}
|
||||
|
||||
fun t6break() : Int {
|
||||
while (1 > 2) {
|
||||
break
|
||||
<error>2</error>
|
||||
}
|
||||
return 1
|
||||
}
|
||||
|
||||
fun t7(b : Int) : Int {
|
||||
for (i in 1..b) {
|
||||
return 1
|
||||
<error>2</error>
|
||||
}
|
||||
return 1
|
||||
}
|
||||
|
||||
fun t7break(b : Int) : Int {
|
||||
for (i in 1..b) {
|
||||
return 1
|
||||
<error>2</error>
|
||||
}
|
||||
return 1
|
||||
}
|
||||
|
||||
fun t7() : Int {
|
||||
try {
|
||||
return 1
|
||||
<error>2</error>
|
||||
}
|
||||
catch (e : Any) {
|
||||
2
|
||||
}
|
||||
return 1 // this is OK, like in Java
|
||||
}
|
||||
|
||||
fun t8() : Int {
|
||||
try {
|
||||
return 1
|
||||
<error>2</error>
|
||||
}
|
||||
catch (e : Any) {
|
||||
return 1
|
||||
<error>2</error>
|
||||
}
|
||||
<error>return 1</error>
|
||||
}
|
||||
|
||||
fun blockAndAndMismatch() : Boolean {
|
||||
<error>(return true) || (return false)</error>
|
||||
<error>return true</error>
|
||||
}
|
||||
|
||||
fun tf() : Int {
|
||||
try {<error>return 1</error>} finally{return 1}
|
||||
<error>return 1</error>
|
||||
}
|
||||
|
||||
fun failtest(a : Int) : Int {
|
||||
if (fail() || <error>true</error>) {
|
||||
|
||||
}
|
||||
<error>return 1</error>
|
||||
}
|
||||
|
||||
fun foo(a : Nothing) : Unit {
|
||||
1
|
||||
a
|
||||
<error>2</error>
|
||||
}
|
||||
|
||||
fun fail() : Nothing {
|
||||
throw java.lang.RuntimeException()
|
||||
}
|
||||
|
||||
fun nullIsNotNothing() : Unit {
|
||||
val x : Int? = 1
|
||||
if (x != null) {
|
||||
return
|
||||
}
|
||||
fail()
|
||||
}
|
||||
@@ -1,31 +0,0 @@
|
||||
namespace unresolved
|
||||
|
||||
fun testGenericArgumentsCount() {
|
||||
val p1: Tuple2<error><Int></error> = (2, 2)
|
||||
val p2: <error>Tuple2</error> = (2, 2)
|
||||
}
|
||||
|
||||
fun testUnresolved() {
|
||||
if (<error>a</error> is String) {
|
||||
val s = <error>a</error>
|
||||
}
|
||||
<error>foo</error>(<error>a</error>)
|
||||
val s = "s"
|
||||
<error>foo</error>(s)
|
||||
foo1(<error>i</error>)
|
||||
s.<error>foo</error>()
|
||||
|
||||
when(<error>a</error>) {
|
||||
is Int => <error>a</error>
|
||||
is String => <error>a</error>
|
||||
}
|
||||
|
||||
//TODO
|
||||
for (j in <error>collection</error>) {
|
||||
var i: Int = j
|
||||
i += 1
|
||||
foo1(j)
|
||||
}
|
||||
}
|
||||
|
||||
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> = <error>c</error>
|
||||
val c2: Consumer<Int> = c1
|
||||
|
||||
val p1: Producer<Any> = p
|
||||
val p2: Producer<Int> = <error>p1</error>
|
||||
|
||||
val u1: Usual<Any> = <error>u</error>
|
||||
val u2: Usual<Int> = <error>u1</error>
|
||||
}
|
||||
|
||||
//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(<error>ints</error>, any)
|
||||
copy2(ints, any) //ok
|
||||
copy2(ints, <error>numbers</error>)
|
||||
copy3<Int>(ints, numbers)
|
||||
copy4(ints, numbers) //ok
|
||||
}
|
||||
@@ -1,63 +0,0 @@
|
||||
fun Int.foo() : Boolean = true
|
||||
|
||||
fun foo() : Int {
|
||||
val s = ""
|
||||
val x = 1
|
||||
when (x) {
|
||||
is * => 1
|
||||
is <error>String</error> => 1
|
||||
!is Int => 1
|
||||
is Any? => 1
|
||||
<error>s</error> => 1
|
||||
1 => 1
|
||||
1 + <error>a</error> => 1
|
||||
in 1..<error>a</error> => 1
|
||||
!in 1..<error>a</error> => 1
|
||||
.<error>a</error> => 1
|
||||
.equals(1).<error>a</error> => 1
|
||||
<warning>?.</warning>equals(1) => 1
|
||||
else => 1
|
||||
}
|
||||
return when (<warning>x</warning>?:null) {
|
||||
<error>.</error>foo() => 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) {
|
||||
<error>s</error> => 1
|
||||
is <error>""</error> => 1
|
||||
x => 1
|
||||
is 1 => 1
|
||||
is <error>(1, 1)</error> => 1
|
||||
}
|
||||
|
||||
val z = (1, 1)
|
||||
|
||||
when (z) {
|
||||
is (*, *) => 1
|
||||
is (*, 1) => 1
|
||||
is (1, 1) => 1
|
||||
is (1, <error>"1"</error>) => 1
|
||||
is <error>(1, "1", *)</error> => 1
|
||||
is boo @ (1, <error>"a"</error>, *) => 1
|
||||
is boo @ <error>(1, *)</error> => 1
|
||||
}
|
||||
|
||||
when (z) {
|
||||
<error>else => 1</error>
|
||||
(1, 1) => 2
|
||||
}
|
||||
|
||||
when (z) {
|
||||
else => 1
|
||||
}
|
||||
}
|
||||
|
||||
val (Int, Int).boo : (Int, Int, Int) = (1, 1, 1)
|
||||
@@ -1,251 +0,0 @@
|
||||
<info descr="null">open</info> class A() {
|
||||
fun foo() {}
|
||||
}
|
||||
|
||||
class B() : A() {
|
||||
fun bar() {}
|
||||
}
|
||||
|
||||
fun f9(a : A?) {
|
||||
a?.foo()
|
||||
a?.<error descr="Unresolved reference: bar">bar</error>()
|
||||
if (a is B) {
|
||||
<info descr="Automatically cast to B">a</info>.bar()
|
||||
<info descr="Automatically cast to A">a</info>.foo()
|
||||
}
|
||||
a?.foo()
|
||||
a?.<error descr="Unresolved reference: bar">bar</error>()
|
||||
if (!(a is B)) {
|
||||
a?.<error descr="Unresolved reference: bar">bar</error>()
|
||||
a?.foo()
|
||||
}
|
||||
if (!(a is B) || <info descr="Automatically cast to B">a</info>.bar() == ()) {
|
||||
a?.<error descr="Unresolved reference: bar">bar</error>()
|
||||
}
|
||||
if (!(a is B)) {
|
||||
return;
|
||||
}
|
||||
<info descr="Automatically cast to B">a</info>.bar()
|
||||
<info descr="Automatically cast to A">a</info>.foo()
|
||||
}
|
||||
|
||||
fun f10(a : A?) {
|
||||
if (!(a is B)) {
|
||||
return;
|
||||
}
|
||||
if (!(a is B)) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
class C() : A() {
|
||||
fun bar() {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
fun f10(a : A?) {
|
||||
if (a is C) {
|
||||
<info descr="Automatically cast to C">a</info>.bar();
|
||||
}
|
||||
}
|
||||
|
||||
fun f11(a : A?) {
|
||||
when (a) {
|
||||
is B => <info descr="Automatically cast to B">a</info>.bar()
|
||||
is A => <info descr="Automatically cast to A">a</info>.foo()
|
||||
is Any => <info descr="Automatically cast to A">a</info>.foo()
|
||||
is Any? => a.<error descr="Unresolved reference: bar">bar</error>()
|
||||
else => a?.foo()
|
||||
}
|
||||
}
|
||||
|
||||
fun f12(a : A?) {
|
||||
when (a) {
|
||||
is B => <info descr="Automatically cast to B">a</info>.bar()
|
||||
is A => <info descr="Automatically cast to A">a</info>.foo()
|
||||
is Any => <info descr="Automatically cast to A">a</info>.foo();
|
||||
is Any? => a.<error descr="Unresolved reference: bar">bar</error>()
|
||||
is val c : <error descr="[TYPE_MISMATCH_IN_BINDING_PATTERN] B must be a supertype of A?. Use is to match against B">B</error> => c.foo()
|
||||
is val c is C => <info descr="Automatically cast to C">c</info>.bar()
|
||||
is val c is C => <info descr="Automatically cast to C">a</info>.bar()
|
||||
else => a?.foo()
|
||||
}
|
||||
|
||||
if (a is val b) {
|
||||
a?.<error descr="Unresolved reference: bar">bar</error>()
|
||||
b?.foo()
|
||||
}
|
||||
if (a is val b is B) {
|
||||
<info descr="Automatically cast to A">b</info>.foo()
|
||||
<info descr="Automatically cast to B">a</info>.bar()
|
||||
<info descr="Automatically cast to B">b</info>.bar()
|
||||
}
|
||||
}
|
||||
|
||||
fun f13(a : A?) {
|
||||
if (a is val c is B) {
|
||||
<info descr="Automatically cast to A">c</info>.foo()
|
||||
<info descr="Automatically cast to B">c</info>.bar()
|
||||
}
|
||||
else {
|
||||
a?.foo()
|
||||
<error descr="Unresolved reference: c">c</error>.bar()
|
||||
}
|
||||
|
||||
a?.foo()
|
||||
if (!(a is val c is B)) {
|
||||
a?.foo()
|
||||
<error descr="Unresolved reference: c">c</error>.bar()
|
||||
}
|
||||
else {
|
||||
<info descr="Automatically cast to A">a</info>.foo()
|
||||
<error descr="Unresolved reference: c">c</error>.bar()
|
||||
}
|
||||
|
||||
a?.foo()
|
||||
if (a is val c is B && <info descr="Automatically cast to A">a</info>.foo() == () && <info descr="Automatically cast to B">c</info>.bar() == ()) {
|
||||
<info descr="Automatically cast to A">c</info>.foo()
|
||||
<info descr="Automatically cast to B">c</info>.bar()
|
||||
}
|
||||
else {
|
||||
a?.foo()
|
||||
<error descr="Unresolved reference: c">c</error>.bar()
|
||||
}
|
||||
|
||||
if (!(a is val c is B) || !(a is val x is C)) {
|
||||
<error descr="Unresolved reference: x">x</error>
|
||||
<error descr="Unresolved reference: c">c</error>
|
||||
}
|
||||
else {
|
||||
<error descr="Unresolved reference: x">x</error>
|
||||
<error descr="Unresolved reference: c">c</error>
|
||||
}
|
||||
|
||||
if (!(a is val c is B) || !(a is val c is C)) {
|
||||
}
|
||||
|
||||
if (!(a is val c is B)) return
|
||||
<info descr="Automatically cast to B">a</info>.bar()
|
||||
<error descr="Unresolved reference: c">c</error>.foo()
|
||||
<error descr="Unresolved reference: c">c</error>.bar()
|
||||
}
|
||||
|
||||
fun f14(a : A?) {
|
||||
while (!(a is val c is B)) {
|
||||
}
|
||||
<info descr="Automatically cast to B">a</info>.bar()
|
||||
<error descr="Unresolved reference: c">c</error>.bar()
|
||||
}
|
||||
fun f15(a : A?) {
|
||||
do {
|
||||
} while (!(a is val c is B))
|
||||
<info descr="Automatically cast to B">a</info>.bar()
|
||||
<error descr="Unresolved reference: c">c</error>.bar()
|
||||
}
|
||||
|
||||
fun getStringLength(obj : Any) : Char? {
|
||||
if (obj !is String)
|
||||
return null
|
||||
return <info descr="Automatically cast to String">obj</info>.get(0) // no cast to String is needed
|
||||
}
|
||||
|
||||
fun toInt(i: Int?): Int = if (i != null) <info descr="Automatically cast to Int">i</info> else 0
|
||||
fun illegalWhenBody(a: Any): Int = when(a) {
|
||||
is Int => <info descr="Automatically cast to Int">a</info>
|
||||
is String => <error descr="[TYPE_MISMATCH] Type mismatch: inferred type is Any but Int was expected">a</error>
|
||||
}
|
||||
fun illegalWhenBlock(a: Any): Int {
|
||||
when(a) {
|
||||
is Int => return <info descr="Automatically cast to Int">a</info>
|
||||
is String => return <error descr="[TYPE_MISMATCH] Type mismatch: inferred type is Any but Int was expected">a</error>
|
||||
}
|
||||
}
|
||||
fun declarations(a: Any?) {
|
||||
if (a is String) {
|
||||
val p4: (Int, String) = (2, <info descr="Automatically cast to String">a</info>)
|
||||
}
|
||||
if (a is String?) {
|
||||
if (a != null) {
|
||||
val s: String = <info descr="Automatically cast to String">a</info>
|
||||
}
|
||||
}
|
||||
if (a != null) {
|
||||
if (a is String?) {
|
||||
val s: String = <info descr="Automatically cast to String">a</info>
|
||||
}
|
||||
}
|
||||
}
|
||||
fun vars(a: Any?) {
|
||||
var b: Int = 0
|
||||
if (a is Int) {
|
||||
b = <info descr="Automatically cast to Int">a</info>
|
||||
}
|
||||
}
|
||||
fun tuples(a: Any?) {
|
||||
if (a != null) {
|
||||
val s: (Any, String) = (<info descr="Automatically cast to Any">a</info>, <error descr="[TYPE_MISMATCH] Type mismatch: inferred type is Any? but String was expected">a</error>)
|
||||
}
|
||||
if (a is String) {
|
||||
val s: (Any, String) = (<info descr="Automatically cast to Any">a</info>, <info descr="Automatically cast to String">a</info>)
|
||||
}
|
||||
fun illegalTupleReturnType(): (Any, String) = (<error descr="[TYPE_MISMATCH] Type mismatch: inferred type is Any? but Any was expected">a</error>, <error descr="[TYPE_MISMATCH] Type mismatch: inferred type is Any? but String was expected">a</error>)
|
||||
if (a is String) {
|
||||
fun legalTupleReturnType(): (Any, String) = (<info descr="Automatically cast to Any">a</info>, <info descr="Automatically cast to String">a</info>)
|
||||
}
|
||||
val illegalFunctionLiteral: Function0<Int> = <error descr="[TYPE_MISMATCH] Type mismatch: inferred type is Function0<Any?> but Function0<Int> was expected">{ <error descr="[TYPE_MISMATCH] Type mismatch: inferred type is Any? but Int was expected">a</error> }</error>
|
||||
val illegalReturnValueInFunctionLiteral: Function0<Int> = { (): Int => <error descr="[TYPE_MISMATCH] Type mismatch: inferred type is Any? but Int was expected">a</error> }
|
||||
|
||||
if (a is Int) {
|
||||
val legalFunctionLiteral: Function0<Int> = { <info descr="Automatically cast to Int">a</info> }
|
||||
val alsoLegalFunctionLiteral: Function0<Int> = { (): Int => <info descr="Automatically cast to Int">a</info> }
|
||||
}
|
||||
}
|
||||
fun returnFunctionLiteralBlock(a: Any?): Function0<Int> {
|
||||
if (a is Int) return { <info descr="Automatically cast to Int">a</info> }
|
||||
else return { 1 }
|
||||
}
|
||||
fun returnFunctionLiteral(a: Any?): Function0<Int> =
|
||||
if (a is Int) { (): Int => <info descr="Automatically cast to Int">a</info> }
|
||||
else { () => 1 }
|
||||
|
||||
fun illegalTupleReturnType(a: Any): (Any, String) = (a, <error descr="[TYPE_MISMATCH] Type mismatch: inferred type is Any but String was expected">a</error>)
|
||||
|
||||
fun declarationInsidePattern(x: (Any, Any)): String = when(x) { is (val a is String, *) => <info descr="Automatically cast to String">a</info>; else => "something" }
|
||||
|
||||
fun mergeAutocasts(a: Any?) {
|
||||
if (a is String || a is Int) {
|
||||
a.<error descr="Unresolved reference: compareTo">compareTo</error>("")
|
||||
a.toString()
|
||||
}
|
||||
if (a is Int || a is String) {
|
||||
a.<error descr="Unresolved reference: compareTo">compareTo</error>("")
|
||||
}
|
||||
when (a) {
|
||||
is String, is Any => a.<error descr="Unresolved reference: compareTo">compareTo</error>("")
|
||||
}
|
||||
if (a is String && a is Any) {
|
||||
val i: Int = <info descr="Automatically cast to String">a</info>.compareTo("")
|
||||
}
|
||||
if (a is String && <info descr="Automatically cast to String">a</info>.compareTo("") == 0) {}
|
||||
if (a is String || a.<error descr="Unresolved reference: compareTo">compareTo</error>("") == 0) {}
|
||||
}
|
||||
|
||||
//mutability
|
||||
fun f(): String {
|
||||
var a: Any = 11
|
||||
if (a is String) {
|
||||
val i: String = <error descr="[AUTOCAST_IMPOSSIBLE] Automatic cast to String is impossible, because a could have changed since the is-check">a</error>
|
||||
<error descr="[AUTOCAST_IMPOSSIBLE] Automatic cast to String is impossible, because a could have changed since the is-check">a</error>.compareTo("f")
|
||||
val f: Function0<String> = { <error descr="[AUTOCAST_IMPOSSIBLE] Automatic cast to String is impossible, because a could have changed since the is-check">a</error> }
|
||||
return <error descr="[AUTOCAST_IMPOSSIBLE] Automatic cast to String is impossible, because a could have changed since the is-check">a</error>
|
||||
}
|
||||
return ""
|
||||
}
|
||||
|
||||
fun foo(var a: Any): Int {
|
||||
if (a is Int) {
|
||||
return <error descr="[AUTOCAST_IMPOSSIBLE] Automatic cast to Int is impossible, because a could have changed since the is-check">a</error>
|
||||
}
|
||||
return 1
|
||||
}
|
||||
@@ -1,55 +0,0 @@
|
||||
<info>abstract</info> class Test() {
|
||||
<info>abstract</info> val x : Int
|
||||
<info>abstract</info> val x1 : Int <info>get</info>
|
||||
<info>abstract</info> val x2 : Int <error><info>get</info>() = 1</error>
|
||||
|
||||
val <error>a</error> : Int
|
||||
val <error>b</error> : Int <info>get</info>
|
||||
val <info>c</info> = 1
|
||||
|
||||
val <info>c1</info> = 1
|
||||
<info>get</info>
|
||||
val c2 : Int
|
||||
<info>get</info>() = 1
|
||||
val c3 : Int
|
||||
<info>get</info>() { return 1 }
|
||||
val c4 : Int
|
||||
<info>get</info>() = 1
|
||||
val <error>c5</error> : Int
|
||||
<info>get</info>() = $c5 + 1
|
||||
|
||||
<info>abstract</info> var y : Int
|
||||
<info>abstract</info> var y1 : Int <info>get</info>
|
||||
<info>abstract</info> var y2 : Int <info>set</info>
|
||||
<info>abstract</info> var y3 : Int <info>set</info> <info>get</info>
|
||||
<info>abstract</info> var y4 : Int <info>set</info> <error><info>get</info>() = 1</error>
|
||||
<info>abstract</info> var y5 : Int <error><info>set</info>(x) {}</error> <error><info>get</info>() = 1</error>
|
||||
<info>abstract</info> var y6 : Int <error><info>set</info>(x) {}</error>
|
||||
|
||||
var <error>v</error> : Int
|
||||
var <error>v1</error> : Int <info>get</info>
|
||||
var <error>v2</error> : Int <info>get</info> <info>set</info>
|
||||
var <error>v3</error> : Int <info>get</info>() = 1; <info>set</info>
|
||||
var v4 : Int <info>get</info>() = 1; <info>set</info>(x){}
|
||||
|
||||
var <error>v5</error> : Int <info>get</info>() = 1; <info>set</info>(x){$v5 = x}
|
||||
var <error>v6</error> : Int <info>get</info>() = $v6 + 1; <info>set</info>(x){}
|
||||
|
||||
var <error>v9</error> : Int <info>set</info>
|
||||
var <error>v10</error> : Int <info>get</info>
|
||||
|
||||
}
|
||||
|
||||
<info>open</info> class Super(i : Int)
|
||||
|
||||
class TestPCParameters(w : Int, x : Int, val <info>y</info> : Int, var <info>z</info> : Int) : Super(w) {
|
||||
|
||||
val <info>xx</info> = w
|
||||
|
||||
{
|
||||
w + 1
|
||||
}
|
||||
|
||||
fun foo() = <error>x</error>
|
||||
|
||||
}
|
||||
@@ -1,37 +0,0 @@
|
||||
fun refs() {
|
||||
var <info>a</info> = 1
|
||||
val v = {
|
||||
<info>a</info> = 2
|
||||
}
|
||||
|
||||
var <info>x</info> = 1
|
||||
val b = object {
|
||||
fun foo() {
|
||||
<info>x</info> = 2
|
||||
}
|
||||
}
|
||||
|
||||
var <info>y</info> = 1
|
||||
fun foo() {
|
||||
<info>y</info> = 1
|
||||
}
|
||||
}
|
||||
|
||||
fun refsPlusAssign() {
|
||||
var <info>a</info> = 1
|
||||
val v = {
|
||||
<info>a</info> += 2
|
||||
}
|
||||
|
||||
var <info>x</info> = 1
|
||||
val b = object {
|
||||
fun foo() {
|
||||
<info>x</info> += 2
|
||||
}
|
||||
}
|
||||
|
||||
var <info>y</info> = 1
|
||||
fun foo() {
|
||||
<info>y</info> += 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() {
|
||||
var 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(<error>1</error>)
|
||||
val a : fun() : Unit = {
|
||||
foo(<error>1</error>)
|
||||
}
|
||||
return 1
|
||||
}
|
||||
@@ -1,66 +0,0 @@
|
||||
import java.*
|
||||
import util.*
|
||||
|
||||
import 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 = takeFirst(<error>expr</error>)
|
||||
if (c >= '0' && c <= '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 = evaluateArg(expr, numbers)
|
||||
if (expr.length() > 0) {
|
||||
|
||||
}
|
||||
return lhs
|
||||
}
|
||||
|
||||
fun evaluate(expr: StringBuilder, numbers: ArrayList<Int>): Int {
|
||||
val lhs = evaluateAdd(expr, numbers)
|
||||
if (expr.length() > 0) {
|
||||
val c = expr.charAt(0)
|
||||
expr.deleteCharAt(0)
|
||||
}
|
||||
return lhs
|
||||
}
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
System.out?.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?.println("Your numbers: " + prompt)
|
||||
System.out?.println("Enter your expression:")
|
||||
val reader = BufferedReader(InputStreamReader(System.`in`))
|
||||
val expr = StringBuilder(reader.readLine())
|
||||
try {
|
||||
val result = evaluate(expr, numbers)
|
||||
if (result != 24)
|
||||
System.out?.println("Sorry, that's " + result)
|
||||
else
|
||||
System.out?.println("You won!");
|
||||
}
|
||||
catch(e: Throwable) {
|
||||
System.out?.println(e.getMessage())
|
||||
}
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
// JET-11 Redeclaration & Forward reference for classes cause an exception
|
||||
open class <error>NoC</error>
|
||||
class NoC1 : NoC
|
||||
open class <error>NoC</error>
|
||||
@@ -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<error>.</error>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 {
|
||||
var 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> {
|
||||
<error>X</error>
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
fun box() {
|
||||
val x: ProtocolState = ProtocolState.WAITING
|
||||
}
|
||||
@@ -1,4 +0,0 @@
|
||||
import java.util.Collections
|
||||
import java.util.List
|
||||
|
||||
val ab = Collections.emptyList<Int>() : List<Int>?
|
||||
@@ -1,4 +0,0 @@
|
||||
abstract class XXX {
|
||||
abstract val a : Int 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 java.util.ArrayList
|
||||
|
||||
abstract class Item(val room: Object) {
|
||||
abstract val name : String
|
||||
}
|
||||
|
||||
val items: ArrayList<Item> = ArrayList<Item>
|
||||
|
||||
fun test(room : Object) {
|
||||
for(val item: Item in items) {
|
||||
if (item.room === room) {
|
||||
System.out?.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 = b
|
||||
val y = 1
|
||||
}
|
||||
|
||||
val b = <error>a</error>.x
|
||||
val c = a.y
|
||||
@@ -1,16 +0,0 @@
|
||||
fun box() {
|
||||
val a : C = C()
|
||||
a.foo()
|
||||
}
|
||||
|
||||
open class A() {
|
||||
open fun foo() {}
|
||||
}
|
||||
|
||||
open class B() : A() {
|
||||
override fun foo() {}
|
||||
}
|
||||
|
||||
open class C() : B() {
|
||||
override fun foo() {}
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
class Foo(var bar : Int, var barr : Int, var barrr : Int) {
|
||||
{
|
||||
bar = 1
|
||||
barr = 1
|
||||
barrr = 1
|
||||
1 : Int
|
||||
this : Foo
|
||||
}
|
||||
|
||||
this(var 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<warning>?.</warning>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<<error>Int</error>, Int>(1)
|
||||
}
|
||||
@@ -1,33 +0,0 @@
|
||||
class A() {
|
||||
var x: Int = 0
|
||||
get() = <error>"s"</error>
|
||||
set(value: <error>String</error>) {
|
||||
$x = <error>value</error>
|
||||
}
|
||||
val y: Int
|
||||
get(): <error>String</error> = "s"
|
||||
val z: Int
|
||||
get() {
|
||||
return <error>"s"</error>
|
||||
}
|
||||
|
||||
var a: Any = 1
|
||||
set(v: <error>String</error>) {
|
||||
$a = v
|
||||
}
|
||||
val b: Int
|
||||
get(): <error>Any</error> = "s"
|
||||
val c: Int
|
||||
get() {
|
||||
return 1
|
||||
}
|
||||
val d = 1
|
||||
get() {
|
||||
return $d
|
||||
}
|
||||
val e = 1
|
||||
get(): <error>String</error> {
|
||||
return <error>$e</error>
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,11 +0,0 @@
|
||||
// KT-303 Stack overflow on a cyclic class hierarchy
|
||||
|
||||
open class Foo() : <error>Bar</error>() {
|
||||
val a : Int = 1
|
||||
}
|
||||
|
||||
open class Bar() : <error>Foo</error>() {
|
||||
|
||||
}
|
||||
|
||||
val x : Int = <error>Foo()</error>
|
||||
@@ -0,0 +1,12 @@
|
||||
fun Any.with(operation : fun Any.() : Any) = operation().toString()
|
||||
|
||||
val f = { (a : Int) :Unit => }
|
||||
|
||||
fun box () : String {
|
||||
return if(20.with {
|
||||
this
|
||||
} == "20")
|
||||
"OK"
|
||||
else
|
||||
"fail"
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
package org.jetbrains.jet;
|
||||
|
||||
import com.intellij.openapi.projectRoots.Sdk;
|
||||
import com.intellij.testFramework.fixtures.DefaultLightProjectDescriptor;
|
||||
|
||||
/**
|
||||
* @author yole
|
||||
*/
|
||||
public class JetLightProjectDescriptor extends DefaultLightProjectDescriptor {
|
||||
public static JetLightProjectDescriptor INSTANCE = new JetLightProjectDescriptor();
|
||||
|
||||
@Override
|
||||
public Sdk getSdk() {
|
||||
return JetTestCaseBase.jdkFromIdeaHome();
|
||||
}
|
||||
}
|
||||
@@ -1,46 +1,21 @@
|
||||
package org.jetbrains.jet;
|
||||
|
||||
import com.intellij.ide.startup.impl.StartupManagerImpl;
|
||||
import com.intellij.lang.*;
|
||||
import com.intellij.lang.impl.PsiBuilderFactoryImpl;
|
||||
import com.intellij.mock.*;
|
||||
import com.intellij.openapi.Disposable;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.editor.EditorFactory;
|
||||
import com.intellij.openapi.extensions.Extensions;
|
||||
import com.intellij.openapi.fileEditor.FileDocumentManager;
|
||||
import com.intellij.openapi.fileEditor.impl.FileDocumentManagerImpl;
|
||||
import com.intellij.openapi.fileEditor.impl.LoadTextUtil;
|
||||
import com.intellij.openapi.fileTypes.FileTypeFactory;
|
||||
import com.intellij.openapi.fileTypes.FileTypeManager;
|
||||
import com.intellij.openapi.options.SchemesManagerFactory;
|
||||
import com.intellij.openapi.progress.impl.ProgressManagerImpl;
|
||||
import com.intellij.openapi.startup.StartupManager;
|
||||
import com.intellij.openapi.util.Disposer;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.CharsetToolkit;
|
||||
import com.intellij.psi.*;
|
||||
import com.intellij.psi.impl.PsiCachedValuesFactory;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.PsiElementVisitor;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.PsiFileFactory;
|
||||
import com.intellij.psi.impl.PsiFileFactoryImpl;
|
||||
import com.intellij.psi.impl.source.resolve.reference.ReferenceProvidersRegistry;
|
||||
import com.intellij.psi.impl.source.resolve.reference.ReferenceProvidersRegistryImpl;
|
||||
import com.intellij.psi.util.CachedValuesManager;
|
||||
import com.intellij.testFramework.LightVirtualFile;
|
||||
import com.intellij.testFramework.MockSchemesManagerFactory;
|
||||
import com.intellij.testFramework.PlatformLiteFixture;
|
||||
import com.intellij.testFramework.TestDataFile;
|
||||
import com.intellij.util.CachedValuesManagerImpl;
|
||||
import com.intellij.util.Function;
|
||||
import com.intellij.util.messages.MessageBus;
|
||||
import com.intellij.util.messages.MessageBusFactory;
|
||||
import com.intellij.testFramework.UsefulTestCase;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.jet.lang.parsing.JetParserDefinition;
|
||||
import org.picocontainer.MutablePicoContainer;
|
||||
import org.picocontainer.PicoContainer;
|
||||
import org.picocontainer.PicoInitializationException;
|
||||
import org.picocontainer.PicoIntrospectionException;
|
||||
import org.picocontainer.defaults.AbstractComponentAdapter;
|
||||
import org.jetbrains.jet.lang.psi.JetFile;
|
||||
import org.jetbrains.jet.plugin.JetLanguage;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@@ -48,81 +23,42 @@ import java.io.IOException;
|
||||
/**
|
||||
* @author abreslav
|
||||
*/
|
||||
public abstract class JetLiteFixture extends PlatformLiteFixture {
|
||||
protected String myFileExt;
|
||||
public abstract class JetLiteFixture extends UsefulTestCase {
|
||||
@NonNls
|
||||
protected final String myFullDataPath;
|
||||
protected PsiFile myFile;
|
||||
private MockPsiManager myPsiManager;
|
||||
private PsiFileFactoryImpl myFileFactory;
|
||||
protected Language myLanguage;
|
||||
protected final ParserDefinition[] myDefinitions;
|
||||
protected JetFile myFile;
|
||||
private JetCoreEnvironment myEnvironment;
|
||||
|
||||
public JetLiteFixture(@NonNls String dataPath) {
|
||||
myFileExt = "jet";
|
||||
myFullDataPath = getTestDataPath() + "/" + dataPath;
|
||||
myDefinitions = new ParserDefinition[] {new JetParserDefinition()};
|
||||
}
|
||||
|
||||
public JetLiteFixture() {
|
||||
myFullDataPath = getTestDataPath();
|
||||
}
|
||||
|
||||
protected String getTestDataPath() {
|
||||
return JetTestCaseBase.getTestDataPathBase();
|
||||
return JetTestCaseBuilder.getTestDataPathBase();
|
||||
}
|
||||
|
||||
public Project getProject() {
|
||||
return myEnvironment.getProject();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
initApplication();
|
||||
getApplication().getPicoContainer().registerComponent(new AbstractComponentAdapter("com.intellij.openapi.progress.ProgressManager", Object.class) {
|
||||
@Override
|
||||
public Object getComponentInstance(PicoContainer container) throws PicoInitializationException, PicoIntrospectionException {
|
||||
return new ProgressManagerImpl(getApplication());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void verify(PicoContainer container) throws PicoIntrospectionException {
|
||||
}
|
||||
});
|
||||
Extensions.registerAreaClass("IDEA_PROJECT", null);
|
||||
myProject = disposeOnTearDown(new MockProjectEx(getTestRootDisposable()));
|
||||
myPsiManager = new MockPsiManager(myProject);
|
||||
myFileFactory = new PsiFileFactoryImpl(myPsiManager);
|
||||
final MutablePicoContainer appContainer = getApplication().getPicoContainer();
|
||||
registerComponentInstance(appContainer, MessageBus.class, MessageBusFactory.newMessageBus(getApplication()));
|
||||
registerComponentInstance(appContainer, SchemesManagerFactory.class, new MockSchemesManagerFactory());
|
||||
final MockEditorFactory editorFactory = new MockEditorFactory();
|
||||
registerComponentInstance(appContainer, EditorFactory.class, editorFactory);
|
||||
registerComponentInstance(appContainer, FileDocumentManager.class, new MockFileDocumentManagerImpl(new Function<CharSequence, Document>() {
|
||||
@Override
|
||||
public Document fun(CharSequence charSequence) {
|
||||
return editorFactory.createDocument(charSequence);
|
||||
}
|
||||
}, FileDocumentManagerImpl.DOCUMENT_KEY));
|
||||
registerComponentInstance(appContainer, PsiDocumentManager.class, new MockPsiDocumentManager());
|
||||
myLanguage = myLanguage == null && myDefinitions != null && myDefinitions.length > 0
|
||||
? myDefinitions[0].getFileNodeType().getLanguage()
|
||||
: myLanguage;
|
||||
registerComponentInstance(appContainer, FileTypeManager.class, new MockFileTypeManager(new MockLanguageFileType(myLanguage, myFileExt)));
|
||||
registerApplicationService(PsiBuilderFactory.class, new PsiBuilderFactoryImpl());
|
||||
registerApplicationService(DefaultASTFactory.class, new DefaultASTFactoryImpl());
|
||||
registerApplicationService(ReferenceProvidersRegistry.class, new ReferenceProvidersRegistryImpl());
|
||||
myProject.registerService(CachedValuesManager.class, new CachedValuesManagerImpl(myProject, new PsiCachedValuesFactory(myPsiManager)));
|
||||
myProject.registerService(PsiManager.class, myPsiManager);
|
||||
myProject.registerService(StartupManager.class, new StartupManagerImpl(myProject));
|
||||
myProject.registerService(PsiFileFactory.class, new PsiFileFactoryImpl(myPsiManager));
|
||||
|
||||
registerExtensionPoint(FileTypeFactory.FILE_TYPE_FACTORY_EP, FileTypeFactory.class);
|
||||
|
||||
for (ParserDefinition definition : myDefinitions) {
|
||||
addExplicitExtension(LanguageParserDefinitions.INSTANCE, definition.getFileNodeType().getLanguage(), definition);
|
||||
}
|
||||
myEnvironment = new JetCoreEnvironment(getTestRootDisposable());
|
||||
final File rtJar = new File(JetTestCaseBuilder.getHomeDirectory(), "compiler/testData/mockJDK-1.7/jre/lib/rt.jar");
|
||||
myEnvironment.addToClasspath(rtJar);
|
||||
myEnvironment.addToClasspath(new File(JetTestCaseBuilder.getHomeDirectory(), "compiler/testData/mockJDK-1.7/jre/lib/annotations.jar"));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void tearDown() throws Exception {
|
||||
super.tearDown();
|
||||
myFile = null;
|
||||
myProject = null;
|
||||
myPsiManager = null;
|
||||
myEnvironment = null;
|
||||
super.tearDown();
|
||||
}
|
||||
|
||||
protected String loadFile(@NonNls @TestDataFile String name) throws IOException {
|
||||
@@ -136,14 +72,22 @@ public abstract class JetLiteFixture extends PlatformLiteFixture {
|
||||
return text;
|
||||
}
|
||||
|
||||
protected PsiFile createPsiFile(String name, String text) {
|
||||
return createFile(name + "." + myFileExt, text);
|
||||
protected JetFile createPsiFile(String name, String text) {
|
||||
return (JetFile) createFile(name + ".jet", text);
|
||||
}
|
||||
|
||||
protected JetFile loadPsiFile(String name) {
|
||||
try {
|
||||
return createPsiFile(name, loadFile(name));
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
protected PsiFile createFile(@NonNls String name, String text) {
|
||||
LightVirtualFile virtualFile = new LightVirtualFile(name, myLanguage, text);
|
||||
LightVirtualFile virtualFile = new LightVirtualFile(name, JetLanguage.INSTANCE, text);
|
||||
virtualFile.setCharset(CharsetToolkit.UTF8_CHARSET);
|
||||
return myFileFactory.trySetupPsiForFile(virtualFile, myLanguage, true, false);
|
||||
return ((PsiFileFactoryImpl) PsiFileFactory.getInstance(myEnvironment.getProject())).trySetupPsiForFile(virtualFile, JetLanguage.INSTANCE, true, false);
|
||||
}
|
||||
|
||||
protected static void ensureParsed(PsiFile file) {
|
||||
@@ -155,28 +99,8 @@ public abstract class JetLiteFixture extends PlatformLiteFixture {
|
||||
});
|
||||
}
|
||||
|
||||
protected <T> void registerApplicationService(final Class<T> aClass, T object) {
|
||||
getApplication().registerService(aClass, object);
|
||||
Disposer.register(myProject, new Disposable() {
|
||||
@Override
|
||||
public void dispose() {
|
||||
getApplication().getPicoContainer().unregisterComponent(aClass.getName());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
protected <T> void addExplicitExtension(final LanguageExtension<T> instance, final Language language, final T object) {
|
||||
instance.addExplicitExtension(language, object);
|
||||
Disposer.register(myProject, new Disposable() {
|
||||
@Override
|
||||
public void dispose() {
|
||||
instance.removeExplicitExtension(language, object);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
protected void prepareForTest(String name) throws IOException {
|
||||
String text = loadFile(name + "." + myFileExt);
|
||||
String text = loadFile(name + ".jet");
|
||||
createAndCheckPsiFile(name, text);
|
||||
}
|
||||
|
||||
|
||||
+8
-63
@@ -1,9 +1,6 @@
|
||||
package org.jetbrains.jet;
|
||||
|
||||
import com.intellij.codeInsight.daemon.LightDaemonAnalyzerTestCase;
|
||||
import com.intellij.openapi.application.PathManager;
|
||||
import com.intellij.openapi.projectRoots.Sdk;
|
||||
import com.intellij.openapi.projectRoots.impl.JavaSdkImpl;
|
||||
import junit.framework.Test;
|
||||
import junit.framework.TestSuite;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -18,72 +15,20 @@ import java.util.List;
|
||||
/**
|
||||
* @author abreslav
|
||||
*/
|
||||
public abstract class JetTestCaseBase extends LightDaemonAnalyzerTestCase {
|
||||
|
||||
private static FilenameFilter emptyFilter;
|
||||
private boolean checkInfos = false;
|
||||
private String dataPath;
|
||||
protected final String name;
|
||||
|
||||
public JetTestCaseBase(String dataPath, String name) {
|
||||
this.dataPath = dataPath;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public final JetTestCaseBase setCheckInfos(boolean checkInfos) {
|
||||
this.checkInfos = checkInfos;
|
||||
return this;
|
||||
}
|
||||
|
||||
public static Sdk jdkFromIdeaHome() {
|
||||
return new JavaSdkImpl().createJdk("JDK", "compiler/testData/mockJDK-1.7/jre", true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getTestDataPath() {
|
||||
return getTestDataPathBase();
|
||||
}
|
||||
public abstract class JetTestCaseBuilder {
|
||||
private static FilenameFilter emptyFilter = new FilenameFilter() {
|
||||
@Override
|
||||
public boolean accept(File file, String name) {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
|
||||
public static String getTestDataPathBase() {
|
||||
return getHomeDirectory() + "/compiler/testData";
|
||||
}
|
||||
|
||||
public static String getHomeDirectory() {
|
||||
return new File(PathManager.getResourceRoot(JetTestCaseBase.class, "/org/jetbrains/jet/JetTestCaseBase.class")).getParentFile().getParentFile().getParent();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Sdk getProjectJDK() {
|
||||
return jdkFromIdeaHome();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName() {
|
||||
return "test" + name;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runTest() throws Throwable {
|
||||
doTest(getTestFilePath(), true, checkInfos);
|
||||
}
|
||||
|
||||
@NotNull
|
||||
protected String getTestFilePath() {
|
||||
return dataPath + File.separator + name + ".jet";
|
||||
}
|
||||
|
||||
protected String getDataPath() {
|
||||
return dataPath;
|
||||
}
|
||||
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
emptyFilter = new FilenameFilter() {
|
||||
@Override
|
||||
public boolean accept(File file, String name) {
|
||||
return true;
|
||||
}
|
||||
};
|
||||
return new File(PathManager.getResourceRoot(JetTestCaseBuilder.class, "/org/jetbrains/jet/JetTestCaseBuilder.class")).getParentFile().getParentFile().getParent();
|
||||
}
|
||||
|
||||
public interface NamedTestFactory {
|
||||
@@ -8,7 +8,8 @@ import com.intellij.openapi.util.text.StringUtil;
|
||||
import junit.framework.Test;
|
||||
import junit.framework.TestSuite;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.JetTestCaseBase;
|
||||
import org.jetbrains.jet.JetLiteFixture;
|
||||
import org.jetbrains.jet.JetTestCaseBuilder;
|
||||
import org.jetbrains.jet.lang.cfg.LoopInfo;
|
||||
import org.jetbrains.jet.lang.cfg.pseudocode.*;
|
||||
import org.jetbrains.jet.lang.psi.*;
|
||||
@@ -20,19 +21,25 @@ import java.io.IOException;
|
||||
import java.io.PrintStream;
|
||||
import java.util.*;
|
||||
|
||||
public class JetControlFlowTest extends JetTestCaseBase {
|
||||
public class JetControlFlowTest extends JetLiteFixture {
|
||||
static {
|
||||
System.setProperty("idea.platform.prefix", "Idea");
|
||||
}
|
||||
|
||||
private String myName;
|
||||
|
||||
public JetControlFlowTest(String dataPath, String name) {
|
||||
super(dataPath, name);
|
||||
super(dataPath);
|
||||
myName = name;
|
||||
}
|
||||
|
||||
|
||||
protected String getTestFilePath() {
|
||||
return myFullDataPath + "/" + myName;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runTest() throws Throwable {
|
||||
configureByFile(getTestFilePath());
|
||||
JetFile file = (JetFile) getFile();
|
||||
JetFile file = loadPsiFile(myName + ".jet");
|
||||
|
||||
final Map<JetElement, Pseudocode> data = new LinkedHashMap<JetElement, Pseudocode>();
|
||||
final JetPseudocodeTrace pseudocodeTrace = new JetPseudocodeTrace() {
|
||||
@@ -68,14 +75,14 @@ public class JetControlFlowTest extends JetTestCaseBase {
|
||||
});
|
||||
|
||||
try {
|
||||
processCFData(name, data);
|
||||
processCFData(myName, data);
|
||||
}
|
||||
catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
finally {
|
||||
if ("true".equals(System.getProperty("jet.control.flow.test.dump.graphs"))) {
|
||||
dumpDot(name, data.values());
|
||||
dumpDot(myName, data.values());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -120,7 +127,7 @@ public class JetControlFlowTest extends JetTestCaseBase {
|
||||
}
|
||||
}
|
||||
|
||||
String expectedInstructionsFileName = getTestDataPath() + "/" + getTestFilePath().replace(".jet", ".instructions");
|
||||
String expectedInstructionsFileName = getTestFilePath() + ".instructions";
|
||||
File expectedInstructionsFile = new File(expectedInstructionsFileName);
|
||||
if (!expectedInstructionsFile.exists()) {
|
||||
FileUtil.writeToFile(expectedInstructionsFile, instructionDump.toString());
|
||||
@@ -351,7 +358,7 @@ public class JetControlFlowTest extends JetTestCaseBase {
|
||||
}
|
||||
|
||||
private void dumpDot(String name, Collection<Pseudocode> pseudocodes) throws FileNotFoundException {
|
||||
String graphFileName = getTestDataPath() + "/" + getTestFilePath().replace(".jet", ".dot");
|
||||
String graphFileName = getTestDataPath() + "/" + getTestFilePath() + ".dot";
|
||||
File target = new File(graphFileName);
|
||||
|
||||
PrintStream out = new PrintStream(target);
|
||||
@@ -386,7 +393,7 @@ public class JetControlFlowTest extends JetTestCaseBase {
|
||||
|
||||
public static TestSuite suite() {
|
||||
TestSuite suite = new TestSuite();
|
||||
suite.addTest(JetTestCaseBase.suiteForDirectory(getTestDataPathBase(), "/cfg/", true, new JetTestCaseBase.NamedTestFactory() {
|
||||
suite.addTest(JetTestCaseBuilder.suiteForDirectory(JetTestCaseBuilder.getTestDataPathBase(), "/cfg/", true, new JetTestCaseBuilder.NamedTestFactory() {
|
||||
@NotNull
|
||||
@Override
|
||||
public Test createTest(@NotNull String dataPath, @NotNull String name) {
|
||||
|
||||
@@ -2,39 +2,34 @@ package org.jetbrains.jet.checkers;
|
||||
|
||||
import com.google.common.collect.Lists;
|
||||
import com.intellij.openapi.util.TextRange;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vfs.CharsetToolkit;
|
||||
import com.intellij.testFramework.LightPlatformCodeInsightTestCase;
|
||||
import junit.framework.Test;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.JetTestCaseBase;
|
||||
import org.jetbrains.jet.JetLiteFixture;
|
||||
import org.jetbrains.jet.JetTestCaseBuilder;
|
||||
import org.jetbrains.jet.lang.diagnostics.DiagnosticUtils;
|
||||
import org.jetbrains.jet.lang.psi.JetFile;
|
||||
import org.jetbrains.jet.lang.resolve.BindingContext;
|
||||
import org.jetbrains.jet.lang.resolve.java.AnalyzerFacade;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* @author abreslav
|
||||
*/
|
||||
public class FullJetPsiCheckerTest extends JetTestCaseBase {
|
||||
public class FullJetPsiCheckerTest extends JetLiteFixture {
|
||||
private final String myDataPath;
|
||||
private String myName;
|
||||
|
||||
public FullJetPsiCheckerTest(@NonNls String dataPath, String name) {
|
||||
super(dataPath, name);
|
||||
myDataPath = dataPath;
|
||||
myName = name;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void runTest() throws Exception {
|
||||
String fileName = name + ".jet";
|
||||
String fullPath = getTestDataPath() + getTestFilePath();
|
||||
String fileName = myName + ".jet";
|
||||
String fullPath = myDataPath + "/" + fileName;
|
||||
|
||||
|
||||
String expectedText = loadFile(fullPath);
|
||||
@@ -42,9 +37,8 @@ public class FullJetPsiCheckerTest extends JetTestCaseBase {
|
||||
List<CheckerTestUtil.DiagnosedRange> diagnosedRanges = Lists.newArrayList();
|
||||
String clearText = CheckerTestUtil.parseDiagnosedRanges(expectedText, diagnosedRanges);
|
||||
|
||||
configureFromFileText(fileName, clearText);
|
||||
JetFile jetFile = (JetFile) myFile;
|
||||
BindingContext bindingContext = AnalyzerFacade.analyzeFileWithCache(jetFile);
|
||||
myFile = createPsiFile(myName, clearText);
|
||||
BindingContext bindingContext = AnalyzerFacade.analyzeFileWithCache(myFile);
|
||||
|
||||
CheckerTestUtil.diagnosticsDiff(diagnosedRanges, bindingContext.getDiagnostics(), new CheckerTestUtil.DiagnosticDiffCallbacks() {
|
||||
@Override
|
||||
@@ -60,7 +54,7 @@ public class FullJetPsiCheckerTest extends JetTestCaseBase {
|
||||
}
|
||||
});
|
||||
|
||||
String actualText = CheckerTestUtil.addDiagnosticMarkersToText(jetFile, bindingContext).toString();
|
||||
String actualText = CheckerTestUtil.addDiagnosticMarkersToText(myFile, bindingContext).toString();
|
||||
|
||||
assertEquals(expectedText, actualText);
|
||||
|
||||
@@ -69,12 +63,7 @@ public class FullJetPsiCheckerTest extends JetTestCaseBase {
|
||||
// convert(new File(myFullDataPath + "/../../checker/"), new File(myFullDataPath));
|
||||
}
|
||||
|
||||
private String loadFile(String fullPath) throws IOException {
|
||||
final File ioFile = new File(fullPath);
|
||||
String fileText = FileUtil.loadFile(ioFile, CharsetToolkit.UTF8);
|
||||
return StringUtil.convertLineSeparators(fileText);
|
||||
}
|
||||
|
||||
/*
|
||||
private void convert(File src, File dest) throws IOException {
|
||||
File[] files = src.listFiles();
|
||||
for (File file : files) {
|
||||
@@ -105,9 +94,10 @@ public class FullJetPsiCheckerTest extends JetTestCaseBase {
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
public static Test suite() {
|
||||
return JetTestCaseBase.suiteForDirectory(JetTestCaseBase.getTestDataPathBase(), "/checkerWithErrorTypes/full/", true, new JetTestCaseBase.NamedTestFactory() {
|
||||
return JetTestCaseBuilder.suiteForDirectory(JetTestCaseBuilder.getTestDataPathBase(), "/checkerWithErrorTypes/full/", true, new JetTestCaseBuilder.NamedTestFactory() {
|
||||
@NotNull
|
||||
@Override
|
||||
public Test createTest(@NotNull String dataPath, @NotNull String name) {
|
||||
|
||||
@@ -1,42 +0,0 @@
|
||||
package org.jetbrains.jet.checkers;
|
||||
|
||||
import junit.framework.Test;
|
||||
import junit.framework.TestSuite;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.JetTestCaseBase;
|
||||
|
||||
/**
|
||||
* @author abreslav
|
||||
*/
|
||||
public class JetPsiCheckerTest extends JetTestCaseBase {
|
||||
|
||||
public JetPsiCheckerTest(String dataPath, String name) {
|
||||
super(dataPath, name);
|
||||
}
|
||||
|
||||
public static Test suite() {
|
||||
TestSuite suite = new TestSuite();
|
||||
suite.addTest(JetTestCaseBase.suiteForDirectory(getTestDataPathBase(), "/checker/", false, new JetTestCaseBase.NamedTestFactory() {
|
||||
@NotNull
|
||||
@Override
|
||||
public Test createTest(@NotNull String dataPath, @NotNull String name) {
|
||||
return new JetPsiCheckerTest(dataPath, name);
|
||||
}
|
||||
}));
|
||||
suite.addTest(JetTestCaseBase.suiteForDirectory(getTestDataPathBase(), "/checker/regression/", false, new JetTestCaseBase.NamedTestFactory() {
|
||||
@NotNull
|
||||
@Override
|
||||
public Test createTest(@NotNull String dataPath, @NotNull String name) {
|
||||
return new JetPsiCheckerTest(dataPath, name);
|
||||
}
|
||||
}));
|
||||
suite.addTest(JetTestCaseBase.suiteForDirectory(getTestDataPathBase(), "/checker/infos/", false, new JetTestCaseBase.NamedTestFactory() {
|
||||
@NotNull
|
||||
@Override
|
||||
public Test createTest(@NotNull String dataPath, @NotNull String name) {
|
||||
return new JetPsiCheckerTest(dataPath, name).setCheckInfos(true);
|
||||
}
|
||||
}));
|
||||
return suite;
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,7 @@ import junit.framework.Test;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.JetLiteFixture;
|
||||
import org.jetbrains.jet.JetTestCaseBase;
|
||||
import org.jetbrains.jet.JetTestCaseBuilder;
|
||||
import org.jetbrains.jet.lang.diagnostics.DiagnosticUtils;
|
||||
import org.jetbrains.jet.lang.psi.JetFile;
|
||||
import org.jetbrains.jet.lang.resolve.AnalyzingUtils;
|
||||
@@ -93,7 +93,7 @@ public class QuickJetPsiCheckerTest extends JetLiteFixture {
|
||||
// }
|
||||
|
||||
public static Test suite() {
|
||||
return JetTestCaseBase.suiteForDirectory(JetTestCaseBase.getTestDataPathBase(), "/checkerWithErrorTypes/quick", true, new JetTestCaseBase.NamedTestFactory() {
|
||||
return JetTestCaseBuilder.suiteForDirectory(JetTestCaseBuilder.getTestDataPathBase(), "/checkerWithErrorTypes/quick", true, new JetTestCaseBuilder.NamedTestFactory() {
|
||||
@NotNull
|
||||
@Override
|
||||
public Test createTest(@NotNull String dataPath, @NotNull String name) {
|
||||
|
||||
@@ -1,17 +1,14 @@
|
||||
package org.jetbrains.jet.codegen;
|
||||
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.testFramework.LightProjectDescriptor;
|
||||
import com.intellij.testFramework.fixtures.LightCodeInsightFixtureTestCase;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.JetLightProjectDescriptor;
|
||||
import org.jetbrains.jet.JetLiteFixture;
|
||||
import org.jetbrains.jet.lang.psi.JetFile;
|
||||
import org.jetbrains.jet.lang.psi.JetNamespace;
|
||||
import org.jetbrains.jet.lang.resolve.AnalyzingUtils;
|
||||
import org.jetbrains.jet.parsing.JetParsingTest;
|
||||
import org.jetbrains.jet.plugin.JetFileType;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.HashMap;
|
||||
@@ -21,7 +18,7 @@ import java.util.Map;
|
||||
/**
|
||||
* @author yole
|
||||
*/
|
||||
public abstract class CodegenTestCase extends LightCodeInsightFixtureTestCase {
|
||||
public abstract class CodegenTestCase extends JetLiteFixture {
|
||||
private MyClassLoader myClassLoader;
|
||||
|
||||
protected static void assertThrows(Method foo, Class<? extends Throwable> exceptionClass, Object instance, Object... args) throws IllegalAccessException {
|
||||
@@ -43,16 +40,24 @@ public abstract class CodegenTestCase extends LightCodeInsightFixtureTestCase {
|
||||
|
||||
@Override
|
||||
protected void tearDown() throws Exception {
|
||||
myFile = null;
|
||||
myClassLoader = null;
|
||||
super.tearDown();
|
||||
}
|
||||
|
||||
protected void loadText(final String text) {
|
||||
myFixture.configureByText(JetFileType.INSTANCE, text);
|
||||
myFile = (JetFile) createFile("a.jet", text);
|
||||
}
|
||||
|
||||
protected void loadFile(final String name) {
|
||||
myFixture.configureByFile(JetParsingTest.getTestDataDir() + "/codegen/" + name);
|
||||
@Override
|
||||
protected String loadFile(final String name) {
|
||||
try {
|
||||
final String content = doLoadFile(JetParsingTest.getTestDataDir() + "/codegen/", name);
|
||||
myFile = (JetFile) createFile(name, content);
|
||||
return content;
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
protected void loadFile() {
|
||||
@@ -85,8 +90,7 @@ public abstract class CodegenTestCase extends LightCodeInsightFixtureTestCase {
|
||||
ClassFileFactory codegens = generateClassesInFile();
|
||||
CodegensClassLoader loader = new CodegensClassLoader(codegens);
|
||||
|
||||
JetFile jetFile = (JetFile) myFixture.getFile();
|
||||
final JetNamespace namespace = jetFile.getRootNamespace();
|
||||
final JetNamespace namespace = myFile.getRootNamespace();
|
||||
String fqName = NamespaceCodegen.getJVMClassName(namespace.getFQName()).replace("/", ".");
|
||||
Class<?> namespaceClass = loader.loadClass(fqName);
|
||||
Method method = namespaceClass.getMethod("box");
|
||||
@@ -95,9 +99,8 @@ public abstract class CodegenTestCase extends LightCodeInsightFixtureTestCase {
|
||||
|
||||
protected String generateToText() {
|
||||
GenerationState state = new GenerationState(getProject(), true);
|
||||
JetFile jetFile = (JetFile) myFixture.getFile();
|
||||
AnalyzingUtils.checkForSyntacticErrors(jetFile);
|
||||
state.compile(jetFile);
|
||||
AnalyzingUtils.checkForSyntacticErrors(myFile);
|
||||
state.compile(myFile);
|
||||
|
||||
StringBuilder answer = new StringBuilder();
|
||||
|
||||
@@ -117,8 +120,7 @@ public abstract class CodegenTestCase extends LightCodeInsightFixtureTestCase {
|
||||
}
|
||||
|
||||
protected Class loadRootNamespaceClass(ClassFileFactory state) {
|
||||
JetFile jetFile = (JetFile) myFixture.getFile();
|
||||
final JetNamespace namespace = jetFile.getRootNamespace();
|
||||
final JetNamespace namespace = myFile.getRootNamespace();
|
||||
String fqName = NamespaceCodegen.getJVMClassName(namespace.getFQName()).replace("/", ".");
|
||||
Map<String, Class> classMap = loadAllClasses(state);
|
||||
return classMap.get(fqName);
|
||||
@@ -151,9 +153,8 @@ public abstract class CodegenTestCase extends LightCodeInsightFixtureTestCase {
|
||||
protected ClassFileFactory generateClassesInFile() {
|
||||
try {
|
||||
GenerationState state = new GenerationState(getProject(), false);
|
||||
JetFile jetFile = (JetFile) myFixture.getFile();
|
||||
AnalyzingUtils.checkForSyntacticErrors(jetFile);
|
||||
state.compile(jetFile);
|
||||
AnalyzingUtils.checkForSyntacticErrors(myFile);
|
||||
state.compile(myFile);
|
||||
|
||||
return state.getFactory();
|
||||
} catch (RuntimeException e) {
|
||||
@@ -233,10 +234,4 @@ public abstract class CodegenTestCase extends LightCodeInsightFixtureTestCase {
|
||||
return super.findClass(name);
|
||||
}
|
||||
}
|
||||
|
||||
@NotNull
|
||||
@Override
|
||||
protected LightProjectDescriptor getProjectDescriptor() {
|
||||
return JetLightProjectDescriptor.INSTANCE;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,6 +26,41 @@ public class FunctionGenTest extends CodegenTestCase {
|
||||
|
||||
}
|
||||
|
||||
public void testNullableAnyToString () throws InvocationTargetException, IllegalAccessException {
|
||||
loadText("fun foo(x: Any?) = x.toString()");
|
||||
System.out.println(generateToText());
|
||||
Method foo = generateFunction();
|
||||
assertEquals("something", foo.invoke(null, "something"));
|
||||
assertEquals("null", foo.invoke(null, new Object[]{null}));
|
||||
|
||||
}
|
||||
|
||||
public void testNullableStringPlus () throws InvocationTargetException, IllegalAccessException {
|
||||
loadText("fun foo(x: String?, y: Any?) = x + y");
|
||||
String text = generateToText();
|
||||
assertTrue(text.contains(".stringPlus"));
|
||||
System.out.println(text);
|
||||
Method foo = generateFunction();
|
||||
assertEquals("something239", foo.invoke(null, "something", 239));
|
||||
assertEquals("null239", foo.invoke(null, null, 239));
|
||||
assertEquals("239null", foo.invoke(null, "239", null));
|
||||
assertEquals("nullnull", foo.invoke(null, null, null));
|
||||
|
||||
}
|
||||
|
||||
public void testNonNullableStringPlus () throws InvocationTargetException, IllegalAccessException {
|
||||
loadText("fun foo(x: String, y: Any?) = x + y + 120");
|
||||
String text = generateToText();
|
||||
assertFalse(text.contains(".stringPlus"));
|
||||
System.out.println(text);
|
||||
Method foo = generateFunction();
|
||||
assertEquals("something239120", foo.invoke(null, "something", 239));
|
||||
assertEquals("null239120", foo.invoke(null, null, 239));
|
||||
assertEquals("239null120", foo.invoke(null, "239", null));
|
||||
assertEquals("nullnull120", foo.invoke(null, null, null));
|
||||
|
||||
}
|
||||
|
||||
public void testAnyEqualsNullable () throws InvocationTargetException, IllegalAccessException {
|
||||
loadText("fun foo(x: Any?) = x.equals(\"lala\")");
|
||||
System.out.println(generateToText());
|
||||
@@ -41,4 +76,8 @@ public class FunctionGenTest extends CodegenTestCase {
|
||||
assertTrue((Boolean) foo.invoke(null, "lala"));
|
||||
assertFalse((Boolean) foo.invoke(null, "mama"));
|
||||
}
|
||||
|
||||
public void testKt395 () {
|
||||
blackBoxFile("regressions/kt395.jet");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,10 +2,8 @@ package org.jetbrains.jet.codegen;
|
||||
|
||||
import jet.IntRange;
|
||||
import jet.Tuple2;
|
||||
import jet.Tuple3;
|
||||
import jet.Tuple4;
|
||||
import jet.typeinfo.TypeInfo;
|
||||
import org.jetbrains.jet.parsing.JetParsingTest;
|
||||
|
||||
import java.awt.*;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
@@ -48,7 +46,7 @@ public class NamespaceGenTest extends CodegenTestCase {
|
||||
}
|
||||
|
||||
public void testLocalProperty() throws Exception {
|
||||
myFixture.configureByFile(JetParsingTest.getTestDataDir() + "/codegen/localProperty.jet");
|
||||
loadFile("localProperty.jet");
|
||||
final String text = generateToText();
|
||||
System.out.println(text);
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ import junit.framework.Test;
|
||||
import junit.framework.TestSuite;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.JetTestCaseBase;
|
||||
import org.jetbrains.jet.JetTestCaseBuilder;
|
||||
import org.jetbrains.jet.lang.parsing.JetParserDefinition;
|
||||
import org.jetbrains.jet.lang.psi.JetElement;
|
||||
import org.jetbrains.jet.lang.psi.JetVisitorVoid;
|
||||
@@ -101,7 +101,7 @@ public class JetParsingTest extends ParsingTestCase {
|
||||
|
||||
public static TestSuite suite() {
|
||||
TestSuite suite = new TestSuite();
|
||||
JetTestCaseBase.NamedTestFactory factory = new JetTestCaseBase.NamedTestFactory() {
|
||||
JetTestCaseBuilder.NamedTestFactory factory = new JetTestCaseBuilder.NamedTestFactory() {
|
||||
@NotNull
|
||||
@Override
|
||||
public Test createTest(@NotNull String dataPath, @NotNull String name) {
|
||||
@@ -109,8 +109,8 @@ public class JetParsingTest extends ParsingTestCase {
|
||||
}
|
||||
};
|
||||
String prefix = JetParsingTest.getTestDataDir() + "/psi/";
|
||||
suite.addTest(JetTestCaseBase.suiteForDirectory(prefix, "/", false, factory));
|
||||
suite.addTest(JetTestCaseBase.suiteForDirectory(prefix, "examples", true, factory));
|
||||
suite.addTest(JetTestCaseBuilder.suiteForDirectory(prefix, "/", false, factory));
|
||||
suite.addTest(JetTestCaseBuilder.suiteForDirectory(prefix, "examples", true, factory));
|
||||
return suite;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package org.jetbrains.jet.resolve;
|
||||
|
||||
import com.intellij.openapi.command.WriteCommandAction;
|
||||
import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.psi.PsiElement;
|
||||
import com.intellij.psi.util.PsiTreeUtil;
|
||||
import org.jetbrains.jet.lang.JetSemanticServices;
|
||||
@@ -48,17 +46,7 @@ public class ExpectedResolveData {
|
||||
// this.nameToType = nameToType;
|
||||
}
|
||||
|
||||
public void extractData(final Document document) {
|
||||
new WriteCommandAction.Simple(null) {
|
||||
public void run() {
|
||||
doExtractData(document);
|
||||
}
|
||||
}.execute().throwException();
|
||||
}
|
||||
|
||||
private void doExtractData(Document document) {
|
||||
String text = document.getText();
|
||||
|
||||
public String extractData(String text) {
|
||||
Pattern pattern = Pattern.compile("(~[^~]+~)|(`[^`]+`)");
|
||||
while (true) {
|
||||
Matcher matcher = pattern.matcher(text);
|
||||
@@ -84,11 +72,11 @@ public class ExpectedResolveData {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
|
||||
document.replaceString(start, matcher.end(), "");
|
||||
text = document.getText();
|
||||
text = text.substring(0, start) + text.substring(matcher.end());
|
||||
}
|
||||
|
||||
System.out.println(text);
|
||||
return text;
|
||||
}
|
||||
|
||||
public void checkResult(JetFile file) {
|
||||
|
||||
@@ -1,108 +1,29 @@
|
||||
package org.jetbrains.jet.resolve;
|
||||
|
||||
import com.intellij.codeHighlighting.Pass;
|
||||
import com.intellij.codeInsight.daemon.DaemonCodeAnalyzer;
|
||||
import com.intellij.codeInsight.daemon.DaemonCodeAnalyzerSettings;
|
||||
import com.intellij.codeInsight.daemon.impl.DaemonCodeAnalyzerImpl;
|
||||
import com.intellij.codeInsight.daemon.impl.HighlightInfo;
|
||||
import com.intellij.injected.editor.EditorWindow;
|
||||
import com.intellij.openapi.command.CommandProcessor;
|
||||
import com.intellij.openapi.editor.Editor;
|
||||
import com.intellij.openapi.vfs.VirtualFileFilter;
|
||||
import com.intellij.psi.PsiDocumentManager;
|
||||
import com.intellij.psi.PsiFile;
|
||||
import com.intellij.psi.impl.source.tree.injected.InjectedLanguageUtil;
|
||||
import com.intellij.testFramework.FileTreeAccessFilter;
|
||||
import com.intellij.testFramework.LightCodeInsightTestCase;
|
||||
import com.intellij.testFramework.fixtures.impl.CodeInsightTestFixtureImpl;
|
||||
import com.intellij.util.ArrayUtil;
|
||||
import org.jetbrains.annotations.NonNls;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.JetLiteFixture;
|
||||
import org.jetbrains.jet.lang.psi.JetFile;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* @author abreslav
|
||||
*/
|
||||
public abstract class ExtensibleResolveTestCase extends LightCodeInsightTestCase {
|
||||
private final FileTreeAccessFilter myJavaFilesFilter = new FileTreeAccessFilter();
|
||||
public abstract class ExtensibleResolveTestCase extends JetLiteFixture {
|
||||
private ExpectedResolveData expectedResolveData;
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
super.setUp();
|
||||
expectedResolveData = getExpectedResolveData();
|
||||
((DaemonCodeAnalyzerImpl) DaemonCodeAnalyzer.getInstance(getProject())).prepareForTest();
|
||||
DaemonCodeAnalyzerSettings.getInstance().setImportHintEnabled(false);
|
||||
}
|
||||
|
||||
protected abstract ExpectedResolveData getExpectedResolveData();
|
||||
|
||||
@Override
|
||||
protected void tearDown() throws Exception {
|
||||
((DaemonCodeAnalyzerImpl) DaemonCodeAnalyzer.getInstance(getProject())).cleanupAfterTest(false); // has to cleanup by hand since light project does not get disposed any time soon
|
||||
super.tearDown();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void runTest() throws Throwable {
|
||||
final Throwable[] throwable = {null};
|
||||
CommandProcessor.getInstance().executeCommand(getProject(), new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
doRunTest();
|
||||
} catch (Throwable t) {
|
||||
throwable[0] = t;
|
||||
}
|
||||
}
|
||||
}, "", null);
|
||||
if (throwable[0] != null) {
|
||||
throw throwable[0];
|
||||
}
|
||||
}
|
||||
|
||||
protected void doTest(@NonNls String filePath, boolean checkWarnings, boolean checkInfos) throws Exception {
|
||||
configureByFile(filePath);
|
||||
doTestConfiguredFile(checkWarnings, checkInfos);
|
||||
}
|
||||
|
||||
protected void doTestConfiguredFile(boolean checkWarnings, boolean checkInfos) {
|
||||
getJavaFacade().setAssertOnFileLoadingFilter(VirtualFileFilter.NONE);
|
||||
|
||||
// ExpectedHighlightingData expectedData = new ExpectedHighlightingData(getEditor().getDocument(), checkWarnings, checkInfos);
|
||||
expectedResolveData.extractData(getEditor().getDocument());
|
||||
|
||||
PsiDocumentManager.getInstance(getProject()).commitAllDocuments();
|
||||
getFile().getText(); //to load text
|
||||
myJavaFilesFilter.allowTreeAccessForFile(getVFile());
|
||||
getJavaFacade().setAssertOnFileLoadingFilter(myJavaFilesFilter); // check repository work
|
||||
|
||||
Collection<HighlightInfo> infos = doHighlighting();
|
||||
|
||||
getJavaFacade().setAssertOnFileLoadingFilter(VirtualFileFilter.NONE);
|
||||
|
||||
expectedResolveData.checkResult((JetFile) getFile());
|
||||
}
|
||||
|
||||
@NotNull
|
||||
protected List<HighlightInfo> doHighlighting() {
|
||||
PsiDocumentManager.getInstance(getProject()).commitAllDocuments();
|
||||
|
||||
int[] toIgnore = doFolding() ? ArrayUtil.EMPTY_INT_ARRAY : new int[]{Pass.UPDATE_FOLDING};
|
||||
Editor editor = getEditor();
|
||||
PsiFile file = getFile();
|
||||
if (editor instanceof EditorWindow) {
|
||||
editor = ((EditorWindow) editor).getDelegate();
|
||||
file = InjectedLanguageUtil.getTopLevelFile(file);
|
||||
}
|
||||
|
||||
return CodeInsightTestFixtureImpl.instantiateAndRun(file, editor, toIgnore, false);
|
||||
}
|
||||
|
||||
protected boolean doFolding() {
|
||||
return false;
|
||||
protected void doTest(@NonNls String filePath) throws Exception {
|
||||
String text = loadFile(filePath);
|
||||
text = expectedResolveData.extractData(text);
|
||||
JetFile jetFile = createPsiFile(new File(filePath).getName(), text);
|
||||
expectedResolveData.checkResult(jetFile);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@ package org.jetbrains.jet.resolve;
|
||||
|
||||
import com.intellij.openapi.application.PathManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.projectRoots.Sdk;
|
||||
import com.intellij.psi.JavaPsiFacade;
|
||||
import com.intellij.psi.PsiClass;
|
||||
import com.intellij.psi.PsiElement;
|
||||
@@ -10,7 +9,7 @@ import com.intellij.psi.PsiMethod;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import junit.framework.Test;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.JetTestCaseBase;
|
||||
import org.jetbrains.jet.JetTestCaseBuilder;
|
||||
import org.jetbrains.jet.lang.JetSemanticServices;
|
||||
import org.jetbrains.jet.lang.descriptors.ClassDescriptor;
|
||||
import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor;
|
||||
@@ -133,10 +132,12 @@ public class JetResolveTest extends ExtensibleResolveTestCase {
|
||||
return getHomeDirectory() + "/compiler/testData";
|
||||
}
|
||||
|
||||
/*
|
||||
@Override
|
||||
protected Sdk getProjectJDK() {
|
||||
return JetTestCaseBase.jdkFromIdeaHome();
|
||||
return PluginTestCaseBase.jdkFromIdeaHome();
|
||||
}
|
||||
*/
|
||||
|
||||
private static String getHomeDirectory() {
|
||||
return new File(PathManager.getResourceRoot(JetParsingTest.class, "/org/jetbrains/jet/parsing/JetParsingTest.class")).getParentFile().getParentFile().getParent();
|
||||
@@ -149,11 +150,11 @@ public class JetResolveTest extends ExtensibleResolveTestCase {
|
||||
|
||||
@Override
|
||||
protected void runTest() throws Throwable {
|
||||
doTest(path, true, false);
|
||||
doTest(path);
|
||||
}
|
||||
|
||||
public static Test suite() {
|
||||
return JetTestCaseBase.suiteForDirectory(getHomeDirectory() + "/compiler/testData/", "/resolve/", true, new JetTestCaseBase.NamedTestFactory() {
|
||||
return JetTestCaseBuilder.suiteForDirectory(getHomeDirectory() + "/compiler/testData/", "/resolve/", true, new JetTestCaseBuilder.NamedTestFactory() {
|
||||
@NotNull
|
||||
@Override
|
||||
public Test createTest(@NotNull String dataPath, @NotNull String name) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package org.jetbrains.jet.types;
|
||||
|
||||
import com.intellij.codeInsight.daemon.LightDaemonAnalyzerTestCase;
|
||||
import org.jetbrains.jet.JetLiteFixture;
|
||||
import org.jetbrains.jet.JetTestUtils;
|
||||
import org.jetbrains.jet.lang.JetSemanticServices;
|
||||
import org.jetbrains.jet.lang.descriptors.*;
|
||||
@@ -18,7 +18,7 @@ import java.util.List;
|
||||
/**
|
||||
* @author svtk
|
||||
*/
|
||||
public class JetDefaultModalityModifiersTest extends LightDaemonAnalyzerTestCase {
|
||||
public class JetDefaultModalityModifiersTest extends JetLiteFixture {
|
||||
private JetDefaultModalityModifiersTestCase tc = new JetDefaultModalityModifiersTestCase();
|
||||
|
||||
@Override
|
||||
@@ -27,7 +27,7 @@ public class JetDefaultModalityModifiersTest extends LightDaemonAnalyzerTestCase
|
||||
tc.setUp();
|
||||
}
|
||||
|
||||
public static class JetDefaultModalityModifiersTestCase {
|
||||
public class JetDefaultModalityModifiersTestCase {
|
||||
private ModuleDescriptor root = new ModuleDescriptor("test_root");
|
||||
private ClassDescriptorResolver classDescriptorResolver;
|
||||
private JetScope scope;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package org.jetbrains.jet.types;
|
||||
|
||||
import com.intellij.codeInsight.daemon.LightDaemonAnalyzerTestCase;
|
||||
import com.intellij.openapi.application.PathManager;
|
||||
import org.jetbrains.jet.JetLiteFixture;
|
||||
import org.jetbrains.jet.JetTestCaseBuilder;
|
||||
import org.jetbrains.jet.JetTestUtils;
|
||||
import org.jetbrains.jet.lang.JetSemanticServices;
|
||||
import org.jetbrains.jet.lang.descriptors.FunctionDescriptor;
|
||||
@@ -11,14 +11,11 @@ import org.jetbrains.jet.lang.psi.JetPsiFactory;
|
||||
import org.jetbrains.jet.lang.resolve.ClassDescriptorResolver;
|
||||
import org.jetbrains.jet.lang.resolve.OverridingUtil;
|
||||
import org.jetbrains.jet.lang.types.JetStandardLibrary;
|
||||
import org.jetbrains.jet.parsing.JetParsingTest;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* @author abreslav
|
||||
*/
|
||||
public class JetOverridingTest extends LightDaemonAnalyzerTestCase {
|
||||
public class JetOverridingTest extends JetLiteFixture {
|
||||
|
||||
private ModuleDescriptor root = new ModuleDescriptor("test_root");
|
||||
private JetStandardLibrary library;
|
||||
@@ -35,11 +32,7 @@ public class JetOverridingTest extends LightDaemonAnalyzerTestCase {
|
||||
|
||||
@Override
|
||||
protected String getTestDataPath() {
|
||||
return getHomeDirectory() + "/compiler/testData";
|
||||
}
|
||||
|
||||
private static String getHomeDirectory() {
|
||||
return new File(PathManager.getResourceRoot(JetParsingTest.class, "/org/jetbrains/jet/parsing/JetParsingTest.class")).getParentFile().getParentFile().getParent();
|
||||
return JetTestCaseBuilder.getTestDataPathBase();
|
||||
}
|
||||
|
||||
public void testBasic() throws Exception {
|
||||
|
||||
@@ -1,13 +1,11 @@
|
||||
package org.jetbrains.jet.types;
|
||||
|
||||
import com.google.common.collect.Sets;
|
||||
import com.intellij.codeInsight.daemon.LightDaemonAnalyzerTestCase;
|
||||
import com.intellij.openapi.application.PathManager;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.projectRoots.Sdk;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jetbrains.jet.JetTestCaseBase;
|
||||
import org.jetbrains.jet.JetLiteFixture;
|
||||
import org.jetbrains.jet.JetTestCaseBuilder;
|
||||
import org.jetbrains.jet.JetTestUtils;
|
||||
import org.jetbrains.jet.lang.JetSemanticServices;
|
||||
import org.jetbrains.jet.lang.descriptors.*;
|
||||
@@ -21,15 +19,13 @@ import org.jetbrains.jet.lang.resolve.scopes.receivers.ExpressionReceiver;
|
||||
import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverDescriptor;
|
||||
import org.jetbrains.jet.lang.types.*;
|
||||
import org.jetbrains.jet.lexer.JetTokens;
|
||||
import org.jetbrains.jet.parsing.JetParsingTest;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @author abreslav
|
||||
*/
|
||||
public class JetTypeCheckerTest extends LightDaemonAnalyzerTestCase {
|
||||
public class JetTypeCheckerTest extends JetLiteFixture {
|
||||
|
||||
private JetStandardLibrary library;
|
||||
private JetSemanticServices semanticServices;
|
||||
@@ -38,6 +34,10 @@ public class JetTypeCheckerTest extends LightDaemonAnalyzerTestCase {
|
||||
private JetScope scopeWithImports;
|
||||
private TypeResolver typeResolver;
|
||||
|
||||
public JetTypeCheckerTest() {
|
||||
super("");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setUp() throws Exception {
|
||||
super.setUp();
|
||||
@@ -51,11 +51,7 @@ public class JetTypeCheckerTest extends LightDaemonAnalyzerTestCase {
|
||||
|
||||
@Override
|
||||
protected String getTestDataPath() {
|
||||
return getHomeDirectory() + "/compiler/testData";
|
||||
}
|
||||
|
||||
private static String getHomeDirectory() {
|
||||
return new File(PathManager.getResourceRoot(JetParsingTest.class, "/org/jetbrains/jet/parsing/JetParsingTest.class")).getParentFile().getParentFile().getParent();
|
||||
return JetTestCaseBuilder.getTestDataPathBase();
|
||||
}
|
||||
|
||||
public void testConstants() throws Exception {
|
||||
@@ -544,11 +540,6 @@ public class JetTypeCheckerTest extends LightDaemonAnalyzerTestCase {
|
||||
return new TypeResolver(semanticServices, JetTestUtils.DUMMY_TRACE, true).resolveType(scope, JetPsiFactory.createType(getProject(), typeStr));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected Sdk getProjectJDK() {
|
||||
return JetTestCaseBase.jdkFromIdeaHome();
|
||||
}
|
||||
|
||||
private class ClassDefinitions {
|
||||
private Map<String, ClassDescriptor> CLASSES = new HashMap<String, ClassDescriptor>();
|
||||
private String[] CLASS_DECLARATIONS = {
|
||||
|
||||
Reference in New Issue
Block a user