diff --git a/build.xml b/build.xml index 7c6d6c4cf23..e5dafdfcbef 100644 --- a/build.xml +++ b/build.xml @@ -139,7 +139,7 @@ - + diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/AnnotationCodegen.java b/compiler/backend/src/org/jetbrains/jet/codegen/AnnotationCodegen.java index df2af34a135..04887664bb4 100644 --- a/compiler/backend/src/org/jetbrains/jet/codegen/AnnotationCodegen.java +++ b/compiler/backend/src/org/jetbrains/jet/codegen/AnnotationCodegen.java @@ -31,7 +31,6 @@ import org.jetbrains.jet.lang.psi.JetModifierListOwner; import org.jetbrains.jet.lang.resolve.BindingContext; import org.jetbrains.jet.lang.resolve.calls.model.ResolvedCall; import org.jetbrains.jet.lang.resolve.constants.*; -import org.jetbrains.jet.lang.resolve.constants.StringValue; import org.jetbrains.jet.lang.resolve.name.FqName; import org.jetbrains.jet.lang.types.JetType; import org.jetbrains.jet.lang.types.TypeUtils; @@ -174,7 +173,7 @@ public abstract class AnnotationCodegen { return; } - boolean isNullableType = JvmCodegenUtil.isNullableType(type); + boolean isNullableType = TypeUtils.isNullableType(type); Class annotationClass = isNullableType ? Nullable.class : NotNull.class; diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/AsmUtil.java b/compiler/backend/src/org/jetbrains/jet/codegen/AsmUtil.java index 9a5f4c39e2e..badbff196fc 100644 --- a/compiler/backend/src/org/jetbrains/jet/codegen/AsmUtil.java +++ b/compiler/backend/src/org/jetbrains/jet/codegen/AsmUtil.java @@ -58,6 +58,7 @@ import static org.jetbrains.jet.lang.resolve.java.AsmTypeConstants.getType; import static org.jetbrains.jet.lang.resolve.java.JvmAnnotationNames.ABI_VERSION_FIELD_NAME; import static org.jetbrains.jet.lang.resolve.java.JvmAnnotationNames.KotlinSyntheticClass; import static org.jetbrains.jet.lang.resolve.java.mapping.PrimitiveTypesUtil.asmTypeForPrimitive; +import static org.jetbrains.jet.lang.types.TypeUtils.isNullableType; import static org.jetbrains.org.objectweb.asm.Opcodes.*; public class AsmUtil { diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/ExpressionCodegen.java b/compiler/backend/src/org/jetbrains/jet/codegen/ExpressionCodegen.java index 60cbe9f7dcc..8e9f9862f95 100644 --- a/compiler/backend/src/org/jetbrains/jet/codegen/ExpressionCodegen.java +++ b/compiler/backend/src/org/jetbrains/jet/codegen/ExpressionCodegen.java @@ -54,6 +54,7 @@ import org.jetbrains.jet.lang.resolve.java.jvmSignature.JvmMethodSignature; import org.jetbrains.jet.lang.resolve.name.Name; import org.jetbrains.jet.lang.resolve.scopes.receivers.*; import org.jetbrains.jet.lang.types.JetType; +import org.jetbrains.jet.lang.types.TypeUtils; import org.jetbrains.jet.lang.types.checker.JetTypeChecker; import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns; import org.jetbrains.jet.lexer.JetTokens; @@ -3506,7 +3507,7 @@ The "returned" value of try expression with no finally is either the last expres value.put(boxType(value.type), v); if (opToken != JetTokens.AS_SAFE) { - if (!JvmCodegenUtil.isNullableType(rightType)) { + if (!TypeUtils.isNullableType(rightType)) { v.dup(); Label nonnull = new Label(); v.ifnonnull(nonnull); diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/ImplementationBodyCodegen.java b/compiler/backend/src/org/jetbrains/jet/codegen/ImplementationBodyCodegen.java index 15ef11f2960..6650d907bfb 100644 --- a/compiler/backend/src/org/jetbrains/jet/codegen/ImplementationBodyCodegen.java +++ b/compiler/backend/src/org/jetbrains/jet/codegen/ImplementationBodyCodegen.java @@ -43,6 +43,7 @@ import org.jetbrains.jet.descriptors.serialization.ProtoBuf; import org.jetbrains.jet.lang.descriptors.*; import org.jetbrains.jet.lang.psi.*; import org.jetbrains.jet.lang.resolve.BindingContext; +import org.jetbrains.jet.lang.resolve.DeclarationResolver; import org.jetbrains.jet.lang.resolve.DescriptorUtils; import org.jetbrains.jet.lang.resolve.calls.CallResolverUtil; import org.jetbrains.jet.lang.resolve.calls.model.ResolvedCall; @@ -838,7 +839,7 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen { iv.anew(thisDescriptorType); iv.dup(); - ConstructorDescriptor constructor = DescriptorUtils.getConstructorOfDataClass(descriptor); + ConstructorDescriptor constructor = DeclarationResolver.getConstructorOfDataClass(descriptor); assert function.getValueParameters().size() == constructor.getValueParameters().size() : "Number of parameters of copy function and constructor are different. " + "Copy: " + function.getValueParameters().size() + ", " + @@ -1124,9 +1125,11 @@ public class ImplementationBodyCodegen extends ClassBodyCodegen { protected void genInitSingleton(ClassDescriptor fieldTypeDescriptor, StackValue.Field field) { if (state.getClassBuilderMode() == ClassBuilderMode.FULL) { - ConstructorDescriptor constructorDescriptor = DescriptorUtils.getConstructorOfSingletonObject(fieldTypeDescriptor); + Collection constructors = fieldTypeDescriptor.getConstructors(); + assert constructors.size() == 1 : "Class of singleton object must have only one constructor: " + constructors; + ExpressionCodegen codegen = createOrGetClInitCodegen(); - FunctionDescriptor fd = codegen.accessibleFunctionDescriptor(constructorDescriptor); + FunctionDescriptor fd = codegen.accessibleFunctionDescriptor(constructors.iterator().next()); generateMethodCallTo(fd, codegen.v); field.store(field.type, codegen.v); } diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/JvmCodegenUtil.java b/compiler/backend/src/org/jetbrains/jet/codegen/JvmCodegenUtil.java index 98dea4fa31b..65d0eaf897b 100644 --- a/compiler/backend/src/org/jetbrains/jet/codegen/JvmCodegenUtil.java +++ b/compiler/backend/src/org/jetbrains/jet/codegen/JvmCodegenUtil.java @@ -16,8 +16,6 @@ package org.jetbrains.jet.codegen; -import com.intellij.openapi.util.io.FileUtil; -import com.intellij.openapi.vfs.VirtualFile; import com.intellij.util.containers.Stack; import kotlin.Function1; import kotlin.KotlinPackage; @@ -37,7 +35,6 @@ import org.jetbrains.jet.lang.resolve.DescriptorUtils; import org.jetbrains.jet.lang.resolve.calls.CallResolverUtil; import org.jetbrains.jet.lang.resolve.name.Name; import org.jetbrains.jet.lang.types.JetType; -import org.jetbrains.jet.lang.types.TypeUtils; import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns; import java.util.Arrays; @@ -193,20 +190,6 @@ public class JvmCodegenUtil { ); } - /** - * A work-around of the generic nullability problem in the type checker - * @return true if a value of this type can be null - */ - public static boolean isNullableType(@NotNull JetType type) { - if (type.isNullable()) { - return true; - } - if (type.getConstructor().getDeclarationDescriptor() instanceof TypeParameterDescriptor) { - return TypeUtils.hasNullableSuperType(type); - } - return false; - } - public static boolean couldUseDirectAccessToProperty( @NotNull PropertyDescriptor propertyDescriptor, boolean forGetter, diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/JvmFunctionImplTypes.java b/compiler/backend/src/org/jetbrains/jet/codegen/JvmRuntimeTypes.java similarity index 94% rename from compiler/backend/src/org/jetbrains/jet/codegen/JvmFunctionImplTypes.java rename to compiler/backend/src/org/jetbrains/jet/codegen/JvmRuntimeTypes.java index c315f11c1c7..25e7ab540d8 100644 --- a/compiler/backend/src/org/jetbrains/jet/codegen/JvmFunctionImplTypes.java +++ b/compiler/backend/src/org/jetbrains/jet/codegen/JvmRuntimeTypes.java @@ -23,17 +23,17 @@ import org.jetbrains.jet.lang.descriptors.impl.MutableClassDescriptor; import org.jetbrains.jet.lang.descriptors.impl.MutablePackageFragmentDescriptor; import org.jetbrains.jet.lang.descriptors.impl.TypeParameterDescriptorImpl; import org.jetbrains.jet.lang.reflect.ReflectionTypes; -import org.jetbrains.jet.lang.resolve.DescriptorUtils; import org.jetbrains.jet.lang.resolve.ImportPath; import org.jetbrains.jet.lang.resolve.java.mapping.JavaToKotlinClassMap; import org.jetbrains.jet.lang.resolve.name.FqName; import org.jetbrains.jet.lang.resolve.name.Name; import org.jetbrains.jet.lang.types.*; +import org.jetbrains.jet.lang.types.expressions.ExpressionTypingUtils; import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns; import java.util.*; -public class JvmFunctionImplTypes { +public class JvmRuntimeTypes { private final ReflectionTypes reflectionTypes; private final ClassDescriptor functionImpl; @@ -42,7 +42,7 @@ public class JvmFunctionImplTypes { private final ClassDescriptor kMemberFunctionImpl; private final ClassDescriptor kExtensionFunctionImpl; - public JvmFunctionImplTypes(@NotNull ReflectionTypes reflectionTypes) { + public JvmRuntimeTypes(@NotNull ReflectionTypes reflectionTypes) { this.reflectionTypes = reflectionTypes; ModuleDescriptor fakeModule = new ModuleDescriptorImpl(Name.special(""), @@ -117,7 +117,7 @@ public class JvmFunctionImplTypes { JetType functionType = KotlinBuiltIns.getInstance().getFunctionType( Annotations.EMPTY, receiverParameter == null ? null : receiverParameter.getType(), - DescriptorUtils.getValueParametersTypes(descriptor.getValueParameters()), + ExpressionTypingUtils.getValueParametersTypes(descriptor.getValueParameters()), descriptor.getReturnType() ); @@ -125,7 +125,7 @@ public class JvmFunctionImplTypes { } @NotNull - public Collection getSupertypesForCallableReference(@NotNull FunctionDescriptor descriptor) { + public Collection getSupertypesForFunctionReference(@NotNull FunctionDescriptor descriptor) { ReceiverParameterDescriptor receiverParameter = descriptor.getReceiverParameter(); ReceiverParameterDescriptor expectedThisObject = descriptor.getExpectedThisObject(); @@ -162,7 +162,7 @@ public class JvmFunctionImplTypes { JetType kFunctionType = reflectionTypes.getKFunctionType( Annotations.EMPTY, receiverType, - DescriptorUtils.getValueParametersTypes(descriptor.getValueParameters()), + ExpressionTypingUtils.getValueParametersTypes(descriptor.getValueParameters()), descriptor.getReturnType(), receiverParameter != null ); diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/MemberCodegen.java b/compiler/backend/src/org/jetbrains/jet/codegen/MemberCodegen.java index 7dc4acb416d..b491052aabb 100644 --- a/compiler/backend/src/org/jetbrains/jet/codegen/MemberCodegen.java +++ b/compiler/backend/src/org/jetbrains/jet/codegen/MemberCodegen.java @@ -199,11 +199,8 @@ public abstract class MemberCodegen should not be generated for light classes. Descriptor: " + descriptor; if (clInit == null) { MethodVisitor mv = v.newMethod(OtherOrigin(descriptor), ACC_STATIC, "", "()V", null, null); - mv.visitCode(); SimpleFunctionDescriptorImpl clInit = SimpleFunctionDescriptorImpl.create(descriptor, Annotations.EMPTY, Name.special(""), SYNTHESIZED); clInit.initialize(null, null, Collections.emptyList(), diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/binding/CodegenAnnotatingVisitor.java b/compiler/backend/src/org/jetbrains/jet/codegen/binding/CodegenAnnotatingVisitor.java index 32c9ced2bd8..00ef7e2abbb 100644 --- a/compiler/backend/src/org/jetbrains/jet/codegen/binding/CodegenAnnotatingVisitor.java +++ b/compiler/backend/src/org/jetbrains/jet/codegen/binding/CodegenAnnotatingVisitor.java @@ -23,7 +23,7 @@ import com.intellij.util.containers.Stack; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.jet.codegen.AsmUtil; -import org.jetbrains.jet.codegen.JvmFunctionImplTypes; +import org.jetbrains.jet.codegen.JvmRuntimeTypes; import org.jetbrains.jet.codegen.SamCodegenUtil; import org.jetbrains.jet.codegen.SamType; import org.jetbrains.jet.codegen.state.GenerationState; @@ -88,13 +88,13 @@ class CodegenAnnotatingVisitor extends JetVisitorVoid { private final BindingTrace bindingTrace; private final BindingContext bindingContext; private final GenerationState.GenerateClassFilter filter; - private final JvmFunctionImplTypes functionImplTypes; + private final JvmRuntimeTypes runtimeTypes; public CodegenAnnotatingVisitor(@NotNull GenerationState state) { this.bindingTrace = state.getBindingTrace(); this.bindingContext = state.getBindingContext(); this.filter = state.getGenerateDeclaredClassFilter(); - this.functionImplTypes = state.getJvmFunctionImplTypes(); + this.runtimeTypes = state.getJvmRuntimeTypes(); } @NotNull @@ -264,7 +264,7 @@ class CodegenAnnotatingVisitor extends JetVisitorVoid { if (functionDescriptor == null) return; String name = inventAnonymousClassName(expression); - Collection supertypes = functionImplTypes.getSupertypesForClosure(functionDescriptor); + Collection supertypes = runtimeTypes.getSupertypesForClosure(functionDescriptor); ClassDescriptor classDescriptor = recordClassForFunction(functionDescriptor, supertypes); recordClosure(functionLiteral, classDescriptor, name); @@ -313,7 +313,7 @@ class CodegenAnnotatingVisitor extends JetVisitorVoid { ResolvedCall referencedFunction = bindingContext.get(RESOLVED_CALL, expression.getCallableReference()); if (referencedFunction == null) return; Collection supertypes = - functionImplTypes.getSupertypesForCallableReference((FunctionDescriptor) referencedFunction.getResultingDescriptor()); + runtimeTypes.getSupertypesForFunctionReference((FunctionDescriptor) referencedFunction.getResultingDescriptor()); String name = inventAnonymousClassName(expression); ClassDescriptor classDescriptor = recordClassForFunction(functionDescriptor, supertypes); @@ -366,7 +366,7 @@ class CodegenAnnotatingVisitor extends JetVisitorVoid { } else { String name = inventAnonymousClassName(function); - Collection supertypes = functionImplTypes.getSupertypesForClosure(functionDescriptor); + Collection supertypes = runtimeTypes.getSupertypesForClosure(functionDescriptor); ClassDescriptor classDescriptor = recordClassForFunction(functionDescriptor, supertypes); recordClosure(function, classDescriptor, name); diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/binding/PsiCodegenPredictor.java b/compiler/backend/src/org/jetbrains/jet/codegen/binding/PsiCodegenPredictor.java index 2657308862a..09947049a9f 100644 --- a/compiler/backend/src/org/jetbrains/jet/codegen/binding/PsiCodegenPredictor.java +++ b/compiler/backend/src/org/jetbrains/jet/codegen/binding/PsiCodegenPredictor.java @@ -33,6 +33,7 @@ import org.jetbrains.jet.lang.resolve.BindingContextUtils; import org.jetbrains.jet.lang.resolve.BindingTrace; import org.jetbrains.jet.lang.resolve.java.JvmAbi; import org.jetbrains.jet.lang.resolve.java.JvmClassName; +import org.jetbrains.jet.lang.resolve.java.PackageClassUtils; import org.jetbrains.jet.lang.resolve.kotlin.PackagePartClassUtils; import org.jetbrains.jet.lang.resolve.name.FqName; import org.jetbrains.jet.lang.resolve.name.Name; @@ -42,7 +43,6 @@ import java.util.ArrayList; import java.util.Collection; import static org.jetbrains.jet.lang.resolve.BindingContextUtils.descriptorToDeclaration; -import static org.jetbrains.jet.lang.resolve.java.PackageClassUtils.getPackageClassFqName; public final class PsiCodegenPredictor { private PsiCodegenPredictor() { @@ -87,9 +87,8 @@ public final class PsiCodegenPredictor { FqName packageFqName = declaration.getContainingJetFile().getPackageFqName(); if (declaration instanceof JetNamedFunction) { - FqName packageClass = getPackageClassFqName(packageFqName); Name name = ((JetNamedFunction) declaration).getNameAsName(); - return name == null ? null : AsmUtil.internalNameByFqNameWithoutInnerClasses(packageClass) + "$" + name.asString(); + return name == null ? null : PackageClassUtils.getPackageClassInternalName(packageFqName) + "$" + name.asString(); } parentInternalName = AsmUtil.internalNameByFqNameWithoutInnerClasses(packageFqName); diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/state/GenerationState.java b/compiler/backend/src/org/jetbrains/jet/codegen/state/GenerationState.java index ae7bedf5c3d..6d9dbc94f2d 100644 --- a/compiler/backend/src/org/jetbrains/jet/codegen/state/GenerationState.java +++ b/compiler/backend/src/org/jetbrains/jet/codegen/state/GenerationState.java @@ -93,7 +93,7 @@ public class GenerationState { @Nullable private List earlierScriptsForReplInterpreter; - private final JvmFunctionImplTypes functionImplTypes; + private final JvmRuntimeTypes runtimeTypes; @NotNull private final ModuleDescriptor module; @@ -153,7 +153,7 @@ public class GenerationState { this.generateClassFilter = generateClassFilter; ReflectionTypes reflectionTypes = new ReflectionTypes(module); - this.functionImplTypes = new JvmFunctionImplTypes(reflectionTypes); + this.runtimeTypes = new JvmRuntimeTypes(reflectionTypes); } @NotNull @@ -220,8 +220,8 @@ public class GenerationState { } @NotNull - public JvmFunctionImplTypes getJvmFunctionImplTypes() { - return functionImplTypes; + public JvmRuntimeTypes getJvmRuntimeTypes() { + return runtimeTypes; } public boolean isInlineEnabled() { diff --git a/compiler/backend/src/org/jetbrains/jet/codegen/state/JetTypeMapper.java b/compiler/backend/src/org/jetbrains/jet/codegen/state/JetTypeMapper.java index 6dee5371442..9531769d875 100644 --- a/compiler/backend/src/org/jetbrains/jet/codegen/state/JetTypeMapper.java +++ b/compiler/backend/src/org/jetbrains/jet/codegen/state/JetTypeMapper.java @@ -143,7 +143,7 @@ public class JetTypeMapper { } } - return PackageClassUtils.getPackageClassFqName(packageFragment.getFqName()).asString().replace('.', '/'); + return PackageClassUtils.getPackageClassInternalName(packageFragment.getFqName()); } @NotNull diff --git a/compiler/cli/bin/kotlinc b/compiler/cli/bin/kotlinc new file mode 100755 index 00000000000..867dd7093a0 --- /dev/null +++ b/compiler/cli/bin/kotlinc @@ -0,0 +1,17 @@ +#!/bin/bash --posix + +# Copyright 2010-2014 JetBrains s.r.o. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +$(dirname $0)/kotlinc-jvm "$@" diff --git a/compiler/cli/bin/kotlinc.bat b/compiler/cli/bin/kotlinc.bat new file mode 100644 index 00000000000..d55e6c86d74 --- /dev/null +++ b/compiler/cli/bin/kotlinc.bat @@ -0,0 +1,17 @@ +@echo off + +rem Copyright 2010-2014 JetBrains s.r.o. +rem +rem Licensed under the Apache License, Version 2.0 (the "License"); +rem you may not use this file except in compliance with the License. +rem You may obtain a copy of the License at +rem +rem http://www.apache.org/licenses/LICENSE-2.0 +rem +rem Unless required by applicable law or agreed to in writing, software +rem distributed under the License is distributed on an "AS IS" BASIS, +rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +rem See the License for the specific language governing permissions and +rem limitations under the License. + +call %~dp0kotlinc-jvm.bat %* diff --git a/compiler/cli/src/org/jetbrains/jet/cli/jvm/K2JVMCompiler.java b/compiler/cli/src/org/jetbrains/jet/cli/jvm/K2JVMCompiler.java index 3d47a36dec5..7fc969f89de 100644 --- a/compiler/cli/src/org/jetbrains/jet/cli/jvm/K2JVMCompiler.java +++ b/compiler/cli/src/org/jetbrains/jet/cli/jvm/K2JVMCompiler.java @@ -20,7 +20,6 @@ import com.google.common.base.Splitter; import com.google.common.collect.Lists; import com.intellij.openapi.Disposable; import com.intellij.openapi.util.text.StringUtil; -import kotlin.modules.Module; import org.jetbrains.annotations.NotNull; import org.jetbrains.jet.cli.common.CLICompiler; import org.jetbrains.jet.cli.common.CLIConfigurationKeys; @@ -28,7 +27,10 @@ import org.jetbrains.jet.cli.common.ExitCode; import org.jetbrains.jet.cli.common.arguments.CompilerArgumentsUtil; import org.jetbrains.jet.cli.common.arguments.K2JVMCompilerArguments; import org.jetbrains.jet.cli.common.messages.*; -import org.jetbrains.jet.cli.jvm.compiler.*; +import org.jetbrains.jet.cli.jvm.compiler.CommandLineScriptUtils; +import org.jetbrains.jet.cli.jvm.compiler.CompileEnvironmentUtil; +import org.jetbrains.jet.cli.jvm.compiler.JetCoreEnvironment; +import org.jetbrains.jet.cli.jvm.compiler.KotlinToJVMBytecodeCompiler; import org.jetbrains.jet.cli.jvm.repl.ReplFromTerminal; import org.jetbrains.jet.codegen.CompilationException; import org.jetbrains.jet.codegen.inline.InlineCodegenUtil; @@ -83,7 +85,8 @@ public class K2JVMCompiler extends CLICompiler { if (!arguments.script && arguments.module == null && arguments.src == null && - arguments.freeArgs.isEmpty() + arguments.freeArgs.isEmpty() && + !arguments.version ) { ReplFromTerminal.run(rootDisposable, configuration); return ExitCode.OK; diff --git a/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/kotlinSignature/JavaToKotlinMethodMap.java b/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/kotlinSignature/JavaToKotlinMethodMap.java index e44ce419307..36866814156 100644 --- a/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/kotlinSignature/JavaToKotlinMethodMap.java +++ b/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/kotlinSignature/JavaToKotlinMethodMap.java @@ -32,10 +32,7 @@ import org.jetbrains.jet.lang.resolve.name.Name; import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns; import org.jetbrains.jet.renderer.DescriptorRenderer; -import java.util.Collection; -import java.util.List; -import java.util.Map; -import java.util.Set; +import java.util.*; public class JavaToKotlinMethodMap { public static final JavaToKotlinMethodMap INSTANCE = new JavaToKotlinMethodMap(); @@ -55,7 +52,7 @@ public class JavaToKotlinMethodMap { List result = Lists.newArrayList(); - Set allSuperClasses = DescriptorUtils.getAllSuperClasses(containingClass); + Set allSuperClasses = new HashSet(DescriptorUtils.getSuperclassDescriptors(containingClass)); String serializedMethod = JavaSignatureFormatter.getInstance().formatMethod(javaMethod); for (ClassData classData : classDatas) { diff --git a/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/structure/impl/JavaPropertyInitializerEvaluatorImpl.java b/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/structure/impl/JavaPropertyInitializerEvaluatorImpl.java index 929a1ecfe28..bfe6d1706fe 100644 --- a/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/structure/impl/JavaPropertyInitializerEvaluatorImpl.java +++ b/compiler/frontend.java/src/org/jetbrains/jet/lang/resolve/java/structure/impl/JavaPropertyInitializerEvaluatorImpl.java @@ -21,7 +21,7 @@ import com.intellij.psi.impl.JavaConstantExpressionEvaluator; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.jet.lang.descriptors.PropertyDescriptor; -import org.jetbrains.jet.lang.resolve.DescriptorUtils; +import org.jetbrains.jet.lang.evaluate.ConstantExpressionEvaluator; import org.jetbrains.jet.lang.resolve.constants.CompileTimeConstant; import org.jetbrains.jet.lang.resolve.constants.ConstantsPackage; import org.jetbrains.jet.lang.resolve.java.structure.JavaField; @@ -36,7 +36,7 @@ public class JavaPropertyInitializerEvaluatorImpl implements JavaPropertyInitial if (evaluatedExpression != null) { return ConstantsPackage.createCompileTimeConstant( evaluatedExpression, - DescriptorUtils.isPropertyCompileTimeConstant(descriptor), + ConstantExpressionEvaluator.object$.isPropertyCompileTimeConstant(descriptor), false, true, descriptor.getType()); diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/cfg/JetFlowInformationProvider.java b/compiler/frontend/src/org/jetbrains/jet/lang/cfg/JetFlowInformationProvider.java index 8bafae1e6a1..6566a125ad4 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/cfg/JetFlowInformationProvider.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/cfg/JetFlowInformationProvider.java @@ -58,6 +58,7 @@ import org.jetbrains.jet.lang.resolve.scopes.receivers.ExpressionReceiver; import org.jetbrains.jet.lang.resolve.scopes.receivers.ReceiverValue; import org.jetbrains.jet.lang.resolve.scopes.receivers.ThisReceiver; import org.jetbrains.jet.lang.types.JetType; +import org.jetbrains.jet.lang.types.expressions.ExpressionTypingUtils; import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns; import org.jetbrains.jet.lexer.JetTokens; import org.jetbrains.jet.plugin.MainFunctionDetector; @@ -591,7 +592,7 @@ public class JetFlowInformationProvider { VariableDescriptor variableDescriptor = PseudocodeUtil.extractVariableDescriptorIfAny( instruction, false, trace.getBindingContext()); if (variableDescriptor == null || !declaredVariables.contains(variableDescriptor) - || !DescriptorUtils.isLocal(variableDescriptor.getContainingDeclaration(), variableDescriptor)) { + || !ExpressionTypingUtils.isLocal(variableDescriptor.getContainingDeclaration(), variableDescriptor)) { return; } PseudocodeVariablesData.VariableUseState variableUseState = in.get(variableDescriptor); diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/evaluate/ConstantExpressionEvaluator.kt b/compiler/frontend/src/org/jetbrains/jet/lang/evaluate/ConstantExpressionEvaluator.kt index 3131614b810..98336f2dd07 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/evaluate/ConstantExpressionEvaluator.kt +++ b/compiler/frontend/src/org/jetbrains/jet/lang/evaluate/ConstantExpressionEvaluator.kt @@ -41,6 +41,17 @@ public class ConstantExpressionEvaluator private (val trace: BindingTrace) : Jet val evaluator = ConstantExpressionEvaluator(trace) return evaluator.evaluate(expression, expectedType) } + + public fun isPropertyCompileTimeConstant(descriptor: VariableDescriptor): Boolean { + if (descriptor.isVar()) { + return false + } + if (DescriptorUtils.isClassObject(descriptor.getContainingDeclaration()) || DescriptorUtils.isTopLevelDeclaration(descriptor)) { + val returnType = descriptor.getType() + return KotlinBuiltIns.getInstance().isPrimitiveType(returnType) || KotlinBuiltIns.getInstance().getStringType() == returnType + } + return false + } } private fun evaluate(expression: JetExpression, expectedType: JetType?): CompileTimeConstant<*>? { @@ -311,7 +322,7 @@ public class ConstantExpressionEvaluator private (val trace: BindingTrace) : Jet else compileTimeConstant.getValue() return createCompileTimeConstant(value, expectedType, isPure = false, - canBeUsedInAnnotation = DescriptorUtils.isPropertyCompileTimeConstant(callableDescriptor), + canBeUsedInAnnotation = isPropertyCompileTimeConstant(callableDescriptor), usesVariableAsConstant = true) } } diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/parsing/JetExpressionParsing.java b/compiler/frontend/src/org/jetbrains/jet/lang/parsing/JetExpressionParsing.java index 1c6dbfb32d7..dba0dd21d60 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/parsing/JetExpressionParsing.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/parsing/JetExpressionParsing.java @@ -372,7 +372,7 @@ public class JetExpressionParsing extends AbstractJetParsing { /* * callableReference - * : userType? "::" SimpleName + * : (userType "?"*)? "::" SimpleName * ; */ private boolean parseCallableReferenceExpression() { @@ -381,7 +381,9 @@ public class JetExpressionParsing extends AbstractJetParsing { if (!at(COLONCOLON)) { PsiBuilder.Marker typeReference = mark(); myJetParsing.parseUserType(); + typeReference = myJetParsing.parseNullableTypeSuffix(typeReference); typeReference.done(TYPE_REFERENCE); + if (!at(COLONCOLON)) { expression.rollbackTo(); return false; diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/parsing/JetParsing.java b/compiler/frontend/src/org/jetbrains/jet/lang/parsing/JetParsing.java index e14ec5a3e90..1644e65d41a 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/parsing/JetParsing.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/parsing/JetParsing.java @@ -19,6 +19,7 @@ package org.jetbrains.jet.lang.parsing; import com.intellij.lang.PsiBuilder; import com.intellij.psi.tree.IElementType; import com.intellij.psi.tree.TokenSet; +import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.jet.JetNodeType; import org.jetbrains.jet.lexer.JetKeywordToken; @@ -1478,14 +1479,7 @@ public class JetParsing extends AbstractJetParsing { TokenSet.create(EQ, COMMA, GT, RBRACKET, DOT, RPAR, RBRACE, LBRACE, SEMICOLON), extraRecoverySet)); } - while (at(QUEST)) { - PsiBuilder.Marker precede = typeRefMarker.precede(); - - advance(); // QUEST - typeRefMarker.done(NULLABLE_TYPE); - - typeRefMarker = precede; - } + typeRefMarker = parseNullableTypeSuffix(typeRefMarker); if (at(DOT)) { // This is a receiver for a function type @@ -1513,6 +1507,17 @@ public class JetParsing extends AbstractJetParsing { return typeRefMarker; } + @NotNull + PsiBuilder.Marker parseNullableTypeSuffix(@NotNull PsiBuilder.Marker typeRefMarker) { + while (at(QUEST)) { + PsiBuilder.Marker precede = typeRefMarker.precede(); + advance(); // QUEST + typeRefMarker.done(NULLABLE_TYPE); + typeRefMarker = precede; + } + return typeRefMarker; + } + /* * userType * : ("package" ".")? simpleUserType{"."} diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/BindingContextUtils.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/BindingContextUtils.java index b982bd5197d..a0f5f88c882 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/BindingContextUtils.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/BindingContextUtils.java @@ -89,7 +89,7 @@ public class BindingContextUtils { public static JetFile getContainingFile(@NotNull BindingContext context, @NotNull DeclarationDescriptor declarationDescriptor) { // declarationDescriptor may describe a synthesized element which doesn't have PSI // To workaround that, we find a top-level parent (which is inside a PackageFragmentDescriptor), which is guaranteed to have PSI - DeclarationDescriptor descriptor = DescriptorUtils.findTopLevelParent(declarationDescriptor); + DeclarationDescriptor descriptor = findTopLevelParent(declarationDescriptor); if (descriptor == null) return null; PsiElement declaration = descriptorToDeclaration(context, descriptor); @@ -100,6 +100,18 @@ public class BindingContextUtils { return (JetFile) containingFile; } + @Nullable + private static DeclarationDescriptor findTopLevelParent(@NotNull DeclarationDescriptor declarationDescriptor) { + DeclarationDescriptor descriptor = declarationDescriptor; + if (declarationDescriptor instanceof PropertyAccessorDescriptor) { + descriptor = ((PropertyAccessorDescriptor) descriptor).getCorrespondingProperty(); + } + while (!(descriptor == null || DescriptorUtils.isTopLevelDeclaration(descriptor))) { + descriptor = descriptor.getContainingDeclaration(); + } + return descriptor; + } + @Nullable private static PsiElement doGetDescriptorToDeclaration(@NotNull BindingContext context, @NotNull DeclarationDescriptor descriptor) { return context.get(DESCRIPTOR_TO_DECLARATION, descriptor); diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/DeclarationResolver.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/DeclarationResolver.java index 8527d137a00..ded579ce706 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/DeclarationResolver.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/DeclarationResolver.java @@ -203,13 +203,20 @@ public class DeclarationResolver { MutableClassDescriptor classDescriptor = (MutableClassDescriptor) entry.getValue(); if (klass instanceof JetClass && klass.hasPrimaryConstructor() && KotlinBuiltIns.getInstance().isData(classDescriptor)) { - ConstructorDescriptor constructor = DescriptorUtils.getConstructorOfDataClass(classDescriptor); + ConstructorDescriptor constructor = getConstructorOfDataClass(classDescriptor); createComponentFunctions(classDescriptor, constructor); createCopyFunction(classDescriptor, constructor); } } } + @NotNull + public static ConstructorDescriptor getConstructorOfDataClass(@NotNull ClassDescriptor classDescriptor) { + Collection constructors = classDescriptor.getConstructors(); + assert constructors.size() == 1 : "Data class must have only one constructor: " + classDescriptor.getConstructors(); + return constructors.iterator().next(); + } + private void createComponentFunctions(@NotNull MutableClassDescriptor classDescriptor, @NotNull ConstructorDescriptor constructorDescriptor) { int parameterIndex = 0; for (ValueParameterDescriptor parameter : constructorDescriptor.getValueParameters()) { diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/DescriptorResolver.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/DescriptorResolver.java index 9afc4b1a47a..f10296c0801 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/DescriptorResolver.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/DescriptorResolver.java @@ -546,7 +546,7 @@ public class DescriptorResolver { JetType variableType = type; if (valueParameter.hasModifier(VARARG_KEYWORD)) { varargElementType = type; - variableType = DescriptorUtils.getVarargParameterType(type); + variableType = getVarargParameterType(type); } ValueParameterDescriptorImpl valueParameterDescriptor = new ValueParameterDescriptorImpl( declarationDescriptor, @@ -563,6 +563,15 @@ public class DescriptorResolver { return valueParameterDescriptor; } + @NotNull + private static JetType getVarargParameterType(@NotNull JetType elementType) { + JetType primitiveArrayType = KotlinBuiltIns.getInstance().getPrimitiveArrayJetTypeByPrimitiveJetType(elementType); + if (primitiveArrayType != null) { + return primitiveArrayType; + } + return KotlinBuiltIns.getInstance().getArrayType(Variance.INVARIANT, elementType); + } + public List resolveTypeParametersForCallableDescriptor( DeclarationDescriptor containingDescriptor, WritableScope extensibleScope, @@ -791,7 +800,7 @@ public class DescriptorResolver { type = ErrorUtils.createErrorType("Annotation is absent"); } if (parameter.hasModifier(VARARG_KEYWORD)) { - return DescriptorUtils.getVarargParameterType(type); + return getVarargParameterType(type); } return type; } @@ -1259,7 +1268,7 @@ public class DescriptorResolver { parameterScope, valueParameters, trace), resolveVisibilityFromModifiers(modifierList, getDefaultConstructorVisibility(classDescriptor)), - DescriptorUtils.isConstructorOfStaticNestedClass(constructorDescriptor)); + isConstructorOfStaticNestedClass(constructorDescriptor)); if (isAnnotationClass(classDescriptor)) { CompileTimeConstantUtils.checkConstructorParametersType(valueParameters, trace); } @@ -1425,6 +1434,19 @@ public class DescriptorResolver { return true; } + private static boolean isInsideOuterClassOrItsSubclass(@Nullable DeclarationDescriptor nested, @NotNull ClassDescriptor outer) { + if (nested == null) return false; + + if (nested instanceof ClassDescriptor && isSubclass((ClassDescriptor) nested, outer)) return true; + + return isInsideOuterClassOrItsSubclass(nested.getContainingDeclaration(), outer); + } + + @Nullable + public static ClassDescriptor getContainingClass(@NotNull JetScope scope) { + return getParentOfType(scope.getContainingDeclaration(), ClassDescriptor.class, false); + } + public static void checkParameterHasNoValOrVar( @NotNull BindingTrace trace, @NotNull JetParameter parameter, diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/results/OverloadingConflictResolver.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/results/OverloadingConflictResolver.java index 2bd6d32a3c8..ab5a4ca37f7 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/results/OverloadingConflictResolver.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/results/OverloadingConflictResolver.java @@ -21,11 +21,11 @@ import gnu.trove.TObjectHashingStrategy; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.jet.lang.descriptors.*; -import org.jetbrains.jet.lang.resolve.DescriptorUtils; import org.jetbrains.jet.lang.resolve.OverrideResolver; import org.jetbrains.jet.lang.resolve.calls.model.MutableResolvedCall; import org.jetbrains.jet.lang.resolve.calls.model.ResolvedCall; import org.jetbrains.jet.lang.resolve.calls.model.VariableAsFunctionResolvedCall; +import org.jetbrains.jet.lang.types.BoundsSubstitutor; import org.jetbrains.jet.lang.types.JetType; import org.jetbrains.jet.lang.types.TypeUtils; import org.jetbrains.jet.lang.types.checker.JetTypeChecker; @@ -131,7 +131,7 @@ public class OverloadingConflictResolver { if (isGenericF && !isGenericG) return false; if (isGenericF && isGenericG) { - return moreSpecific(DescriptorUtils.substituteBounds(f), DescriptorUtils.substituteBounds(g), false); + return moreSpecific(BoundsSubstitutor.substituteBounds(f), BoundsSubstitutor.substituteBounds(g), false); } } diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/tasks/TaskPrioritizer.java b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/tasks/TaskPrioritizer.java index 5166f22bd2a..63b8aa1c049 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/tasks/TaskPrioritizer.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/resolve/calls/tasks/TaskPrioritizer.java @@ -38,8 +38,11 @@ import org.jetbrains.jet.lang.types.ErrorUtils; import org.jetbrains.jet.lang.types.JetType; import org.jetbrains.jet.lang.types.PackageType; import org.jetbrains.jet.lang.types.checker.JetTypeChecker; +import org.jetbrains.jet.lang.types.expressions.ExpressionTypingUtils; -import java.util.*; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; import static org.jetbrains.jet.lang.resolve.calls.CallResolverUtil.isOrOverridesSynthesized; import static org.jetbrains.jet.lang.resolve.calls.tasks.ExplicitReceiverKind.*; @@ -54,7 +57,7 @@ public class TaskPrioritizer { @NotNull Collection> nonlocal ) { for (ResolutionCandidate resolvedCall : allDescriptors) { - if (DescriptorUtils.isLocal(containerOfTheCurrentLocality, resolvedCall.getDescriptor())) { + if (ExpressionTypingUtils.isLocal(containerOfTheCurrentLocality, resolvedCall.getDescriptor())) { local.add(resolvedCall); } else { diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/types/BoundsSubstitutor.java b/compiler/frontend/src/org/jetbrains/jet/lang/types/BoundsSubstitutor.java new file mode 100644 index 00000000000..c0f85a943ab --- /dev/null +++ b/compiler/frontend/src/org/jetbrains/jet/lang/types/BoundsSubstitutor.java @@ -0,0 +1,121 @@ +/* + * Copyright 2010-2013 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.jet.lang.types; + +import com.google.common.base.Function; +import com.google.common.collect.Collections2; +import org.jetbrains.annotations.NotNull; +import org.jetbrains.jet.lang.descriptors.CallableDescriptor; +import org.jetbrains.jet.lang.descriptors.ClassifierDescriptor; +import org.jetbrains.jet.lang.descriptors.TypeParameterDescriptor; +import org.jetbrains.jet.utils.DFS; + +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +public class BoundsSubstitutor { + private static final Function PROJECTIONS_TO_TYPES = new Function() { + @Override + public JetType apply(TypeProjection projection) { + return projection.getType(); + } + }; + + private BoundsSubstitutor() { + } + + @NotNull + public static D substituteBounds(@NotNull D functionDescriptor) { + List typeParameters = functionDescriptor.getTypeParameters(); + if (typeParameters.isEmpty()) return functionDescriptor; + + // TODO: this does not handle any recursion in the bounds + @SuppressWarnings("unchecked") + D substitutedFunction = (D) functionDescriptor.substitute(createUpperBoundsSubstitutor(typeParameters)); + assert substitutedFunction != null : "Substituting upper bounds should always be legal"; + + return substitutedFunction; + } + + @NotNull + private static TypeSubstitutor createUpperBoundsSubstitutor(@NotNull List typeParameters) { + Map mutableSubstitution = new HashMap(); + TypeSubstitutor substitutor = TypeSubstitutor.create(mutableSubstitution); + + // todo assert: no loops + for (TypeParameterDescriptor descriptor : topologicallySortTypeParameters(typeParameters)) { + JetType upperBoundsAsType = descriptor.getUpperBoundsAsType(); + JetType substitutedUpperBoundsAsType = substitutor.substitute(upperBoundsAsType, Variance.INVARIANT); + mutableSubstitution.put(descriptor.getTypeConstructor(), new TypeProjectionImpl(substitutedUpperBoundsAsType)); + } + + return substitutor; + } + + @NotNull + private static List topologicallySortTypeParameters(@NotNull final List typeParameters) { + // In the end, we want every parameter to have no references to those after it in the list + // This gives us the reversed order: the one that refers to everybody else comes first + List topOrder = DFS.topologicalOrder( + typeParameters, + new DFS.Neighbors() { + @NotNull + @Override + public Iterable getNeighbors(TypeParameterDescriptor current) { + return getTypeParametersFromUpperBounds(current, typeParameters); + } + }); + + assert topOrder.size() == typeParameters.size() : "All type parameters must be visited, but only " + topOrder + " were"; + + // Now, the one that refers to everybody else stands in the last position + Collections.reverse(topOrder); + return topOrder; + } + + @NotNull + private static List getTypeParametersFromUpperBounds( + @NotNull TypeParameterDescriptor current, + @NotNull final List typeParameters + ) { + return DFS.dfs( + current.getUpperBounds(), + new DFS.Neighbors() { + @NotNull + @Override + public Iterable getNeighbors(JetType current) { + return Collections2.transform(current.getArguments(), PROJECTIONS_TO_TYPES); + } + }, + new DFS.NodeHandlerWithListResult() { + @Override + public boolean beforeChildren(JetType current) { + ClassifierDescriptor declarationDescriptor = current.getConstructor().getDeclarationDescriptor(); + // typeParameters in a list, but it contains very few elements, so it's fine to call contains() on it + //noinspection SuspiciousMethodCalls + if (typeParameters.contains(declarationDescriptor)) { + result.add((TypeParameterDescriptor) declarationDescriptor); + } + + return true; + } + } + ); + } +} diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/BasicExpressionTypingVisitor.java b/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/BasicExpressionTypingVisitor.java index edf331d8c97..976d1b5ab19 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/BasicExpressionTypingVisitor.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/BasicExpressionTypingVisitor.java @@ -498,7 +498,7 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor { JetType type = components.reflectionTypes.getKFunctionType( Annotations.EMPTY, receiverType, - DescriptorUtils.getValueParametersTypes(descriptor.getValueParameters()), + getValueParametersTypes(descriptor.getValueParameters()), descriptor.getReturnType(), receiverParameter != null ); diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/ClosureExpressionsTypingVisitor.java b/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/ClosureExpressionsTypingVisitor.java index 73331a549fb..4053ecc3467 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/ClosureExpressionsTypingVisitor.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/ClosureExpressionsTypingVisitor.java @@ -111,7 +111,7 @@ public class ClosureExpressionsTypingVisitor extends ExpressionTypingVisitor { functionDescriptor.setReturnType(safeReturnType); JetType receiver = DescriptorUtils.getReceiverParameterType(functionDescriptor.getReceiverParameter()); - List valueParametersTypes = DescriptorUtils.getValueParametersTypes(functionDescriptor.getValueParameters()); + List valueParametersTypes = ExpressionTypingUtils.getValueParametersTypes(functionDescriptor.getValueParameters()); JetType resultType = KotlinBuiltIns.getInstance().getFunctionType( Annotations.EMPTY, receiver, valueParametersTypes, safeReturnType); if (!noExpectedType(expectedType) && KotlinBuiltIns.getInstance().isFunctionOrExtensionFunctionType(expectedType)) { @@ -187,7 +187,7 @@ public class ClosureExpressionsTypingVisitor extends ExpressionTypingVisitor { } else { if (expectedValueParameters != null && declaredValueParameters.size() != expectedValueParameters.size()) { - List expectedParameterTypes = DescriptorUtils.getValueParametersTypes(expectedValueParameters); + List expectedParameterTypes = ExpressionTypingUtils.getValueParametersTypes(expectedValueParameters); context.trace.report(EXPECTED_PARAMETERS_NUMBER_MISMATCH.on(functionLiteral, expectedParameterTypes.size(), expectedParameterTypes)); } for (int i = 0; i < declaredValueParameters.size(); i++) { diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/ControlStructureTypingVisitor.java b/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/ControlStructureTypingVisitor.java index e0ce8f2fcc5..df43995bb2e 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/ControlStructureTypingVisitor.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/ControlStructureTypingVisitor.java @@ -370,7 +370,7 @@ public class ControlStructureTypingVisitor extends ExpressionTypingVisitor { // http://youtrack.jetbrains.net/issue/KT-527 VariableDescriptor olderVariable = context.scope.getLocalVariable(variableDescriptor.getName()); - if (olderVariable != null && DescriptorUtils.isLocal(context.scope.getContainingDeclaration(), olderVariable)) { + if (olderVariable != null && isLocal(context.scope.getContainingDeclaration(), olderVariable)) { PsiElement declaration = BindingContextUtils.descriptorToDeclaration(context.trace.getBindingContext(), variableDescriptor); context.trace.report(Errors.NAME_SHADOWING.on(declaration, variableDescriptor.getName().asString())); } diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/ExpressionTypingServices.java b/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/ExpressionTypingServices.java index e6885543fc2..9d53a508a8b 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/ExpressionTypingServices.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/ExpressionTypingServices.java @@ -395,7 +395,7 @@ public class ExpressionTypingServices { JetExpression defaultValue = jetParameter.getDefaultValue(); if (defaultValue != null) { getType(declaringScope, defaultValue, valueParameterDescriptor.getType(), dataFlowInfo, trace); - if (DescriptorUtils.isAnnotationClass(DescriptorUtils.getContainingClass(declaringScope))) { + if (DescriptorUtils.isAnnotationClass(DescriptorResolver.getContainingClass(declaringScope))) { ConstantExpressionEvaluator.object$.evaluate(defaultValue, trace, valueParameterDescriptor.getType()); } } diff --git a/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/ExpressionTypingUtils.java b/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/ExpressionTypingUtils.java index c56aee232cf..ee3202b6044 100644 --- a/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/ExpressionTypingUtils.java +++ b/compiler/frontend/src/org/jetbrains/jet/lang/types/expressions/ExpressionTypingUtils.java @@ -427,7 +427,7 @@ public class ExpressionTypingUtils { } public static void checkVariableShadowing(@NotNull ExpressionTypingContext context, @NotNull VariableDescriptor variableDescriptor, VariableDescriptor oldDescriptor) { - if (oldDescriptor != null && DescriptorUtils.isLocal(variableDescriptor.getContainingDeclaration(), oldDescriptor)) { + if (oldDescriptor != null && isLocal(variableDescriptor.getContainingDeclaration(), oldDescriptor)) { PsiElement declaration = BindingContextUtils.descriptorToDeclaration(context.trace.getBindingContext(), variableDescriptor); if (declaration != null) { context.trace.report(Errors.NAME_SHADOWING.on(declaration, variableDescriptor.getName().asString())); @@ -486,4 +486,44 @@ public class ExpressionTypingUtils { public static boolean isUnaryExpressionDependentOnExpectedType(@NotNull JetUnaryExpression expression) { return expression.getOperationReference().getReferencedNameElementType() == JetTokens.EXCLEXCL; } + + @NotNull + public static List getValueParametersTypes(@NotNull List valueParameters) { + List parameterTypes = new ArrayList(valueParameters.size()); + for (ValueParameterDescriptor parameter : valueParameters) { + parameterTypes.add(parameter.getType()); + } + return parameterTypes; + } + + /** + * The primary case for local extensions is the following: + * + * I had a locally declared extension function or a local variable of function type called foo + * And I called it on my x + * Now, someone added function foo() to the class of x + * My code should not change + * + * thus + * + * local extension prevail over members (and members prevail over all non-local extensions) + */ + public static boolean isLocal(DeclarationDescriptor containerOfTheCurrentLocality, DeclarationDescriptor candidate) { + if (candidate instanceof ValueParameterDescriptor) { + return true; + } + DeclarationDescriptor parent = candidate.getContainingDeclaration(); + if (!(parent instanceof FunctionDescriptor)) { + return false; + } + FunctionDescriptor functionDescriptor = (FunctionDescriptor) parent; + DeclarationDescriptor current = containerOfTheCurrentLocality; + while (current != null) { + if (current == functionDescriptor) { + return true; + } + current = current.getContainingDeclaration(); + } + return false; + } } diff --git a/compiler/testData/codegen/boxWithJava/annotations/javaAnnotationCall.java b/compiler/testData/codegen/boxAgainstJava/annotations/javaAnnotationCall.java similarity index 100% rename from compiler/testData/codegen/boxWithJava/annotations/javaAnnotationCall.java rename to compiler/testData/codegen/boxAgainstJava/annotations/javaAnnotationCall.java diff --git a/compiler/testData/codegen/boxWithJava/annotations/javaAnnotationCall.kt b/compiler/testData/codegen/boxAgainstJava/annotations/javaAnnotationCall.kt similarity index 100% rename from compiler/testData/codegen/boxWithJava/annotations/javaAnnotationCall.kt rename to compiler/testData/codegen/boxAgainstJava/annotations/javaAnnotationCall.kt diff --git a/compiler/testData/codegen/boxWithJava/annotations/javaAnnotationDefault.java b/compiler/testData/codegen/boxAgainstJava/annotations/javaAnnotationDefault.java similarity index 100% rename from compiler/testData/codegen/boxWithJava/annotations/javaAnnotationDefault.java rename to compiler/testData/codegen/boxAgainstJava/annotations/javaAnnotationDefault.java diff --git a/compiler/testData/codegen/boxWithJava/annotations/javaAnnotationDefault.kt b/compiler/testData/codegen/boxAgainstJava/annotations/javaAnnotationDefault.kt similarity index 100% rename from compiler/testData/codegen/boxWithJava/annotations/javaAnnotationDefault.kt rename to compiler/testData/codegen/boxAgainstJava/annotations/javaAnnotationDefault.kt diff --git a/compiler/testData/codegen/boxWithJava/annotations/javaNegativePropertyAsAnnotationParameter.java b/compiler/testData/codegen/boxAgainstJava/annotations/javaNegativePropertyAsAnnotationParameter.java similarity index 100% rename from compiler/testData/codegen/boxWithJava/annotations/javaNegativePropertyAsAnnotationParameter.java rename to compiler/testData/codegen/boxAgainstJava/annotations/javaNegativePropertyAsAnnotationParameter.java diff --git a/compiler/testData/codegen/boxWithJava/annotations/javaNegativePropertyAsAnnotationParameter.kt b/compiler/testData/codegen/boxAgainstJava/annotations/javaNegativePropertyAsAnnotationParameter.kt similarity index 100% rename from compiler/testData/codegen/boxWithJava/annotations/javaNegativePropertyAsAnnotationParameter.kt rename to compiler/testData/codegen/boxAgainstJava/annotations/javaNegativePropertyAsAnnotationParameter.kt diff --git a/compiler/testData/codegen/boxWithJava/annotations/javaPropertyAsAnnotationParameter.java b/compiler/testData/codegen/boxAgainstJava/annotations/javaPropertyAsAnnotationParameter.java similarity index 100% rename from compiler/testData/codegen/boxWithJava/annotations/javaPropertyAsAnnotationParameter.java rename to compiler/testData/codegen/boxAgainstJava/annotations/javaPropertyAsAnnotationParameter.java diff --git a/compiler/testData/codegen/boxWithJava/annotations/javaPropertyAsAnnotationParameter.kt b/compiler/testData/codegen/boxAgainstJava/annotations/javaPropertyAsAnnotationParameter.kt similarity index 100% rename from compiler/testData/codegen/boxWithJava/annotations/javaPropertyAsAnnotationParameter.kt rename to compiler/testData/codegen/boxAgainstJava/annotations/javaPropertyAsAnnotationParameter.kt diff --git a/compiler/testData/codegen/boxWithJava/annotations/javaPropertyWithIntInitializer.java b/compiler/testData/codegen/boxAgainstJava/annotations/javaPropertyWithIntInitializer.java similarity index 100% rename from compiler/testData/codegen/boxWithJava/annotations/javaPropertyWithIntInitializer.java rename to compiler/testData/codegen/boxAgainstJava/annotations/javaPropertyWithIntInitializer.java diff --git a/compiler/testData/codegen/boxWithJava/annotations/javaPropertyWithIntInitializer.kt b/compiler/testData/codegen/boxAgainstJava/annotations/javaPropertyWithIntInitializer.kt similarity index 100% rename from compiler/testData/codegen/boxWithJava/annotations/javaPropertyWithIntInitializer.kt rename to compiler/testData/codegen/boxAgainstJava/annotations/javaPropertyWithIntInitializer.kt diff --git a/compiler/testData/codegen/boxWithJava/annotations/RetentionInJava.java b/compiler/testData/codegen/boxAgainstJava/annotations/retentionInJava.java similarity index 100% rename from compiler/testData/codegen/boxWithJava/annotations/RetentionInJava.java rename to compiler/testData/codegen/boxAgainstJava/annotations/retentionInJava.java diff --git a/compiler/testData/codegen/boxWithJava/annotations/RetentionInJava.kt b/compiler/testData/codegen/boxAgainstJava/annotations/retentionInJava.kt similarity index 100% rename from compiler/testData/codegen/boxWithJava/annotations/RetentionInJava.kt rename to compiler/testData/codegen/boxAgainstJava/annotations/retentionInJava.kt diff --git a/compiler/testData/codegen/boxWithJava/callableReference/constructor.java b/compiler/testData/codegen/boxAgainstJava/callableReference/constructor.java similarity index 100% rename from compiler/testData/codegen/boxWithJava/callableReference/constructor.java rename to compiler/testData/codegen/boxAgainstJava/callableReference/constructor.java diff --git a/compiler/testData/codegen/boxWithJava/callableReference/constructor.kt b/compiler/testData/codegen/boxAgainstJava/callableReference/constructor.kt similarity index 100% rename from compiler/testData/codegen/boxWithJava/callableReference/constructor.kt rename to compiler/testData/codegen/boxAgainstJava/callableReference/constructor.kt diff --git a/compiler/testData/codegen/boxWithJava/constructor/genericConstructor.java b/compiler/testData/codegen/boxAgainstJava/constructor/genericConstructor.java similarity index 100% rename from compiler/testData/codegen/boxWithJava/constructor/genericConstructor.java rename to compiler/testData/codegen/boxAgainstJava/constructor/genericConstructor.java diff --git a/compiler/testData/codegen/boxWithJava/constructor/genericConstructor.kt b/compiler/testData/codegen/boxAgainstJava/constructor/genericConstructor.kt similarity index 100% rename from compiler/testData/codegen/boxWithJava/constructor/genericConstructor.kt rename to compiler/testData/codegen/boxAgainstJava/constructor/genericConstructor.kt diff --git a/compiler/testData/codegen/boxWithJava/delegation/delegationAndInheritanceFromJava.java b/compiler/testData/codegen/boxAgainstJava/delegation/delegationAndInheritanceFromJava.java similarity index 100% rename from compiler/testData/codegen/boxWithJava/delegation/delegationAndInheritanceFromJava.java rename to compiler/testData/codegen/boxAgainstJava/delegation/delegationAndInheritanceFromJava.java diff --git a/compiler/testData/codegen/boxWithJava/delegation/delegationAndInheritanceFromJava.kt b/compiler/testData/codegen/boxAgainstJava/delegation/delegationAndInheritanceFromJava.kt similarity index 100% rename from compiler/testData/codegen/boxWithJava/delegation/delegationAndInheritanceFromJava.kt rename to compiler/testData/codegen/boxAgainstJava/delegation/delegationAndInheritanceFromJava.kt diff --git a/compiler/testData/codegen/boxWithJava/enum/simpleJavaEnum.java b/compiler/testData/codegen/boxAgainstJava/enum/simpleJavaEnum.java similarity index 100% rename from compiler/testData/codegen/boxWithJava/enum/simpleJavaEnum.java rename to compiler/testData/codegen/boxAgainstJava/enum/simpleJavaEnum.java diff --git a/compiler/testData/codegen/boxWithJava/enum/simpleJavaEnum.kt b/compiler/testData/codegen/boxAgainstJava/enum/simpleJavaEnum.kt similarity index 100% rename from compiler/testData/codegen/boxWithJava/enum/simpleJavaEnum.kt rename to compiler/testData/codegen/boxAgainstJava/enum/simpleJavaEnum.kt diff --git a/compiler/testData/codegen/boxWithJava/enum/simpleJavaEnumWithFunction.java b/compiler/testData/codegen/boxAgainstJava/enum/simpleJavaEnumWithFunction.java similarity index 100% rename from compiler/testData/codegen/boxWithJava/enum/simpleJavaEnumWithFunction.java rename to compiler/testData/codegen/boxAgainstJava/enum/simpleJavaEnumWithFunction.java diff --git a/compiler/testData/codegen/boxWithJava/enum/simpleJavaEnumWithFunction.kt b/compiler/testData/codegen/boxAgainstJava/enum/simpleJavaEnumWithFunction.kt similarity index 100% rename from compiler/testData/codegen/boxWithJava/enum/simpleJavaEnumWithFunction.kt rename to compiler/testData/codegen/boxAgainstJava/enum/simpleJavaEnumWithFunction.kt diff --git a/compiler/testData/codegen/boxWithJava/enum/simpleJavaEnumWithStaticImport.java b/compiler/testData/codegen/boxAgainstJava/enum/simpleJavaEnumWithStaticImport.java similarity index 100% rename from compiler/testData/codegen/boxWithJava/enum/simpleJavaEnumWithStaticImport.java rename to compiler/testData/codegen/boxAgainstJava/enum/simpleJavaEnumWithStaticImport.java diff --git a/compiler/testData/codegen/boxWithJava/enum/simpleJavaEnumWithStaticImport.kt b/compiler/testData/codegen/boxAgainstJava/enum/simpleJavaEnumWithStaticImport.kt similarity index 100% rename from compiler/testData/codegen/boxWithJava/enum/simpleJavaEnumWithStaticImport.kt rename to compiler/testData/codegen/boxAgainstJava/enum/simpleJavaEnumWithStaticImport.kt diff --git a/compiler/testData/codegen/boxWithJava/enum/simpleJavaInnerEnum.java b/compiler/testData/codegen/boxAgainstJava/enum/simpleJavaInnerEnum.java similarity index 100% rename from compiler/testData/codegen/boxWithJava/enum/simpleJavaInnerEnum.java rename to compiler/testData/codegen/boxAgainstJava/enum/simpleJavaInnerEnum.java diff --git a/compiler/testData/codegen/boxWithJava/enum/simpleJavaInnerEnum.kt b/compiler/testData/codegen/boxAgainstJava/enum/simpleJavaInnerEnum.kt similarity index 100% rename from compiler/testData/codegen/boxWithJava/enum/simpleJavaInnerEnum.kt rename to compiler/testData/codegen/boxAgainstJava/enum/simpleJavaInnerEnum.kt diff --git a/compiler/testData/codegen/boxWithJava/enum/staticField.java b/compiler/testData/codegen/boxAgainstJava/enum/staticField.java similarity index 100% rename from compiler/testData/codegen/boxWithJava/enum/staticField.java rename to compiler/testData/codegen/boxAgainstJava/enum/staticField.java diff --git a/compiler/testData/codegen/boxWithJava/enum/staticField.kt b/compiler/testData/codegen/boxAgainstJava/enum/staticField.kt similarity index 100% rename from compiler/testData/codegen/boxWithJava/enum/staticField.kt rename to compiler/testData/codegen/boxAgainstJava/enum/staticField.kt diff --git a/compiler/testData/codegen/boxWithJava/enum/staticMethod.java b/compiler/testData/codegen/boxAgainstJava/enum/staticMethod.java similarity index 100% rename from compiler/testData/codegen/boxWithJava/enum/staticMethod.java rename to compiler/testData/codegen/boxAgainstJava/enum/staticMethod.java diff --git a/compiler/testData/codegen/boxWithJava/enum/staticMethod.kt b/compiler/testData/codegen/boxAgainstJava/enum/staticMethod.kt similarity index 100% rename from compiler/testData/codegen/boxWithJava/enum/staticMethod.kt rename to compiler/testData/codegen/boxAgainstJava/enum/staticMethod.kt diff --git a/compiler/testData/codegen/boxWithJava/functions/constructor.java b/compiler/testData/codegen/boxAgainstJava/functions/constructor.java similarity index 100% rename from compiler/testData/codegen/boxWithJava/functions/constructor.java rename to compiler/testData/codegen/boxAgainstJava/functions/constructor.java diff --git a/compiler/testData/codegen/boxWithJava/functions/constructor.kt b/compiler/testData/codegen/boxAgainstJava/functions/constructor.kt similarity index 100% rename from compiler/testData/codegen/boxWithJava/functions/constructor.kt rename to compiler/testData/codegen/boxAgainstJava/functions/constructor.kt diff --git a/compiler/testData/codegen/boxWithJava/functions/max.java b/compiler/testData/codegen/boxAgainstJava/functions/max.java similarity index 100% rename from compiler/testData/codegen/boxWithJava/functions/max.java rename to compiler/testData/codegen/boxAgainstJava/functions/max.java diff --git a/compiler/testData/codegen/boxWithJava/functions/max.kt b/compiler/testData/codegen/boxAgainstJava/functions/max.kt similarity index 100% rename from compiler/testData/codegen/boxWithJava/functions/max.kt rename to compiler/testData/codegen/boxAgainstJava/functions/max.kt diff --git a/compiler/testData/codegen/boxWithJava/functions/referencesStaticInnerClassMethod.java b/compiler/testData/codegen/boxAgainstJava/functions/referencesStaticInnerClassMethod.java similarity index 100% rename from compiler/testData/codegen/boxWithJava/functions/referencesStaticInnerClassMethod.java rename to compiler/testData/codegen/boxAgainstJava/functions/referencesStaticInnerClassMethod.java diff --git a/compiler/testData/codegen/boxWithJava/functions/referencesStaticInnerClassMethod.kt b/compiler/testData/codegen/boxAgainstJava/functions/referencesStaticInnerClassMethod.kt similarity index 100% rename from compiler/testData/codegen/boxWithJava/functions/referencesStaticInnerClassMethod.kt rename to compiler/testData/codegen/boxAgainstJava/functions/referencesStaticInnerClassMethod.kt diff --git a/compiler/testData/codegen/boxWithJava/functions/referencesStaticInnerClassMethodL2.java b/compiler/testData/codegen/boxAgainstJava/functions/referencesStaticInnerClassMethodL2.java similarity index 100% rename from compiler/testData/codegen/boxWithJava/functions/referencesStaticInnerClassMethodL2.java rename to compiler/testData/codegen/boxAgainstJava/functions/referencesStaticInnerClassMethodL2.java diff --git a/compiler/testData/codegen/boxWithJava/functions/referencesStaticInnerClassMethodL2.kt b/compiler/testData/codegen/boxAgainstJava/functions/referencesStaticInnerClassMethodL2.kt similarity index 100% rename from compiler/testData/codegen/boxWithJava/functions/referencesStaticInnerClassMethodL2.kt rename to compiler/testData/codegen/boxAgainstJava/functions/referencesStaticInnerClassMethodL2.kt diff --git a/compiler/testData/codegen/boxWithJava/functions/unrelatedUpperBounds.java b/compiler/testData/codegen/boxAgainstJava/functions/unrelatedUpperBounds.java similarity index 100% rename from compiler/testData/codegen/boxWithJava/functions/unrelatedUpperBounds.java rename to compiler/testData/codegen/boxAgainstJava/functions/unrelatedUpperBounds.java diff --git a/compiler/testData/codegen/boxWithJava/functions/unrelatedUpperBounds.kt b/compiler/testData/codegen/boxAgainstJava/functions/unrelatedUpperBounds.kt similarity index 100% rename from compiler/testData/codegen/boxWithJava/functions/unrelatedUpperBounds.kt rename to compiler/testData/codegen/boxAgainstJava/functions/unrelatedUpperBounds.kt diff --git a/compiler/testData/codegen/boxWithJava/innerClass/kt3532.java b/compiler/testData/codegen/boxAgainstJava/innerClass/kt3532.java similarity index 100% rename from compiler/testData/codegen/boxWithJava/innerClass/kt3532.java rename to compiler/testData/codegen/boxAgainstJava/innerClass/kt3532.java diff --git a/compiler/testData/codegen/boxWithJava/innerClass/kt3532.kt b/compiler/testData/codegen/boxAgainstJava/innerClass/kt3532.kt similarity index 100% rename from compiler/testData/codegen/boxWithJava/innerClass/kt3532.kt rename to compiler/testData/codegen/boxAgainstJava/innerClass/kt3532.kt diff --git a/compiler/testData/codegen/boxWithJava/innerClass/kt3812.java b/compiler/testData/codegen/boxAgainstJava/innerClass/kt3812.java similarity index 100% rename from compiler/testData/codegen/boxWithJava/innerClass/kt3812.java rename to compiler/testData/codegen/boxAgainstJava/innerClass/kt3812.java diff --git a/compiler/testData/codegen/boxWithJava/innerClass/kt3812.kt b/compiler/testData/codegen/boxAgainstJava/innerClass/kt3812.kt similarity index 100% rename from compiler/testData/codegen/boxWithJava/innerClass/kt3812.kt rename to compiler/testData/codegen/boxAgainstJava/innerClass/kt3812.kt diff --git a/compiler/testData/codegen/boxWithJava/innerClass/kt4036.java b/compiler/testData/codegen/boxAgainstJava/innerClass/kt4036.java similarity index 100% rename from compiler/testData/codegen/boxWithJava/innerClass/kt4036.java rename to compiler/testData/codegen/boxAgainstJava/innerClass/kt4036.java diff --git a/compiler/testData/codegen/boxWithJava/innerClass/kt4036.kt b/compiler/testData/codegen/boxAgainstJava/innerClass/kt4036.kt similarity index 100% rename from compiler/testData/codegen/boxWithJava/innerClass/kt4036.kt rename to compiler/testData/codegen/boxAgainstJava/innerClass/kt4036.kt diff --git a/compiler/testData/codegen/boxWithJava/property/fieldAccessFromExtensionInTraitImpl.java b/compiler/testData/codegen/boxAgainstJava/property/fieldAccessFromExtensionInTraitImpl.java similarity index 100% rename from compiler/testData/codegen/boxWithJava/property/fieldAccessFromExtensionInTraitImpl.java rename to compiler/testData/codegen/boxAgainstJava/property/fieldAccessFromExtensionInTraitImpl.java diff --git a/compiler/testData/codegen/boxWithJava/property/fieldAccessFromExtensionInTraitImpl.kt b/compiler/testData/codegen/boxAgainstJava/property/fieldAccessFromExtensionInTraitImpl.kt similarity index 100% rename from compiler/testData/codegen/boxWithJava/property/fieldAccessFromExtensionInTraitImpl.kt rename to compiler/testData/codegen/boxAgainstJava/property/fieldAccessFromExtensionInTraitImpl.kt diff --git a/compiler/testData/codegen/boxWithJava/property/fieldAccessViaSubclass.java b/compiler/testData/codegen/boxAgainstJava/property/fieldAccessViaSubclass.java similarity index 100% rename from compiler/testData/codegen/boxWithJava/property/fieldAccessViaSubclass.java rename to compiler/testData/codegen/boxAgainstJava/property/fieldAccessViaSubclass.java diff --git a/compiler/testData/codegen/boxWithJava/property/fieldAccessViaSubclass.kt b/compiler/testData/codegen/boxAgainstJava/property/fieldAccessViaSubclass.kt similarity index 100% rename from compiler/testData/codegen/boxWithJava/property/fieldAccessViaSubclass.kt rename to compiler/testData/codegen/boxAgainstJava/property/fieldAccessViaSubclass.kt diff --git a/compiler/testData/codegen/boxWithJava/sam/adapters/callAbstractAdapter.java b/compiler/testData/codegen/boxAgainstJava/sam/adapters/callAbstractAdapter.java similarity index 100% rename from compiler/testData/codegen/boxWithJava/sam/adapters/callAbstractAdapter.java rename to compiler/testData/codegen/boxAgainstJava/sam/adapters/callAbstractAdapter.java diff --git a/compiler/testData/codegen/boxWithJava/sam/adapters/callAbstractAdapter.kt b/compiler/testData/codegen/boxAgainstJava/sam/adapters/callAbstractAdapter.kt similarity index 100% rename from compiler/testData/codegen/boxWithJava/sam/adapters/callAbstractAdapter.kt rename to compiler/testData/codegen/boxAgainstJava/sam/adapters/callAbstractAdapter.kt diff --git a/compiler/testData/codegen/boxWithJava/sam/adapters/comparator.java b/compiler/testData/codegen/boxAgainstJava/sam/adapters/comparator.java similarity index 100% rename from compiler/testData/codegen/boxWithJava/sam/adapters/comparator.java rename to compiler/testData/codegen/boxAgainstJava/sam/adapters/comparator.java diff --git a/compiler/testData/codegen/boxWithJava/sam/adapters/comparator.kt b/compiler/testData/codegen/boxAgainstJava/sam/adapters/comparator.kt similarity index 100% rename from compiler/testData/codegen/boxWithJava/sam/adapters/comparator.kt rename to compiler/testData/codegen/boxAgainstJava/sam/adapters/comparator.kt diff --git a/compiler/testData/codegen/boxWithJava/sam/adapters/constructor.java b/compiler/testData/codegen/boxAgainstJava/sam/adapters/constructor.java similarity index 100% rename from compiler/testData/codegen/boxWithJava/sam/adapters/constructor.java rename to compiler/testData/codegen/boxAgainstJava/sam/adapters/constructor.java diff --git a/compiler/testData/codegen/boxWithJava/sam/adapters/constructor.kt b/compiler/testData/codegen/boxAgainstJava/sam/adapters/constructor.kt similarity index 100% rename from compiler/testData/codegen/boxWithJava/sam/adapters/constructor.kt rename to compiler/testData/codegen/boxAgainstJava/sam/adapters/constructor.kt diff --git a/compiler/testData/codegen/boxWithJava/sam/adapters/fileFilter.java b/compiler/testData/codegen/boxAgainstJava/sam/adapters/fileFilter.java similarity index 100% rename from compiler/testData/codegen/boxWithJava/sam/adapters/fileFilter.java rename to compiler/testData/codegen/boxAgainstJava/sam/adapters/fileFilter.java diff --git a/compiler/testData/codegen/boxWithJava/sam/adapters/fileFilter.kt b/compiler/testData/codegen/boxAgainstJava/sam/adapters/fileFilter.kt similarity index 100% rename from compiler/testData/codegen/boxWithJava/sam/adapters/fileFilter.kt rename to compiler/testData/codegen/boxAgainstJava/sam/adapters/fileFilter.kt diff --git a/compiler/testData/codegen/boxWithJava/sam/adapters/genericSignature.java b/compiler/testData/codegen/boxAgainstJava/sam/adapters/genericSignature.java similarity index 100% rename from compiler/testData/codegen/boxWithJava/sam/adapters/genericSignature.java rename to compiler/testData/codegen/boxAgainstJava/sam/adapters/genericSignature.java diff --git a/compiler/testData/codegen/boxWithJava/sam/adapters/genericSignature.kt b/compiler/testData/codegen/boxAgainstJava/sam/adapters/genericSignature.kt similarity index 100% rename from compiler/testData/codegen/boxWithJava/sam/adapters/genericSignature.kt rename to compiler/testData/codegen/boxAgainstJava/sam/adapters/genericSignature.kt diff --git a/compiler/testData/codegen/boxWithJava/sam/adapters/implementAdapter.java b/compiler/testData/codegen/boxAgainstJava/sam/adapters/implementAdapter.java similarity index 100% rename from compiler/testData/codegen/boxWithJava/sam/adapters/implementAdapter.java rename to compiler/testData/codegen/boxAgainstJava/sam/adapters/implementAdapter.java diff --git a/compiler/testData/codegen/boxWithJava/sam/adapters/implementAdapter.kt b/compiler/testData/codegen/boxAgainstJava/sam/adapters/implementAdapter.kt similarity index 100% rename from compiler/testData/codegen/boxWithJava/sam/adapters/implementAdapter.kt rename to compiler/testData/codegen/boxAgainstJava/sam/adapters/implementAdapter.kt diff --git a/compiler/testData/codegen/boxWithJava/sam/adapters/inheritedInKotlin.java b/compiler/testData/codegen/boxAgainstJava/sam/adapters/inheritedInKotlin.java similarity index 100% rename from compiler/testData/codegen/boxWithJava/sam/adapters/inheritedInKotlin.java rename to compiler/testData/codegen/boxAgainstJava/sam/adapters/inheritedInKotlin.java diff --git a/compiler/testData/codegen/boxWithJava/sam/adapters/inheritedInKotlin.kt b/compiler/testData/codegen/boxAgainstJava/sam/adapters/inheritedInKotlin.kt similarity index 100% rename from compiler/testData/codegen/boxWithJava/sam/adapters/inheritedInKotlin.kt rename to compiler/testData/codegen/boxAgainstJava/sam/adapters/inheritedInKotlin.kt diff --git a/compiler/testData/codegen/boxWithJava/sam/adapters/inheritedOverriddenAdapter.java b/compiler/testData/codegen/boxAgainstJava/sam/adapters/inheritedOverriddenAdapter.java similarity index 100% rename from compiler/testData/codegen/boxWithJava/sam/adapters/inheritedOverriddenAdapter.java rename to compiler/testData/codegen/boxAgainstJava/sam/adapters/inheritedOverriddenAdapter.java diff --git a/compiler/testData/codegen/boxWithJava/sam/adapters/inheritedOverriddenAdapter.kt b/compiler/testData/codegen/boxAgainstJava/sam/adapters/inheritedOverriddenAdapter.kt similarity index 100% rename from compiler/testData/codegen/boxWithJava/sam/adapters/inheritedOverriddenAdapter.kt rename to compiler/testData/codegen/boxAgainstJava/sam/adapters/inheritedOverriddenAdapter.kt diff --git a/compiler/testData/codegen/boxWithJava/sam/adapters/inheritedSimple.java b/compiler/testData/codegen/boxAgainstJava/sam/adapters/inheritedSimple.java similarity index 100% rename from compiler/testData/codegen/boxWithJava/sam/adapters/inheritedSimple.java rename to compiler/testData/codegen/boxAgainstJava/sam/adapters/inheritedSimple.java diff --git a/compiler/testData/codegen/boxWithJava/sam/adapters/inheritedSimple.kt b/compiler/testData/codegen/boxAgainstJava/sam/adapters/inheritedSimple.kt similarity index 100% rename from compiler/testData/codegen/boxWithJava/sam/adapters/inheritedSimple.kt rename to compiler/testData/codegen/boxAgainstJava/sam/adapters/inheritedSimple.kt diff --git a/compiler/testData/codegen/boxWithJava/sam/adapters/nonLiteralAndLiteralRunnable.java b/compiler/testData/codegen/boxAgainstJava/sam/adapters/nonLiteralAndLiteralRunnable.java similarity index 100% rename from compiler/testData/codegen/boxWithJava/sam/adapters/nonLiteralAndLiteralRunnable.java rename to compiler/testData/codegen/boxAgainstJava/sam/adapters/nonLiteralAndLiteralRunnable.java diff --git a/compiler/testData/codegen/boxWithJava/sam/adapters/nonLiteralAndLiteralRunnable.kt b/compiler/testData/codegen/boxAgainstJava/sam/adapters/nonLiteralAndLiteralRunnable.kt similarity index 100% rename from compiler/testData/codegen/boxWithJava/sam/adapters/nonLiteralAndLiteralRunnable.kt rename to compiler/testData/codegen/boxAgainstJava/sam/adapters/nonLiteralAndLiteralRunnable.kt diff --git a/compiler/testData/codegen/boxWithJava/sam/adapters/nonLiteralComparator.java b/compiler/testData/codegen/boxAgainstJava/sam/adapters/nonLiteralComparator.java similarity index 100% rename from compiler/testData/codegen/boxWithJava/sam/adapters/nonLiteralComparator.java rename to compiler/testData/codegen/boxAgainstJava/sam/adapters/nonLiteralComparator.java diff --git a/compiler/testData/codegen/boxWithJava/sam/adapters/nonLiteralComparator.kt b/compiler/testData/codegen/boxAgainstJava/sam/adapters/nonLiteralComparator.kt similarity index 100% rename from compiler/testData/codegen/boxWithJava/sam/adapters/nonLiteralComparator.kt rename to compiler/testData/codegen/boxAgainstJava/sam/adapters/nonLiteralComparator.kt diff --git a/compiler/testData/codegen/boxWithJava/sam/adapters/nonLiteralInConstructor.java b/compiler/testData/codegen/boxAgainstJava/sam/adapters/nonLiteralInConstructor.java similarity index 100% rename from compiler/testData/codegen/boxWithJava/sam/adapters/nonLiteralInConstructor.java rename to compiler/testData/codegen/boxAgainstJava/sam/adapters/nonLiteralInConstructor.java diff --git a/compiler/testData/codegen/boxWithJava/sam/adapters/nonLiteralInConstructor.kt b/compiler/testData/codegen/boxAgainstJava/sam/adapters/nonLiteralInConstructor.kt similarity index 100% rename from compiler/testData/codegen/boxWithJava/sam/adapters/nonLiteralInConstructor.kt rename to compiler/testData/codegen/boxAgainstJava/sam/adapters/nonLiteralInConstructor.kt diff --git a/compiler/testData/codegen/boxWithJava/sam/adapters/nonLiteralNull.java b/compiler/testData/codegen/boxAgainstJava/sam/adapters/nonLiteralNull.java similarity index 100% rename from compiler/testData/codegen/boxWithJava/sam/adapters/nonLiteralNull.java rename to compiler/testData/codegen/boxAgainstJava/sam/adapters/nonLiteralNull.java diff --git a/compiler/testData/codegen/boxWithJava/sam/adapters/nonLiteralNull.kt b/compiler/testData/codegen/boxAgainstJava/sam/adapters/nonLiteralNull.kt similarity index 100% rename from compiler/testData/codegen/boxWithJava/sam/adapters/nonLiteralNull.kt rename to compiler/testData/codegen/boxAgainstJava/sam/adapters/nonLiteralNull.kt diff --git a/compiler/testData/codegen/boxWithJava/sam/adapters/nonLiteralRunnable.java b/compiler/testData/codegen/boxAgainstJava/sam/adapters/nonLiteralRunnable.java similarity index 100% rename from compiler/testData/codegen/boxWithJava/sam/adapters/nonLiteralRunnable.java rename to compiler/testData/codegen/boxAgainstJava/sam/adapters/nonLiteralRunnable.java diff --git a/compiler/testData/codegen/boxWithJava/sam/adapters/nonLiteralRunnable.kt b/compiler/testData/codegen/boxAgainstJava/sam/adapters/nonLiteralRunnable.kt similarity index 100% rename from compiler/testData/codegen/boxWithJava/sam/adapters/nonLiteralRunnable.kt rename to compiler/testData/codegen/boxAgainstJava/sam/adapters/nonLiteralRunnable.kt diff --git a/compiler/testData/codegen/boxWithJava/sam/adapters/operators/augmentedAssignmentAndSquareBrackets.java b/compiler/testData/codegen/boxAgainstJava/sam/adapters/operators/augmentedAssignmentAndSquareBrackets.java similarity index 100% rename from compiler/testData/codegen/boxWithJava/sam/adapters/operators/augmentedAssignmentAndSquareBrackets.java rename to compiler/testData/codegen/boxAgainstJava/sam/adapters/operators/augmentedAssignmentAndSquareBrackets.java diff --git a/compiler/testData/codegen/boxWithJava/sam/adapters/operators/augmentedAssignmentAndSquareBrackets.kt b/compiler/testData/codegen/boxAgainstJava/sam/adapters/operators/augmentedAssignmentAndSquareBrackets.kt similarity index 100% rename from compiler/testData/codegen/boxWithJava/sam/adapters/operators/augmentedAssignmentAndSquareBrackets.kt rename to compiler/testData/codegen/boxAgainstJava/sam/adapters/operators/augmentedAssignmentAndSquareBrackets.kt diff --git a/compiler/testData/codegen/boxWithJava/sam/adapters/operators/augmentedAssignmentPure.java b/compiler/testData/codegen/boxAgainstJava/sam/adapters/operators/augmentedAssignmentPure.java similarity index 100% rename from compiler/testData/codegen/boxWithJava/sam/adapters/operators/augmentedAssignmentPure.java rename to compiler/testData/codegen/boxAgainstJava/sam/adapters/operators/augmentedAssignmentPure.java diff --git a/compiler/testData/codegen/boxWithJava/sam/adapters/operators/augmentedAssignmentPure.kt b/compiler/testData/codegen/boxAgainstJava/sam/adapters/operators/augmentedAssignmentPure.kt similarity index 100% rename from compiler/testData/codegen/boxWithJava/sam/adapters/operators/augmentedAssignmentPure.kt rename to compiler/testData/codegen/boxAgainstJava/sam/adapters/operators/augmentedAssignmentPure.kt diff --git a/compiler/testData/codegen/boxWithJava/sam/adapters/operators/augmentedAssignmentViaSimpleBinary.java b/compiler/testData/codegen/boxAgainstJava/sam/adapters/operators/augmentedAssignmentViaSimpleBinary.java similarity index 100% rename from compiler/testData/codegen/boxWithJava/sam/adapters/operators/augmentedAssignmentViaSimpleBinary.java rename to compiler/testData/codegen/boxAgainstJava/sam/adapters/operators/augmentedAssignmentViaSimpleBinary.java diff --git a/compiler/testData/codegen/boxWithJava/sam/adapters/operators/augmentedAssignmentViaSimpleBinary.kt b/compiler/testData/codegen/boxAgainstJava/sam/adapters/operators/augmentedAssignmentViaSimpleBinary.kt similarity index 100% rename from compiler/testData/codegen/boxWithJava/sam/adapters/operators/augmentedAssignmentViaSimpleBinary.kt rename to compiler/testData/codegen/boxAgainstJava/sam/adapters/operators/augmentedAssignmentViaSimpleBinary.kt diff --git a/compiler/testData/codegen/boxWithJava/sam/adapters/operators/binary.java b/compiler/testData/codegen/boxAgainstJava/sam/adapters/operators/binary.java similarity index 100% rename from compiler/testData/codegen/boxWithJava/sam/adapters/operators/binary.java rename to compiler/testData/codegen/boxAgainstJava/sam/adapters/operators/binary.java diff --git a/compiler/testData/codegen/boxWithJava/sam/adapters/operators/binary.kt b/compiler/testData/codegen/boxAgainstJava/sam/adapters/operators/binary.kt similarity index 100% rename from compiler/testData/codegen/boxWithJava/sam/adapters/operators/binary.kt rename to compiler/testData/codegen/boxAgainstJava/sam/adapters/operators/binary.kt diff --git a/compiler/testData/codegen/boxWithJava/sam/adapters/operators/compareTo.java b/compiler/testData/codegen/boxAgainstJava/sam/adapters/operators/compareTo.java similarity index 100% rename from compiler/testData/codegen/boxWithJava/sam/adapters/operators/compareTo.java rename to compiler/testData/codegen/boxAgainstJava/sam/adapters/operators/compareTo.java diff --git a/compiler/testData/codegen/boxWithJava/sam/adapters/operators/compareTo.kt b/compiler/testData/codegen/boxAgainstJava/sam/adapters/operators/compareTo.kt similarity index 100% rename from compiler/testData/codegen/boxWithJava/sam/adapters/operators/compareTo.kt rename to compiler/testData/codegen/boxAgainstJava/sam/adapters/operators/compareTo.kt diff --git a/compiler/testData/codegen/boxWithJava/sam/adapters/operators/contains.java b/compiler/testData/codegen/boxAgainstJava/sam/adapters/operators/contains.java similarity index 100% rename from compiler/testData/codegen/boxWithJava/sam/adapters/operators/contains.java rename to compiler/testData/codegen/boxAgainstJava/sam/adapters/operators/contains.java diff --git a/compiler/testData/codegen/boxWithJava/sam/adapters/operators/contains.kt b/compiler/testData/codegen/boxAgainstJava/sam/adapters/operators/contains.kt similarity index 100% rename from compiler/testData/codegen/boxWithJava/sam/adapters/operators/contains.kt rename to compiler/testData/codegen/boxAgainstJava/sam/adapters/operators/contains.kt diff --git a/compiler/testData/codegen/boxWithJava/sam/adapters/operators/get.java b/compiler/testData/codegen/boxAgainstJava/sam/adapters/operators/get.java similarity index 100% rename from compiler/testData/codegen/boxWithJava/sam/adapters/operators/get.java rename to compiler/testData/codegen/boxAgainstJava/sam/adapters/operators/get.java diff --git a/compiler/testData/codegen/boxWithJava/sam/adapters/operators/get.kt b/compiler/testData/codegen/boxAgainstJava/sam/adapters/operators/get.kt similarity index 100% rename from compiler/testData/codegen/boxWithJava/sam/adapters/operators/get.kt rename to compiler/testData/codegen/boxAgainstJava/sam/adapters/operators/get.kt diff --git a/compiler/testData/codegen/boxWithJava/sam/adapters/operators/infixCall.java b/compiler/testData/codegen/boxAgainstJava/sam/adapters/operators/infixCall.java similarity index 100% rename from compiler/testData/codegen/boxWithJava/sam/adapters/operators/infixCall.java rename to compiler/testData/codegen/boxAgainstJava/sam/adapters/operators/infixCall.java diff --git a/compiler/testData/codegen/boxWithJava/sam/adapters/operators/infixCall.kt b/compiler/testData/codegen/boxAgainstJava/sam/adapters/operators/infixCall.kt similarity index 100% rename from compiler/testData/codegen/boxWithJava/sam/adapters/operators/infixCall.kt rename to compiler/testData/codegen/boxAgainstJava/sam/adapters/operators/infixCall.kt diff --git a/compiler/testData/codegen/boxWithJava/sam/adapters/operators/invoke.java b/compiler/testData/codegen/boxAgainstJava/sam/adapters/operators/invoke.java similarity index 100% rename from compiler/testData/codegen/boxWithJava/sam/adapters/operators/invoke.java rename to compiler/testData/codegen/boxAgainstJava/sam/adapters/operators/invoke.java diff --git a/compiler/testData/codegen/boxWithJava/sam/adapters/operators/invoke.kt b/compiler/testData/codegen/boxAgainstJava/sam/adapters/operators/invoke.kt similarity index 100% rename from compiler/testData/codegen/boxWithJava/sam/adapters/operators/invoke.kt rename to compiler/testData/codegen/boxAgainstJava/sam/adapters/operators/invoke.kt diff --git a/compiler/testData/codegen/boxWithJava/sam/adapters/operators/multiGetSet.java b/compiler/testData/codegen/boxAgainstJava/sam/adapters/operators/multiGetSet.java similarity index 100% rename from compiler/testData/codegen/boxWithJava/sam/adapters/operators/multiGetSet.java rename to compiler/testData/codegen/boxAgainstJava/sam/adapters/operators/multiGetSet.java diff --git a/compiler/testData/codegen/boxWithJava/sam/adapters/operators/multiGetSet.kt b/compiler/testData/codegen/boxAgainstJava/sam/adapters/operators/multiGetSet.kt similarity index 100% rename from compiler/testData/codegen/boxWithJava/sam/adapters/operators/multiGetSet.kt rename to compiler/testData/codegen/boxAgainstJava/sam/adapters/operators/multiGetSet.kt diff --git a/compiler/testData/codegen/boxWithJava/sam/adapters/operators/multiInvoke.java b/compiler/testData/codegen/boxAgainstJava/sam/adapters/operators/multiInvoke.java similarity index 100% rename from compiler/testData/codegen/boxWithJava/sam/adapters/operators/multiInvoke.java rename to compiler/testData/codegen/boxAgainstJava/sam/adapters/operators/multiInvoke.java diff --git a/compiler/testData/codegen/boxWithJava/sam/adapters/operators/multiInvoke.kt b/compiler/testData/codegen/boxAgainstJava/sam/adapters/operators/multiInvoke.kt similarity index 100% rename from compiler/testData/codegen/boxWithJava/sam/adapters/operators/multiInvoke.kt rename to compiler/testData/codegen/boxAgainstJava/sam/adapters/operators/multiInvoke.kt diff --git a/compiler/testData/codegen/boxWithJava/sam/adapters/operators/set.java b/compiler/testData/codegen/boxAgainstJava/sam/adapters/operators/set.java similarity index 100% rename from compiler/testData/codegen/boxWithJava/sam/adapters/operators/set.java rename to compiler/testData/codegen/boxAgainstJava/sam/adapters/operators/set.java diff --git a/compiler/testData/codegen/boxWithJava/sam/adapters/operators/set.kt b/compiler/testData/codegen/boxAgainstJava/sam/adapters/operators/set.kt similarity index 100% rename from compiler/testData/codegen/boxWithJava/sam/adapters/operators/set.kt rename to compiler/testData/codegen/boxAgainstJava/sam/adapters/operators/set.kt diff --git a/compiler/testData/codegen/boxWithJava/sam/adapters/severalSamParameters.java b/compiler/testData/codegen/boxAgainstJava/sam/adapters/severalSamParameters.java similarity index 100% rename from compiler/testData/codegen/boxWithJava/sam/adapters/severalSamParameters.java rename to compiler/testData/codegen/boxAgainstJava/sam/adapters/severalSamParameters.java diff --git a/compiler/testData/codegen/boxWithJava/sam/adapters/severalSamParameters.kt b/compiler/testData/codegen/boxAgainstJava/sam/adapters/severalSamParameters.kt similarity index 100% rename from compiler/testData/codegen/boxWithJava/sam/adapters/severalSamParameters.kt rename to compiler/testData/codegen/boxAgainstJava/sam/adapters/severalSamParameters.kt diff --git a/compiler/testData/codegen/boxWithJava/sam/adapters/simplest.java b/compiler/testData/codegen/boxAgainstJava/sam/adapters/simplest.java similarity index 100% rename from compiler/testData/codegen/boxWithJava/sam/adapters/simplest.java rename to compiler/testData/codegen/boxAgainstJava/sam/adapters/simplest.java diff --git a/compiler/testData/codegen/boxWithJava/sam/adapters/simplest.kt b/compiler/testData/codegen/boxAgainstJava/sam/adapters/simplest.kt similarity index 100% rename from compiler/testData/codegen/boxWithJava/sam/adapters/simplest.kt rename to compiler/testData/codegen/boxAgainstJava/sam/adapters/simplest.kt diff --git a/compiler/testData/codegen/boxWithJava/sam/adapters/superconstructor.java b/compiler/testData/codegen/boxAgainstJava/sam/adapters/superconstructor.java similarity index 100% rename from compiler/testData/codegen/boxWithJava/sam/adapters/superconstructor.java rename to compiler/testData/codegen/boxAgainstJava/sam/adapters/superconstructor.java diff --git a/compiler/testData/codegen/boxWithJava/sam/adapters/superconstructor.kt b/compiler/testData/codegen/boxAgainstJava/sam/adapters/superconstructor.kt similarity index 100% rename from compiler/testData/codegen/boxWithJava/sam/adapters/superconstructor.kt rename to compiler/testData/codegen/boxAgainstJava/sam/adapters/superconstructor.kt diff --git a/compiler/testData/codegen/boxWithJava/sam/adapters/typeParameterOfClass.java b/compiler/testData/codegen/boxAgainstJava/sam/adapters/typeParameterOfClass.java similarity index 100% rename from compiler/testData/codegen/boxWithJava/sam/adapters/typeParameterOfClass.java rename to compiler/testData/codegen/boxAgainstJava/sam/adapters/typeParameterOfClass.java diff --git a/compiler/testData/codegen/boxWithJava/sam/adapters/typeParameterOfClass.kt b/compiler/testData/codegen/boxAgainstJava/sam/adapters/typeParameterOfClass.kt similarity index 100% rename from compiler/testData/codegen/boxWithJava/sam/adapters/typeParameterOfClass.kt rename to compiler/testData/codegen/boxAgainstJava/sam/adapters/typeParameterOfClass.kt diff --git a/compiler/testData/codegen/boxWithJava/sam/adapters/typeParameterOfMethod.java b/compiler/testData/codegen/boxAgainstJava/sam/adapters/typeParameterOfMethod.java similarity index 100% rename from compiler/testData/codegen/boxWithJava/sam/adapters/typeParameterOfMethod.java rename to compiler/testData/codegen/boxAgainstJava/sam/adapters/typeParameterOfMethod.java diff --git a/compiler/testData/codegen/boxWithJava/sam/adapters/typeParameterOfMethod.kt b/compiler/testData/codegen/boxAgainstJava/sam/adapters/typeParameterOfMethod.kt similarity index 100% rename from compiler/testData/codegen/boxWithJava/sam/adapters/typeParameterOfMethod.kt rename to compiler/testData/codegen/boxAgainstJava/sam/adapters/typeParameterOfMethod.kt diff --git a/compiler/testData/codegen/boxWithJava/sam/adapters/typeParameterOfOuterClass.java b/compiler/testData/codegen/boxAgainstJava/sam/adapters/typeParameterOfOuterClass.java similarity index 100% rename from compiler/testData/codegen/boxWithJava/sam/adapters/typeParameterOfOuterClass.java rename to compiler/testData/codegen/boxAgainstJava/sam/adapters/typeParameterOfOuterClass.java diff --git a/compiler/testData/codegen/boxWithJava/sam/adapters/typeParameterOfOuterClass.kt b/compiler/testData/codegen/boxAgainstJava/sam/adapters/typeParameterOfOuterClass.kt similarity index 100% rename from compiler/testData/codegen/boxWithJava/sam/adapters/typeParameterOfOuterClass.kt rename to compiler/testData/codegen/boxAgainstJava/sam/adapters/typeParameterOfOuterClass.kt diff --git a/compiler/testData/codegen/boxWithJava/sam/differentFqNames.java b/compiler/testData/codegen/boxAgainstJava/sam/differentFqNames.java similarity index 100% rename from compiler/testData/codegen/boxWithJava/sam/differentFqNames.java rename to compiler/testData/codegen/boxAgainstJava/sam/differentFqNames.java diff --git a/compiler/testData/codegen/boxWithJava/sam/differentFqNames.kt b/compiler/testData/codegen/boxAgainstJava/sam/differentFqNames.kt similarity index 100% rename from compiler/testData/codegen/boxWithJava/sam/differentFqNames.kt rename to compiler/testData/codegen/boxAgainstJava/sam/differentFqNames.kt diff --git a/compiler/testData/codegen/boxWithJava/sam/samConstructorGenericSignature.java b/compiler/testData/codegen/boxAgainstJava/sam/samConstructorGenericSignature.java similarity index 100% rename from compiler/testData/codegen/boxWithJava/sam/samConstructorGenericSignature.java rename to compiler/testData/codegen/boxAgainstJava/sam/samConstructorGenericSignature.java diff --git a/compiler/testData/codegen/boxWithJava/sam/samConstructorGenericSignature.kt b/compiler/testData/codegen/boxAgainstJava/sam/samConstructorGenericSignature.kt similarity index 100% rename from compiler/testData/codegen/boxWithJava/sam/samConstructorGenericSignature.kt rename to compiler/testData/codegen/boxAgainstJava/sam/samConstructorGenericSignature.kt diff --git a/compiler/testData/codegen/boxWithJava/staticFun/classWithNestedEnum.java b/compiler/testData/codegen/boxAgainstJava/staticFun/classWithNestedEnum.java similarity index 100% rename from compiler/testData/codegen/boxWithJava/staticFun/classWithNestedEnum.java rename to compiler/testData/codegen/boxAgainstJava/staticFun/classWithNestedEnum.java diff --git a/compiler/testData/codegen/boxWithJava/staticFun/classWithNestedEnum.kt b/compiler/testData/codegen/boxAgainstJava/staticFun/classWithNestedEnum.kt similarity index 100% rename from compiler/testData/codegen/boxWithJava/staticFun/classWithNestedEnum.kt rename to compiler/testData/codegen/boxAgainstJava/staticFun/classWithNestedEnum.kt diff --git a/compiler/testData/codegen/boxWithJava/visibility/package/kt2781.java b/compiler/testData/codegen/boxAgainstJava/visibility/package/kt2781.java similarity index 100% rename from compiler/testData/codegen/boxWithJava/visibility/package/kt2781.java rename to compiler/testData/codegen/boxAgainstJava/visibility/package/kt2781.java diff --git a/compiler/testData/codegen/boxWithJava/visibility/package/kt2781.kt b/compiler/testData/codegen/boxAgainstJava/visibility/package/kt2781.kt similarity index 100% rename from compiler/testData/codegen/boxWithJava/visibility/package/kt2781.kt rename to compiler/testData/codegen/boxAgainstJava/visibility/package/kt2781.kt diff --git a/compiler/testData/codegen/boxWithJava/visibility/package/packageClass.java b/compiler/testData/codegen/boxAgainstJava/visibility/package/packageClass.java similarity index 100% rename from compiler/testData/codegen/boxWithJava/visibility/package/packageClass.java rename to compiler/testData/codegen/boxAgainstJava/visibility/package/packageClass.java diff --git a/compiler/testData/codegen/boxWithJava/visibility/package/packageClass.kt b/compiler/testData/codegen/boxAgainstJava/visibility/package/packageClass.kt similarity index 100% rename from compiler/testData/codegen/boxWithJava/visibility/package/packageClass.kt rename to compiler/testData/codegen/boxAgainstJava/visibility/package/packageClass.kt diff --git a/compiler/testData/codegen/boxWithJava/visibility/package/packageFun.java b/compiler/testData/codegen/boxAgainstJava/visibility/package/packageFun.java similarity index 100% rename from compiler/testData/codegen/boxWithJava/visibility/package/packageFun.java rename to compiler/testData/codegen/boxAgainstJava/visibility/package/packageFun.java diff --git a/compiler/testData/codegen/boxWithJava/visibility/package/packageFun.kt b/compiler/testData/codegen/boxAgainstJava/visibility/package/packageFun.kt similarity index 100% rename from compiler/testData/codegen/boxWithJava/visibility/package/packageFun.kt rename to compiler/testData/codegen/boxAgainstJava/visibility/package/packageFun.kt diff --git a/compiler/testData/codegen/boxWithJava/visibility/package/packageProperty.java b/compiler/testData/codegen/boxAgainstJava/visibility/package/packageProperty.java similarity index 100% rename from compiler/testData/codegen/boxWithJava/visibility/package/packageProperty.java rename to compiler/testData/codegen/boxAgainstJava/visibility/package/packageProperty.java diff --git a/compiler/testData/codegen/boxWithJava/visibility/package/packageProperty.kt b/compiler/testData/codegen/boxAgainstJava/visibility/package/packageProperty.kt similarity index 100% rename from compiler/testData/codegen/boxWithJava/visibility/package/packageProperty.kt rename to compiler/testData/codegen/boxAgainstJava/visibility/package/packageProperty.kt diff --git a/compiler/testData/codegen/boxWithJava/visibility/protectedAndPackage/overrideProtectedFunInPackage.java b/compiler/testData/codegen/boxAgainstJava/visibility/protectedAndPackage/overrideProtectedFunInPackage.java similarity index 100% rename from compiler/testData/codegen/boxWithJava/visibility/protectedAndPackage/overrideProtectedFunInPackage.java rename to compiler/testData/codegen/boxAgainstJava/visibility/protectedAndPackage/overrideProtectedFunInPackage.java diff --git a/compiler/testData/codegen/boxWithJava/visibility/protectedAndPackage/overrideProtectedFunInPackage.kt b/compiler/testData/codegen/boxAgainstJava/visibility/protectedAndPackage/overrideProtectedFunInPackage.kt similarity index 100% rename from compiler/testData/codegen/boxWithJava/visibility/protectedAndPackage/overrideProtectedFunInPackage.kt rename to compiler/testData/codegen/boxAgainstJava/visibility/protectedAndPackage/overrideProtectedFunInPackage.kt diff --git a/compiler/testData/codegen/boxWithJava/visibility/protectedAndPackage/protectedFunInPackage.java b/compiler/testData/codegen/boxAgainstJava/visibility/protectedAndPackage/protectedFunInPackage.java similarity index 100% rename from compiler/testData/codegen/boxWithJava/visibility/protectedAndPackage/protectedFunInPackage.java rename to compiler/testData/codegen/boxAgainstJava/visibility/protectedAndPackage/protectedFunInPackage.java diff --git a/compiler/testData/codegen/boxWithJava/visibility/protectedAndPackage/protectedFunInPackage.kt b/compiler/testData/codegen/boxAgainstJava/visibility/protectedAndPackage/protectedFunInPackage.kt similarity index 100% rename from compiler/testData/codegen/boxWithJava/visibility/protectedAndPackage/protectedFunInPackage.kt rename to compiler/testData/codegen/boxAgainstJava/visibility/protectedAndPackage/protectedFunInPackage.kt diff --git a/compiler/testData/codegen/boxWithJava/visibility/protectedAndPackage/protectedPropertyInPackage.java b/compiler/testData/codegen/boxAgainstJava/visibility/protectedAndPackage/protectedPropertyInPackage.java similarity index 100% rename from compiler/testData/codegen/boxWithJava/visibility/protectedAndPackage/protectedPropertyInPackage.java rename to compiler/testData/codegen/boxAgainstJava/visibility/protectedAndPackage/protectedPropertyInPackage.java diff --git a/compiler/testData/codegen/boxWithJava/visibility/protectedAndPackage/protectedPropertyInPackage.kt b/compiler/testData/codegen/boxAgainstJava/visibility/protectedAndPackage/protectedPropertyInPackage.kt similarity index 100% rename from compiler/testData/codegen/boxWithJava/visibility/protectedAndPackage/protectedPropertyInPackage.kt rename to compiler/testData/codegen/boxAgainstJava/visibility/protectedAndPackage/protectedPropertyInPackage.kt diff --git a/compiler/testData/codegen/boxWithJava/visibility/protectedAndPackage/protectedStaticClass.java b/compiler/testData/codegen/boxAgainstJava/visibility/protectedAndPackage/protectedStaticClass.java similarity index 100% rename from compiler/testData/codegen/boxWithJava/visibility/protectedAndPackage/protectedStaticClass.java rename to compiler/testData/codegen/boxAgainstJava/visibility/protectedAndPackage/protectedStaticClass.java diff --git a/compiler/testData/codegen/boxWithJava/visibility/protectedAndPackage/protectedStaticClass.kt b/compiler/testData/codegen/boxAgainstJava/visibility/protectedAndPackage/protectedStaticClass.kt similarity index 100% rename from compiler/testData/codegen/boxWithJava/visibility/protectedAndPackage/protectedStaticClass.kt rename to compiler/testData/codegen/boxAgainstJava/visibility/protectedAndPackage/protectedStaticClass.kt diff --git a/compiler/testData/codegen/boxWithJava/visibility/protectedStatic/funCallInConstructor.java b/compiler/testData/codegen/boxAgainstJava/visibility/protectedStatic/funCallInConstructor.java similarity index 100% rename from compiler/testData/codegen/boxWithJava/visibility/protectedStatic/funCallInConstructor.java rename to compiler/testData/codegen/boxAgainstJava/visibility/protectedStatic/funCallInConstructor.java diff --git a/compiler/testData/codegen/boxWithJava/visibility/protectedStatic/funCallInConstructor.kt b/compiler/testData/codegen/boxAgainstJava/visibility/protectedStatic/funCallInConstructor.kt similarity index 100% rename from compiler/testData/codegen/boxWithJava/visibility/protectedStatic/funCallInConstructor.kt rename to compiler/testData/codegen/boxAgainstJava/visibility/protectedStatic/funCallInConstructor.kt diff --git a/compiler/testData/codegen/boxWithJava/visibility/protectedStatic/funClassObject.java b/compiler/testData/codegen/boxAgainstJava/visibility/protectedStatic/funClassObject.java similarity index 100% rename from compiler/testData/codegen/boxWithJava/visibility/protectedStatic/funClassObject.java rename to compiler/testData/codegen/boxAgainstJava/visibility/protectedStatic/funClassObject.java diff --git a/compiler/testData/codegen/boxWithJava/visibility/protectedStatic/funClassObject.kt b/compiler/testData/codegen/boxAgainstJava/visibility/protectedStatic/funClassObject.kt similarity index 100% rename from compiler/testData/codegen/boxWithJava/visibility/protectedStatic/funClassObject.kt rename to compiler/testData/codegen/boxAgainstJava/visibility/protectedStatic/funClassObject.kt diff --git a/compiler/testData/codegen/boxWithJava/visibility/protectedStatic/funGenericClass.java b/compiler/testData/codegen/boxAgainstJava/visibility/protectedStatic/funGenericClass.java similarity index 100% rename from compiler/testData/codegen/boxWithJava/visibility/protectedStatic/funGenericClass.java rename to compiler/testData/codegen/boxAgainstJava/visibility/protectedStatic/funGenericClass.java diff --git a/compiler/testData/codegen/boxWithJava/visibility/protectedStatic/funGenericClass.kt b/compiler/testData/codegen/boxAgainstJava/visibility/protectedStatic/funGenericClass.kt similarity index 100% rename from compiler/testData/codegen/boxWithJava/visibility/protectedStatic/funGenericClass.kt rename to compiler/testData/codegen/boxAgainstJava/visibility/protectedStatic/funGenericClass.kt diff --git a/compiler/testData/codegen/boxWithJava/visibility/protectedStatic/funNestedStaticClass.java b/compiler/testData/codegen/boxAgainstJava/visibility/protectedStatic/funNestedStaticClass.java similarity index 100% rename from compiler/testData/codegen/boxWithJava/visibility/protectedStatic/funNestedStaticClass.java rename to compiler/testData/codegen/boxAgainstJava/visibility/protectedStatic/funNestedStaticClass.java diff --git a/compiler/testData/codegen/boxWithJava/visibility/protectedStatic/funNestedStaticClass.kt b/compiler/testData/codegen/boxAgainstJava/visibility/protectedStatic/funNestedStaticClass.kt similarity index 100% rename from compiler/testData/codegen/boxWithJava/visibility/protectedStatic/funNestedStaticClass.kt rename to compiler/testData/codegen/boxAgainstJava/visibility/protectedStatic/funNestedStaticClass.kt diff --git a/compiler/testData/codegen/boxWithJava/visibility/protectedStatic/funNestedStaticClass2.java b/compiler/testData/codegen/boxAgainstJava/visibility/protectedStatic/funNestedStaticClass2.java similarity index 100% rename from compiler/testData/codegen/boxWithJava/visibility/protectedStatic/funNestedStaticClass2.java rename to compiler/testData/codegen/boxAgainstJava/visibility/protectedStatic/funNestedStaticClass2.java diff --git a/compiler/testData/codegen/boxWithJava/visibility/protectedStatic/funNestedStaticClass2.kt b/compiler/testData/codegen/boxAgainstJava/visibility/protectedStatic/funNestedStaticClass2.kt similarity index 100% rename from compiler/testData/codegen/boxWithJava/visibility/protectedStatic/funNestedStaticClass2.kt rename to compiler/testData/codegen/boxAgainstJava/visibility/protectedStatic/funNestedStaticClass2.kt diff --git a/compiler/testData/codegen/boxWithJava/visibility/protectedStatic/funNestedStaticGenericClass.java b/compiler/testData/codegen/boxAgainstJava/visibility/protectedStatic/funNestedStaticGenericClass.java similarity index 100% rename from compiler/testData/codegen/boxWithJava/visibility/protectedStatic/funNestedStaticGenericClass.java rename to compiler/testData/codegen/boxAgainstJava/visibility/protectedStatic/funNestedStaticGenericClass.java diff --git a/compiler/testData/codegen/boxWithJava/visibility/protectedStatic/funNestedStaticGenericClass.kt b/compiler/testData/codegen/boxAgainstJava/visibility/protectedStatic/funNestedStaticGenericClass.kt similarity index 100% rename from compiler/testData/codegen/boxWithJava/visibility/protectedStatic/funNestedStaticGenericClass.kt rename to compiler/testData/codegen/boxAgainstJava/visibility/protectedStatic/funNestedStaticGenericClass.kt diff --git a/compiler/testData/codegen/boxWithJava/visibility/protectedStatic/funNotDirectSuperClass.java b/compiler/testData/codegen/boxAgainstJava/visibility/protectedStatic/funNotDirectSuperClass.java similarity index 100% rename from compiler/testData/codegen/boxWithJava/visibility/protectedStatic/funNotDirectSuperClass.java rename to compiler/testData/codegen/boxAgainstJava/visibility/protectedStatic/funNotDirectSuperClass.java diff --git a/compiler/testData/codegen/boxWithJava/visibility/protectedStatic/funNotDirectSuperClass.kt b/compiler/testData/codegen/boxAgainstJava/visibility/protectedStatic/funNotDirectSuperClass.kt similarity index 100% rename from compiler/testData/codegen/boxWithJava/visibility/protectedStatic/funNotDirectSuperClass.kt rename to compiler/testData/codegen/boxAgainstJava/visibility/protectedStatic/funNotDirectSuperClass.kt diff --git a/compiler/testData/codegen/boxWithJava/visibility/protectedStatic/funObject.java b/compiler/testData/codegen/boxAgainstJava/visibility/protectedStatic/funObject.java similarity index 100% rename from compiler/testData/codegen/boxWithJava/visibility/protectedStatic/funObject.java rename to compiler/testData/codegen/boxAgainstJava/visibility/protectedStatic/funObject.java diff --git a/compiler/testData/codegen/boxWithJava/visibility/protectedStatic/funObject.kt b/compiler/testData/codegen/boxAgainstJava/visibility/protectedStatic/funObject.kt similarity index 100% rename from compiler/testData/codegen/boxWithJava/visibility/protectedStatic/funObject.kt rename to compiler/testData/codegen/boxAgainstJava/visibility/protectedStatic/funObject.kt diff --git a/compiler/testData/codegen/boxWithJava/visibility/protectedStatic/simpleClass.java b/compiler/testData/codegen/boxAgainstJava/visibility/protectedStatic/simpleClass.java similarity index 100% rename from compiler/testData/codegen/boxWithJava/visibility/protectedStatic/simpleClass.java rename to compiler/testData/codegen/boxAgainstJava/visibility/protectedStatic/simpleClass.java diff --git a/compiler/testData/codegen/boxWithJava/visibility/protectedStatic/simpleClass.kt b/compiler/testData/codegen/boxAgainstJava/visibility/protectedStatic/simpleClass.kt similarity index 100% rename from compiler/testData/codegen/boxWithJava/visibility/protectedStatic/simpleClass.kt rename to compiler/testData/codegen/boxAgainstJava/visibility/protectedStatic/simpleClass.kt diff --git a/compiler/testData/codegen/boxWithJava/visibility/protectedStatic/simpleClass2.java b/compiler/testData/codegen/boxAgainstJava/visibility/protectedStatic/simpleClass2.java similarity index 100% rename from compiler/testData/codegen/boxWithJava/visibility/protectedStatic/simpleClass2.java rename to compiler/testData/codegen/boxAgainstJava/visibility/protectedStatic/simpleClass2.java diff --git a/compiler/testData/codegen/boxWithJava/visibility/protectedStatic/simpleClass2.kt b/compiler/testData/codegen/boxAgainstJava/visibility/protectedStatic/simpleClass2.kt similarity index 100% rename from compiler/testData/codegen/boxWithJava/visibility/protectedStatic/simpleClass2.kt rename to compiler/testData/codegen/boxAgainstJava/visibility/protectedStatic/simpleClass2.kt diff --git a/compiler/testData/codegen/boxWithJava/visibility/protectedStatic/simpleFun.java b/compiler/testData/codegen/boxAgainstJava/visibility/protectedStatic/simpleFun.java similarity index 100% rename from compiler/testData/codegen/boxWithJava/visibility/protectedStatic/simpleFun.java rename to compiler/testData/codegen/boxAgainstJava/visibility/protectedStatic/simpleFun.java diff --git a/compiler/testData/codegen/boxWithJava/visibility/protectedStatic/simpleFun.kt b/compiler/testData/codegen/boxAgainstJava/visibility/protectedStatic/simpleFun.kt similarity index 100% rename from compiler/testData/codegen/boxWithJava/visibility/protectedStatic/simpleFun.kt rename to compiler/testData/codegen/boxAgainstJava/visibility/protectedStatic/simpleFun.kt diff --git a/compiler/testData/codegen/boxWithJava/visibility/protectedStatic/simpleProperty.java b/compiler/testData/codegen/boxAgainstJava/visibility/protectedStatic/simpleProperty.java similarity index 100% rename from compiler/testData/codegen/boxWithJava/visibility/protectedStatic/simpleProperty.java rename to compiler/testData/codegen/boxAgainstJava/visibility/protectedStatic/simpleProperty.java diff --git a/compiler/testData/codegen/boxWithJava/visibility/protectedStatic/simpleProperty.kt b/compiler/testData/codegen/boxAgainstJava/visibility/protectedStatic/simpleProperty.kt similarity index 100% rename from compiler/testData/codegen/boxWithJava/visibility/protectedStatic/simpleProperty.kt rename to compiler/testData/codegen/boxAgainstJava/visibility/protectedStatic/simpleProperty.kt diff --git a/compiler/testData/codegen/boxWithJava/.empty b/compiler/testData/codegen/boxWithJava/.empty new file mode 100644 index 00000000000..e69de29bb2d diff --git a/compiler/testData/diagnostics/tests/j+k/protectedStaticSamePackage.kt b/compiler/testData/diagnostics/tests/j+k/protectedStaticSamePackage.kt new file mode 100644 index 00000000000..e51d7bc5689 --- /dev/null +++ b/compiler/testData/diagnostics/tests/j+k/protectedStaticSamePackage.kt @@ -0,0 +1,20 @@ +// FILE: test/JavaClass.java + +package test; + +public class JavaClass { + protected static int field; + + protected static String method() { + return ""; + } +} + +// FILE: test.kt + +package test + +fun test() { + JavaClass.field + JavaClass.method() +} diff --git a/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/extensionOnNullable.kt b/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/extensionOnNullable.kt new file mode 100644 index 00000000000..f6fb90d4f42 --- /dev/null +++ b/compiler/testData/diagnostics/testsWithStdLib/callableReference/function/extensionOnNullable.kt @@ -0,0 +1,8 @@ +class A { + fun foo() {} +} + +fun A?.foo() {} + +val f = A::foo : KMemberFunction0 +val g = A?::foo : KExtensionFunction0 diff --git a/compiler/testData/psi/DoubleColon.kt b/compiler/testData/psi/DoubleColon.kt index bf44a1c132d..acb42293fbe 100644 --- a/compiler/testData/psi/DoubleColon.kt +++ b/compiler/testData/psi/DoubleColon.kt @@ -23,6 +23,11 @@ fun ok() { (a::b)() a.(b::c)() a.b::c() + + a?::b + a??::b + a?::c + a?::d } fun err0() { diff --git a/compiler/testData/psi/DoubleColon.txt b/compiler/testData/psi/DoubleColon.txt index a1e37dc967d..278f3d7554f 100644 --- a/compiler/testData/psi/DoubleColon.txt +++ b/compiler/testData/psi/DoubleColon.txt @@ -392,6 +392,78 @@ JetFile: DoubleColon.kt PsiErrorElement:Unexpected tokens (use ';' to separate expressions on the same line) PsiElement(LPAR)('(') PsiElement(RPAR)(')') + PsiWhiteSpace('\n\n ') + CALLABLE_REFERENCE_EXPRESSION + TYPE_REFERENCE + NULLABLE_TYPE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('a') + PsiElement(QUEST)('?') + PsiElement(COLONCOLON)('::') + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('b') + PsiWhiteSpace('\n ') + CALLABLE_REFERENCE_EXPRESSION + TYPE_REFERENCE + NULLABLE_TYPE + NULLABLE_TYPE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('a') + PsiElement(QUEST)('?') + PsiElement(QUEST)('?') + PsiElement(COLONCOLON)('::') + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('b') + PsiWhiteSpace('\n ') + CALLABLE_REFERENCE_EXPRESSION + TYPE_REFERENCE + NULLABLE_TYPE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('a') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_PROJECTION + TYPE_REFERENCE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('b') + PsiElement(GT)('>') + PsiElement(QUEST)('?') + PsiElement(COLONCOLON)('::') + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('c') + PsiWhiteSpace('\n ') + CALLABLE_REFERENCE_EXPRESSION + TYPE_REFERENCE + NULLABLE_TYPE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('a') + TYPE_ARGUMENT_LIST + PsiElement(LT)('<') + TYPE_PROJECTION + TYPE_REFERENCE + NULLABLE_TYPE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('b') + PsiElement(QUEST)('?') + PsiElement(COMMA)(',') + TYPE_PROJECTION + TYPE_REFERENCE + NULLABLE_TYPE + USER_TYPE + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('c') + PsiElement(QUEST)('?') + PsiElement(GT)('>') + PsiElement(QUEST)('?') + PsiElement(COLONCOLON)('::') + REFERENCE_EXPRESSION + PsiElement(IDENTIFIER)('d') PsiWhiteSpace('\n') PsiElement(RBRACE)('}') PsiWhiteSpace('\n\n') diff --git a/compiler/tests/org/jetbrains/jet/checkers/JetDiagnosticsTestGenerated.java b/compiler/tests/org/jetbrains/jet/checkers/JetDiagnosticsTestGenerated.java index c5b4ea4326f..6495690ade4 100644 --- a/compiler/tests/org/jetbrains/jet/checkers/JetDiagnosticsTestGenerated.java +++ b/compiler/tests/org/jetbrains/jet/checkers/JetDiagnosticsTestGenerated.java @@ -5032,6 +5032,11 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest { doTest("compiler/testData/diagnostics/tests/j+k/packageVisibility.kt"); } + @TestMetadata("protectedStaticSamePackage.kt") + public void testProtectedStaticSamePackage() throws Exception { + doTest("compiler/testData/diagnostics/tests/j+k/protectedStaticSamePackage.kt"); + } + @TestMetadata("recursiveRawUpperBound.kt") public void testRecursiveRawUpperBound() throws Exception { doTest("compiler/testData/diagnostics/tests/j+k/recursiveRawUpperBound.kt"); diff --git a/compiler/tests/org/jetbrains/jet/checkers/JetDiagnosticsTestWithStdLibGenerated.java b/compiler/tests/org/jetbrains/jet/checkers/JetDiagnosticsTestWithStdLibGenerated.java index 186d535e122..ed8963048ac 100644 --- a/compiler/tests/org/jetbrains/jet/checkers/JetDiagnosticsTestWithStdLibGenerated.java +++ b/compiler/tests/org/jetbrains/jet/checkers/JetDiagnosticsTestWithStdLibGenerated.java @@ -192,6 +192,11 @@ public class JetDiagnosticsTestWithStdLibGenerated extends AbstractJetDiagnostic doTest("compiler/testData/diagnostics/testsWithStdLib/callableReference/function/extensionInClassDisallowed.kt"); } + @TestMetadata("extensionOnNullable.kt") + public void testExtensionOnNullable() throws Exception { + doTest("compiler/testData/diagnostics/testsWithStdLib/callableReference/function/extensionOnNullable.kt"); + } + @TestMetadata("genericClassFromTopLevel.kt") public void testGenericClassFromTopLevel() throws Exception { doTest("compiler/testData/diagnostics/testsWithStdLib/callableReference/function/genericClassFromTopLevel.kt"); diff --git a/compiler/tests/org/jetbrains/jet/codegen/AbstractTopLevelMembersInvocationTest.java b/compiler/tests/org/jetbrains/jet/codegen/AbstractTopLevelMembersInvocationTest.java index b0b05c8892b..4765d3f5c63 100644 --- a/compiler/tests/org/jetbrains/jet/codegen/AbstractTopLevelMembersInvocationTest.java +++ b/compiler/tests/org/jetbrains/jet/codegen/AbstractTopLevelMembersInvocationTest.java @@ -20,10 +20,7 @@ import com.intellij.openapi.util.io.FileUtil; import com.intellij.util.ArrayUtil; import com.intellij.util.Processor; import org.jetbrains.annotations.NotNull; -import org.jetbrains.jet.ConfigurationKind; -import org.jetbrains.jet.JetTestUtils; -import org.jetbrains.jet.MockLibraryUtil; -import org.jetbrains.jet.TestJdkKind; +import org.jetbrains.jet.*; import org.jetbrains.jet.cli.jvm.compiler.JetCoreEnvironment; import java.io.File; @@ -45,7 +42,7 @@ public abstract class AbstractTopLevelMembersInvocationTest extends AbstractByte @Override public boolean process(File file) { if (file.getName().endsWith(".kt")) { - sourceFiles.add(file.getPath().substring("compiler/testData/codegen/".length())); + sourceFiles.add(relativePath(file)); return true; } return true; @@ -70,7 +67,8 @@ public abstract class AbstractTopLevelMembersInvocationTest extends AbstractByte loadFiles(ArrayUtil.toStringArray(sourceFiles)); - List expected = readExpectedOccurrences("compiler/testData/codegen/" + sourceFiles.get(0)); + List expected = + readExpectedOccurrences(JetTestCaseBuilder.getTestDataPathBase() + "/codegen/" + sourceFiles.get(0)); countAndCompareActualOccurrences(expected); } } diff --git a/compiler/tests/org/jetbrains/jet/codegen/CodegenTestCase.java b/compiler/tests/org/jetbrains/jet/codegen/CodegenTestCase.java index 09e99df26d8..6114fd05da0 100644 --- a/compiler/tests/org/jetbrains/jet/codegen/CodegenTestCase.java +++ b/compiler/tests/org/jetbrains/jet/codegen/CodegenTestCase.java @@ -53,12 +53,9 @@ import static org.jetbrains.jet.codegen.CodegenTestUtil.*; import static org.jetbrains.jet.lang.resolve.java.PackageClassUtils.getPackageClassFqName; public abstract class CodegenTestCase extends UsefulTestCase { - - // for environment and classloader protected JetCoreEnvironment myEnvironment; protected CodegenTestFiles myFiles; - - private ClassFileFactory classFileFactory; + protected ClassFileFactory classFileFactory; protected GeneratedClassLoader initializedClassLoader; protected void createEnvironmentWithMockJdkAndIdeaAnnotations(@NotNull ConfigurationKind configurationKind) { @@ -111,6 +108,13 @@ public abstract class CodegenTestCase extends UsefulTestCase { loadFile(getPrefix() + "/" + getTestName(true) + ".kt"); } + @NotNull + protected String relativePath(@NotNull File file) { + String stringToCut = "compiler/testData/codegen/"; + assert file.getPath().startsWith(stringToCut) : "File path is not absolute: " + file; + return file.getPath().substring(stringToCut.length()); + } + @NotNull protected String getPrefix() { throw new UnsupportedOperationException(); diff --git a/compiler/tests/org/jetbrains/jet/codegen/CodegenTestUtil.java b/compiler/tests/org/jetbrains/jet/codegen/CodegenTestUtil.java index 368261974d4..490f37be3b6 100644 --- a/compiler/tests/org/jetbrains/jet/codegen/CodegenTestUtil.java +++ b/compiler/tests/org/jetbrains/jet/codegen/CodegenTestUtil.java @@ -19,8 +19,10 @@ package org.jetbrains.jet.codegen; import com.google.common.base.Predicates; import com.intellij.openapi.util.SystemInfo; import com.intellij.psi.PsiFile; +import kotlin.KotlinPackage; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; +import org.jetbrains.jet.JetTestCaseBuilder; import org.jetbrains.jet.JetTestUtils; import org.jetbrains.jet.analyzer.AnalyzeExhaust; import org.jetbrains.jet.cli.jvm.JVMConfigurationKeys; @@ -39,6 +41,7 @@ import java.io.File; import java.io.IOException; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; +import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.List; @@ -108,17 +111,19 @@ public class CodegenTestUtil { } @NotNull - public static File compileJava(@NotNull String filename) { + public static File compileJava(@NotNull String filename, @NotNull String... additionalClasspath) { try { File javaClassesTempDirectory = JetTestUtils.tmpDir("java-classes"); - String classPath = ForTestCompileRuntime.runtimeJarForTests() + File.pathSeparator + - JetTestUtils.getAnnotationsJar().getPath(); + List classpath = new ArrayList(); + classpath.add(ForTestCompileRuntime.runtimeJarForTests().getPath()); + classpath.add(JetTestUtils.getAnnotationsJar().getPath()); + classpath.addAll(Arrays.asList(additionalClasspath)); List options = Arrays.asList( - "-classpath", classPath, + "-classpath", KotlinPackage.join(classpath, File.pathSeparator, "", "", -1, ""), "-d", javaClassesTempDirectory.getPath() ); - File javaFile = new File("compiler/testData/codegen/" + filename); + File javaFile = new File(JetTestCaseBuilder.getTestDataPathBase() + "/codegen/" + filename); JetTestUtils.compileJavaFiles(Collections.singleton(javaFile), options); return javaClassesTempDirectory; diff --git a/compiler/tests/org/jetbrains/jet/codegen/TestlibTest.java b/compiler/tests/org/jetbrains/jet/codegen/TestlibTest.java index bbbbde9c4da..43d7f71df2b 100644 --- a/compiler/tests/org/jetbrains/jet/codegen/TestlibTest.java +++ b/compiler/tests/org/jetbrains/jet/codegen/TestlibTest.java @@ -41,13 +41,15 @@ import org.jetbrains.jet.lang.psi.JetDeclaration; import org.jetbrains.jet.lang.psi.JetFile; import org.jetbrains.jet.lang.resolve.BindingContext; import org.jetbrains.jet.lang.resolve.BindingContextUtils; -import org.jetbrains.jet.lang.resolve.DescriptorUtils; +import org.jetbrains.jet.lang.types.JetType; import java.io.File; import java.lang.reflect.Modifier; import java.net.URL; import java.net.URLClassLoader; +import static org.jetbrains.jet.lang.types.TypeUtils.getAllSupertypes; + @SuppressWarnings("JUnitTestCaseWithNoTests") public class TestlibTest extends UsefulTestCase { public static Test suite() { @@ -123,8 +125,8 @@ public class TestlibTest extends UsefulTestCase { BindingContext.DECLARATION_TO_DESCRIPTOR, declaration); - for (ClassDescriptor superClass : DescriptorUtils.getAllSuperClasses(descriptor)) { - if (!"junit/framework/Test".equals(typeMapper.mapClass(superClass).getInternalName())) continue; + for (JetType superType : getAllSupertypes(descriptor.getDefaultType())) { + if (!"junit/framework/Test".equals(typeMapper.mapType(superType).getInternalName())) continue; String name = typeMapper.mapClass(descriptor).getInternalName(); diff --git a/compiler/tests/org/jetbrains/jet/codegen/generated/AbstractBlackBoxCodegenTest.java b/compiler/tests/org/jetbrains/jet/codegen/generated/AbstractBlackBoxCodegenTest.java index 16f021d68a9..637e5a27c34 100644 --- a/compiler/tests/org/jetbrains/jet/codegen/generated/AbstractBlackBoxCodegenTest.java +++ b/compiler/tests/org/jetbrains/jet/codegen/generated/AbstractBlackBoxCodegenTest.java @@ -17,12 +17,20 @@ package org.jetbrains.jet.codegen.generated; import com.intellij.openapi.util.io.FileUtil; +import com.intellij.util.ArrayUtil; import com.intellij.util.Processor; +import kotlin.KotlinPackage; import org.jetbrains.annotations.NotNull; -import org.jetbrains.jet.*; +import org.jetbrains.jet.ConfigurationKind; +import org.jetbrains.jet.JetTestUtils; +import org.jetbrains.jet.TestJdkKind; +import org.jetbrains.jet.cli.common.output.outputUtils.OutputUtilsPackage; +import org.jetbrains.jet.cli.jvm.JVMConfigurationKeys; import org.jetbrains.jet.cli.jvm.compiler.JetCoreEnvironment; import org.jetbrains.jet.codegen.CodegenTestCase; +import org.jetbrains.jet.codegen.GenerationUtils; import org.jetbrains.jet.codegen.InlineTestUtil; +import org.jetbrains.jet.config.CompilerConfiguration; import org.jetbrains.jet.lang.psi.JetFile; import org.jetbrains.jet.utils.UtilsPackage; @@ -41,8 +49,17 @@ public abstract class AbstractBlackBoxCodegenTest extends CodegenTestCase { blackBoxFileByFullPath(filename); } + public void doTestAgainstJava(@NotNull String filename) { + blackBoxFileAgainstJavaByFullPath(filename); + } + public void doTestWithJava(@NotNull String filename) { - blackBoxFileWithJavaByFullPath(filename); + try { + blackBoxFileWithJavaByFullPath(filename); + } + catch (Exception e) { + throw UtilsPackage.rethrow(e); + } } public void doTestWithStdlib(@NotNull String filename) { @@ -58,7 +75,7 @@ public abstract class AbstractBlackBoxCodegenTest extends CodegenTestCase { @Override public boolean process(File file) { if (file.getName().endsWith(".kt")) { - files.add(file.getPath().substring("compiler/testData/codegen/".length())); + files.add(relativePath(file)); } return true; } @@ -66,7 +83,7 @@ public abstract class AbstractBlackBoxCodegenTest extends CodegenTestCase { Collections.sort(files); - loadFiles(files.toArray(new String[files.size()])); + loadFiles(ArrayUtil.toStringArray(files)); blackBox(); } @@ -75,8 +92,8 @@ public abstract class AbstractBlackBoxCodegenTest extends CodegenTestCase { InlineTestUtil.checkNoCallsToInline(initializedClassLoader.getAllGeneratedFiles()); } - private void blackBoxFileWithJavaByFullPath(@NotNull String ktFileFullPath) { - String ktFile = ktFileFullPath.substring("compiler/testData/codegen/".length()); + private void blackBoxFileAgainstJavaByFullPath(@NotNull String ktFileFullPath) { + String ktFile = relativePath(new File(ktFileFullPath)); File javaClassesTempDirectory = compileJava(ktFile.replaceFirst("\\.kt$", ".java")); myEnvironment = JetCoreEnvironment.createForTests(getTestRootDisposable(), JetTestUtils.compilerConfigurationForTests( @@ -86,6 +103,44 @@ public abstract class AbstractBlackBoxCodegenTest extends CodegenTestCase { blackBox(); } + private void blackBoxFileWithJavaByFullPath(@NotNull String directory) throws Exception { + File dirFile = new File(directory); + + final List javaFilePaths = new ArrayList(); + final List ktFilePaths = new ArrayList(); + FileUtil.processFilesRecursively(dirFile, new Processor() { + @Override + public boolean process(File file) { + String path = relativePath(file); + if (path.endsWith(".kt")) { + ktFilePaths.add(path); + } + else if (path.endsWith(".java")) { + javaFilePaths.add(path); + } + return true; + } + }); + + CompilerConfiguration configuration = JetTestUtils.compilerConfigurationForTests( + ConfigurationKind.ALL, TestJdkKind.FULL_JDK, JetTestUtils.getAnnotationsJar() + ); + configuration.add(JVMConfigurationKeys.CLASSPATH_KEY, dirFile); + myEnvironment = JetCoreEnvironment.createForTests(getTestRootDisposable(), configuration); + loadFiles(ArrayUtil.toStringArray(ktFilePaths)); + classFileFactory = + GenerationUtils.compileManyFilesGetGenerationStateForTest(myEnvironment.getProject(), myFiles.getPsiFiles()).getFactory(); + File kotlinOut = JetTestUtils.tmpDir(toString()); + OutputUtilsPackage.writeAllTo(classFileFactory, kotlinOut); + + // TODO: support several Java sources + File javaOut = compileJava(KotlinPackage.single(javaFilePaths), kotlinOut.getPath()); + // Add javac output to classpath so that the created class loader can find generated Java classes + configuration.add(JVMConfigurationKeys.CLASSPATH_KEY, javaOut); + + blackBox(); + } + private void blackBoxFileByFullPath(@NotNull String filename) { loadFileByFullPath(filename); blackBox(); diff --git a/compiler/tests/org/jetbrains/jet/codegen/generated/BlackBoxAgainstJavaCodegenTestGenerated.java b/compiler/tests/org/jetbrains/jet/codegen/generated/BlackBoxAgainstJavaCodegenTestGenerated.java new file mode 100644 index 00000000000..ba89e324887 --- /dev/null +++ b/compiler/tests/org/jetbrains/jet/codegen/generated/BlackBoxAgainstJavaCodegenTestGenerated.java @@ -0,0 +1,607 @@ +/* + * Copyright 2010-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package org.jetbrains.jet.codegen.generated; + +import junit.framework.Assert; +import junit.framework.Test; +import junit.framework.TestSuite; + +import java.io.File; +import java.util.regex.Pattern; +import org.jetbrains.jet.JetTestUtils; +import org.jetbrains.jet.test.InnerTestClasses; +import org.jetbrains.jet.test.TestMetadata; + +import org.jetbrains.jet.codegen.generated.AbstractBlackBoxCodegenTest; + +/** This class is generated by {@link org.jetbrains.jet.generators.tests.TestsPackage}. DO NOT MODIFY MANUALLY */ +@SuppressWarnings("all") +@TestMetadata("compiler/testData/codegen/boxAgainstJava") +@InnerTestClasses({BlackBoxAgainstJavaCodegenTestGenerated.Annotations.class, BlackBoxAgainstJavaCodegenTestGenerated.CallableReference.class, BlackBoxAgainstJavaCodegenTestGenerated.Constructor.class, BlackBoxAgainstJavaCodegenTestGenerated.Delegation.class, BlackBoxAgainstJavaCodegenTestGenerated.Enum.class, BlackBoxAgainstJavaCodegenTestGenerated.Functions.class, BlackBoxAgainstJavaCodegenTestGenerated.InnerClass.class, BlackBoxAgainstJavaCodegenTestGenerated.Property.class, BlackBoxAgainstJavaCodegenTestGenerated.Sam.class, BlackBoxAgainstJavaCodegenTestGenerated.StaticFun.class, BlackBoxAgainstJavaCodegenTestGenerated.Visibility.class}) +public class BlackBoxAgainstJavaCodegenTestGenerated extends AbstractBlackBoxCodegenTest { + public void testAllFilesPresentInBoxAgainstJava() throws Exception { + JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage", new File("compiler/testData/codegen/boxAgainstJava"), Pattern.compile("^(.+)\\.kt$"), true); + } + + @TestMetadata("compiler/testData/codegen/boxAgainstJava/annotations") + public static class Annotations extends AbstractBlackBoxCodegenTest { + public void testAllFilesPresentInAnnotations() throws Exception { + JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage", new File("compiler/testData/codegen/boxAgainstJava/annotations"), Pattern.compile("^(.+)\\.kt$"), true); + } + + @TestMetadata("javaAnnotationCall.kt") + public void testJavaAnnotationCall() throws Exception { + doTestAgainstJava("compiler/testData/codegen/boxAgainstJava/annotations/javaAnnotationCall.kt"); + } + + @TestMetadata("javaAnnotationDefault.kt") + public void testJavaAnnotationDefault() throws Exception { + doTestAgainstJava("compiler/testData/codegen/boxAgainstJava/annotations/javaAnnotationDefault.kt"); + } + + @TestMetadata("javaNegativePropertyAsAnnotationParameter.kt") + public void testJavaNegativePropertyAsAnnotationParameter() throws Exception { + doTestAgainstJava("compiler/testData/codegen/boxAgainstJava/annotations/javaNegativePropertyAsAnnotationParameter.kt"); + } + + @TestMetadata("javaPropertyAsAnnotationParameter.kt") + public void testJavaPropertyAsAnnotationParameter() throws Exception { + doTestAgainstJava("compiler/testData/codegen/boxAgainstJava/annotations/javaPropertyAsAnnotationParameter.kt"); + } + + @TestMetadata("javaPropertyWithIntInitializer.kt") + public void testJavaPropertyWithIntInitializer() throws Exception { + doTestAgainstJava("compiler/testData/codegen/boxAgainstJava/annotations/javaPropertyWithIntInitializer.kt"); + } + + @TestMetadata("retentionInJava.kt") + public void testRetentionInJava() throws Exception { + doTestAgainstJava("compiler/testData/codegen/boxAgainstJava/annotations/retentionInJava.kt"); + } + + } + + @TestMetadata("compiler/testData/codegen/boxAgainstJava/callableReference") + public static class CallableReference extends AbstractBlackBoxCodegenTest { + public void testAllFilesPresentInCallableReference() throws Exception { + JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage", new File("compiler/testData/codegen/boxAgainstJava/callableReference"), Pattern.compile("^(.+)\\.kt$"), true); + } + + @TestMetadata("constructor.kt") + public void testConstructor() throws Exception { + doTestAgainstJava("compiler/testData/codegen/boxAgainstJava/callableReference/constructor.kt"); + } + + } + + @TestMetadata("compiler/testData/codegen/boxAgainstJava/constructor") + public static class Constructor extends AbstractBlackBoxCodegenTest { + public void testAllFilesPresentInConstructor() throws Exception { + JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage", new File("compiler/testData/codegen/boxAgainstJava/constructor"), Pattern.compile("^(.+)\\.kt$"), true); + } + + @TestMetadata("genericConstructor.kt") + public void testGenericConstructor() throws Exception { + doTestAgainstJava("compiler/testData/codegen/boxAgainstJava/constructor/genericConstructor.kt"); + } + + } + + @TestMetadata("compiler/testData/codegen/boxAgainstJava/delegation") + public static class Delegation extends AbstractBlackBoxCodegenTest { + public void testAllFilesPresentInDelegation() throws Exception { + JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage", new File("compiler/testData/codegen/boxAgainstJava/delegation"), Pattern.compile("^(.+)\\.kt$"), true); + } + + @TestMetadata("delegationAndInheritanceFromJava.kt") + public void testDelegationAndInheritanceFromJava() throws Exception { + doTestAgainstJava("compiler/testData/codegen/boxAgainstJava/delegation/delegationAndInheritanceFromJava.kt"); + } + + } + + @TestMetadata("compiler/testData/codegen/boxAgainstJava/enum") + public static class Enum extends AbstractBlackBoxCodegenTest { + public void testAllFilesPresentInEnum() throws Exception { + JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage", new File("compiler/testData/codegen/boxAgainstJava/enum"), Pattern.compile("^(.+)\\.kt$"), true); + } + + @TestMetadata("simpleJavaEnum.kt") + public void testSimpleJavaEnum() throws Exception { + doTestAgainstJava("compiler/testData/codegen/boxAgainstJava/enum/simpleJavaEnum.kt"); + } + + @TestMetadata("simpleJavaEnumWithFunction.kt") + public void testSimpleJavaEnumWithFunction() throws Exception { + doTestAgainstJava("compiler/testData/codegen/boxAgainstJava/enum/simpleJavaEnumWithFunction.kt"); + } + + @TestMetadata("simpleJavaEnumWithStaticImport.kt") + public void testSimpleJavaEnumWithStaticImport() throws Exception { + doTestAgainstJava("compiler/testData/codegen/boxAgainstJava/enum/simpleJavaEnumWithStaticImport.kt"); + } + + @TestMetadata("simpleJavaInnerEnum.kt") + public void testSimpleJavaInnerEnum() throws Exception { + doTestAgainstJava("compiler/testData/codegen/boxAgainstJava/enum/simpleJavaInnerEnum.kt"); + } + + @TestMetadata("staticField.kt") + public void testStaticField() throws Exception { + doTestAgainstJava("compiler/testData/codegen/boxAgainstJava/enum/staticField.kt"); + } + + @TestMetadata("staticMethod.kt") + public void testStaticMethod() throws Exception { + doTestAgainstJava("compiler/testData/codegen/boxAgainstJava/enum/staticMethod.kt"); + } + + } + + @TestMetadata("compiler/testData/codegen/boxAgainstJava/functions") + public static class Functions extends AbstractBlackBoxCodegenTest { + public void testAllFilesPresentInFunctions() throws Exception { + JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage", new File("compiler/testData/codegen/boxAgainstJava/functions"), Pattern.compile("^(.+)\\.kt$"), true); + } + + @TestMetadata("constructor.kt") + public void testConstructor() throws Exception { + doTestAgainstJava("compiler/testData/codegen/boxAgainstJava/functions/constructor.kt"); + } + + @TestMetadata("max.kt") + public void testMax() throws Exception { + doTestAgainstJava("compiler/testData/codegen/boxAgainstJava/functions/max.kt"); + } + + @TestMetadata("referencesStaticInnerClassMethod.kt") + public void testReferencesStaticInnerClassMethod() throws Exception { + doTestAgainstJava("compiler/testData/codegen/boxAgainstJava/functions/referencesStaticInnerClassMethod.kt"); + } + + @TestMetadata("referencesStaticInnerClassMethodL2.kt") + public void testReferencesStaticInnerClassMethodL2() throws Exception { + doTestAgainstJava("compiler/testData/codegen/boxAgainstJava/functions/referencesStaticInnerClassMethodL2.kt"); + } + + @TestMetadata("unrelatedUpperBounds.kt") + public void testUnrelatedUpperBounds() throws Exception { + doTestAgainstJava("compiler/testData/codegen/boxAgainstJava/functions/unrelatedUpperBounds.kt"); + } + + } + + @TestMetadata("compiler/testData/codegen/boxAgainstJava/innerClass") + public static class InnerClass extends AbstractBlackBoxCodegenTest { + public void testAllFilesPresentInInnerClass() throws Exception { + JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage", new File("compiler/testData/codegen/boxAgainstJava/innerClass"), Pattern.compile("^(.+)\\.kt$"), true); + } + + @TestMetadata("kt3532.kt") + public void testKt3532() throws Exception { + doTestAgainstJava("compiler/testData/codegen/boxAgainstJava/innerClass/kt3532.kt"); + } + + @TestMetadata("kt3812.kt") + public void testKt3812() throws Exception { + doTestAgainstJava("compiler/testData/codegen/boxAgainstJava/innerClass/kt3812.kt"); + } + + @TestMetadata("kt4036.kt") + public void testKt4036() throws Exception { + doTestAgainstJava("compiler/testData/codegen/boxAgainstJava/innerClass/kt4036.kt"); + } + + } + + @TestMetadata("compiler/testData/codegen/boxAgainstJava/property") + public static class Property extends AbstractBlackBoxCodegenTest { + public void testAllFilesPresentInProperty() throws Exception { + JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage", new File("compiler/testData/codegen/boxAgainstJava/property"), Pattern.compile("^(.+)\\.kt$"), true); + } + + @TestMetadata("fieldAccessFromExtensionInTraitImpl.kt") + public void testFieldAccessFromExtensionInTraitImpl() throws Exception { + doTestAgainstJava("compiler/testData/codegen/boxAgainstJava/property/fieldAccessFromExtensionInTraitImpl.kt"); + } + + @TestMetadata("fieldAccessViaSubclass.kt") + public void testFieldAccessViaSubclass() throws Exception { + doTestAgainstJava("compiler/testData/codegen/boxAgainstJava/property/fieldAccessViaSubclass.kt"); + } + + } + + @TestMetadata("compiler/testData/codegen/boxAgainstJava/sam") + @InnerTestClasses({Sam.Adapters.class}) + public static class Sam extends AbstractBlackBoxCodegenTest { + public void testAllFilesPresentInSam() throws Exception { + JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage", new File("compiler/testData/codegen/boxAgainstJava/sam"), Pattern.compile("^(.+)\\.kt$"), true); + } + + @TestMetadata("differentFqNames.kt") + public void testDifferentFqNames() throws Exception { + doTestAgainstJava("compiler/testData/codegen/boxAgainstJava/sam/differentFqNames.kt"); + } + + @TestMetadata("samConstructorGenericSignature.kt") + public void testSamConstructorGenericSignature() throws Exception { + doTestAgainstJava("compiler/testData/codegen/boxAgainstJava/sam/samConstructorGenericSignature.kt"); + } + + @TestMetadata("compiler/testData/codegen/boxAgainstJava/sam/adapters") + @InnerTestClasses({Adapters.Operators.class}) + public static class Adapters extends AbstractBlackBoxCodegenTest { + public void testAllFilesPresentInAdapters() throws Exception { + JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage", new File("compiler/testData/codegen/boxAgainstJava/sam/adapters"), Pattern.compile("^(.+)\\.kt$"), true); + } + + @TestMetadata("callAbstractAdapter.kt") + public void testCallAbstractAdapter() throws Exception { + doTestAgainstJava("compiler/testData/codegen/boxAgainstJava/sam/adapters/callAbstractAdapter.kt"); + } + + @TestMetadata("comparator.kt") + public void testComparator() throws Exception { + doTestAgainstJava("compiler/testData/codegen/boxAgainstJava/sam/adapters/comparator.kt"); + } + + @TestMetadata("constructor.kt") + public void testConstructor() throws Exception { + doTestAgainstJava("compiler/testData/codegen/boxAgainstJava/sam/adapters/constructor.kt"); + } + + @TestMetadata("fileFilter.kt") + public void testFileFilter() throws Exception { + doTestAgainstJava("compiler/testData/codegen/boxAgainstJava/sam/adapters/fileFilter.kt"); + } + + @TestMetadata("genericSignature.kt") + public void testGenericSignature() throws Exception { + doTestAgainstJava("compiler/testData/codegen/boxAgainstJava/sam/adapters/genericSignature.kt"); + } + + @TestMetadata("implementAdapter.kt") + public void testImplementAdapter() throws Exception { + doTestAgainstJava("compiler/testData/codegen/boxAgainstJava/sam/adapters/implementAdapter.kt"); + } + + @TestMetadata("inheritedInKotlin.kt") + public void testInheritedInKotlin() throws Exception { + doTestAgainstJava("compiler/testData/codegen/boxAgainstJava/sam/adapters/inheritedInKotlin.kt"); + } + + @TestMetadata("inheritedOverriddenAdapter.kt") + public void testInheritedOverriddenAdapter() throws Exception { + doTestAgainstJava("compiler/testData/codegen/boxAgainstJava/sam/adapters/inheritedOverriddenAdapter.kt"); + } + + @TestMetadata("inheritedSimple.kt") + public void testInheritedSimple() throws Exception { + doTestAgainstJava("compiler/testData/codegen/boxAgainstJava/sam/adapters/inheritedSimple.kt"); + } + + @TestMetadata("nonLiteralAndLiteralRunnable.kt") + public void testNonLiteralAndLiteralRunnable() throws Exception { + doTestAgainstJava("compiler/testData/codegen/boxAgainstJava/sam/adapters/nonLiteralAndLiteralRunnable.kt"); + } + + @TestMetadata("nonLiteralComparator.kt") + public void testNonLiteralComparator() throws Exception { + doTestAgainstJava("compiler/testData/codegen/boxAgainstJava/sam/adapters/nonLiteralComparator.kt"); + } + + @TestMetadata("nonLiteralInConstructor.kt") + public void testNonLiteralInConstructor() throws Exception { + doTestAgainstJava("compiler/testData/codegen/boxAgainstJava/sam/adapters/nonLiteralInConstructor.kt"); + } + + @TestMetadata("nonLiteralNull.kt") + public void testNonLiteralNull() throws Exception { + doTestAgainstJava("compiler/testData/codegen/boxAgainstJava/sam/adapters/nonLiteralNull.kt"); + } + + @TestMetadata("nonLiteralRunnable.kt") + public void testNonLiteralRunnable() throws Exception { + doTestAgainstJava("compiler/testData/codegen/boxAgainstJava/sam/adapters/nonLiteralRunnable.kt"); + } + + @TestMetadata("severalSamParameters.kt") + public void testSeveralSamParameters() throws Exception { + doTestAgainstJava("compiler/testData/codegen/boxAgainstJava/sam/adapters/severalSamParameters.kt"); + } + + @TestMetadata("simplest.kt") + public void testSimplest() throws Exception { + doTestAgainstJava("compiler/testData/codegen/boxAgainstJava/sam/adapters/simplest.kt"); + } + + @TestMetadata("superconstructor.kt") + public void testSuperconstructor() throws Exception { + doTestAgainstJava("compiler/testData/codegen/boxAgainstJava/sam/adapters/superconstructor.kt"); + } + + @TestMetadata("typeParameterOfClass.kt") + public void testTypeParameterOfClass() throws Exception { + doTestAgainstJava("compiler/testData/codegen/boxAgainstJava/sam/adapters/typeParameterOfClass.kt"); + } + + @TestMetadata("typeParameterOfMethod.kt") + public void testTypeParameterOfMethod() throws Exception { + doTestAgainstJava("compiler/testData/codegen/boxAgainstJava/sam/adapters/typeParameterOfMethod.kt"); + } + + @TestMetadata("typeParameterOfOuterClass.kt") + public void testTypeParameterOfOuterClass() throws Exception { + doTestAgainstJava("compiler/testData/codegen/boxAgainstJava/sam/adapters/typeParameterOfOuterClass.kt"); + } + + @TestMetadata("compiler/testData/codegen/boxAgainstJava/sam/adapters/operators") + public static class Operators extends AbstractBlackBoxCodegenTest { + public void testAllFilesPresentInOperators() throws Exception { + JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage", new File("compiler/testData/codegen/boxAgainstJava/sam/adapters/operators"), Pattern.compile("^(.+)\\.kt$"), true); + } + + @TestMetadata("augmentedAssignmentAndSquareBrackets.kt") + public void testAugmentedAssignmentAndSquareBrackets() throws Exception { + doTestAgainstJava("compiler/testData/codegen/boxAgainstJava/sam/adapters/operators/augmentedAssignmentAndSquareBrackets.kt"); + } + + @TestMetadata("augmentedAssignmentPure.kt") + public void testAugmentedAssignmentPure() throws Exception { + doTestAgainstJava("compiler/testData/codegen/boxAgainstJava/sam/adapters/operators/augmentedAssignmentPure.kt"); + } + + @TestMetadata("augmentedAssignmentViaSimpleBinary.kt") + public void testAugmentedAssignmentViaSimpleBinary() throws Exception { + doTestAgainstJava("compiler/testData/codegen/boxAgainstJava/sam/adapters/operators/augmentedAssignmentViaSimpleBinary.kt"); + } + + @TestMetadata("binary.kt") + public void testBinary() throws Exception { + doTestAgainstJava("compiler/testData/codegen/boxAgainstJava/sam/adapters/operators/binary.kt"); + } + + @TestMetadata("compareTo.kt") + public void testCompareTo() throws Exception { + doTestAgainstJava("compiler/testData/codegen/boxAgainstJava/sam/adapters/operators/compareTo.kt"); + } + + @TestMetadata("contains.kt") + public void testContains() throws Exception { + doTestAgainstJava("compiler/testData/codegen/boxAgainstJava/sam/adapters/operators/contains.kt"); + } + + @TestMetadata("get.kt") + public void testGet() throws Exception { + doTestAgainstJava("compiler/testData/codegen/boxAgainstJava/sam/adapters/operators/get.kt"); + } + + @TestMetadata("infixCall.kt") + public void testInfixCall() throws Exception { + doTestAgainstJava("compiler/testData/codegen/boxAgainstJava/sam/adapters/operators/infixCall.kt"); + } + + @TestMetadata("invoke.kt") + public void testInvoke() throws Exception { + doTestAgainstJava("compiler/testData/codegen/boxAgainstJava/sam/adapters/operators/invoke.kt"); + } + + @TestMetadata("multiGetSet.kt") + public void testMultiGetSet() throws Exception { + doTestAgainstJava("compiler/testData/codegen/boxAgainstJava/sam/adapters/operators/multiGetSet.kt"); + } + + @TestMetadata("multiInvoke.kt") + public void testMultiInvoke() throws Exception { + doTestAgainstJava("compiler/testData/codegen/boxAgainstJava/sam/adapters/operators/multiInvoke.kt"); + } + + @TestMetadata("set.kt") + public void testSet() throws Exception { + doTestAgainstJava("compiler/testData/codegen/boxAgainstJava/sam/adapters/operators/set.kt"); + } + + } + + public static Test innerSuite() { + TestSuite suite = new TestSuite("Adapters"); + suite.addTestSuite(Adapters.class); + suite.addTestSuite(Operators.class); + return suite; + } + } + + public static Test innerSuite() { + TestSuite suite = new TestSuite("Sam"); + suite.addTestSuite(Sam.class); + suite.addTest(Adapters.innerSuite()); + return suite; + } + } + + @TestMetadata("compiler/testData/codegen/boxAgainstJava/staticFun") + public static class StaticFun extends AbstractBlackBoxCodegenTest { + public void testAllFilesPresentInStaticFun() throws Exception { + JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage", new File("compiler/testData/codegen/boxAgainstJava/staticFun"), Pattern.compile("^(.+)\\.kt$"), true); + } + + @TestMetadata("classWithNestedEnum.kt") + public void testClassWithNestedEnum() throws Exception { + doTestAgainstJava("compiler/testData/codegen/boxAgainstJava/staticFun/classWithNestedEnum.kt"); + } + + } + + @TestMetadata("compiler/testData/codegen/boxAgainstJava/visibility") + @InnerTestClasses({Visibility.Package.class, Visibility.ProtectedAndPackage.class, Visibility.ProtectedStatic.class}) + public static class Visibility extends AbstractBlackBoxCodegenTest { + public void testAllFilesPresentInVisibility() throws Exception { + JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage", new File("compiler/testData/codegen/boxAgainstJava/visibility"), Pattern.compile("^(.+)\\.kt$"), true); + } + + @TestMetadata("compiler/testData/codegen/boxAgainstJava/visibility/package") + public static class Package extends AbstractBlackBoxCodegenTest { + public void testAllFilesPresentInPackage() throws Exception { + JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage", new File("compiler/testData/codegen/boxAgainstJava/visibility/package"), Pattern.compile("^(.+)\\.kt$"), true); + } + + @TestMetadata("kt2781.kt") + public void testKt2781() throws Exception { + doTestAgainstJava("compiler/testData/codegen/boxAgainstJava/visibility/package/kt2781.kt"); + } + + @TestMetadata("packageClass.kt") + public void testPackageClass() throws Exception { + doTestAgainstJava("compiler/testData/codegen/boxAgainstJava/visibility/package/packageClass.kt"); + } + + @TestMetadata("packageFun.kt") + public void testPackageFun() throws Exception { + doTestAgainstJava("compiler/testData/codegen/boxAgainstJava/visibility/package/packageFun.kt"); + } + + @TestMetadata("packageProperty.kt") + public void testPackageProperty() throws Exception { + doTestAgainstJava("compiler/testData/codegen/boxAgainstJava/visibility/package/packageProperty.kt"); + } + + } + + @TestMetadata("compiler/testData/codegen/boxAgainstJava/visibility/protectedAndPackage") + public static class ProtectedAndPackage extends AbstractBlackBoxCodegenTest { + public void testAllFilesPresentInProtectedAndPackage() throws Exception { + JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage", new File("compiler/testData/codegen/boxAgainstJava/visibility/protectedAndPackage"), Pattern.compile("^(.+)\\.kt$"), true); + } + + @TestMetadata("overrideProtectedFunInPackage.kt") + public void testOverrideProtectedFunInPackage() throws Exception { + doTestAgainstJava("compiler/testData/codegen/boxAgainstJava/visibility/protectedAndPackage/overrideProtectedFunInPackage.kt"); + } + + @TestMetadata("protectedFunInPackage.kt") + public void testProtectedFunInPackage() throws Exception { + doTestAgainstJava("compiler/testData/codegen/boxAgainstJava/visibility/protectedAndPackage/protectedFunInPackage.kt"); + } + + @TestMetadata("protectedPropertyInPackage.kt") + public void testProtectedPropertyInPackage() throws Exception { + doTestAgainstJava("compiler/testData/codegen/boxAgainstJava/visibility/protectedAndPackage/protectedPropertyInPackage.kt"); + } + + @TestMetadata("protectedStaticClass.kt") + public void testProtectedStaticClass() throws Exception { + doTestAgainstJava("compiler/testData/codegen/boxAgainstJava/visibility/protectedAndPackage/protectedStaticClass.kt"); + } + + } + + @TestMetadata("compiler/testData/codegen/boxAgainstJava/visibility/protectedStatic") + public static class ProtectedStatic extends AbstractBlackBoxCodegenTest { + public void testAllFilesPresentInProtectedStatic() throws Exception { + JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage", new File("compiler/testData/codegen/boxAgainstJava/visibility/protectedStatic"), Pattern.compile("^(.+)\\.kt$"), true); + } + + @TestMetadata("funCallInConstructor.kt") + public void testFunCallInConstructor() throws Exception { + doTestAgainstJava("compiler/testData/codegen/boxAgainstJava/visibility/protectedStatic/funCallInConstructor.kt"); + } + + @TestMetadata("funClassObject.kt") + public void testFunClassObject() throws Exception { + doTestAgainstJava("compiler/testData/codegen/boxAgainstJava/visibility/protectedStatic/funClassObject.kt"); + } + + @TestMetadata("funGenericClass.kt") + public void testFunGenericClass() throws Exception { + doTestAgainstJava("compiler/testData/codegen/boxAgainstJava/visibility/protectedStatic/funGenericClass.kt"); + } + + @TestMetadata("funNestedStaticClass.kt") + public void testFunNestedStaticClass() throws Exception { + doTestAgainstJava("compiler/testData/codegen/boxAgainstJava/visibility/protectedStatic/funNestedStaticClass.kt"); + } + + @TestMetadata("funNestedStaticClass2.kt") + public void testFunNestedStaticClass2() throws Exception { + doTestAgainstJava("compiler/testData/codegen/boxAgainstJava/visibility/protectedStatic/funNestedStaticClass2.kt"); + } + + @TestMetadata("funNestedStaticGenericClass.kt") + public void testFunNestedStaticGenericClass() throws Exception { + doTestAgainstJava("compiler/testData/codegen/boxAgainstJava/visibility/protectedStatic/funNestedStaticGenericClass.kt"); + } + + @TestMetadata("funNotDirectSuperClass.kt") + public void testFunNotDirectSuperClass() throws Exception { + doTestAgainstJava("compiler/testData/codegen/boxAgainstJava/visibility/protectedStatic/funNotDirectSuperClass.kt"); + } + + @TestMetadata("funObject.kt") + public void testFunObject() throws Exception { + doTestAgainstJava("compiler/testData/codegen/boxAgainstJava/visibility/protectedStatic/funObject.kt"); + } + + @TestMetadata("simpleClass.kt") + public void testSimpleClass() throws Exception { + doTestAgainstJava("compiler/testData/codegen/boxAgainstJava/visibility/protectedStatic/simpleClass.kt"); + } + + @TestMetadata("simpleClass2.kt") + public void testSimpleClass2() throws Exception { + doTestAgainstJava("compiler/testData/codegen/boxAgainstJava/visibility/protectedStatic/simpleClass2.kt"); + } + + @TestMetadata("simpleFun.kt") + public void testSimpleFun() throws Exception { + doTestAgainstJava("compiler/testData/codegen/boxAgainstJava/visibility/protectedStatic/simpleFun.kt"); + } + + @TestMetadata("simpleProperty.kt") + public void testSimpleProperty() throws Exception { + doTestAgainstJava("compiler/testData/codegen/boxAgainstJava/visibility/protectedStatic/simpleProperty.kt"); + } + + } + + public static Test innerSuite() { + TestSuite suite = new TestSuite("Visibility"); + suite.addTestSuite(Visibility.class); + suite.addTestSuite(Package.class); + suite.addTestSuite(ProtectedAndPackage.class); + suite.addTestSuite(ProtectedStatic.class); + return suite; + } + } + + public static Test suite() { + TestSuite suite = new TestSuite("BlackBoxAgainstJavaCodegenTestGenerated"); + suite.addTestSuite(BlackBoxAgainstJavaCodegenTestGenerated.class); + suite.addTestSuite(Annotations.class); + suite.addTestSuite(CallableReference.class); + suite.addTestSuite(Constructor.class); + suite.addTestSuite(Delegation.class); + suite.addTestSuite(Enum.class); + suite.addTestSuite(Functions.class); + suite.addTestSuite(InnerClass.class); + suite.addTestSuite(Property.class); + suite.addTest(Sam.innerSuite()); + suite.addTestSuite(StaticFun.class); + suite.addTest(Visibility.innerSuite()); + return suite; + } +} diff --git a/compiler/tests/org/jetbrains/jet/codegen/generated/BlackBoxWithJavaCodegenTestGenerated.java b/compiler/tests/org/jetbrains/jet/codegen/generated/BlackBoxWithJavaCodegenTestGenerated.java index 178e38534cc..612db880d58 100644 --- a/compiler/tests/org/jetbrains/jet/codegen/generated/BlackBoxWithJavaCodegenTestGenerated.java +++ b/compiler/tests/org/jetbrains/jet/codegen/generated/BlackBoxWithJavaCodegenTestGenerated.java @@ -31,577 +31,9 @@ import org.jetbrains.jet.codegen.generated.AbstractBlackBoxCodegenTest; /** This class is generated by {@link org.jetbrains.jet.generators.tests.TestsPackage}. DO NOT MODIFY MANUALLY */ @SuppressWarnings("all") @TestMetadata("compiler/testData/codegen/boxWithJava") -@InnerTestClasses({BlackBoxWithJavaCodegenTestGenerated.Annotations.class, BlackBoxWithJavaCodegenTestGenerated.CallableReference.class, BlackBoxWithJavaCodegenTestGenerated.Constructor.class, BlackBoxWithJavaCodegenTestGenerated.Delegation.class, BlackBoxWithJavaCodegenTestGenerated.Enum.class, BlackBoxWithJavaCodegenTestGenerated.Functions.class, BlackBoxWithJavaCodegenTestGenerated.InnerClass.class, BlackBoxWithJavaCodegenTestGenerated.Property.class, BlackBoxWithJavaCodegenTestGenerated.Sam.class, BlackBoxWithJavaCodegenTestGenerated.StaticFun.class, BlackBoxWithJavaCodegenTestGenerated.Visibility.class}) public class BlackBoxWithJavaCodegenTestGenerated extends AbstractBlackBoxCodegenTest { public void testAllFilesPresentInBoxWithJava() throws Exception { - JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage", new File("compiler/testData/codegen/boxWithJava"), Pattern.compile("^(.+)\\.kt$"), true); + JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage", new File("compiler/testData/codegen/boxWithJava"), Pattern.compile("^([^\\.]+)$"), false); } - @TestMetadata("compiler/testData/codegen/boxWithJava/annotations") - public static class Annotations extends AbstractBlackBoxCodegenTest { - public void testAllFilesPresentInAnnotations() throws Exception { - JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage", new File("compiler/testData/codegen/boxWithJava/annotations"), Pattern.compile("^(.+)\\.kt$"), true); - } - - @TestMetadata("javaAnnotationCall.kt") - public void testJavaAnnotationCall() throws Exception { - doTestWithJava("compiler/testData/codegen/boxWithJava/annotations/javaAnnotationCall.kt"); - } - - @TestMetadata("javaAnnotationDefault.kt") - public void testJavaAnnotationDefault() throws Exception { - doTestWithJava("compiler/testData/codegen/boxWithJava/annotations/javaAnnotationDefault.kt"); - } - - @TestMetadata("javaNegativePropertyAsAnnotationParameter.kt") - public void testJavaNegativePropertyAsAnnotationParameter() throws Exception { - doTestWithJava("compiler/testData/codegen/boxWithJava/annotations/javaNegativePropertyAsAnnotationParameter.kt"); - } - - @TestMetadata("javaPropertyAsAnnotationParameter.kt") - public void testJavaPropertyAsAnnotationParameter() throws Exception { - doTestWithJava("compiler/testData/codegen/boxWithJava/annotations/javaPropertyAsAnnotationParameter.kt"); - } - - @TestMetadata("javaPropertyWithIntInitializer.kt") - public void testJavaPropertyWithIntInitializer() throws Exception { - doTestWithJava("compiler/testData/codegen/boxWithJava/annotations/javaPropertyWithIntInitializer.kt"); - } - - @TestMetadata("RetentionInJava.kt") - public void testRetentionInJava() throws Exception { - doTestWithJava("compiler/testData/codegen/boxWithJava/annotations/RetentionInJava.kt"); - } - - } - - @TestMetadata("compiler/testData/codegen/boxWithJava/callableReference") - public static class CallableReference extends AbstractBlackBoxCodegenTest { - public void testAllFilesPresentInCallableReference() throws Exception { - JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage", new File("compiler/testData/codegen/boxWithJava/callableReference"), Pattern.compile("^(.+)\\.kt$"), true); - } - - @TestMetadata("constructor.kt") - public void testConstructor() throws Exception { - doTestWithJava("compiler/testData/codegen/boxWithJava/callableReference/constructor.kt"); - } - - } - - @TestMetadata("compiler/testData/codegen/boxWithJava/constructor") - public static class Constructor extends AbstractBlackBoxCodegenTest { - public void testAllFilesPresentInConstructor() throws Exception { - JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage", new File("compiler/testData/codegen/boxWithJava/constructor"), Pattern.compile("^(.+)\\.kt$"), true); - } - - @TestMetadata("genericConstructor.kt") - public void testGenericConstructor() throws Exception { - doTestWithJava("compiler/testData/codegen/boxWithJava/constructor/genericConstructor.kt"); - } - - } - - @TestMetadata("compiler/testData/codegen/boxWithJava/delegation") - public static class Delegation extends AbstractBlackBoxCodegenTest { - public void testAllFilesPresentInDelegation() throws Exception { - JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage", new File("compiler/testData/codegen/boxWithJava/delegation"), Pattern.compile("^(.+)\\.kt$"), true); - } - - @TestMetadata("delegationAndInheritanceFromJava.kt") - public void testDelegationAndInheritanceFromJava() throws Exception { - doTestWithJava("compiler/testData/codegen/boxWithJava/delegation/delegationAndInheritanceFromJava.kt"); - } - - } - - @TestMetadata("compiler/testData/codegen/boxWithJava/enum") - public static class Enum extends AbstractBlackBoxCodegenTest { - public void testAllFilesPresentInEnum() throws Exception { - JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage", new File("compiler/testData/codegen/boxWithJava/enum"), Pattern.compile("^(.+)\\.kt$"), true); - } - - @TestMetadata("simpleJavaEnum.kt") - public void testSimpleJavaEnum() throws Exception { - doTestWithJava("compiler/testData/codegen/boxWithJava/enum/simpleJavaEnum.kt"); - } - - @TestMetadata("simpleJavaEnumWithFunction.kt") - public void testSimpleJavaEnumWithFunction() throws Exception { - doTestWithJava("compiler/testData/codegen/boxWithJava/enum/simpleJavaEnumWithFunction.kt"); - } - - @TestMetadata("simpleJavaEnumWithStaticImport.kt") - public void testSimpleJavaEnumWithStaticImport() throws Exception { - doTestWithJava("compiler/testData/codegen/boxWithJava/enum/simpleJavaEnumWithStaticImport.kt"); - } - - @TestMetadata("simpleJavaInnerEnum.kt") - public void testSimpleJavaInnerEnum() throws Exception { - doTestWithJava("compiler/testData/codegen/boxWithJava/enum/simpleJavaInnerEnum.kt"); - } - - @TestMetadata("staticField.kt") - public void testStaticField() throws Exception { - doTestWithJava("compiler/testData/codegen/boxWithJava/enum/staticField.kt"); - } - - @TestMetadata("staticMethod.kt") - public void testStaticMethod() throws Exception { - doTestWithJava("compiler/testData/codegen/boxWithJava/enum/staticMethod.kt"); - } - - } - - @TestMetadata("compiler/testData/codegen/boxWithJava/functions") - public static class Functions extends AbstractBlackBoxCodegenTest { - public void testAllFilesPresentInFunctions() throws Exception { - JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage", new File("compiler/testData/codegen/boxWithJava/functions"), Pattern.compile("^(.+)\\.kt$"), true); - } - - @TestMetadata("constructor.kt") - public void testConstructor() throws Exception { - doTestWithJava("compiler/testData/codegen/boxWithJava/functions/constructor.kt"); - } - - @TestMetadata("max.kt") - public void testMax() throws Exception { - doTestWithJava("compiler/testData/codegen/boxWithJava/functions/max.kt"); - } - - @TestMetadata("referencesStaticInnerClassMethod.kt") - public void testReferencesStaticInnerClassMethod() throws Exception { - doTestWithJava("compiler/testData/codegen/boxWithJava/functions/referencesStaticInnerClassMethod.kt"); - } - - @TestMetadata("referencesStaticInnerClassMethodL2.kt") - public void testReferencesStaticInnerClassMethodL2() throws Exception { - doTestWithJava("compiler/testData/codegen/boxWithJava/functions/referencesStaticInnerClassMethodL2.kt"); - } - - @TestMetadata("unrelatedUpperBounds.kt") - public void testUnrelatedUpperBounds() throws Exception { - doTestWithJava("compiler/testData/codegen/boxWithJava/functions/unrelatedUpperBounds.kt"); - } - - } - - @TestMetadata("compiler/testData/codegen/boxWithJava/innerClass") - public static class InnerClass extends AbstractBlackBoxCodegenTest { - public void testAllFilesPresentInInnerClass() throws Exception { - JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage", new File("compiler/testData/codegen/boxWithJava/innerClass"), Pattern.compile("^(.+)\\.kt$"), true); - } - - @TestMetadata("kt3532.kt") - public void testKt3532() throws Exception { - doTestWithJava("compiler/testData/codegen/boxWithJava/innerClass/kt3532.kt"); - } - - @TestMetadata("kt3812.kt") - public void testKt3812() throws Exception { - doTestWithJava("compiler/testData/codegen/boxWithJava/innerClass/kt3812.kt"); - } - - @TestMetadata("kt4036.kt") - public void testKt4036() throws Exception { - doTestWithJava("compiler/testData/codegen/boxWithJava/innerClass/kt4036.kt"); - } - - } - - @TestMetadata("compiler/testData/codegen/boxWithJava/property") - public static class Property extends AbstractBlackBoxCodegenTest { - public void testAllFilesPresentInProperty() throws Exception { - JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage", new File("compiler/testData/codegen/boxWithJava/property"), Pattern.compile("^(.+)\\.kt$"), true); - } - - @TestMetadata("fieldAccessFromExtensionInTraitImpl.kt") - public void testFieldAccessFromExtensionInTraitImpl() throws Exception { - doTestWithJava("compiler/testData/codegen/boxWithJava/property/fieldAccessFromExtensionInTraitImpl.kt"); - } - - @TestMetadata("fieldAccessViaSubclass.kt") - public void testFieldAccessViaSubclass() throws Exception { - doTestWithJava("compiler/testData/codegen/boxWithJava/property/fieldAccessViaSubclass.kt"); - } - - } - - @TestMetadata("compiler/testData/codegen/boxWithJava/sam") - @InnerTestClasses({Sam.Adapters.class}) - public static class Sam extends AbstractBlackBoxCodegenTest { - public void testAllFilesPresentInSam() throws Exception { - JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage", new File("compiler/testData/codegen/boxWithJava/sam"), Pattern.compile("^(.+)\\.kt$"), true); - } - - @TestMetadata("differentFqNames.kt") - public void testDifferentFqNames() throws Exception { - doTestWithJava("compiler/testData/codegen/boxWithJava/sam/differentFqNames.kt"); - } - - @TestMetadata("samConstructorGenericSignature.kt") - public void testSamConstructorGenericSignature() throws Exception { - doTestWithJava("compiler/testData/codegen/boxWithJava/sam/samConstructorGenericSignature.kt"); - } - - @TestMetadata("compiler/testData/codegen/boxWithJava/sam/adapters") - @InnerTestClasses({Adapters.Operators.class}) - public static class Adapters extends AbstractBlackBoxCodegenTest { - public void testAllFilesPresentInAdapters() throws Exception { - JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage", new File("compiler/testData/codegen/boxWithJava/sam/adapters"), Pattern.compile("^(.+)\\.kt$"), true); - } - - @TestMetadata("callAbstractAdapter.kt") - public void testCallAbstractAdapter() throws Exception { - doTestWithJava("compiler/testData/codegen/boxWithJava/sam/adapters/callAbstractAdapter.kt"); - } - - @TestMetadata("comparator.kt") - public void testComparator() throws Exception { - doTestWithJava("compiler/testData/codegen/boxWithJava/sam/adapters/comparator.kt"); - } - - @TestMetadata("constructor.kt") - public void testConstructor() throws Exception { - doTestWithJava("compiler/testData/codegen/boxWithJava/sam/adapters/constructor.kt"); - } - - @TestMetadata("fileFilter.kt") - public void testFileFilter() throws Exception { - doTestWithJava("compiler/testData/codegen/boxWithJava/sam/adapters/fileFilter.kt"); - } - - @TestMetadata("genericSignature.kt") - public void testGenericSignature() throws Exception { - doTestWithJava("compiler/testData/codegen/boxWithJava/sam/adapters/genericSignature.kt"); - } - - @TestMetadata("implementAdapter.kt") - public void testImplementAdapter() throws Exception { - doTestWithJava("compiler/testData/codegen/boxWithJava/sam/adapters/implementAdapter.kt"); - } - - @TestMetadata("inheritedInKotlin.kt") - public void testInheritedInKotlin() throws Exception { - doTestWithJava("compiler/testData/codegen/boxWithJava/sam/adapters/inheritedInKotlin.kt"); - } - - @TestMetadata("inheritedOverriddenAdapter.kt") - public void testInheritedOverriddenAdapter() throws Exception { - doTestWithJava("compiler/testData/codegen/boxWithJava/sam/adapters/inheritedOverriddenAdapter.kt"); - } - - @TestMetadata("inheritedSimple.kt") - public void testInheritedSimple() throws Exception { - doTestWithJava("compiler/testData/codegen/boxWithJava/sam/adapters/inheritedSimple.kt"); - } - - @TestMetadata("nonLiteralAndLiteralRunnable.kt") - public void testNonLiteralAndLiteralRunnable() throws Exception { - doTestWithJava("compiler/testData/codegen/boxWithJava/sam/adapters/nonLiteralAndLiteralRunnable.kt"); - } - - @TestMetadata("nonLiteralComparator.kt") - public void testNonLiteralComparator() throws Exception { - doTestWithJava("compiler/testData/codegen/boxWithJava/sam/adapters/nonLiteralComparator.kt"); - } - - @TestMetadata("nonLiteralInConstructor.kt") - public void testNonLiteralInConstructor() throws Exception { - doTestWithJava("compiler/testData/codegen/boxWithJava/sam/adapters/nonLiteralInConstructor.kt"); - } - - @TestMetadata("nonLiteralNull.kt") - public void testNonLiteralNull() throws Exception { - doTestWithJava("compiler/testData/codegen/boxWithJava/sam/adapters/nonLiteralNull.kt"); - } - - @TestMetadata("nonLiteralRunnable.kt") - public void testNonLiteralRunnable() throws Exception { - doTestWithJava("compiler/testData/codegen/boxWithJava/sam/adapters/nonLiteralRunnable.kt"); - } - - @TestMetadata("severalSamParameters.kt") - public void testSeveralSamParameters() throws Exception { - doTestWithJava("compiler/testData/codegen/boxWithJava/sam/adapters/severalSamParameters.kt"); - } - - @TestMetadata("simplest.kt") - public void testSimplest() throws Exception { - doTestWithJava("compiler/testData/codegen/boxWithJava/sam/adapters/simplest.kt"); - } - - @TestMetadata("superconstructor.kt") - public void testSuperconstructor() throws Exception { - doTestWithJava("compiler/testData/codegen/boxWithJava/sam/adapters/superconstructor.kt"); - } - - @TestMetadata("typeParameterOfClass.kt") - public void testTypeParameterOfClass() throws Exception { - doTestWithJava("compiler/testData/codegen/boxWithJava/sam/adapters/typeParameterOfClass.kt"); - } - - @TestMetadata("typeParameterOfMethod.kt") - public void testTypeParameterOfMethod() throws Exception { - doTestWithJava("compiler/testData/codegen/boxWithJava/sam/adapters/typeParameterOfMethod.kt"); - } - - @TestMetadata("typeParameterOfOuterClass.kt") - public void testTypeParameterOfOuterClass() throws Exception { - doTestWithJava("compiler/testData/codegen/boxWithJava/sam/adapters/typeParameterOfOuterClass.kt"); - } - - @TestMetadata("compiler/testData/codegen/boxWithJava/sam/adapters/operators") - public static class Operators extends AbstractBlackBoxCodegenTest { - public void testAllFilesPresentInOperators() throws Exception { - JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage", new File("compiler/testData/codegen/boxWithJava/sam/adapters/operators"), Pattern.compile("^(.+)\\.kt$"), true); - } - - @TestMetadata("augmentedAssignmentAndSquareBrackets.kt") - public void testAugmentedAssignmentAndSquareBrackets() throws Exception { - doTestWithJava("compiler/testData/codegen/boxWithJava/sam/adapters/operators/augmentedAssignmentAndSquareBrackets.kt"); - } - - @TestMetadata("augmentedAssignmentPure.kt") - public void testAugmentedAssignmentPure() throws Exception { - doTestWithJava("compiler/testData/codegen/boxWithJava/sam/adapters/operators/augmentedAssignmentPure.kt"); - } - - @TestMetadata("augmentedAssignmentViaSimpleBinary.kt") - public void testAugmentedAssignmentViaSimpleBinary() throws Exception { - doTestWithJava("compiler/testData/codegen/boxWithJava/sam/adapters/operators/augmentedAssignmentViaSimpleBinary.kt"); - } - - @TestMetadata("binary.kt") - public void testBinary() throws Exception { - doTestWithJava("compiler/testData/codegen/boxWithJava/sam/adapters/operators/binary.kt"); - } - - @TestMetadata("compareTo.kt") - public void testCompareTo() throws Exception { - doTestWithJava("compiler/testData/codegen/boxWithJava/sam/adapters/operators/compareTo.kt"); - } - - @TestMetadata("contains.kt") - public void testContains() throws Exception { - doTestWithJava("compiler/testData/codegen/boxWithJava/sam/adapters/operators/contains.kt"); - } - - @TestMetadata("get.kt") - public void testGet() throws Exception { - doTestWithJava("compiler/testData/codegen/boxWithJava/sam/adapters/operators/get.kt"); - } - - @TestMetadata("infixCall.kt") - public void testInfixCall() throws Exception { - doTestWithJava("compiler/testData/codegen/boxWithJava/sam/adapters/operators/infixCall.kt"); - } - - @TestMetadata("invoke.kt") - public void testInvoke() throws Exception { - doTestWithJava("compiler/testData/codegen/boxWithJava/sam/adapters/operators/invoke.kt"); - } - - @TestMetadata("multiGetSet.kt") - public void testMultiGetSet() throws Exception { - doTestWithJava("compiler/testData/codegen/boxWithJava/sam/adapters/operators/multiGetSet.kt"); - } - - @TestMetadata("multiInvoke.kt") - public void testMultiInvoke() throws Exception { - doTestWithJava("compiler/testData/codegen/boxWithJava/sam/adapters/operators/multiInvoke.kt"); - } - - @TestMetadata("set.kt") - public void testSet() throws Exception { - doTestWithJava("compiler/testData/codegen/boxWithJava/sam/adapters/operators/set.kt"); - } - - } - - public static Test innerSuite() { - TestSuite suite = new TestSuite("Adapters"); - suite.addTestSuite(Adapters.class); - suite.addTestSuite(Operators.class); - return suite; - } - } - - public static Test innerSuite() { - TestSuite suite = new TestSuite("Sam"); - suite.addTestSuite(Sam.class); - suite.addTest(Adapters.innerSuite()); - return suite; - } - } - - @TestMetadata("compiler/testData/codegen/boxWithJava/staticFun") - public static class StaticFun extends AbstractBlackBoxCodegenTest { - public void testAllFilesPresentInStaticFun() throws Exception { - JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage", new File("compiler/testData/codegen/boxWithJava/staticFun"), Pattern.compile("^(.+)\\.kt$"), true); - } - - @TestMetadata("classWithNestedEnum.kt") - public void testClassWithNestedEnum() throws Exception { - doTestWithJava("compiler/testData/codegen/boxWithJava/staticFun/classWithNestedEnum.kt"); - } - - } - - @TestMetadata("compiler/testData/codegen/boxWithJava/visibility") - @InnerTestClasses({Visibility.Package.class, Visibility.ProtectedAndPackage.class, Visibility.ProtectedStatic.class}) - public static class Visibility extends AbstractBlackBoxCodegenTest { - public void testAllFilesPresentInVisibility() throws Exception { - JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage", new File("compiler/testData/codegen/boxWithJava/visibility"), Pattern.compile("^(.+)\\.kt$"), true); - } - - @TestMetadata("compiler/testData/codegen/boxWithJava/visibility/package") - public static class Package extends AbstractBlackBoxCodegenTest { - public void testAllFilesPresentInPackage() throws Exception { - JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage", new File("compiler/testData/codegen/boxWithJava/visibility/package"), Pattern.compile("^(.+)\\.kt$"), true); - } - - @TestMetadata("kt2781.kt") - public void testKt2781() throws Exception { - doTestWithJava("compiler/testData/codegen/boxWithJava/visibility/package/kt2781.kt"); - } - - @TestMetadata("packageClass.kt") - public void testPackageClass() throws Exception { - doTestWithJava("compiler/testData/codegen/boxWithJava/visibility/package/packageClass.kt"); - } - - @TestMetadata("packageFun.kt") - public void testPackageFun() throws Exception { - doTestWithJava("compiler/testData/codegen/boxWithJava/visibility/package/packageFun.kt"); - } - - @TestMetadata("packageProperty.kt") - public void testPackageProperty() throws Exception { - doTestWithJava("compiler/testData/codegen/boxWithJava/visibility/package/packageProperty.kt"); - } - - } - - @TestMetadata("compiler/testData/codegen/boxWithJava/visibility/protectedAndPackage") - public static class ProtectedAndPackage extends AbstractBlackBoxCodegenTest { - public void testAllFilesPresentInProtectedAndPackage() throws Exception { - JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage", new File("compiler/testData/codegen/boxWithJava/visibility/protectedAndPackage"), Pattern.compile("^(.+)\\.kt$"), true); - } - - @TestMetadata("overrideProtectedFunInPackage.kt") - public void testOverrideProtectedFunInPackage() throws Exception { - doTestWithJava("compiler/testData/codegen/boxWithJava/visibility/protectedAndPackage/overrideProtectedFunInPackage.kt"); - } - - @TestMetadata("protectedFunInPackage.kt") - public void testProtectedFunInPackage() throws Exception { - doTestWithJava("compiler/testData/codegen/boxWithJava/visibility/protectedAndPackage/protectedFunInPackage.kt"); - } - - @TestMetadata("protectedPropertyInPackage.kt") - public void testProtectedPropertyInPackage() throws Exception { - doTestWithJava("compiler/testData/codegen/boxWithJava/visibility/protectedAndPackage/protectedPropertyInPackage.kt"); - } - - @TestMetadata("protectedStaticClass.kt") - public void testProtectedStaticClass() throws Exception { - doTestWithJava("compiler/testData/codegen/boxWithJava/visibility/protectedAndPackage/protectedStaticClass.kt"); - } - - } - - @TestMetadata("compiler/testData/codegen/boxWithJava/visibility/protectedStatic") - public static class ProtectedStatic extends AbstractBlackBoxCodegenTest { - public void testAllFilesPresentInProtectedStatic() throws Exception { - JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), "org.jetbrains.jet.generators.tests.TestsPackage", new File("compiler/testData/codegen/boxWithJava/visibility/protectedStatic"), Pattern.compile("^(.+)\\.kt$"), true); - } - - @TestMetadata("funCallInConstructor.kt") - public void testFunCallInConstructor() throws Exception { - doTestWithJava("compiler/testData/codegen/boxWithJava/visibility/protectedStatic/funCallInConstructor.kt"); - } - - @TestMetadata("funClassObject.kt") - public void testFunClassObject() throws Exception { - doTestWithJava("compiler/testData/codegen/boxWithJava/visibility/protectedStatic/funClassObject.kt"); - } - - @TestMetadata("funGenericClass.kt") - public void testFunGenericClass() throws Exception { - doTestWithJava("compiler/testData/codegen/boxWithJava/visibility/protectedStatic/funGenericClass.kt"); - } - - @TestMetadata("funNestedStaticClass.kt") - public void testFunNestedStaticClass() throws Exception { - doTestWithJava("compiler/testData/codegen/boxWithJava/visibility/protectedStatic/funNestedStaticClass.kt"); - } - - @TestMetadata("funNestedStaticClass2.kt") - public void testFunNestedStaticClass2() throws Exception { - doTestWithJava("compiler/testData/codegen/boxWithJava/visibility/protectedStatic/funNestedStaticClass2.kt"); - } - - @TestMetadata("funNestedStaticGenericClass.kt") - public void testFunNestedStaticGenericClass() throws Exception { - doTestWithJava("compiler/testData/codegen/boxWithJava/visibility/protectedStatic/funNestedStaticGenericClass.kt"); - } - - @TestMetadata("funNotDirectSuperClass.kt") - public void testFunNotDirectSuperClass() throws Exception { - doTestWithJava("compiler/testData/codegen/boxWithJava/visibility/protectedStatic/funNotDirectSuperClass.kt"); - } - - @TestMetadata("funObject.kt") - public void testFunObject() throws Exception { - doTestWithJava("compiler/testData/codegen/boxWithJava/visibility/protectedStatic/funObject.kt"); - } - - @TestMetadata("simpleClass.kt") - public void testSimpleClass() throws Exception { - doTestWithJava("compiler/testData/codegen/boxWithJava/visibility/protectedStatic/simpleClass.kt"); - } - - @TestMetadata("simpleClass2.kt") - public void testSimpleClass2() throws Exception { - doTestWithJava("compiler/testData/codegen/boxWithJava/visibility/protectedStatic/simpleClass2.kt"); - } - - @TestMetadata("simpleFun.kt") - public void testSimpleFun() throws Exception { - doTestWithJava("compiler/testData/codegen/boxWithJava/visibility/protectedStatic/simpleFun.kt"); - } - - @TestMetadata("simpleProperty.kt") - public void testSimpleProperty() throws Exception { - doTestWithJava("compiler/testData/codegen/boxWithJava/visibility/protectedStatic/simpleProperty.kt"); - } - - } - - public static Test innerSuite() { - TestSuite suite = new TestSuite("Visibility"); - suite.addTestSuite(Visibility.class); - suite.addTestSuite(Package.class); - suite.addTestSuite(ProtectedAndPackage.class); - suite.addTestSuite(ProtectedStatic.class); - return suite; - } - } - - public static Test suite() { - TestSuite suite = new TestSuite("BlackBoxWithJavaCodegenTestGenerated"); - suite.addTestSuite(BlackBoxWithJavaCodegenTestGenerated.class); - suite.addTestSuite(Annotations.class); - suite.addTestSuite(CallableReference.class); - suite.addTestSuite(Constructor.class); - suite.addTestSuite(Delegation.class); - suite.addTestSuite(Enum.class); - suite.addTestSuite(Functions.class); - suite.addTestSuite(InnerClass.class); - suite.addTestSuite(Property.class); - suite.addTest(Sam.innerSuite()); - suite.addTestSuite(StaticFun.class); - suite.addTest(Visibility.innerSuite()); - return suite; - } } diff --git a/compiler/tests/org/jetbrains/jet/types/BoundsSubstitutorTest.java b/compiler/tests/org/jetbrains/jet/types/BoundsSubstitutorTest.java index 70e8ff0fd92..f348090e4f0 100644 --- a/compiler/tests/org/jetbrains/jet/types/BoundsSubstitutorTest.java +++ b/compiler/tests/org/jetbrains/jet/types/BoundsSubstitutorTest.java @@ -23,11 +23,11 @@ import org.jetbrains.jet.lang.descriptors.FunctionDescriptor; import org.jetbrains.jet.lang.descriptors.ModuleDescriptor; import org.jetbrains.jet.lang.psi.JetFile; import org.jetbrains.jet.lang.psi.JetPsiFactory; -import org.jetbrains.jet.lang.resolve.DescriptorUtils; import org.jetbrains.jet.lang.resolve.lazy.KotlinTestWithEnvironment; import org.jetbrains.jet.lang.resolve.lazy.LazyResolveTestUtil; import org.jetbrains.jet.lang.resolve.name.FqName; import org.jetbrains.jet.lang.resolve.name.Name; +import org.jetbrains.jet.lang.types.BoundsSubstitutor; import org.jetbrains.jet.renderer.DescriptorRenderer; import java.util.Collection; @@ -76,7 +76,7 @@ public class BoundsSubstitutorTest extends KotlinTestWithEnvironment { assert functions.size() == 1 : "Many functions defined"; FunctionDescriptor function = ContainerUtil.getFirstItem(functions); - FunctionDescriptor substituted = DescriptorUtils.substituteBounds(function); + FunctionDescriptor substituted = BoundsSubstitutor.substituteBounds(function); String actual = DescriptorRenderer.COMPACT.render(substituted); assertEquals(expected, actual); } diff --git a/core/descriptor.loader.java/src/org/jetbrains/jet/lang/resolve/java/JavaVisibilities.java b/core/descriptor.loader.java/src/org/jetbrains/jet/lang/resolve/java/JavaVisibilities.java index 05ccf6de960..d088f6da55a 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/jet/lang/resolve/java/JavaVisibilities.java +++ b/core/descriptor.loader.java/src/org/jetbrains/jet/lang/resolve/java/JavaVisibilities.java @@ -54,6 +54,10 @@ public class JavaVisibilities { public static final Visibility PROTECTED_STATIC_VISIBILITY = new Visibility("protected_static", false) { @Override protected boolean isVisible(@NotNull DeclarationDescriptorWithVisibility what, @NotNull DeclarationDescriptor from) { + if (areInSamePackage(what, from)) { + return true; + } + ClassDescriptor fromClass = DescriptorUtils.getParentOfType(from, ClassDescriptor.class, false); if (fromClass == null) return false; diff --git a/core/descriptor.loader.java/src/org/jetbrains/jet/lang/resolve/java/PackageClassUtils.java b/core/descriptor.loader.java/src/org/jetbrains/jet/lang/resolve/java/PackageClassUtils.java index 72b5c45e4f5..bfa1a3b6ed2 100644 --- a/core/descriptor.loader.java/src/org/jetbrains/jet/lang/resolve/java/PackageClassUtils.java +++ b/core/descriptor.loader.java/src/org/jetbrains/jet/lang/resolve/java/PackageClassUtils.java @@ -46,6 +46,11 @@ public final class PackageClassUtils { return packageFQN.child(Name.identifier(getPackageClassName(packageFQN))); } + @NotNull + public static String getPackageClassInternalName(@NotNull FqName packageFQN) { + return JvmClassName.byFqNameWithoutInnerClasses(getPackageClassFqName(packageFQN)).getInternalName(); + } + public static boolean isPackageClassFqName(@NotNull FqName fqName) { return !fqName.isRoot() && getPackageClassFqName(fqName.parent()).equals(fqName); } diff --git a/core/descriptors/src/org/jetbrains/jet/lang/resolve/DescriptorUtils.java b/core/descriptors/src/org/jetbrains/jet/lang/resolve/DescriptorUtils.java index fd07e32b8ca..b9c443231cb 100644 --- a/core/descriptors/src/org/jetbrains/jet/lang/resolve/DescriptorUtils.java +++ b/core/descriptors/src/org/jetbrains/jet/lang/resolve/DescriptorUtils.java @@ -17,8 +17,6 @@ package org.jetbrains.jet.lang.resolve; import com.google.common.base.Predicate; -import com.google.common.collect.Lists; -import com.google.common.collect.Sets; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.jet.lang.descriptors.*; @@ -33,7 +31,6 @@ import org.jetbrains.jet.lang.types.*; import org.jetbrains.jet.lang.types.checker.JetTypeChecker; import org.jetbrains.jet.lang.types.lang.KotlinBuiltIns; -import javax.rmi.CORBA.ClassDesc; import java.util.ArrayList; import java.util.Collection; import java.util.List; @@ -45,19 +42,6 @@ public class DescriptorUtils { private DescriptorUtils() { } - @NotNull - public static D substituteBounds(@NotNull D functionDescriptor) { - List typeParameters = functionDescriptor.getTypeParameters(); - if (typeParameters.isEmpty()) return functionDescriptor; - - // TODO: this does not handle any recursion in the bounds - @SuppressWarnings("unchecked") - D substitutedFunction = (D) functionDescriptor.substitute(DescriptorSubstitutor.createUpperBoundsSubstitutor(typeParameters)); - assert substitutedFunction != null : "Substituting upper bounds should always be legal"; - - return substitutedFunction; - } - @Nullable public static ReceiverParameterDescriptor getExpectedThisObjectIfNeeded(@NotNull DeclarationDescriptor containingDeclaration) { if (containingDeclaration instanceof ClassDescriptor) { @@ -72,38 +56,7 @@ public class DescriptorUtils { } /** - * The primary case for local extensions is the following: - * - * I had a locally declared extension function or a local variable of function type called foo - * And I called it on my x - * Now, someone added function foo() to the class of x - * My code should not change - * - * thus - * - * local extension prevail over members (and members prevail over all non-local extensions) - */ - public static boolean isLocal(DeclarationDescriptor containerOfTheCurrentLocality, DeclarationDescriptor candidate) { - if (candidate instanceof ValueParameterDescriptor) { - return true; - } - DeclarationDescriptor parent = candidate.getContainingDeclaration(); - if (!(parent instanceof FunctionDescriptor)) { - return false; - } - FunctionDescriptor functionDescriptor = (FunctionDescriptor) parent; - DeclarationDescriptor current = containerOfTheCurrentLocality; - while (current != null) { - if (current == functionDescriptor) { - return true; - } - current = current.getContainingDeclaration(); - } - return false; - } - - /** - * descriptor may be local itself or have a local ancestor + * Descriptor may be local itself or have a local ancestor */ public static boolean isLocal(@NotNull DeclarationDescriptor descriptor) { DeclarationDescriptor current = descriptor; @@ -166,18 +119,6 @@ public class DescriptorUtils { return getContainingModule(first).equals(getContainingModule(second)); } - @Nullable - public static DeclarationDescriptor findTopLevelParent(@NotNull DeclarationDescriptor declarationDescriptor) { - DeclarationDescriptor descriptor = declarationDescriptor; - if (declarationDescriptor instanceof PropertyAccessorDescriptor) { - descriptor = ((PropertyAccessorDescriptor) descriptor).getCorrespondingProperty(); - } - while (!(descriptor == null || isTopLevelDeclaration(descriptor))) { - descriptor = descriptor.getContainingDeclaration(); - } - return descriptor; - } - @Nullable public static D getParentOfType( @Nullable DeclarationDescriptor descriptor, @@ -372,55 +313,9 @@ public class DescriptorUtils { return (ClassDescriptor) classifier; } - @NotNull - public static ConstructorDescriptor getConstructorOfDataClass(ClassDescriptor classDescriptor) { - ConstructorDescriptor descriptor = getConstructorDescriptorIfOnlyOne(classDescriptor); - assert descriptor != null : "Data class must have only one constructor: " + classDescriptor.getConstructors(); - return descriptor; - } - - @NotNull - public static ConstructorDescriptor getConstructorOfSingletonObject(ClassDescriptor classDescriptor) { - ConstructorDescriptor descriptor = getConstructorDescriptorIfOnlyOne(classDescriptor); - assert descriptor != null : "Class of singleton object must have only one constructor: " + classDescriptor.getConstructors(); - return descriptor; - } - - @Nullable - private static ConstructorDescriptor getConstructorDescriptorIfOnlyOne(ClassDescriptor classDescriptor) { - Collection constructors = classDescriptor.getConstructors(); - return constructors.size() != 1 ? null : constructors.iterator().next(); - } - @Nullable public static JetType getReceiverParameterType(@Nullable ReceiverParameterDescriptor receiverParameterDescriptor) { - if (receiverParameterDescriptor == null) { - return null; - } - return receiverParameterDescriptor.getType(); - } - - @NotNull - public static JetType getVarargParameterType(@NotNull JetType elementType) { - JetType primitiveArrayType = KotlinBuiltIns.getInstance().getPrimitiveArrayJetTypeByPrimitiveJetType(elementType); - return primitiveArrayType != null ? primitiveArrayType : KotlinBuiltIns.getInstance().getArrayType(Variance.INVARIANT, elementType); - } - - @NotNull - public static List getValueParametersTypes(@NotNull List valueParameters) { - List parameterTypes = Lists.newArrayList(); - for (ValueParameterDescriptor parameter : valueParameters) { - parameterTypes.add(parameter.getType()); - } - return parameterTypes; - } - - public static boolean isInsideOuterClassOrItsSubclass(@Nullable DeclarationDescriptor nested, @NotNull ClassDescriptor outer) { - if (nested == null) return false; - - if (nested instanceof ClassDescriptor && isSubclass((ClassDescriptor) nested, outer)) return true; - - return isInsideOuterClassOrItsSubclass(nested.getContainingDeclaration(), outer); + return receiverParameterDescriptor == null ? null : receiverParameterDescriptor.getType(); } public static boolean isConstructorOfStaticNestedClass(@Nullable CallableDescriptor descriptor) { @@ -437,12 +332,6 @@ public class DescriptorUtils { !((ClassDescriptor) descriptor).isInner(); } - @Nullable - public static ClassDescriptor getContainingClass(@NotNull JetScope scope) { - DeclarationDescriptor containingDeclaration = scope.getContainingDeclaration(); - return getParentOfType(containingDeclaration, ClassDescriptor.class, false); - } - @NotNull public static JetScope getStaticNestedClassesScope(@NotNull ClassDescriptor descriptor) { JetScope innerClassesScope = descriptor.getUnsubstitutedInnerClassesScope(); @@ -468,18 +357,6 @@ public class DescriptorUtils { && methodTypeParameters.isEmpty(); } - @NotNull - public static Set getAllSuperClasses(@NotNull ClassDescriptor klass) { - Set allSupertypes = TypeUtils.getAllSupertypes(klass.getDefaultType()); - Set allSuperclasses = Sets.newHashSet(); - for (JetType supertype : allSupertypes) { - ClassDescriptor superclass = TypeUtils.getClassDescriptor(supertype); - assert superclass != null; - allSuperclasses.add(superclass); - } - return allSuperclasses; - } - /** * @return true iff {@code descriptor}'s first non-class container is a package */ @@ -507,17 +384,6 @@ public class DescriptorUtils { return descriptor; } - public static boolean isPropertyCompileTimeConstant(@NotNull VariableDescriptor descriptor) { - if (descriptor.isVar()) { - return false; - } - if (isClassObject(descriptor.getContainingDeclaration()) || isTopLevelDeclaration(descriptor)) { - JetType type = descriptor.getType(); - return KotlinBuiltIns.getInstance().isPrimitiveType(type) || KotlinBuiltIns.getInstance().getStringType().equals(type); - } - return false; - } - public static boolean shouldRecordInitializerForProperty(@NotNull VariableDescriptor variable, @NotNull JetType type) { if (variable.isVar() || type.isError()) return false; diff --git a/core/descriptors/src/org/jetbrains/jet/lang/resolve/calls/inference/TypeBoundsImpl.java b/core/descriptors/src/org/jetbrains/jet/lang/resolve/calls/inference/TypeBoundsImpl.java index cb08c23f4b7..edc9d573c28 100644 --- a/core/descriptors/src/org/jetbrains/jet/lang/resolve/calls/inference/TypeBoundsImpl.java +++ b/core/descriptors/src/org/jetbrains/jet/lang/resolve/calls/inference/TypeBoundsImpl.java @@ -19,16 +19,17 @@ package org.jetbrains.jet.lang.resolve.calls.inference; import com.google.common.collect.Lists; import com.google.common.collect.Sets; import com.intellij.openapi.util.Condition; -import com.intellij.openapi.util.Pair; import com.intellij.util.containers.ContainerUtil; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.jet.lang.descriptors.TypeParameterDescriptor; +import org.jetbrains.jet.lang.resolve.constants.IntegerValueTypeConstructor; import org.jetbrains.jet.lang.types.*; import org.jetbrains.jet.lang.types.checker.JetTypeChecker; import java.util.Collection; import java.util.Collections; +import java.util.LinkedHashSet; import java.util.Set; import static org.jetbrains.jet.lang.resolve.calls.inference.TypeBounds.BoundKind.LOWER_BOUND; @@ -167,10 +168,9 @@ public class TypeBoundsImpl implements TypeBounds { } values.addAll(exactBounds); - Pair, Collection> pair = - TypeUtils.filterNumberTypes(filterBounds(bounds, LOWER_BOUND, values)); - Collection generalLowerBounds = pair.getFirst(); - Collection numberLowerBounds = pair.getSecond(); + Collection numberLowerBounds = new LinkedHashSet(); + Collection generalLowerBounds = new LinkedHashSet(); + filterNumberTypes(filterBounds(bounds, LOWER_BOUND, values), numberLowerBounds, generalLowerBounds); JetType superTypeOfLowerBounds = CommonSupertypes.commonSupertypeForNonDenotableTypes(generalLowerBounds); if (tryPossibleAnswer(superTypeOfLowerBounds)) { @@ -209,6 +209,21 @@ public class TypeBoundsImpl implements TypeBounds { return values; } + private static void filterNumberTypes( + @NotNull Collection types, + @NotNull Collection numberTypes, + @NotNull Collection otherTypes + ) { + for (JetType type : types) { + if (type.getConstructor() instanceof IntegerValueTypeConstructor) { + numberTypes.add(type); + } + else { + otherTypes.add(type); + } + } + } + private boolean tryPossibleAnswer(@Nullable JetType possibleAnswer) { if (possibleAnswer == null) return false; if (!possibleAnswer.getConstructor().isDenotable()) return false; diff --git a/core/descriptors/src/org/jetbrains/jet/lang/types/DescriptorSubstitutor.java b/core/descriptors/src/org/jetbrains/jet/lang/types/DescriptorSubstitutor.java index 3615141469b..b6c3e9aa16f 100644 --- a/core/descriptors/src/org/jetbrains/jet/lang/types/DescriptorSubstitutor.java +++ b/core/descriptors/src/org/jetbrains/jet/lang/types/DescriptorSubstitutor.java @@ -1,5 +1,5 @@ /* - * Copyright 2010-2013 JetBrains s.r.o. + * Copyright 2010-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -16,38 +16,28 @@ package org.jetbrains.jet.lang.types; -import com.google.common.base.Function; -import com.google.common.collect.Collections2; -import com.google.common.collect.Maps; import org.jetbrains.annotations.NotNull; -import org.jetbrains.jet.lang.descriptors.ClassifierDescriptor; import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor; import org.jetbrains.jet.lang.descriptors.TypeParameterDescriptor; import org.jetbrains.jet.lang.descriptors.impl.TypeParameterDescriptorImpl; -import org.jetbrains.jet.utils.DFS; -import java.util.Collections; +import java.util.HashMap; import java.util.List; import java.util.Map; public class DescriptorSubstitutor { - - private static final Function PROJECTIONS_TO_TYPES = new Function() { - @Override - public JetType apply(TypeProjection projection) { - return projection.getType(); - } - }; + private DescriptorSubstitutor() { + } @NotNull public static TypeSubstitutor substituteTypeParameters( @NotNull List typeParameters, @NotNull final TypeSubstitutor originalSubstitutor, @NotNull DeclarationDescriptor newContainingDeclaration, - @NotNull List result) { - final Map mutableSubstitution = Maps.newHashMap(); + @NotNull List result + ) { + final Map mutableSubstitution = new HashMap(); TypeSubstitutor substitutor = TypeSubstitutor.create(new TypeSubstitution() { - @Override public TypeProjection get(TypeConstructor key) { if (originalSubstitutor.inRange(key)) { @@ -66,7 +56,9 @@ public class DescriptorSubstitutor { return "DescriptorSubstitutor.substituteTypeParameters(" + mutableSubstitution + " / " + originalSubstitutor.getSubstitution() + ")"; } }); - Map substitutedMap = Maps.newHashMap(); + + Map substitutedMap = + new HashMap(); for (TypeParameterDescriptor descriptor : typeParameters) { TypeParameterDescriptorImpl substituted = TypeParameterDescriptorImpl.createForFurtherModification( newContainingDeclaration, @@ -74,7 +66,8 @@ public class DescriptorSubstitutor { descriptor.isReified(), descriptor.getVariance(), descriptor.getName(), - descriptor.getIndex()); + descriptor.getIndex() + ); substituted.setInitialized(); mutableSubstitution.put(descriptor.getTypeConstructor(), new TypeProjectionImpl(substituted.getDefaultType())); @@ -92,72 +85,4 @@ public class DescriptorSubstitutor { return substitutor; } - - - - @NotNull - public static TypeSubstitutor createUpperBoundsSubstitutor( - @NotNull List typeParameters - ) { - Map mutableSubstitution = Maps.newHashMap(); - TypeSubstitutor substitutor = TypeSubstitutor.create(mutableSubstitution); - - // todo assert: no loops - for (TypeParameterDescriptor descriptor : topologicallySortTypeParameters(typeParameters)) { - JetType upperBoundsAsType = descriptor.getUpperBoundsAsType(); - JetType substitutedUpperBoundsAsType = substitutor.substitute(upperBoundsAsType, Variance.INVARIANT); - mutableSubstitution.put(descriptor.getTypeConstructor(), new TypeProjectionImpl(substitutedUpperBoundsAsType)); - } - - return substitutor; - } - - private static List topologicallySortTypeParameters(final List typeParameters) { - // In the end, we want every parameter to have no references to those after it in the list - // This gives us the reversed order: the one that refers to everybody else comes first - List topOrder = DFS.topologicalOrder( - typeParameters, - new DFS.Neighbors() { - @NotNull - @Override - public Iterable getNeighbors(TypeParameterDescriptor current) { - return getTypeParametersFromUpperBounds(current, typeParameters); - } - }); - - assert topOrder.size() == typeParameters.size() : "All type parameters must be visited, but only " + topOrder + " were"; - - // Now, the one that refers to everybody else stands in the last position - Collections.reverse(topOrder); - return topOrder; - } - - private static List getTypeParametersFromUpperBounds( - TypeParameterDescriptor current, - final List typeParameters - ) { - return DFS.dfs( - current.getUpperBounds(), - new DFS.Neighbors() { - @NotNull - @Override - public Iterable getNeighbors(JetType current) { - return Collections2.transform(current.getArguments(), PROJECTIONS_TO_TYPES); - } - }, - new DFS.NodeHandlerWithListResult() { - @Override - public boolean beforeChildren(JetType current) { - ClassifierDescriptor declarationDescriptor = current.getConstructor().getDeclarationDescriptor(); - // typeParameters in a list, but it contains very few elements, so it's fine to call contains() on it - //noinspection SuspiciousMethodCalls - if (typeParameters.contains(declarationDescriptor)) { - result.add((TypeParameterDescriptor) declarationDescriptor); - } - - return true; - } - } - ); - } } diff --git a/core/descriptors/src/org/jetbrains/jet/lang/types/TypeUtils.java b/core/descriptors/src/org/jetbrains/jet/lang/types/TypeUtils.java index ecebe07b469..ea62956e631 100644 --- a/core/descriptors/src/org/jetbrains/jet/lang/types/TypeUtils.java +++ b/core/descriptors/src/org/jetbrains/jet/lang/types/TypeUtils.java @@ -21,7 +21,6 @@ import com.google.common.collect.Collections2; import com.google.common.collect.Lists; import com.google.common.collect.Maps; import com.google.common.collect.Sets; -import com.intellij.openapi.util.Pair; import com.intellij.util.Processor; import kotlin.Function1; import kotlin.KotlinPackage; @@ -420,6 +419,20 @@ public class TypeUtils { return false; } + /** + * A work-around of the generic nullability problem in the type checker + * @return true if a value of this type can be null + */ + public static boolean isNullableType(@NotNull JetType type) { + if (type.isNullable()) { + return true; + } + if (type.getConstructor().getDeclarationDescriptor() instanceof TypeParameterDescriptor) { + return hasNullableSuperType(type); + } + return false; + } + public static boolean hasNullableSuperType(@NotNull JetType type) { if (type.getConstructor().getDeclarationDescriptor() instanceof ClassDescriptor) { // A class/trait cannot have a nullable supertype @@ -541,12 +554,12 @@ public class TypeUtils { private static Set getIntersectionOfSupertypes(@NotNull Collection types) { Set upperBounds = Sets.newHashSet(); for (JetType type : types) { - Set supertypes = Sets.newHashSet(type.getConstructor().getSupertypes()); + Collection supertypes = type.getConstructor().getSupertypes(); if (upperBounds.isEmpty()) { upperBounds.addAll(supertypes); } else { - upperBounds = Sets.intersection(upperBounds, supertypes); + upperBounds.retainAll(supertypes); } } return upperBounds; @@ -593,21 +606,6 @@ public class TypeUtils { return getDefaultPrimitiveNumberType(numberValueTypeConstructor); } - @NotNull - public static Pair, Collection> filterNumberTypes(@NotNull Collection types) { - Collection numberTypes = Sets.newLinkedHashSet(); - Collection otherTypes = Sets.newLinkedHashSet(); - for (JetType type : types) { - if (type.getConstructor() instanceof IntegerValueTypeConstructor) { - numberTypes.add(type); - } - else { - otherTypes.add(type); - } - } - return Pair.create(otherTypes, numberTypes); - } - public static List topologicallySortSuperclassesAndRecordAllInstances( @NotNull JetType type, @NotNull final Map> constructorToAllInstances, diff --git a/core/runtime.jvm/src/kotlin/jvm/internal/Ref.java b/core/runtime.jvm/src/kotlin/jvm/internal/Ref.java index 7e46c5a4cec..962ea0ccad0 100644 --- a/core/runtime.jvm/src/kotlin/jvm/internal/Ref.java +++ b/core/runtime.jvm/src/kotlin/jvm/internal/Ref.java @@ -16,42 +16,89 @@ package kotlin.jvm.internal; +import java.lang.Override; + public class Ref { private Ref() {} public static final class ObjectRef { public volatile T element; + + @Override + public String toString() { + return String.valueOf(element); + } } public static final class ByteRef { public volatile byte element; + + @Override + public String toString() { + return String.valueOf(element); + } } public static final class ShortRef { public volatile short element; + + @Override + public String toString() { + return String.valueOf(element); + } } public static final class IntRef { public volatile int element; + + @Override + public String toString() { + return String.valueOf(element); + } } public static final class LongRef { public volatile long element; + + @Override + public String toString() { + return String.valueOf(element); + } } public static final class FloatRef { public volatile float element; + + @Override + public String toString() { + return String.valueOf(element); + } } public static final class DoubleRef { public volatile double element; + + @Override + public String toString() { + return String.valueOf(element); + } } public static final class CharRef { public volatile char element; + + @Override + public String toString() { + return String.valueOf(element); + } } public static final class BooleanRef { public volatile boolean element; + + @Override + public String toString() { + return String.valueOf(element); + } } } diff --git a/generators/src/org/jetbrains/jet/generators/tests/GenerateTests.kt b/generators/src/org/jetbrains/jet/generators/tests/GenerateTests.kt index 835a0d55f15..916edb20269 100644 --- a/generators/src/org/jetbrains/jet/generators/tests/GenerateTests.kt +++ b/generators/src/org/jetbrains/jet/generators/tests/GenerateTests.kt @@ -168,8 +168,12 @@ fun main(args: Array) { model("codegen/boxMultiFile", extension = null, recursive = false, testMethod = "doTestMultiFile") } + testClass(javaClass(), "BlackBoxAgainstJavaCodegenTestGenerated") { + model("codegen/boxAgainstJava", testMethod = "doTestAgainstJava") + } + testClass(javaClass(), "BlackBoxWithJavaCodegenTestGenerated") { - model("codegen/boxWithJava", testMethod = "doTestWithJava") + model("codegen/boxWithJava", testMethod = "doTestWithJava", extension = null, recursive = false) } testClass(javaClass(), "BlackBoxWithStdlibCodegenTestGenerated") { diff --git a/grammar/src/expressions.grm b/grammar/src/expressions.grm index 5b4bae7859e..39e547baaf0 100644 --- a/grammar/src/expressions.grm +++ b/grammar/src/expressions.grm @@ -104,7 +104,7 @@ postfixUnaryExpression // TODO: callSuffix is forbidden after callableReference, since parentheses will be used to provide parameter types callableReference - : userType? "::" SimpleName + : (userType "?"*)? "::" SimpleName ; // !!! When you add here, remember to update the FIRST set in the parser diff --git a/idea/src/org/jetbrains/jet/plugin/debugger/evaluate/KotlinEvaluationBuilder.kt b/idea/src/org/jetbrains/jet/plugin/debugger/evaluate/KotlinEvaluationBuilder.kt index 4ef6861a05d..b13a3920367 100644 --- a/idea/src/org/jetbrains/jet/plugin/debugger/evaluate/KotlinEvaluationBuilder.kt +++ b/idea/src/org/jetbrains/jet/plugin/debugger/evaluate/KotlinEvaluationBuilder.kt @@ -270,7 +270,7 @@ package packageForDebugger !FUNCTION! """ -private val packageInternalName = PackageClassUtils.getPackageClassFqName(FqName("packageForDebugger")).asString().replace(".", "/") +private val packageInternalName = PackageClassUtils.getPackageClassInternalName(FqName("packageForDebugger")) private fun createFileForDebugger(codeFragment: JetCodeFragment, extractedFunction: JetNamedFunction diff --git a/idea/src/org/jetbrains/jet/plugin/highlighter/DeprecatedAnnotationVisitor.java b/idea/src/org/jetbrains/jet/plugin/highlighter/DeprecatedAnnotationVisitor.java index 7fceaa5ab24..3924ddde1d0 100644 --- a/idea/src/org/jetbrains/jet/plugin/highlighter/DeprecatedAnnotationVisitor.java +++ b/idea/src/org/jetbrains/jet/plugin/highlighter/DeprecatedAnnotationVisitor.java @@ -229,18 +229,28 @@ public class DeprecatedAnnotationVisitor extends AfterAnalysisHighlightingVisito } private static String composeTooltipString(@NotNull DeclarationDescriptor declarationDescriptor, @NotNull AnnotationDescriptor descriptor) { - return "'" + getDescriptorString(declarationDescriptor) + "' is deprecated. " + getMessageFromAnnotationDescriptor(descriptor); + String fact = "'" + getDescriptorString(declarationDescriptor) + "' is deprecated."; + String message = getMessageFromAnnotationDescriptor(descriptor); + return message == null ? fact : fact + " " + message; } + @Nullable private static String getMessageFromAnnotationDescriptor(@NotNull AnnotationDescriptor descriptor) { ClassDescriptor classDescriptor = TypeUtils.getClassDescriptor(descriptor.getType()); - assert classDescriptor != null : "ClassDescriptor for kotlin.deprecated mustn't be null"; - ValueParameterDescriptor parameter = - DescriptorResolverUtils.getAnnotationParameterByName(DEFAULT_ANNOTATION_MEMBER_NAME, classDescriptor); - assert parameter != null : "kotlin.deprecated must have one parameter called value"; - CompileTimeConstant valueArgument = descriptor.getValueArgument(parameter); - assert valueArgument != null : "kotlin.deprecated must have value argument"; - return (String) valueArgument.getValue(); + if (classDescriptor != null) { + ValueParameterDescriptor parameter = + DescriptorResolverUtils.getAnnotationParameterByName(DEFAULT_ANNOTATION_MEMBER_NAME, classDescriptor); + if (parameter != null) { + CompileTimeConstant valueArgument = descriptor.getValueArgument(parameter); + if (valueArgument != null) { + Object value = valueArgument.getValue(); + if (value instanceof String) { + return String.valueOf(value); + } + } + } + } + return null; } private static String getDescriptorString(@NotNull DeclarationDescriptor descriptor) { diff --git a/idea/src/org/jetbrains/jet/plugin/libraries/DecompiledNavigationUtils.java b/idea/src/org/jetbrains/jet/plugin/libraries/DecompiledNavigationUtils.java index 1d5023991d5..e5a8a3ffd9d 100644 --- a/idea/src/org/jetbrains/jet/plugin/libraries/DecompiledNavigationUtils.java +++ b/idea/src/org/jetbrains/jet/plugin/libraries/DecompiledNavigationUtils.java @@ -29,6 +29,7 @@ import org.jetbrains.jet.lang.resolve.DescriptorUtils; import org.jetbrains.jet.lang.resolve.java.PackageClassUtils; import org.jetbrains.jet.lang.resolve.kotlin.VirtualFileFinder; import org.jetbrains.jet.lang.resolve.name.FqName; +import org.jetbrains.jet.lang.types.expressions.ExpressionTypingUtils; import static org.jetbrains.jet.lang.resolve.DescriptorUtils.getFqName; import static org.jetbrains.jet.lang.resolve.DescriptorUtils.getFqNameSafe; @@ -113,7 +114,7 @@ public final class DecompiledNavigationUtils { } if (containerDescriptor instanceof ClassDescriptor) { if (containerDescriptor.getContainingDeclaration() instanceof ClassDescriptor - || DescriptorUtils.isLocal(containerDescriptor.getContainingDeclaration(), containerDescriptor)) { + || ExpressionTypingUtils.isLocal(containerDescriptor.getContainingDeclaration(), containerDescriptor)) { return getContainerFqName(containerDescriptor.getContainingDeclaration()); } return getFqNameSafe(containerDescriptor); diff --git a/idea/testData/highlighter/deprecated/Invalid.kt b/idea/testData/highlighter/deprecated/Invalid.kt new file mode 100644 index 00000000000..a8c2ed95adc --- /dev/null +++ b/idea/testData/highlighter/deprecated/Invalid.kt @@ -0,0 +1,11 @@ +deprecated() +fun foo() {} +deprecated(false) +fun boo() {} + +fun far() = foo() + +fun bar() = boo() + +// NO_CHECK_INFOS +// NO_CHECK_WEAK_WARNINGS diff --git a/idea/tests/org/jetbrains/jet/findUsages/JetFindUsagesTestGenerated.java b/idea/tests/org/jetbrains/jet/findUsages/JetFindUsagesTestGenerated.java index 345e7fb76ae..575b522c734 100644 --- a/idea/tests/org/jetbrains/jet/findUsages/JetFindUsagesTestGenerated.java +++ b/idea/tests/org/jetbrains/jet/findUsages/JetFindUsagesTestGenerated.java @@ -16,14 +16,17 @@ package org.jetbrains.jet.findUsages; +import junit.framework.Assert; import junit.framework.Test; import junit.framework.TestSuite; + +import java.io.File; +import java.util.regex.Pattern; import org.jetbrains.jet.JetTestUtils; import org.jetbrains.jet.test.InnerTestClasses; import org.jetbrains.jet.test.TestMetadata; -import java.io.File; -import java.util.regex.Pattern; +import org.jetbrains.jet.findUsages.AbstractJetFindUsagesTest; /** This class is generated by {@link org.jetbrains.jet.generators.tests.TestsPackage}. DO NOT MODIFY MANUALLY */ @SuppressWarnings("all") diff --git a/idea/tests/org/jetbrains/jet/plugin/highlighter/HighlightingTestGenerated.java b/idea/tests/org/jetbrains/jet/plugin/highlighter/HighlightingTestGenerated.java index 4341b8c45ad..0ef47a5fff0 100644 --- a/idea/tests/org/jetbrains/jet/plugin/highlighter/HighlightingTestGenerated.java +++ b/idea/tests/org/jetbrains/jet/plugin/highlighter/HighlightingTestGenerated.java @@ -108,6 +108,11 @@ public class HighlightingTestGenerated extends AbstractHighlightingTest { doTest("idea/testData/highlighter/deprecated/Inc.kt"); } + @TestMetadata("Invalid.kt") + public void testInvalid() throws Exception { + doTest("idea/testData/highlighter/deprecated/Invalid.kt"); + } + @TestMetadata("Invoke.kt") public void testInvoke() throws Exception { doTest("idea/testData/highlighter/deprecated/Invoke.kt"); diff --git a/js/js.libraries/src/core/javautil.kt b/js/js.libraries/src/core/javautil.kt index 9113fb56c59..2713cadedbc 100644 --- a/js/js.libraries/src/core/javautil.kt +++ b/js/js.libraries/src/core/javautil.kt @@ -1,5 +1,11 @@ package java.util +native +private val DEFAULT_INITIAL_CAPACITY = 16 + +native +private val DEFAULT_LOAD_FACTOR = 0.75f + library public trait Comparator { fun compare(obj1: T, obj2: T): Int; @@ -67,8 +73,9 @@ public open class LinkedList() : AbstractList() { } library -public open class HashSet(capacity: Int = 0) : AbstractCollection(), MutableSet { -} +public open class HashSet( + initialCapacity: Int = DEFAULT_INITIAL_CAPACITY, loadFactor: Float = DEFAULT_LOAD_FACTOR +) : AbstractCollection(), MutableSet library public trait SortedSet : Set { @@ -79,11 +86,12 @@ public open class TreeSet() : AbstractCollection(), MutableSet, SortedS } library -public open class LinkedHashSet() : AbstractCollection(), MutableSet { -} +public open class LinkedHashSet( + initialCapacity: Int = DEFAULT_INITIAL_CAPACITY, loadFactor: Float = DEFAULT_LOAD_FACTOR +) : HashSet(initialCapacity, loadFactor), MutableSet library -public open class HashMap(capacity: Int = 0) : MutableMap { +public open class HashMap(initialCapacity: Int = DEFAULT_INITIAL_CAPACITY, loadFactor: Float = DEFAULT_LOAD_FACTOR) : MutableMap { public override fun size(): Int = js.noImpl public override fun isEmpty(): Boolean = js.noImpl public override fun get(key: Any?): V? = js.noImpl @@ -99,7 +107,9 @@ public open class HashMap(capacity: Int = 0) : MutableMap { } library -public open class LinkedHashMap(capacity: Int = 0) : HashMap(capacity) +public open class LinkedHashMap( + initialCapacity: Int = DEFAULT_INITIAL_CAPACITY, loadFactor: Float = DEFAULT_LOAD_FACTOR, accessOrder: Boolean = false +) : HashMap(initialCapacity, loadFactor) library public class NoSuchElementException(message: String? = null) : Exception() {} diff --git a/js/js.libraries/src/core/javautilCode.kt b/js/js.libraries/src/core/javautilCode.kt new file mode 100644 index 00000000000..92121fda205 --- /dev/null +++ b/js/js.libraries/src/core/javautilCode.kt @@ -0,0 +1,41 @@ +/* + * Copyright 2010-2014 JetBrains s.r.o. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package java.util + +public fun HashSet(c: Collection): HashSet { + val set: HashSet = HashSet(c.size()) + set.addAll(c) + return set +} + +public fun LinkedHashSet(c: Collection): HashSet { + val set: LinkedHashSet = LinkedHashSet(c.size()) + set.addAll(c) + return set +} + +public fun HashMap(m: Map): HashMap { + val map: HashMap = HashMap(m.size()) + map.putAll(m) + return map +} + +public fun LinkedHashMap(m: Map): LinkedHashMap { + val map: LinkedHashMap = LinkedHashMap(m.size()) + map.putAll(m) + return map +} diff --git a/js/js.tests/test/org/jetbrains/k2js/test/semantics/CastTest.java b/js/js.tests/test/org/jetbrains/k2js/test/semantics/CastTest.java index 74cab0ed722..84a795ec856 100644 --- a/js/js.tests/test/org/jetbrains/k2js/test/semantics/CastTest.java +++ b/js/js.tests/test/org/jetbrains/k2js/test/semantics/CastTest.java @@ -32,6 +32,10 @@ public final class CastTest extends AbstractExpressionTest { checkFooBoxIsOk(); } + public void testCastToGenericType() throws Exception { + checkFooBoxIsOk(); + } + public void testSmartCastInExtensionFunction() throws Exception { checkFooBoxIsOk(); } diff --git a/js/js.translator/src/org/jetbrains/k2js/config/Config.java b/js/js.translator/src/org/jetbrains/k2js/config/Config.java index aea3607710f..fdf9cc33357 100644 --- a/js/js.translator/src/org/jetbrains/k2js/config/Config.java +++ b/js/js.translator/src/org/jetbrains/k2js/config/Config.java @@ -101,6 +101,7 @@ public abstract class Config { public static final List LIB_FILE_NAMES_DEPENDENT_ON_STDLIB = Arrays.asList( "/core/stringsCode.kt", "/stdlib/domCode.kt", + "/core/javautilCode.kt", "/stdlib/jutilCode.kt", "/stdlib/testCode.kt" ); diff --git a/js/js.translator/src/org/jetbrains/k2js/translate/expression/ExpressionVisitor.java b/js/js.translator/src/org/jetbrains/k2js/translate/expression/ExpressionVisitor.java index ad27cb000e9..bff86d88814 100644 --- a/js/js.translator/src/org/jetbrains/k2js/translate/expression/ExpressionVisitor.java +++ b/js/js.translator/src/org/jetbrains/k2js/translate/expression/ExpressionVisitor.java @@ -17,7 +17,6 @@ package org.jetbrains.k2js.translate.expression; import com.google.dart.compiler.backend.js.ast.*; -import com.intellij.psi.tree.IElementType; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.jet.lang.descriptors.DeclarationDescriptor; @@ -29,6 +28,7 @@ import org.jetbrains.jet.lang.resolve.BindingContextUtils; import org.jetbrains.jet.lang.resolve.constants.CompileTimeConstant; import org.jetbrains.jet.lang.resolve.constants.NullValue; import org.jetbrains.jet.lang.types.JetType; +import org.jetbrains.jet.lang.types.TypeUtils; import org.jetbrains.jet.lexer.JetTokens; import org.jetbrains.k2js.translate.context.TemporaryVariable; import org.jetbrains.k2js.translate.context.TranslationContext; @@ -347,9 +347,12 @@ public final class ExpressionVisitor extends TranslatorVisitor { if (expression.getOperationReference().getReferencedNameElementType() != JetTokens.AS_KEYWORD) return jsExpression.source(expression); - JetType rightType = BindingContextUtils.getNotNull(context.bindingContext(), BindingContext.TYPE, expression.getRight()); + JetTypeReference right = expression.getRight(); + assert right != null; + + JetType rightType = BindingContextUtils.getNotNull(context.bindingContext(), BindingContext.TYPE, right); JetType leftType = BindingContextUtils.getNotNull(context.bindingContext(), BindingContext.EXPRESSION_TYPE, expression.getLeft()); - if (rightType.isNullable() || !leftType.isNullable()) { + if (TypeUtils.isNullableType(rightType) || !TypeUtils.isNullableType(leftType)) { return jsExpression.source(expression); } diff --git a/js/js.translator/testData/expression/cast/cases/castToGenericType.kt b/js/js.translator/testData/expression/cast/cases/castToGenericType.kt new file mode 100644 index 00000000000..09687e93127 --- /dev/null +++ b/js/js.translator/testData/expression/cast/cases/castToGenericType.kt @@ -0,0 +1,74 @@ +package foo + +class A(val s: String) + +fun castsNotNullToNullableT(a: Any) { + a as T + a as T? + a as? T + a as? T? +} + +fun castsNullableToNullableT(a: Any?) { + a as T + a as T? + a as? T + a as? T? +} + + +fun castsNotNullToNotNullT(a: Any) { + a as T + a as T? + a as? T + a as? T? +} + +fun castNullableToNotNullT(a: Any?) { + a as T +} + +fun castsNullableToNotNullT(a: Any?) { + a as T? + a as? T + a as? T? +} + +fun test(f: () -> Unit) { + try { + f() + } + catch(e: Exception) { + throw Exception("Failed in $f with unexpected exception $e") + } +} + +fun fails(f: () -> Unit) { + try { + f() + } + catch(e: Exception) { + return + } + + throw Exception("Expected an exception to be thrown from $f") +} + +fun box(): String { + val a = A("OK") + + test { castsNotNullToNullableT(a) } + + test { castsNullableToNullableT(a) } + test { castsNullableToNullableT(null) } + + test { castsNotNullToNotNullT(a) } + + test { castsNullableToNotNullT(a) } + test { castsNullableToNotNullT(null) } + + test { castNullableToNotNullT(a) } + fails { castNullableToNotNullT(null) } + + return "OK" +} diff --git a/js/js.translator/testData/maps.js b/js/js.translator/testData/maps.js index 565bc253777..61e02737d8c 100644 --- a/js/js.translator/testData/maps.js +++ b/js/js.translator/testData/maps.js @@ -37,6 +37,14 @@ return this.value; }; + function hashMapPutAll (fromMap) { + var entries = fromMap.entrySet(); + var it = entries.iterator(); + while (it.hasNext()) { + var e = it.next(); + this.put_wn2jw4$(e.getKey(), e.getValue()); + } + } /** @const */ var FUNCTION = "function"; @@ -387,24 +395,8 @@ /** * @param {Hashtable.} hashtable - * @param {(function(Key, Value, Value): Value)=} conflictCallback */ - this.putAll_za3j1t$ = function (hashtable, conflictCallback) { - var entries = hashtable._entries(); - var entry, key, value, thisValue, i = entries.length; - var hasConflictCallback = (typeof conflictCallback == FUNCTION); - while (i--) { - entry = entries[i]; - key = entry[0]; - value = entry[1]; - - // Check for a conflict. The default behaviour is to overwrite the value for an existing key - if (hasConflictCallback && (thisValue = that.get(key))) { - value = conflictCallback(key, thisValue, value); - } - that.put_wn2jw4$(key, value); - } - }; + this.putAll_za3j1t$ = hashMapPutAll; this.clone = function () { var clone = new Hashtable(hashingFunctionParam, equalityFunctionParam); @@ -554,14 +546,7 @@ this.$size = 0; this.map = {}; }, - putAll_za3j1t$: function (fromMap) { - var map = fromMap.map; - for (var key in map) { - //noinspection JSUnfilteredForInLoop - this.map[key] = map[key]; - this.$size++; - } - }, + putAll_za3j1t$: hashMapPutAll, entrySet: function () { var result = new Kotlin.ComplexHashSet(); var map = this.map; diff --git a/libraries/pom.xml b/libraries/pom.xml index 736e5c92dab..545322b176b 100644 --- a/libraries/pom.xml +++ b/libraries/pom.xml @@ -83,6 +83,7 @@ tools/kotlin-gradle-plugin tools/kotlin-gradle-plugin-core tools/kotlin-maven-plugin + tools/kotlin-maven-plugin-test tools/kotlin-js-library tools/kotlin-js-tests tools/kotlin-js-tests-junit diff --git a/libraries/stdlib/src/kotlin/test/Test.kt b/libraries/stdlib/src/kotlin/test/Test.kt index d35700281d8..e76a0710c9a 100644 --- a/libraries/stdlib/src/kotlin/test/Test.kt +++ b/libraries/stdlib/src/kotlin/test/Test.kt @@ -13,7 +13,7 @@ public inline fun assertTrue(message: String, block: ()-> Boolean) { } /** Asserts that the given block returns true */ -public inline fun assertTrue(block: ()-> Boolean) : Unit = assertTrue("exprected true", block) +public inline fun assertTrue(block: ()-> Boolean) : Unit = assertTrue("expected true", block) /** Asserts that the given block returns false */ public inline fun assertNot(message: String, block: ()-> Boolean) { diff --git a/libraries/stdlib/test/js/MapJsTest.kt b/libraries/stdlib/test/js/MapJsTest.kt index 0ee938152ba..9e976453f7a 100644 --- a/libraries/stdlib/test/js/MapJsTest.kt +++ b/libraries/stdlib/test/js/MapJsTest.kt @@ -6,17 +6,53 @@ import java.util.* import org.junit.Test as test class ComplexMapJsTest : MapJsTest() { + // Helper function with generic parameter to force to use ComlpexHashMap + fun doTest>() { + HashMap() + HashMap(3) + HashMap(3, 0.5f) + val map = HashMap(createTestMap() as HashMap) + + assertEquals(KEYS.toNormalizedList(), map.keySet().toNormalizedList()) + assertEquals(VALUES.toNormalizedList(), map.values().toNormalizedList()) + } + test override fun constructors() { + doTest() + } + override fun > Collection.toNormalizedList(): List = this.toSortedList() // hashMapOf returns ComlpexHashMap because it is Generic override fun emptyMutableMap(): MutableMap = hashMapOf() } class PrimitiveMapJsTest : MapJsTest() { + test override fun constructors() { + HashMap() + HashMap(3) + HashMap(3, 0.5f) + + val map = HashMap(createTestMap()) + + assertEquals(KEYS.toNormalizedList(), map.keySet().toNormalizedList()) + assertEquals(VALUES.toNormalizedList(), map.values().toNormalizedList()) + } + override fun > Collection.toNormalizedList(): List = this.toSortedList() override fun emptyMutableMap(): MutableMap = HashMap() } class LinkedHashMapTest : MapJsTest() { + test override fun constructors() { + LinkedHashMap() + LinkedHashMap(3) + LinkedHashMap(3, 0.5f) + + val map = LinkedHashMap(createTestMap()) + + assertEquals(KEYS.toNormalizedList(), map.keySet().toNormalizedList()) + assertEquals(VALUES.toNormalizedList(), map.values().toNormalizedList()) + } + override fun > Collection.toNormalizedList(): List = this.toList() override fun emptyMutableMap(): MutableMap = LinkedHashMap() } @@ -284,6 +320,8 @@ abstract class MapJsTest { } } + test abstract fun constructors() + /* test fun createLinkedMap() { val map = linkedMapOf("c" to 3, "b" to 2, "a" to 1) diff --git a/libraries/stdlib/test/js/SetJsTest.kt b/libraries/stdlib/test/js/SetJsTest.kt index 0d2f8719823..6cf3a28a4a3 100644 --- a/libraries/stdlib/test/js/SetJsTest.kt +++ b/libraries/stdlib/test/js/SetJsTest.kt @@ -6,15 +6,50 @@ import java.util.HashSet import java.util.LinkedHashSet class ComplexSetJsTest : SetJsTest() { + // Helper function with generic parameter to force to use ComlpexHashMap + fun doTest() { + HashSet() + HashSet(3) + HashSet(3, 0.5f) + + val set = HashSet(data as HashSet) + + assertEquals(data, set) + } + + test override fun constructors() { + doTest() + } + // hashSetOf returns ComlpexHashSet because it is Generic override fun createEmptyMutableSet(): MutableSet = hashSetOf() } class PrimitiveSetJsTest : SetJsTest() { + test override fun constructors() { + HashSet() + HashSet(3) + HashSet(3, 0.5f) + + val set = HashSet(data) + + assertEquals(data, set) + } + override fun createEmptyMutableSet(): MutableSet = HashSet() } class LinkedHashSetTest : SetJsTest() { + test override fun constructors() { + LinkedHashSet() + LinkedHashSet(3) + LinkedHashSet(3, 0.5f) + + val set = LinkedHashSet(data) + + assertEquals(data, set) + } + override fun createEmptyMutableSet(): MutableSet = LinkedHashSet() } @@ -150,6 +185,8 @@ abstract class SetJsTest { } } + test abstract fun constructors() + //Helpers abstract fun createEmptyMutableSet(): MutableSet diff --git a/libraries/tools/kotlin-maven-plugin-test/.gitignore b/libraries/tools/kotlin-maven-plugin-test/.gitignore new file mode 100644 index 00000000000..b97b22398a9 --- /dev/null +++ b/libraries/tools/kotlin-maven-plugin-test/.gitignore @@ -0,0 +1 @@ +local-repo diff --git a/libraries/tools/kotlin-maven-plugin-test/pom.xml b/libraries/tools/kotlin-maven-plugin-test/pom.xml new file mode 100644 index 00000000000..45d894a6ed1 --- /dev/null +++ b/libraries/tools/kotlin-maven-plugin-test/pom.xml @@ -0,0 +1,78 @@ + + + + kotlin-project + org.jetbrains.kotlin + 0.1-SNAPSHOT + ../../pom.xml + + 4.0.0 + + kotlin-maven-plugin-test + + + + org.jetbrains.kotlin + kotlin-maven-plugin + ${project.version} + + + org.jetbrains.kotlin + kotlin-runtime + ${project.version} + + + + + + + integrationTest + + true + + + + + maven-invoker-plugin + 1.5 + + src/it + ${project.build.directory}/it + + */pom.xml + + + + local-repo + verify.bsh + true + + + + integration-test + + + install + run + + + + + + + + + + + noTest + + false + + + + diff --git a/libraries/tools/kotlin-maven-plugin/src/it/settings.xml b/libraries/tools/kotlin-maven-plugin-test/src/it/settings.xml similarity index 100% rename from libraries/tools/kotlin-maven-plugin/src/it/settings.xml rename to libraries/tools/kotlin-maven-plugin-test/src/it/settings.xml diff --git a/libraries/tools/kotlin-maven-plugin/src/it/test-classpath/pom.xml b/libraries/tools/kotlin-maven-plugin-test/src/it/test-classpath/pom.xml similarity index 82% rename from libraries/tools/kotlin-maven-plugin/src/it/test-classpath/pom.xml rename to libraries/tools/kotlin-maven-plugin-test/src/it/test-classpath/pom.xml index c6f3fa142f1..a0eab05def2 100644 --- a/libraries/tools/kotlin-maven-plugin/src/it/test-classpath/pom.xml +++ b/libraries/tools/kotlin-maven-plugin-test/src/it/test-classpath/pom.xml @@ -4,18 +4,14 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - org.jetbrains.kotlin.it + + org.jetbrains.kotlin + kotlin-project + 0.1-SNAPSHOT + ../../pom.xml + + test-classpath - 1.0 - Test Hello World project - - - Test the kotlin-maven-plugin:compile goal on test-classpath project. - - - - 0.1-SNAPSHOT - @@ -23,6 +19,11 @@ junit 4.9 + + org.jetbrains.kotlin + kotlin-runtime + ${project.version} + @@ -45,14 +46,12 @@ - ${project.basedir}/src/main/kotlin - kotlin-maven-plugin org.jetbrains.kotlin - ${kotlin.version} + ${project.version} compile diff --git a/libraries/tools/kotlin-maven-plugin/src/it/test-classpath/src/main/kotlin/org/jetbrains/HelloWorld.kt b/libraries/tools/kotlin-maven-plugin-test/src/it/test-classpath/src/main/kotlin/org/jetbrains/HelloWorld.kt similarity index 100% rename from libraries/tools/kotlin-maven-plugin/src/it/test-classpath/src/main/kotlin/org/jetbrains/HelloWorld.kt rename to libraries/tools/kotlin-maven-plugin-test/src/it/test-classpath/src/main/kotlin/org/jetbrains/HelloWorld.kt diff --git a/libraries/tools/kotlin-maven-plugin/src/it/test-classpath/src/test/java/org/jetbrains/HelloWorldJavaTest.java b/libraries/tools/kotlin-maven-plugin-test/src/it/test-classpath/src/test/java/org/jetbrains/HelloWorldJavaTest.java similarity index 100% rename from libraries/tools/kotlin-maven-plugin/src/it/test-classpath/src/test/java/org/jetbrains/HelloWorldJavaTest.java rename to libraries/tools/kotlin-maven-plugin-test/src/it/test-classpath/src/test/java/org/jetbrains/HelloWorldJavaTest.java diff --git a/libraries/tools/kotlin-maven-plugin-test/src/it/test-classpath/verify.bsh b/libraries/tools/kotlin-maven-plugin-test/src/it/test-classpath/verify.bsh new file mode 100644 index 00000000000..170fc10928f --- /dev/null +++ b/libraries/tools/kotlin-maven-plugin-test/src/it/test-classpath/verify.bsh @@ -0,0 +1,6 @@ +import java.io.*; + +File file = new File(basedir, "target/test-classpath-0.1-SNAPSHOT.jar"); +if (!file.exists() || !file.isFile()) { + throw new FileNotFoundException("Could not find generated JAR: " + file); +} diff --git a/libraries/tools/kotlin-maven-plugin/src/it/test-helloworld/pom.xml b/libraries/tools/kotlin-maven-plugin-test/src/it/test-helloworld/pom.xml similarity index 79% rename from libraries/tools/kotlin-maven-plugin/src/it/test-helloworld/pom.xml rename to libraries/tools/kotlin-maven-plugin-test/src/it/test-helloworld/pom.xml index 1d279ecede0..be4a3ab1e40 100644 --- a/libraries/tools/kotlin-maven-plugin/src/it/test-helloworld/pom.xml +++ b/libraries/tools/kotlin-maven-plugin-test/src/it/test-helloworld/pom.xml @@ -4,18 +4,14 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - org.jetbrains.kotlin.it + + org.jetbrains.kotlin + kotlin-project + 0.1-SNAPSHOT + ../../pom.xml + + test-helloworld - 1.0 - Test Hello World project - - - Test the kotlin-maven-plugin:compile goal on HelloWorld project. - - - - 0.1-SNAPSHOT - @@ -23,6 +19,11 @@ junit 4.9 + + org.jetbrains.kotlin + kotlin-runtime + ${project.version} + @@ -45,15 +46,12 @@ - ${project.basedir}/src/main/kotlin - - kotlin-maven-plugin org.jetbrains.kotlin - ${kotlin.version} + ${project.version} compile diff --git a/libraries/tools/kotlin-maven-plugin/src/it/test-helloworld/src/main/kotlin/org/jetbrains/HelloWorld.kt b/libraries/tools/kotlin-maven-plugin-test/src/it/test-helloworld/src/main/kotlin/org/jetbrains/HelloWorld.kt similarity index 100% rename from libraries/tools/kotlin-maven-plugin/src/it/test-helloworld/src/main/kotlin/org/jetbrains/HelloWorld.kt rename to libraries/tools/kotlin-maven-plugin-test/src/it/test-helloworld/src/main/kotlin/org/jetbrains/HelloWorld.kt diff --git a/libraries/tools/kotlin-maven-plugin/src/it/test-helloworld/src/test/java/org/jetbrains/HelloWorldJavaTest.java b/libraries/tools/kotlin-maven-plugin-test/src/it/test-helloworld/src/test/java/org/jetbrains/HelloWorldJavaTest.java similarity index 100% rename from libraries/tools/kotlin-maven-plugin/src/it/test-helloworld/src/test/java/org/jetbrains/HelloWorldJavaTest.java rename to libraries/tools/kotlin-maven-plugin-test/src/it/test-helloworld/src/test/java/org/jetbrains/HelloWorldJavaTest.java diff --git a/libraries/tools/kotlin-maven-plugin-test/src/it/test-helloworld/verify.bsh b/libraries/tools/kotlin-maven-plugin-test/src/it/test-helloworld/verify.bsh new file mode 100644 index 00000000000..00656d3d18d --- /dev/null +++ b/libraries/tools/kotlin-maven-plugin-test/src/it/test-helloworld/verify.bsh @@ -0,0 +1,6 @@ +import java.io.*; + +File file = new File(basedir, "target/test-helloworld-0.1-SNAPSHOT.jar"); +if (!file.exists() || !file.isFile()) { + throw new FileNotFoundException("Could not find generated JAR: " + file); +} diff --git a/libraries/tools/kotlin-maven-plugin/src/it/test-inlineDisabled/pom.xml b/libraries/tools/kotlin-maven-plugin-test/src/it/test-inlineDisabled/pom.xml similarity index 76% rename from libraries/tools/kotlin-maven-plugin/src/it/test-inlineDisabled/pom.xml rename to libraries/tools/kotlin-maven-plugin-test/src/it/test-inlineDisabled/pom.xml index e3962d2f054..505a63a79ef 100644 --- a/libraries/tools/kotlin-maven-plugin/src/it/test-inlineDisabled/pom.xml +++ b/libraries/tools/kotlin-maven-plugin-test/src/it/test-inlineDisabled/pom.xml @@ -4,18 +4,14 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - org.jetbrains.kotlin.it + + org.jetbrains.kotlin + kotlin-project + 0.1-SNAPSHOT + ../../pom.xml + + test-inlineDisabled - 1.0 - Test Hello World project - - - Test the kotlin-maven-plugin:compile goal on HelloWorld project. - - - - 0.1-SNAPSHOT - @@ -23,6 +19,11 @@ junit 4.9 + + org.jetbrains.kotlin + kotlin-runtime + ${project.version} + @@ -45,15 +46,12 @@ - ${project.basedir}/src/main/kotlin - - kotlin-maven-plugin org.jetbrains.kotlin - ${kotlin.version} + ${project.version} compile @@ -70,11 +68,11 @@ - - false - + + false + - \ No newline at end of file + diff --git a/libraries/tools/kotlin-maven-plugin/src/it/test-inlineDisabled/src/main/kotlin/org/jetbrains/HelloWorld.kt b/libraries/tools/kotlin-maven-plugin-test/src/it/test-inlineDisabled/src/main/kotlin/org/jetbrains/HelloWorld.kt similarity index 100% rename from libraries/tools/kotlin-maven-plugin/src/it/test-inlineDisabled/src/main/kotlin/org/jetbrains/HelloWorld.kt rename to libraries/tools/kotlin-maven-plugin-test/src/it/test-inlineDisabled/src/main/kotlin/org/jetbrains/HelloWorld.kt diff --git a/libraries/tools/kotlin-maven-plugin/src/it/test-inlineDisabled/src/test/java/org/jetbrains/HelloWorldJavaTest.java b/libraries/tools/kotlin-maven-plugin-test/src/it/test-inlineDisabled/src/test/java/org/jetbrains/HelloWorldJavaTest.java similarity index 100% rename from libraries/tools/kotlin-maven-plugin/src/it/test-inlineDisabled/src/test/java/org/jetbrains/HelloWorldJavaTest.java rename to libraries/tools/kotlin-maven-plugin-test/src/it/test-inlineDisabled/src/test/java/org/jetbrains/HelloWorldJavaTest.java diff --git a/libraries/tools/kotlin-maven-plugin-test/src/it/test-inlineDisabled/verify.bsh b/libraries/tools/kotlin-maven-plugin-test/src/it/test-inlineDisabled/verify.bsh new file mode 100644 index 00000000000..5ecd01be2e1 --- /dev/null +++ b/libraries/tools/kotlin-maven-plugin-test/src/it/test-inlineDisabled/verify.bsh @@ -0,0 +1,6 @@ +import java.io.*; + +File file = new File(basedir, "target/test-inlineDisabled-0.1-SNAPSHOT.jar"); +if (!file.exists() || !file.isFile()) { + throw new FileNotFoundException("Could not find generated JAR: " + file); +} diff --git a/libraries/tools/kotlin-maven-plugin/pom.xml b/libraries/tools/kotlin-maven-plugin/pom.xml index 548c9a40337..eb5a0280675 100644 --- a/libraries/tools/kotlin-maven-plugin/pom.xml +++ b/libraries/tools/kotlin-maven-plugin/pom.xml @@ -20,12 +20,12 @@ maven-plugin - + org.apache.maven maven-core ${maven.version} - - + + org.apache.maven maven-plugin-api ${maven.version} @@ -60,55 +60,4 @@ - - - - - integrationTest - - true - - - - - maven-invoker-plugin - 1.5 - - src/it - ${project.build.directory}/it - - */pom.xml - - - - local-repo - verify.bsh - true - - - - integration-test - - - install - run - - - - - - - - - - - noTest - - false - - - diff --git a/libraries/tools/kotlin-maven-plugin/src/it/test-classpath/verify.bsh b/libraries/tools/kotlin-maven-plugin/src/it/test-classpath/verify.bsh deleted file mode 100644 index 84e8c9cabd5..00000000000 --- a/libraries/tools/kotlin-maven-plugin/src/it/test-classpath/verify.bsh +++ /dev/null @@ -1,7 +0,0 @@ -import java.io.*; - -File file = new File( basedir, "target/test-classpath-1.0.jar" ); -if (!file.exists() || !file.isFile()) -{ - throw new FileNotFoundException( "Could not find generated JAR: " + file ); -} \ No newline at end of file diff --git a/libraries/tools/kotlin-maven-plugin/src/it/test-helloworld/verify.bsh b/libraries/tools/kotlin-maven-plugin/src/it/test-helloworld/verify.bsh deleted file mode 100644 index 760db7e13d0..00000000000 --- a/libraries/tools/kotlin-maven-plugin/src/it/test-helloworld/verify.bsh +++ /dev/null @@ -1,7 +0,0 @@ -import java.io.*; - -File file = new File( basedir, "target/test-helloworld-1.0.jar" ); -if (!file.exists() || !file.isFile()) -{ - throw new FileNotFoundException( "Could not find generated JAR: " + file ); -} \ No newline at end of file diff --git a/libraries/tools/kotlin-maven-plugin/src/it/test-inlineDisabled/verify.bsh b/libraries/tools/kotlin-maven-plugin/src/it/test-inlineDisabled/verify.bsh deleted file mode 100644 index c6efc3505ec..00000000000 --- a/libraries/tools/kotlin-maven-plugin/src/it/test-inlineDisabled/verify.bsh +++ /dev/null @@ -1,7 +0,0 @@ -import java.io.*; - -File file = new File( basedir, "target/test-inlineDisabled-1.0.jar" ); -if (!file.exists() || !file.isFile()) -{ - throw new FileNotFoundException( "Could not find generated JAR: " + file ); -} \ No newline at end of file