Merge remote-tracking branch 'origin/master'

This commit is contained in:
Dmitry Jemerov
2017-07-07 13:26:59 +02:00
25 changed files with 244 additions and 67 deletions
@@ -66,6 +66,8 @@ public interface Errors {
DiagnosticFactory1<PsiElement, Pair<LanguageFeature, LanguageVersionSettings>> UNSUPPORTED_FEATURE = DiagnosticFactory1.create(ERROR);
DiagnosticFactory1<PsiElement, Throwable> EXCEPTION_FROM_ANALYZER = DiagnosticFactory1.create(ERROR);
DiagnosticFactory1<PsiElement, String> MISSING_STDLIB = DiagnosticFactory1.create(ERROR);
DiagnosticFactory1<PsiElement, Pair<LanguageFeature, LanguageVersionSettings>> EXPERIMENTAL_FEATURE_WARNING = DiagnosticFactory1.create(WARNING);
DiagnosticFactory1<PsiElement, Pair<LanguageFeature, LanguageVersionSettings>> EXPERIMENTAL_FEATURE_ERROR = DiagnosticFactory1.create(ERROR);
@@ -156,7 +156,7 @@ public class DefaultErrorMessages {
MAP.put(INAPPLICABLE_TARGET_PROPERTY_IMMUTABLE, "''@{0}:'' annotations could be applied only to mutable properties", TO_STRING);
MAP.put(INAPPLICABLE_TARGET_PROPERTY_HAS_NO_DELEGATE, "'@delegate:' annotations could be applied only to delegated properties");
MAP.put(INAPPLICABLE_TARGET_PROPERTY_HAS_NO_BACKING_FIELD, "'@field:' annotations could be applied only to properties with backing fields");
MAP.put(INAPPLICABLE_RECEIVER_TARGET, "'@receiver:' annotations could be applied only to extension function or extension property declarations");
MAP.put(INAPPLICABLE_RECEIVER_TARGET, "'@receiver:' annotations can only be applied to the receiver type of extension function or extension property declarations");
MAP.put(INAPPLICABLE_PARAM_TARGET, "'@param:' annotations could be applied only to primary constructor parameters");
MAP.put(REDUNDANT_ANNOTATION_TARGET, "Redundant annotation target ''{0}''", STRING);
@@ -578,6 +578,7 @@ public class DefaultErrorMessages {
MAP.put(EXPERIMENTAL_FEATURE_ERROR, "{0}", new LanguageFeatureMessageRenderer(LanguageFeatureMessageRenderer.Type.ERROR));
MAP.put(EXCEPTION_FROM_ANALYZER, "Internal Error occurred while analyzing this expression:\n{0}", THROWABLE);
MAP.put(MISSING_STDLIB, "{0}. Ensure you have the standard Kotlin library in dependencies", STRING);
MAP.put(UNNECESSARY_SAFE_CALL, "Unnecessary safe call on a non-null receiver of type {0}", RENDER_TYPE);
MAP.put(UNEXPECTED_SAFE_CALL, "Safe-call is not allowed here");
MAP.put(UNNECESSARY_NOT_NULL_ASSERTION, "Unnecessary non-null assertion (!!) on a non-null receiver of type {0}", RENDER_TYPE);
@@ -21,9 +21,9 @@ import org.jetbrains.kotlin.builtins.KotlinBuiltIns
import org.jetbrains.kotlin.builtins.PrimitiveType
import org.jetbrains.kotlin.config.LanguageFeature
import org.jetbrains.kotlin.config.LanguageVersionSettings
import org.jetbrains.kotlin.descriptors.ModuleDescriptor
import org.jetbrains.kotlin.descriptors.SimpleFunctionDescriptor
import org.jetbrains.kotlin.diagnostics.Errors.UNSUPPORTED
import org.jetbrains.kotlin.diagnostics.Errors.UNSUPPORTED_FEATURE
import org.jetbrains.kotlin.diagnostics.Errors.*
import org.jetbrains.kotlin.incremental.KotlinLookupLocation
import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.psi.KtAnnotationEntry
@@ -39,43 +39,47 @@ import org.jetbrains.kotlin.types.expressions.KotlinTypeInfo
import org.jetbrains.kotlin.types.expressions.typeInfoFactory.createTypeInfo
import org.jetbrains.kotlin.types.expressions.typeInfoFactory.noTypeInfo
object CollectionLiteralResolver {
val PRIMITIVE_TYPE_TO_ARRAY: Map<PrimitiveType, Name> = hashMapOf(
PrimitiveType.BOOLEAN to Name.identifier("booleanArrayOf"),
PrimitiveType.CHAR to Name.identifier("charArrayOf"),
PrimitiveType.INT to Name.identifier("intArrayOf"),
PrimitiveType.BYTE to Name.identifier("byteArrayOf"),
PrimitiveType.SHORT to Name.identifier("shortArrayOf"),
PrimitiveType.FLOAT to Name.identifier("floatArrayOf"),
PrimitiveType.LONG to Name.identifier("longArrayOf"),
PrimitiveType.DOUBLE to Name.identifier("doubleArrayOf")
)
class CollectionLiteralResolver(val module: ModuleDescriptor, val callResolver: CallResolver, val languageVersionSettings: LanguageVersionSettings) {
companion object {
val PRIMITIVE_TYPE_TO_ARRAY: Map<PrimitiveType, Name> = hashMapOf(
PrimitiveType.BOOLEAN to Name.identifier("booleanArrayOf"),
PrimitiveType.CHAR to Name.identifier("charArrayOf"),
PrimitiveType.INT to Name.identifier("intArrayOf"),
PrimitiveType.BYTE to Name.identifier("byteArrayOf"),
PrimitiveType.SHORT to Name.identifier("shortArrayOf"),
PrimitiveType.FLOAT to Name.identifier("floatArrayOf"),
PrimitiveType.LONG to Name.identifier("longArrayOf"),
PrimitiveType.DOUBLE to Name.identifier("doubleArrayOf")
)
val ARRAY_OF_FUNCTION = Name.identifier("arrayOf")
val ARRAY_OF_FUNCTION = Name.identifier("arrayOf")
}
fun resolveCollectionLiteral(collectionLiteralExpression: KtCollectionLiteralExpression,
context: ExpressionTypingContext,
callResolver: CallResolver,
builtIns: KotlinBuiltIns,
languageVersionSettings: LanguageVersionSettings
fun resolveCollectionLiteral(
collectionLiteralExpression: KtCollectionLiteralExpression,
context: ExpressionTypingContext
): KotlinTypeInfo {
if (!isInsideAnnotationEntryOrClass(collectionLiteralExpression)) {
context.trace.report(UNSUPPORTED.on(collectionLiteralExpression, "Collection literals outside of annotations"))
}
checkSupportsArrayLiterals(collectionLiteralExpression, context, languageVersionSettings)
checkSupportsArrayLiterals(collectionLiteralExpression, context)
return resolveCollectionLiteralSpecialMethod(collectionLiteralExpression, context, callResolver, builtIns)
return resolveCollectionLiteralSpecialMethod(collectionLiteralExpression, context)
}
private fun resolveCollectionLiteralSpecialMethod(
expression: KtCollectionLiteralExpression,
context: ExpressionTypingContext,
callResolver: CallResolver,
builtIns: KotlinBuiltIns
context: ExpressionTypingContext
): KotlinTypeInfo {
val call = CallMaker.makeCallForCollectionLiteral(expression)
val functionDescriptor = getFunctionDescriptorForCollectionLiteral(expression, context, builtIns)
val callName = getArrayFunctionCallName(context.expectedType)
val functionDescriptor = getFunctionDescriptorForCollectionLiteral(expression, callName)
if (functionDescriptor == null) {
context.trace.report(MISSING_STDLIB.on(
expression, "Collection literal call '$callName()' is unresolved"))
return noTypeInfo(context)
}
val resolutionResults = callResolver.resolveCollectionLiteralCallWithGivenDescriptor(context, expression, call, functionDescriptor)
@@ -90,17 +94,13 @@ object CollectionLiteralResolver {
private fun getFunctionDescriptorForCollectionLiteral(
expression: KtCollectionLiteralExpression,
context: ExpressionTypingContext,
builtIns: KotlinBuiltIns
): SimpleFunctionDescriptor {
val callName = getArrayFunctionCallName(context.expectedType)
return builtIns.builtInsPackageScope.getContributedFunctions(callName, KotlinLookupLocation(expression)).single()
callName: Name
): SimpleFunctionDescriptor? {
val memberScopeOfKotlinPackage = module.getPackage(KotlinBuiltIns.BUILT_INS_PACKAGE_FQ_NAME).memberScope
return memberScopeOfKotlinPackage.getContributedFunctions(callName, KotlinLookupLocation(expression)).singleOrNull()
}
private fun checkSupportsArrayLiterals(expression: KtCollectionLiteralExpression,
context: ExpressionTypingContext,
languageVersionSettings: LanguageVersionSettings
) {
private fun checkSupportsArrayLiterals(expression: KtCollectionLiteralExpression, context: ExpressionTypingContext) {
if (isInsideAnnotationEntryOrClass(expression) &&
!languageVersionSettings.supportsFeature(LanguageFeature.ArrayLiteralsInAnnotations)) {
context.trace.report(UNSUPPORTED_FEATURE.on(expression, LanguageFeature.ArrayLiteralsInAnnotations to languageVersionSettings))
@@ -87,7 +87,6 @@ public class ValueArgumentsToParametersMapper {
private final Map<Name,ValueParameterDescriptor> parameterByName;
private Map<Name,ValueParameterDescriptor> parameterByNameInOverriddenMethods;
private final Set<ValueArgument> unmappedArguments = Sets.newHashSet();
private final Map<ValueParameterDescriptor, VarargValueArgument> varargs = Maps.newHashMap();
private final Set<ValueParameterDescriptor> usedParameters = Sets.newHashSet();
private Status status = OK;
@@ -164,7 +163,6 @@ public class ValueArgumentsToParametersMapper {
}
else {
report(TOO_MANY_ARGUMENTS.on(argument.asElement(), candidateCall.getCandidateDescriptor()));
unmappedArguments.add(argument);
setStatus(WEAK_ERROR);
}
}
@@ -218,7 +216,6 @@ public class ValueArgumentsToParametersMapper {
if (nameReference != null) {
report(NAMED_PARAMETER_NOT_FOUND.on(nameReference, nameReference));
}
unmappedArguments.add(argument);
setStatus(WEAK_ERROR);
}
else {
@@ -229,7 +226,6 @@ public class ValueArgumentsToParametersMapper {
if (nameReference != null) {
report(ARGUMENT_PASSED_TWICE.on(nameReference));
}
unmappedArguments.add(argument);
setStatus(WEAK_ERROR);
}
else {
@@ -244,7 +240,6 @@ public class ValueArgumentsToParametersMapper {
public ProcessorState processPositionedArgument(@NotNull ValueArgument argument) {
report(MIXING_NAMED_AND_POSITIONED_ARGUMENTS.on(argument.asElement()));
setStatus(WEAK_ERROR);
unmappedArguments.add(argument);
return positionedThenNamed;
}
@@ -1,5 +1,5 @@
/*
* Copyright 2010-2015 JetBrains s.r.o.
* Copyright 2010-2017 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,18 +16,27 @@
package org.jetbrains.kotlin.resolve.calls.tasks;
import kotlin.collections.CollectionsKt;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import org.jetbrains.kotlin.builtins.FunctionTypesKt;
import org.jetbrains.kotlin.descriptors.CallableDescriptor;
import org.jetbrains.kotlin.descriptors.DeclarationDescriptor;
import org.jetbrains.kotlin.descriptors.FunctionDescriptor;
import org.jetbrains.kotlin.descriptors.VariableDescriptor;
import org.jetbrains.kotlin.diagnostics.Errors;
import org.jetbrains.kotlin.psi.Call;
import org.jetbrains.kotlin.psi.KtReferenceExpression;
import org.jetbrains.kotlin.resolve.BindingTrace;
import org.jetbrains.kotlin.resolve.calls.callResolverUtil.CallResolverUtilKt;
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall;
import org.jetbrains.kotlin.resolve.calls.model.VariableAsFunctionResolvedCall;
import org.jetbrains.kotlin.resolve.calls.util.FakeCallableDescriptorForObject;
import org.jetbrains.kotlin.types.ErrorUtils;
import org.jetbrains.kotlin.types.KotlinType;
import java.util.Collection;
import java.util.List;
import static org.jetbrains.kotlin.diagnostics.Errors.UNRESOLVED_REFERENCE;
import static org.jetbrains.kotlin.diagnostics.Errors.UNRESOLVED_REFERENCE_WRONG_RECEIVER;
@@ -82,6 +91,41 @@ public class TracingStrategyImpl extends AbstractTracingStrategy {
@Override
public <D extends CallableDescriptor> void unresolvedReferenceWrongReceiver(@NotNull BindingTrace trace, @NotNull Collection<? extends ResolvedCall<D>> candidates) {
trace.report(UNRESOLVED_REFERENCE_WRONG_RECEIVER.on(reference, candidates));
VariableDescriptor variableDescriptor = isFunctionExpectedError(candidates);
if (variableDescriptor != null) {
trace.report(Errors.FUNCTION_EXPECTED.on(reference, reference, variableDescriptor.getType()));
}
else {
trace.report(UNRESOLVED_REFERENCE_WRONG_RECEIVER.on(reference, candidates));
}
}
@Nullable
private static <D extends CallableDescriptor> VariableDescriptor isFunctionExpectedError(
@NotNull Collection<? extends ResolvedCall<D>> candidates
) {
List<VariableDescriptor> variables = CollectionsKt.map(candidates, TracingStrategyImpl::variableIfFunctionExpectedError);
List<VariableDescriptor> distinctVariables = CollectionsKt.distinct(variables);
return CollectionsKt.singleOrNull(distinctVariables);
}
@Nullable
private static <D extends CallableDescriptor> VariableDescriptor variableIfFunctionExpectedError(
@NotNull ResolvedCall<D> candidate
) {
if (!(candidate instanceof VariableAsFunctionResolvedCall)) return null;
ResolvedCall<VariableDescriptor> variableCall = ((VariableAsFunctionResolvedCall) candidate).getVariableCall();
ResolvedCall<FunctionDescriptor> functionCall = ((VariableAsFunctionResolvedCall) candidate).getFunctionCall();
KotlinType type = variableCall.getCandidateDescriptor().getType();
boolean nonFunctionalVar = variableCall.getStatus().isSuccess() && !FunctionTypesKt.isFunctionType(type);
Call functionPsiCall = functionCall.getCall();
if (nonFunctionalVar && CallResolverUtilKt.isInvokeCallOnVariable(functionPsiCall) && functionPsiCall.getValueArguments().isEmpty()) {
return variableCall.getCandidateDescriptor();
}
return null;
}
}
@@ -1423,8 +1423,7 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
public KotlinTypeInfo visitCollectionLiteralExpression(
@NotNull KtCollectionLiteralExpression expression, ExpressionTypingContext context
) {
return CollectionLiteralResolver.INSTANCE.resolveCollectionLiteral(
expression, context, components.callResolver, components.builtIns, components.languageVersionSettings);
return components.collectionLiteralResolver.resolveCollectionLiteral(expression, context);
}
@Override
@@ -1,5 +1,5 @@
/*
* Copyright 2010-2016 JetBrains s.r.o.
* Copyright 2010-2017 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.
@@ -62,6 +62,7 @@ public class ExpressionTypingComponents {
/*package*/ LanguageVersionSettings languageVersionSettings;
/*package*/ Iterable<RttiExpressionChecker> rttiExpressionCheckers;
/*package*/ WrappedTypeFactory wrappedTypeFactory;
/*package*/ CollectionLiteralResolver collectionLiteralResolver;
@Inject
public void setGlobalContext(@NotNull GlobalContext globalContext) {
@@ -207,4 +208,9 @@ public class ExpressionTypingComponents {
public void setWrappedTypeFactory(WrappedTypeFactory wrappedTypeFactory) {
this.wrappedTypeFactory = wrappedTypeFactory;
}
@Inject
public void setCollectionLiteralResolver(CollectionLiteralResolver collectionLiteralResolver) {
this.collectionLiteralResolver = collectionLiteralResolver;
}
}
@@ -1,5 +1,5 @@
/*
* Copyright 2010-2016 JetBrains s.r.o.
* Copyright 2010-2017 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.
@@ -108,18 +108,31 @@ public class ExpressionTypingUtils {
@NotNull VariableDescriptor variableDescriptor
) {
VariableDescriptor oldDescriptor = ScopeUtilsKt.findLocalVariable(scope, variableDescriptor.getName());
if (oldDescriptor == null) return;
if (oldDescriptor != null && isLocal(variableDescriptor.getContainingDeclaration(), oldDescriptor)) {
PsiElement declaration = DescriptorToSourceUtils.descriptorToDeclaration(variableDescriptor);
if (declaration != null) {
if (declaration instanceof KtDestructuringDeclarationEntry && declaration.getParent().getParent() instanceof KtParameter) {
// foo { a, (a, b) -> } -- do not report NAME_SHADOWING on the second 'a', because REDECLARATION must be reported here
PsiElement oldElement = DescriptorToSourceUtils.descriptorToDeclaration(oldDescriptor);
DeclarationDescriptor variableContainingDeclaration = variableDescriptor.getContainingDeclaration();
if (!isLocal(variableContainingDeclaration, oldDescriptor)) return;
if (oldElement != null && oldElement.getParent().equals(declaration.getParent().getParent().getParent())) return;
}
trace.report(Errors.NAME_SHADOWING.on(declaration, variableDescriptor.getName().asString()));
if (variableDescriptor instanceof ParameterDescriptor) {
if (!isFunctionLiteral(variableContainingDeclaration)) {
return;
}
// parameter of lambda
if (variableContainingDeclaration.getContainingDeclaration() != oldDescriptor.getContainingDeclaration()) {
return;
}
}
PsiElement declaration = DescriptorToSourceUtils.descriptorToDeclaration(variableDescriptor);
if (declaration != null) {
if (declaration instanceof KtDestructuringDeclarationEntry && declaration.getParent().getParent() instanceof KtParameter) {
// foo { a, (a, b) -> } -- do not report NAME_SHADOWING on the second 'a', because REDECLARATION must be reported here
PsiElement oldElement = DescriptorToSourceUtils.descriptorToDeclaration(oldDescriptor);
if (oldElement != null && oldElement.getParent().equals(declaration.getParent().getParent().getParent())) return;
}
trace.report(Errors.NAME_SHADOWING.on(declaration, variableDescriptor.getName().asString()));
}
}
@@ -45,8 +45,8 @@ fun foo(y: IntArray) {
<!ANNOTATIONS_ON_BLOCK_LEVEL_EXPRESSION_ON_THE_SAME_LINE!>@Ann1 x<!> + 6 * 2 > 0
<!ANNOTATIONS_ON_BLOCK_LEVEL_EXPRESSION_ON_THE_SAME_LINE!>@Ann1 x<!> * 6 + 2 > 0
<!ANNOTATIONS_ON_BLOCK_LEVEL_EXPRESSION_ON_THE_SAME_LINE!>@Ann1 object { operator fun plus(<!NAME_SHADOWING!>x<!>: Int) = 1 }<!> + 1
<!ANNOTATIONS_ON_BLOCK_LEVEL_EXPRESSION_ON_THE_SAME_LINE!>@Ann1 object { operator fun plus(<!NAME_SHADOWING!>x<!>: Int) = 1 }<!> + 1 * 4 > 0
<!ANNOTATIONS_ON_BLOCK_LEVEL_EXPRESSION_ON_THE_SAME_LINE!>@Ann1 object { operator fun plus(x: Int) = 1 }<!> + 1
<!ANNOTATIONS_ON_BLOCK_LEVEL_EXPRESSION_ON_THE_SAME_LINE!>@Ann1 object { operator fun plus(x: Int) = 1 }<!> + 1 * 4 > 0
<!ANNOTATIONS_ON_BLOCK_LEVEL_EXPRESSION_ON_THE_SAME_LINE!>@Ann1 x<!> foo z + 8
@@ -1,4 +1,4 @@
data class A1(val <!REDECLARATION, REDECLARATION, REDECLARATION!>x<!>: Int, val y: String, val <!NAME_SHADOWING, REDECLARATION, REDECLARATION, REDECLARATION!>x<!>: Int) {
data class A1(val <!REDECLARATION, REDECLARATION, REDECLARATION!>x<!>: Int, val y: String, val <!REDECLARATION, REDECLARATION, REDECLARATION!>x<!>: Int) {
val z = ""
}
@@ -1,10 +1,10 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER -PRIMARY_CONSTRUCTOR_DELEGATION_CALL_EXPECTED
fun test(<!MULTIPLE_VARARG_PARAMETERS!>vararg<!> x1: Int, <!MULTIPLE_VARARG_PARAMETERS!>vararg<!> x2: Int) {
fun test2(<!MULTIPLE_VARARG_PARAMETERS!>vararg<!> <!NAME_SHADOWING!>x1<!>: Int, <!MULTIPLE_VARARG_PARAMETERS!>vararg<!> <!NAME_SHADOWING!>x2<!>: Int) {
class LocalClass(<!MULTIPLE_VARARG_PARAMETERS!>vararg<!> <!NAME_SHADOWING!>x1<!>: Int, <!MULTIPLE_VARARG_PARAMETERS!>vararg<!> <!NAME_SHADOWING!>x2<!>: Int) {
constructor(<!MULTIPLE_VARARG_PARAMETERS!>vararg<!> <!NAME_SHADOWING!>x1<!>: Int, <!MULTIPLE_VARARG_PARAMETERS!>vararg<!> <!NAME_SHADOWING!>x2<!>: Int, xx: Int) {}
fun test2(<!MULTIPLE_VARARG_PARAMETERS!>vararg<!> x1: Int, <!MULTIPLE_VARARG_PARAMETERS!>vararg<!> x2: Int) {
class LocalClass(<!MULTIPLE_VARARG_PARAMETERS!>vararg<!> x1: Int, <!MULTIPLE_VARARG_PARAMETERS!>vararg<!> x2: Int) {
constructor(<!MULTIPLE_VARARG_PARAMETERS!>vararg<!> x1: Int, <!MULTIPLE_VARARG_PARAMETERS!>vararg<!> x2: Int, xx: Int) {}
}
fun test3(<!MULTIPLE_VARARG_PARAMETERS!>vararg<!> <!NAME_SHADOWING!>x1<!>: Int, <!MULTIPLE_VARARG_PARAMETERS!>vararg<!> <!NAME_SHADOWING!>x2<!>: Int) {}
fun test3(<!MULTIPLE_VARARG_PARAMETERS!>vararg<!> x1: Int, <!MULTIPLE_VARARG_PARAMETERS!>vararg<!> x2: Int) {}
}
}
@@ -40,7 +40,7 @@ fun bar() {
_ checkType { _<String>() }
}
foo { <!REDECLARATION, REDECLARATION, UNUSED_ANONYMOUS_PARAMETER!>`_`<!>, <!NAME_SHADOWING, REDECLARATION, REDECLARATION!>`_`<!> ->
foo { <!REDECLARATION, REDECLARATION, UNUSED_ANONYMOUS_PARAMETER!>`_`<!>, <!REDECLARATION, REDECLARATION!>`_`<!> ->
_ checkType { _<String>() }
}
@@ -22,6 +22,6 @@ fun bar(b: B): String {
// Ok: local variable
val tmp = if (b is A && b is C) b else null
// Error: local function
fun <!IMPLICIT_INTERSECTION_TYPE!>foo<!>(<!NAME_SHADOWING!>b<!>: B) = if (b is A && b is C) b else null
fun <!IMPLICIT_INTERSECTION_TYPE!>foo<!>(b: B) = if (b is A && b is C) b else null
return tmp.toString()
}
@@ -0,0 +1,13 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
fun Int.invoke(a: Int) {}
fun Int.invoke(a: Int, b: Int) {}
class SomeClass
fun test(identifier: SomeClass, fn: String.() -> Unit) {
<!FUNCTION_EXPECTED, DEBUG_INFO_MISSING_UNRESOLVED!>identifier<!>()
<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>identifier<!>(123)
<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>identifier<!>(1, 2)
1.<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>fn<!>()
}
@@ -0,0 +1,12 @@
package
public fun test(/*0*/ identifier: SomeClass, /*1*/ fn: kotlin.String.() -> kotlin.Unit): kotlin.Unit
public fun kotlin.Int.invoke(/*0*/ a: kotlin.Int): kotlin.Unit
public fun kotlin.Int.invoke(/*0*/ a: kotlin.Int, /*1*/ b: kotlin.Int): kotlin.Unit
public final class SomeClass {
public constructor SomeClass()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
@@ -0,0 +1,12 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
fun Int.invoke() {}
class SomeClass
fun test(identifier: SomeClass, fn: String.() -> Unit) {
<!FUNCTION_EXPECTED, DEBUG_INFO_MISSING_UNRESOLVED!>identifier<!>()
<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>identifier<!>(123)
<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>identifier<!>(1, 2)
1.<!UNRESOLVED_REFERENCE_WRONG_RECEIVER!>fn<!>()
}
@@ -0,0 +1,11 @@
package
public fun test(/*0*/ identifier: SomeClass, /*1*/ fn: kotlin.String.() -> kotlin.Unit): kotlin.Unit
public fun kotlin.Int.invoke(): kotlin.Unit
public final class SomeClass {
public constructor SomeClass()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
@@ -0,0 +1,24 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER, -UNUSED_ANONYMOUS_PARAMETER
open class Base {
open fun foo(name: String) {}
}
fun test1(name: String) {
class Local : Base() {
override fun foo(name: String) {
}
}
}
fun test2(param: String) {
fun local(param: String) {}
}
fun test3(param: String) {
fun local() {
fff { param -> }
}
}
fun fff(x: (y: String) -> Unit) {}
@@ -0,0 +1,14 @@
package
public fun fff(/*0*/ x: (y: kotlin.String) -> kotlin.Unit): kotlin.Unit
public fun test1(/*0*/ name: kotlin.String): kotlin.Unit
public fun test2(/*0*/ param: kotlin.String): kotlin.Unit
public fun test3(/*0*/ param: kotlin.String): kotlin.Unit
public open class Base {
public constructor Base()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open fun foo(/*0*/ name: kotlin.String): kotlin.Unit
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
+1 -1
View File
@@ -15,7 +15,7 @@ fun foo(x: Int, y: String = <!CALL_TO_DEFINED_EXTERNALLY_FROM_NON_EXTERNAL_DECLA
listOf<String>()
.map<String, String> { <!CALL_TO_DEFINED_EXTERNALLY_FROM_NON_EXTERNAL_DECLARATION!>definedExternally<!> }
.filter(fun(<!NAME_SHADOWING!>x<!>: String): Boolean { <!CALL_TO_DEFINED_EXTERNALLY_FROM_NON_EXTERNAL_DECLARATION!>definedExternally<!> })
.filter(fun(x: String): Boolean { <!CALL_TO_DEFINED_EXTERNALLY_FROM_NON_EXTERNAL_DECLARATION!>definedExternally<!> })
<!CALL_TO_DEFINED_EXTERNALLY_FROM_NON_EXTERNAL_DECLARATION!>definedExternally<!>
}
@@ -17607,6 +17607,12 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest {
doTest(fileName);
}
@TestMetadata("functionExpectedWhenSeveralInvokesExist.kt")
public void testFunctionExpectedWhenSeveralInvokesExist() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/resolve/invoke/functionExpectedWhenSeveralInvokesExist.kt");
doTest(fileName);
}
@TestMetadata("implicitInvoke.kt")
public void testImplicitInvoke() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/resolve/invoke/implicitInvoke.kt");
@@ -17697,6 +17703,12 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest {
doTest(fileName);
}
@TestMetadata("reportFunctionExpectedWhenOneInvokeExist.kt")
public void testReportFunctionExpectedWhenOneInvokeExist() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/resolve/invoke/reportFunctionExpectedWhenOneInvokeExist.kt");
doTest(fileName);
}
@TestMetadata("valNamedInvoke.kt")
public void testValNamedInvoke() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/resolve/invoke/valNamedInvoke.kt");
@@ -19402,6 +19414,12 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest {
KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/diagnostics/tests/shadowing"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true);
}
@TestMetadata("noNameShadowingForSimpleParameters.kt")
public void testNoNameShadowingForSimpleParameters() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/shadowing/noNameShadowingForSimpleParameters.kt");
doTest(fileName);
}
@TestMetadata("ShadowLambdaParameter.kt")
public void testShadowLambdaParameter() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/shadowing/ShadowLambdaParameter.kt");
@@ -0,0 +1,7 @@
class A {
inner class XYZ
fun foo() {
val <warning>v</warning>: A.XYZ = A.<error descr="[RESOLUTION_TO_CLASSIFIER] Constructor of inner class XYZ can be called only with receiver of containing class">XYZ</error>()
}
}
@@ -1,5 +1,5 @@
// "Move annotation to receiver type" "false"
// ERROR: '@receiver:' annotations could be applied only to extension function or extension property declarations
// ERROR: '@receiver:' annotations can only be applied to the receiver type of extension function or extension property declarations
// ACTION: Convert to expression body
// ACTION: Make internal
// ACTION: Make private
@@ -1,5 +1,5 @@
// "Move annotation to receiver type" "false"
// ERROR: '@receiver:' annotations could be applied only to extension function or extension property declarations
// ERROR: '@receiver:' annotations can only be applied to the receiver type of extension function or extension property declarations
// ACTION: Make internal
// ACTION: Make private
// ACTION: Specify type explicitly
@@ -992,6 +992,12 @@ public class PsiCheckerTestGenerated extends AbstractPsiCheckerTest {
doTest(fileName);
}
@TestMetadata("instantiationOfInnerClassInQualifiedForm.kt")
public void testInstantiationOfInnerClassInQualifiedForm() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/checker/diagnosticsMessage/instantiationOfInnerClassInQualifiedForm.kt");
doTest(fileName);
}
@TestMetadata("noSubstitutedTypeParameter.kt")
public void testNoSubstitutedTypeParameter() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/checker/diagnosticsMessage/noSubstitutedTypeParameter.kt");