diff --git a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java index 09c51ce0fee..a20ebdf8df2 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/Errors.java @@ -80,6 +80,13 @@ public interface Errors { DiagnosticFactory1 PACKAGE_OR_CLASSIFIER_REDECLARATION = DiagnosticFactory1.create(ERROR, FOR_REDECLARATION); + DiagnosticFactory1 EXTENSION_SHADOWED_BY_MEMBER = + DiagnosticFactory1.create(WARNING, FOR_REDECLARATION); + DiagnosticFactory1 EXTENSION_FUNCTION_SHADOWED_BY_INNER_CLASS_CONSTRUCTOR = + DiagnosticFactory1.create(WARNING, FOR_REDECLARATION); + DiagnosticFactory2 EXTENSION_FUNCTION_SHADOWED_BY_MEMBER_PROPERTY_WITH_INVOKE = + DiagnosticFactory2.create(WARNING, FOR_REDECLARATION); + DiagnosticFactory1 UNRESOLVED_REFERENCE = DiagnosticFactory1.create(ERROR, FOR_UNRESOLVED_REFERENCE); diff --git a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java index 1b608538b64..ae79a11a113 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/diagnostics/rendering/DefaultErrorMessages.java @@ -114,6 +114,12 @@ public class DefaultErrorMessages { MAP.put(EXPOSED_SUPER_INTERFACE, "''{0}'' sub-interface exposes its ''{2}'' supertype{1}", TO_STRING, TO_STRING, TO_STRING); MAP.put(EXPOSED_TYPEALIAS_EXPANDED_TYPE, "''{0}'' typealias exposes ''{2}'' in expanded type{1}", TO_STRING, TO_STRING, TO_STRING); + MAP.put(EXTENSION_SHADOWED_BY_MEMBER, "Extension is shadowed by a member: {0}", COMPACT_WITH_MODIFIERS); + MAP.put(EXTENSION_FUNCTION_SHADOWED_BY_INNER_CLASS_CONSTRUCTOR, + "Extension function is shadowed by an inner class constructor: {0}", COMPACT_WITH_MODIFIERS); + MAP.put(EXTENSION_FUNCTION_SHADOWED_BY_MEMBER_PROPERTY_WITH_INVOKE, + "Extension function is shadowed by a member property ''{0}'' with {1}", NAME, COMPACT_WITH_MODIFIERS); + MAP.put(INACCESSIBLE_TYPE, "Type {0} is inaccessible in this context due to: {1}", RENDER_TYPE, commaSeparated(FQ_NAMES_IN_TYPES)); MAP.put(REDECLARATION, "Conflicting declarations: {0}", commaSeparated(COMPACT_WITH_MODIFIERS)); diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/DeclarationResolver.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/DeclarationResolver.kt index acd84bcff27..ebe4d729529 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/DeclarationResolver.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/DeclarationResolver.kt @@ -80,7 +80,7 @@ class DeclarationResolver( // TODO: report error on header class and impl val, or vice versa val (header, impl) = - getTopLevelDescriptorsByFqName(topLevelDescriptorProvider, fqName, NoLookupLocation.WHEN_CHECK_REDECLARATIONS) + getTopLevelDescriptorsByFqName(topLevelDescriptorProvider, fqName, NoLookupLocation.WHEN_CHECK_DECLARATION_CONFLICTS) .partition { it is MemberDescriptor && it.isHeader } for (descriptors in listOf(header, impl)) { diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/DeclarationsChecker.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/DeclarationsChecker.kt index e16479a39f9..e6815327a82 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/DeclarationsChecker.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/DeclarationsChecker.kt @@ -33,6 +33,7 @@ import org.jetbrains.kotlin.psi.psiUtil.visibilityModifier import org.jetbrains.kotlin.resolve.BindingContext.* import org.jetbrains.kotlin.resolve.DescriptorUtils.classCanHaveAbstractMembers import org.jetbrains.kotlin.resolve.DescriptorUtils.classCanHaveOpenMembers +import org.jetbrains.kotlin.resolve.calls.results.TypeSpecificityComparator import org.jetbrains.kotlin.resolve.source.KotlinSourceElement import org.jetbrains.kotlin.types.* import org.jetbrains.kotlin.types.checker.KotlinTypeChecker @@ -45,10 +46,11 @@ internal class DeclarationsCheckerBuilder( private val originalModifiersChecker: ModifiersChecker, private val annotationChecker: AnnotationChecker, private val identifierChecker: IdentifierChecker, - private val languageVersionSettings: LanguageVersionSettings + private val languageVersionSettings: LanguageVersionSettings, + private val typeSpecificityComparator: TypeSpecificityComparator ) { fun withTrace(trace: BindingTrace) = - DeclarationsChecker(descriptorResolver, originalModifiersChecker, annotationChecker, identifierChecker, trace, languageVersionSettings) + DeclarationsChecker(descriptorResolver, originalModifiersChecker, annotationChecker, identifierChecker, trace, languageVersionSettings, typeSpecificityComparator) } class DeclarationsChecker( @@ -57,13 +59,16 @@ class DeclarationsChecker( private val annotationChecker: AnnotationChecker, private val identifierChecker: IdentifierChecker, private val trace: BindingTrace, - private val languageVersionSettings: LanguageVersionSettings + private val languageVersionSettings: LanguageVersionSettings, + typeSpecificityComparator: TypeSpecificityComparator ) { private val modifiersChecker = modifiersChecker.withTrace(trace) private val exposedChecker = ExposedVisibilityChecker(trace) + private val shadowedExtensionChecker = ShadowedExtensionChecker(typeSpecificityComparator, trace) + fun process(bodiesResolveContext: BodiesResolveContext) { for (file in bodiesResolveContext.files) { checkModifiersAndAnnotationsInPackageDirective(file) @@ -524,6 +529,7 @@ class DeclarationsChecker( checkAccessors(property, propertyDescriptor) checkTypeParameterConstraints(property) exposedChecker.checkProperty(property, propertyDescriptor) + shadowedExtensionChecker.checkDeclaration(property, propertyDescriptor) checkPropertyTypeParametersAreUsedInReceiverType(propertyDescriptor) checkImplicitCallableType(property, propertyDescriptor) } @@ -766,6 +772,8 @@ class DeclarationsChecker( if (functionDescriptor.isHeader) { checkHeaderFunction(function) } + + shadowedExtensionChecker.checkDeclaration(function, functionDescriptor) } private fun checkHeaderFunction(function: KtNamedFunction) { diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/OverloadChecker.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/OverloadChecker.kt index e69a8738b54..a8c414bfeb8 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/OverloadChecker.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/OverloadChecker.kt @@ -16,25 +16,22 @@ package org.jetbrains.kotlin.resolve -import com.intellij.util.containers.MultiMap import org.jetbrains.kotlin.descriptors.* -import org.jetbrains.kotlin.incremental.components.NoLookupLocation -import org.jetbrains.kotlin.name.FqNameUnsafe -import org.jetbrains.kotlin.name.Name import org.jetbrains.kotlin.resolve.calls.inference.ConstraintSystemBuilderImpl import org.jetbrains.kotlin.resolve.calls.results.FlatSignature import org.jetbrains.kotlin.resolve.calls.results.SpecificityComparisonCallbacks import org.jetbrains.kotlin.resolve.calls.results.TypeSpecificityComparator import org.jetbrains.kotlin.resolve.calls.results.isSignatureNotLessSpecific -import org.jetbrains.kotlin.resolve.calls.tower.getTypeAliasConstructors import org.jetbrains.kotlin.resolve.descriptorUtil.hasLowPriorityInOverloadResolution -import org.jetbrains.kotlin.resolve.descriptorUtil.varargParameterPosition import org.jetbrains.kotlin.resolve.descriptorUtil.isExtensionProperty -import org.jetbrains.kotlin.resolve.scopes.MemberScope +import org.jetbrains.kotlin.resolve.descriptorUtil.varargParameterPosition import org.jetbrains.kotlin.types.ErrorUtils import org.jetbrains.kotlin.types.KotlinType -import org.jetbrains.kotlin.utils.singletonOrEmptyList -import java.util.* + +object OverloadabilitySpecificityCallbacks : SpecificityComparisonCallbacks { + override fun isNonSubtypeNotLessSpecific(specific: KotlinType, general: KotlinType): Boolean = + false +} class OverloadChecker(val specificityComparator: TypeSpecificityComparator) { /** @@ -50,11 +47,6 @@ class OverloadChecker(val specificityComparator: TypeSpecificityComparator) { return checkOverloadability(a, b) } - private object OverloadabilitySpecificityCallbacks : SpecificityComparisonCallbacks { - override fun isNonSubtypeNotLessSpecific(specific: KotlinType, general: KotlinType): Boolean = - false - } - private fun checkOverloadability(a: CallableDescriptor, b: CallableDescriptor): Boolean { if (a.hasLowPriorityInOverloadResolution() != b.hasLowPriorityInOverloadResolution()) return true @@ -69,7 +61,7 @@ class OverloadChecker(val specificityComparator: TypeSpecificityComparator) { val aSignature = FlatSignature.createFromCallableDescriptor(a) val bSignature = FlatSignature.createFromCallableDescriptor(b) - val aIsNotLessSpecificThanB = ConstraintSystemBuilderImpl.forSpecificity().isSignatureNotLessSpecific (aSignature, bSignature, OverloadabilitySpecificityCallbacks, specificityComparator) + val aIsNotLessSpecificThanB = ConstraintSystemBuilderImpl.forSpecificity().isSignatureNotLessSpecific(aSignature, bSignature, OverloadabilitySpecificityCallbacks, specificityComparator) val bIsNotLessSpecificThanA = ConstraintSystemBuilderImpl.forSpecificity().isSignatureNotLessSpecific(bSignature, aSignature, OverloadabilitySpecificityCallbacks, specificityComparator) return !(aIsNotLessSpecificThanB && bIsNotLessSpecificThanA) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/OverloadResolver.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/OverloadResolver.kt index 443c3c4e291..d33bcb3a087 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/OverloadResolver.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/OverloadResolver.kt @@ -96,8 +96,8 @@ class OverloadResolver( overloadFilter ) { scope, name -> - val functions = scope.getContributedFunctions(name, NoLookupLocation.WHEN_CHECK_REDECLARATIONS) - val classifier = scope.getContributedClassifier(name, NoLookupLocation.WHEN_CHECK_REDECLARATIONS) + val functions = scope.getContributedFunctions(name, NoLookupLocation.WHEN_CHECK_DECLARATION_CONFLICTS) + val classifier = scope.getContributedClassifier(name, NoLookupLocation.WHEN_CHECK_DECLARATION_CONFLICTS) when (classifier) { is ClassDescriptor -> if (!classifier.kind.isSingleton) @@ -113,8 +113,8 @@ class OverloadResolver( collectModulePackageMembersWithSameName(packageMembersByName, c.properties.values, overloadFilter) { scope, name -> - val variables = scope.getContributedVariables(name, NoLookupLocation.WHEN_CHECK_REDECLARATIONS) - val classifier = scope.getContributedClassifier(name, NoLookupLocation.WHEN_CHECK_REDECLARATIONS) + val variables = scope.getContributedVariables(name, NoLookupLocation.WHEN_CHECK_DECLARATION_CONFLICTS) + val classifier = scope.getContributedClassifier(name, NoLookupLocation.WHEN_CHECK_DECLARATION_CONFLICTS) variables + classifier.singletonOrEmptyList() } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/ShadowedExtensionChecker.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/ShadowedExtensionChecker.kt new file mode 100644 index 00000000000..b9776c593b1 --- /dev/null +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/ShadowedExtensionChecker.kt @@ -0,0 +1,122 @@ +/* + * 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. + * 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.kotlin.resolve + +import org.jetbrains.kotlin.descriptors.* +import org.jetbrains.kotlin.diagnostics.DiagnosticSink +import org.jetbrains.kotlin.diagnostics.Errors +import org.jetbrains.kotlin.incremental.components.NoLookupLocation +import org.jetbrains.kotlin.psi.KtDeclaration +import org.jetbrains.kotlin.resolve.calls.inference.ConstraintSystemBuilderImpl +import org.jetbrains.kotlin.resolve.calls.results.FlatSignature +import org.jetbrains.kotlin.resolve.calls.results.TypeSpecificityComparator +import org.jetbrains.kotlin.resolve.calls.results.isSignatureNotLessSpecific +import org.jetbrains.kotlin.resolve.descriptorUtil.hasHidesMembersAnnotation +import org.jetbrains.kotlin.resolve.descriptorUtil.isExtension +import org.jetbrains.kotlin.resolve.descriptorUtil.varargParameterPosition +import org.jetbrains.kotlin.util.OperatorNameConventions + +class ShadowedExtensionChecker(val typeSpecificityComparator: TypeSpecificityComparator, val trace: DiagnosticSink) { + fun checkDeclaration(declaration: KtDeclaration, descriptor: DeclarationDescriptor) { + if (declaration.name == null) return + if (descriptor !is CallableMemberDescriptor) return + if (descriptor.hasHidesMembersAnnotation()) return + val extensionReceiverType = descriptor.extensionReceiverParameter?.type ?: return + if (extensionReceiverType.isError) return + if (extensionReceiverType.isMarkedNullable) return + + when (descriptor) { + is FunctionDescriptor -> + checkShadowedExtensionFunction(declaration, descriptor, trace) + is PropertyDescriptor -> + checkShadowedExtensionProperty(declaration, descriptor, trace) + } + } + + private fun checkShadowedExtensionFunction(declaration: KtDeclaration, extensionFunction: FunctionDescriptor, trace: DiagnosticSink) { + val memberScope = extensionFunction.extensionReceiverParameter?.type?.memberScope ?: return + + for (memberFunction in memberScope.getContributedFunctions(extensionFunction.name, NoLookupLocation.WHEN_CHECK_DECLARATION_CONFLICTS)) { + if (memberFunction.isPublic() && isExtensionFunctionShadowedByMemberFunction(extensionFunction, memberFunction)) { + trace.report(Errors.EXTENSION_SHADOWED_BY_MEMBER.on(declaration, memberFunction)) + return + } + } + + val nestedClass = memberScope.getContributedClassifier(extensionFunction.name, NoLookupLocation.WHEN_CHECK_DECLARATION_CONFLICTS) + if (nestedClass is ClassDescriptor && nestedClass.isInner && nestedClass.isPublic()) { + for (constructor in nestedClass.constructors) { + if (constructor.isPublic() && isExtensionFunctionShadowedByMemberFunction(extensionFunction, constructor)) { + trace.report(Errors.EXTENSION_FUNCTION_SHADOWED_BY_INNER_CLASS_CONSTRUCTOR.on(declaration, constructor)) + return + } + } + } + + for (memberProperty in memberScope.getContributedVariables(extensionFunction.name, NoLookupLocation.WHEN_CHECK_DECLARATION_CONFLICTS)) { + if (!memberProperty.isPublic()) continue + + val invokeOperator = getInvokeOperatorShadowingExtensionFunction(extensionFunction, memberProperty) + if (invokeOperator != null) { + trace.report(Errors.EXTENSION_FUNCTION_SHADOWED_BY_MEMBER_PROPERTY_WITH_INVOKE.on(declaration, memberProperty, invokeOperator)) + return + } + } + } + + private fun DeclarationDescriptorWithVisibility.isPublic() = + visibility.normalize() == Visibilities.PUBLIC + + private fun isExtensionFunctionShadowedByMemberFunction(extension: FunctionDescriptor, member: FunctionDescriptor): Boolean { + // Permissive check: + // (1) functions should have same number of arguments; + // (2) varargs should be in the same positions; + // (3) extension signature should be not less specific than member signature. + // (1) & (2) are required so that we can match signatures easily. + + if (extension.valueParameters.size != member.valueParameters.size) return false + if (extension.varargParameterPosition() != member.varargParameterPosition()) return false + if (extension.isOperator && !member.isOperator) return false + + val extensionSignature = FlatSignature.createForPossiblyShadowedExtension(extension) + val memberSignature = FlatSignature.createFromCallableDescriptor(member) + return isSignatureNotLessSpecific(extensionSignature, memberSignature) + } + + private fun getInvokeOperatorShadowingExtensionFunction(extension: FunctionDescriptor, member: PropertyDescriptor): FunctionDescriptor? = + member.type.memberScope.getContributedFunctions(OperatorNameConventions.INVOKE, NoLookupLocation.WHEN_CHECK_DECLARATION_CONFLICTS) + .firstOrNull { it.isPublic() && it.isOperator && isExtensionFunctionShadowedByMemberFunction(extension, it) } + + private fun isSignatureNotLessSpecific(extensionSignature: FlatSignature, memberSignature: FlatSignature): Boolean = + ConstraintSystemBuilderImpl.forSpecificity().isSignatureNotLessSpecific( + extensionSignature, + memberSignature, + OverloadabilitySpecificityCallbacks, + typeSpecificityComparator + ) + + private fun checkShadowedExtensionProperty(declaration: KtDeclaration, extensionProperty: PropertyDescriptor, trace: DiagnosticSink) { + val memberScope = extensionProperty.extensionReceiverParameter?.type?.memberScope ?: return + + memberScope.getContributedVariables(extensionProperty.name, NoLookupLocation.WHEN_CHECK_DECLARATION_CONFLICTS) + .firstOrNull { it.isPublic() && !it.isExtension } + ?.let { memberProperty -> + trace.report(Errors.EXTENSION_SHADOWED_BY_MEMBER.on(declaration, memberProperty)) + } + } + +} \ No newline at end of file diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/scopes/LocalRedeclarationChecker.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/scopes/LocalRedeclarationChecker.kt index 02c50423539..20af1e574d0 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/scopes/LocalRedeclarationChecker.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/scopes/LocalRedeclarationChecker.kt @@ -32,7 +32,7 @@ import org.jetbrains.kotlin.resolve.OverloadChecker abstract class AbstractLocalRedeclarationChecker(val overloadChecker: OverloadChecker) : LocalRedeclarationChecker { override fun checkBeforeAddingToScope(scope: LexicalScope, newDescriptor: DeclarationDescriptor) { val name = newDescriptor.name - val location = NoLookupLocation.WHEN_CHECK_REDECLARATIONS + val location = NoLookupLocation.WHEN_CHECK_DECLARATION_CONFLICTS when (newDescriptor) { is ClassifierDescriptor, is VariableDescriptor -> { val otherDescriptor = scope.getContributedClassifier(name, location) diff --git a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/results/FlatSignature.kt b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/results/FlatSignature.kt index ec366fc04ed..d858cd5f650 100644 --- a/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/results/FlatSignature.kt +++ b/compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/results/FlatSignature.kt @@ -21,6 +21,7 @@ import org.jetbrains.kotlin.descriptors.MemberDescriptor import org.jetbrains.kotlin.descriptors.TypeParameterDescriptor import org.jetbrains.kotlin.descriptors.ValueParameterDescriptor import org.jetbrains.kotlin.descriptors.synthetic.SyntheticMemberDescriptor +import org.jetbrains.kotlin.resolve.descriptorUtil.hasDefaultValue import org.jetbrains.kotlin.types.* import org.jetbrains.kotlin.types.checker.KotlinTypeChecker import org.jetbrains.kotlin.utils.singletonOrEmptyList @@ -75,6 +76,17 @@ class FlatSignature private constructor( ): FlatSignature = create(descriptor, descriptor, numDefaults = 0, parameterTypes = descriptor.valueParameters.map { it.argumentValueType }) + fun createForPossiblyShadowedExtension(descriptor: D): FlatSignature = + FlatSignature(descriptor, + descriptor.typeParameters, + valueParameterTypes = descriptor.valueParameters.map { it.argumentValueType }, + hasExtensionReceiver = false, + hasVarargs = descriptor.valueParameters.any { it.varargElementType != null }, + numDefaults = descriptor.valueParameters.count { it.hasDefaultValue() }, + isHeader = descriptor is MemberDescriptor && descriptor.isHeader, + isSyntheticMember = descriptor is SyntheticMemberDescriptor<*> + ) + val ValueParameterDescriptor.argumentValueType get() = varargElementType ?: type } } diff --git a/compiler/testData/diagnostics/tests/OperatorChecks.kt b/compiler/testData/diagnostics/tests/OperatorChecks.kt index 3e7b299ec59..01cbaefd66b 100644 --- a/compiler/testData/diagnostics/tests/OperatorChecks.kt +++ b/compiler/testData/diagnostics/tests/OperatorChecks.kt @@ -1,3 +1,5 @@ +// !DIAGNOSTICS: -EXTENSION_SHADOWED_BY_MEMBER + import kotlin.reflect.KProperty interface Example { diff --git a/compiler/testData/diagnostics/tests/callableReference/emptyLhs.kt b/compiler/testData/diagnostics/tests/callableReference/emptyLhs.kt index d814b08aceb..7a22a2cd1b9 100644 --- a/compiler/testData/diagnostics/tests/callableReference/emptyLhs.kt +++ b/compiler/testData/diagnostics/tests/callableReference/emptyLhs.kt @@ -1,4 +1,4 @@ -// !DIAGNOSTICS: -UNUSED_EXPRESSION +// !DIAGNOSTICS: -UNUSED_EXPRESSION, -EXTENSION_SHADOWED_BY_MEMBER val topLevelVal = 1 fun topLevelFun() = 2 diff --git a/compiler/testData/diagnostics/tests/callableReference/function/noAmbiguityMemberVsExtension.kt b/compiler/testData/diagnostics/tests/callableReference/function/noAmbiguityMemberVsExtension.kt index f8cbe71c6b2..d84c9cc1ce1 100644 --- a/compiler/testData/diagnostics/tests/callableReference/function/noAmbiguityMemberVsExtension.kt +++ b/compiler/testData/diagnostics/tests/callableReference/function/noAmbiguityMemberVsExtension.kt @@ -6,7 +6,7 @@ class A { fun foo() = 42 } -fun A.foo() {} +fun A.foo() {} fun main() { val x = A::foo diff --git a/compiler/testData/diagnostics/tests/callableReference/resolve/withExtFun.kt b/compiler/testData/diagnostics/tests/callableReference/resolve/withExtFun.kt index 5a52d59c4d3..cfe695bb2a9 100644 --- a/compiler/testData/diagnostics/tests/callableReference/resolve/withExtFun.kt +++ b/compiler/testData/diagnostics/tests/callableReference/resolve/withExtFun.kt @@ -1,4 +1,4 @@ -// !DIAGNOSTICS: -UNUSED_PARAMETER +// !DIAGNOSTICS: -UNUSED_PARAMETER, -EXTENSION_SHADOWED_BY_MEMBER import kotlin.reflect.* diff --git a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/BinaryExpressionIdentifier.kt b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/BinaryExpressionIdentifier.kt index 8d07b8b532a..8edf3e80777 100644 --- a/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/BinaryExpressionIdentifier.kt +++ b/compiler/testData/diagnostics/tests/dataFlowInfoTraversal/BinaryExpressionIdentifier.kt @@ -1,6 +1,6 @@ // !CHECK_TYPE -infix fun Int.compareTo(o: Int) = 0 +infix fun Int.compareTo(o: Int) = 0 fun foo(a: Number): Int { val result = (a as Int) compareTo a diff --git a/compiler/testData/diagnostics/tests/declarationChecks/localDeclarationModifiers.kt b/compiler/testData/diagnostics/tests/declarationChecks/localDeclarationModifiers.kt index 563d53a17da..d816dd7182f 100644 --- a/compiler/testData/diagnostics/tests/declarationChecks/localDeclarationModifiers.kt +++ b/compiler/testData/diagnostics/tests/declarationChecks/localDeclarationModifiers.kt @@ -7,6 +7,6 @@ class T { fun foo() { public val i = 11 abstract val j - override fun T.baz() = 2 + override fun T.baz() = 2 private fun bar() = 2 } \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/declarationChecks/localFunctionNoInheritVisibility.kt b/compiler/testData/diagnostics/tests/declarationChecks/localFunctionNoInheritVisibility.kt index 44a5b20249e..859148ef51b 100644 --- a/compiler/testData/diagnostics/tests/declarationChecks/localFunctionNoInheritVisibility.kt +++ b/compiler/testData/diagnostics/tests/declarationChecks/localFunctionNoInheritVisibility.kt @@ -7,7 +7,7 @@ class T { override fun zzz() {} fun foo(t: T) { - override fun T.baz() = 2 + override fun T.baz() = 2 // was "Visibility is unknown yet exception" t.baz() diff --git a/compiler/testData/diagnostics/tests/extensions/ExtensionFunctions.kt b/compiler/testData/diagnostics/tests/extensions/ExtensionFunctions.kt index c11724ad947..718d0585865 100644 --- a/compiler/testData/diagnostics/tests/extensions/ExtensionFunctions.kt +++ b/compiler/testData/diagnostics/tests/extensions/ExtensionFunctions.kt @@ -51,7 +51,7 @@ import outer.* val foo : Int = 0 } - fun Any.equals(other : Any?) : Boolean = true + fun Any.equals(other : Any?) : Boolean = true fun Any?.equals1(other : Any?) : Boolean = true fun Any.equals2(other : Any?) : Boolean = true diff --git a/compiler/testData/diagnostics/tests/extensions/ExtensionsCalledOnSuper.kt b/compiler/testData/diagnostics/tests/extensions/ExtensionsCalledOnSuper.kt index 16744a9ad03..220d2cbeb2a 100644 --- a/compiler/testData/diagnostics/tests/extensions/ExtensionsCalledOnSuper.kt +++ b/compiler/testData/diagnostics/tests/extensions/ExtensionsCalledOnSuper.kt @@ -6,12 +6,12 @@ interface T { fun T.bar() {} -fun T.buzz() {} +fun T.buzz() {} fun T.buzz1() {} class C : T { fun test() { - fun T.buzz() {} + fun T.buzz() {} fun T.buzz1() {} super.foo() // OK super.bar() // Error diff --git a/compiler/testData/diagnostics/tests/inference/nestedCalls/binaryExpressions.kt b/compiler/testData/diagnostics/tests/inference/nestedCalls/binaryExpressions.kt index 596a86607ea..279645dd144 100644 --- a/compiler/testData/diagnostics/tests/inference/nestedCalls/binaryExpressions.kt +++ b/compiler/testData/diagnostics/tests/inference/nestedCalls/binaryExpressions.kt @@ -41,7 +41,7 @@ fun test2(z: Z) { } //'equals' operation -fun Z.equals(any: Any): Int { use(any); return 1 } +fun Z.equals(any: Any): Int { use(any); return 1 } fun test3(z: Z) { z == newA() diff --git a/compiler/testData/diagnostics/tests/inference/regressions/kt2179.kt b/compiler/testData/diagnostics/tests/inference/regressions/kt2179.kt index b19c3e751d1..6101e0ebdc4 100644 --- a/compiler/testData/diagnostics/tests/inference/regressions/kt2179.kt +++ b/compiler/testData/diagnostics/tests/inference/regressions/kt2179.kt @@ -42,5 +42,5 @@ fun > Array.toCollection(result: C) : C { return result } -val Collection<*>.size : Int +val Collection<*>.size : Int get() = size diff --git a/compiler/testData/diagnostics/tests/modifiers/operatorInfix/MemberFunctions.kt b/compiler/testData/diagnostics/tests/modifiers/operatorInfix/MemberFunctions.kt index 82811b756f2..118c18e1137 100644 --- a/compiler/testData/diagnostics/tests/modifiers/operatorInfix/MemberFunctions.kt +++ b/compiler/testData/diagnostics/tests/modifiers/operatorInfix/MemberFunctions.kt @@ -1,4 +1,4 @@ -// !DIAGNOSTICS: -UNUSED_PARAMETER +// !DIAGNOSTICS: -UNUSED_PARAMETER, -EXTENSION_SHADOWED_BY_MEMBER class Example { operator infix fun plus(other: Example) = 0 diff --git a/compiler/testData/diagnostics/tests/modifiers/operatorInfix/Simple.kt b/compiler/testData/diagnostics/tests/modifiers/operatorInfix/Simple.kt index 3d0a15c26c5..b58a31a2e03 100644 --- a/compiler/testData/diagnostics/tests/modifiers/operatorInfix/Simple.kt +++ b/compiler/testData/diagnostics/tests/modifiers/operatorInfix/Simple.kt @@ -1,4 +1,4 @@ -// !DIAGNOSTICS: -UNUSED_PARAMETER +// !DIAGNOSTICS: -UNUSED_PARAMETER, -EXTENSION_SHADOWED_BY_MEMBER open class Example { fun invoke() = 0 diff --git a/compiler/testData/diagnostics/tests/operatorRem/modWithRemAssign.kt b/compiler/testData/diagnostics/tests/operatorRem/modWithRemAssign.kt index 5b69f5d996f..c190b101aec 100644 --- a/compiler/testData/diagnostics/tests/operatorRem/modWithRemAssign.kt +++ b/compiler/testData/diagnostics/tests/operatorRem/modWithRemAssign.kt @@ -1,4 +1,4 @@ -// !DIAGNOSTICS: -UNUSED_PARAMETER +// !DIAGNOSTICS: -UNUSED_PARAMETER, -EXTENSION_SHADOWED_BY_MEMBER class ModAndRemAssign { operator fun mod(x: Int) = ModAndRemAssign() diff --git a/compiler/testData/diagnostics/tests/operatorRem/noOperatorRemFeature.kt b/compiler/testData/diagnostics/tests/operatorRem/noOperatorRemFeature.kt index 9c9582086ab..c100ee377f1 100644 --- a/compiler/testData/diagnostics/tests/operatorRem/noOperatorRemFeature.kt +++ b/compiler/testData/diagnostics/tests/operatorRem/noOperatorRemFeature.kt @@ -1,5 +1,5 @@ // !LANGUAGE: -OperatorRem -// !DIAGNOSTICS: -UNUSED_PARAMETER, -UNUSED_VARIABLE +// !DIAGNOSTICS: -UNUSED_PARAMETER, -UNUSED_VARIABLE, -EXTENSION_SHADOWED_BY_MEMBER class Foo { operator fun rem(x: Int): Foo = Foo() diff --git a/compiler/testData/diagnostics/tests/operatorRem/numberRemConversions.kt b/compiler/testData/diagnostics/tests/operatorRem/numberRemConversions.kt index 9ba8553cda5..8a4f61dc926 100644 --- a/compiler/testData/diagnostics/tests/operatorRem/numberRemConversions.kt +++ b/compiler/testData/diagnostics/tests/operatorRem/numberRemConversions.kt @@ -12,4 +12,4 @@ fun test() { fooShort(1 % 1) } -public operator fun Int.rem(other: Int): Int = 0 \ No newline at end of file +public operator fun Int.rem(other: Int): Int = 0 \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/operatorRem/remWithModAndModAssign.kt b/compiler/testData/diagnostics/tests/operatorRem/remWithModAndModAssign.kt index a4550801ae3..c401be2e4a7 100644 --- a/compiler/testData/diagnostics/tests/operatorRem/remWithModAndModAssign.kt +++ b/compiler/testData/diagnostics/tests/operatorRem/remWithModAndModAssign.kt @@ -1,4 +1,4 @@ -// !DIAGNOSTICS: -UNUSED_PARAMETER +// !DIAGNOSTICS: -UNUSED_PARAMETER, -EXTENSION_SHADOWED_BY_MEMBER class ModAndRemAssign { operator fun mod(x: Int) = ModAndRemAssign() diff --git a/compiler/testData/diagnostics/tests/redeclarations/shadowedExtension/extensionFunShadowedByInnerClassConstructor.kt b/compiler/testData/diagnostics/tests/redeclarations/shadowedExtension/extensionFunShadowedByInnerClassConstructor.kt new file mode 100644 index 00000000000..729b0ca5e3c --- /dev/null +++ b/compiler/testData/diagnostics/tests/redeclarations/shadowedExtension/extensionFunShadowedByInnerClassConstructor.kt @@ -0,0 +1,31 @@ +// !DIAGNOSTICS: -UNUSED_PARAMETER + +class Outer { + inner class Test1 + inner class Test2(val x: Int) + inner class Test3(val x: Any) + inner class Test4(val x: T) + inner class Test5(val x: Int) { + constructor() : this(0) + private constructor(z: String) : this(z.length) + } + + class TestNested + + internal class TestInternal + protected class TestProtected + private class TestPrivate +} + +fun Outer.Test1() {} +fun Outer.Test2(x: Int) {} +fun Outer.Test3(x: String) {} +fun Outer.Test3(x: T) {} +fun Outer.Test4(x: T) {} +fun Outer.Test5() {} +fun Outer.Test5(z: String) {} + +fun Outer.TestNested() {} +fun Outer.TestInternal() {} +fun Outer.TestProtected() {} +fun Outer.TestPrivate() {} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/redeclarations/shadowedExtension/extensionFunShadowedByInnerClassConstructor.txt b/compiler/testData/diagnostics/tests/redeclarations/shadowedExtension/extensionFunShadowedByInnerClassConstructor.txt new file mode 100644 index 00000000000..1e5eaebda8d --- /dev/null +++ b/compiler/testData/diagnostics/tests/redeclarations/shadowedExtension/extensionFunShadowedByInnerClassConstructor.txt @@ -0,0 +1,89 @@ +package + +public fun Outer.Test1(): kotlin.Unit +public fun Outer.Test2(/*0*/ x: kotlin.Int): kotlin.Unit +public fun Outer.Test3(/*0*/ x: T): kotlin.Unit +public fun Outer.Test3(/*0*/ x: kotlin.String): kotlin.Unit +public fun Outer.Test4(/*0*/ x: T): kotlin.Unit +public fun Outer.Test5(): kotlin.Unit +public fun Outer.Test5(/*0*/ z: kotlin.String): kotlin.Unit +public fun Outer.TestInternal(): kotlin.Unit +public fun Outer.TestNested(): kotlin.Unit +public fun Outer.TestPrivate(): kotlin.Unit +public fun Outer.TestProtected(): kotlin.Unit + +public final class Outer { + public constructor Outer() + 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 + + public final inner class Test1 { + public constructor Test1() + 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 + } + + public final inner class Test2 { + public constructor Test2(/*0*/ x: kotlin.Int) + public final val x: kotlin.Int + 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 + } + + public final inner class Test3 { + public constructor Test3(/*0*/ x: kotlin.Any) + public final val x: kotlin.Any + 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 + } + + public final inner class Test4 { + public constructor Test4(/*0*/ x: T) + public final val x: T + 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 + } + + public final inner class Test5 { + public constructor Test5() + public constructor Test5(/*0*/ x: kotlin.Int) + private constructor Test5(/*0*/ z: kotlin.String) + public final val x: kotlin.Int + 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 + } + + internal final class TestInternal { + public constructor TestInternal() + 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 + } + + public final class TestNested { + public constructor TestNested() + 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 + } + + private final class TestPrivate { + public constructor TestPrivate() + 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 + } + + protected final class TestProtected { + public constructor TestProtected() + 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 + } +} diff --git a/compiler/testData/diagnostics/tests/redeclarations/shadowedExtension/extensionFunShadowedByMemberFun.kt b/compiler/testData/diagnostics/tests/redeclarations/shadowedExtension/extensionFunShadowedByMemberFun.kt new file mode 100644 index 00000000000..f7766e89acd --- /dev/null +++ b/compiler/testData/diagnostics/tests/redeclarations/shadowedExtension/extensionFunShadowedByMemberFun.kt @@ -0,0 +1,32 @@ +// !DIAGNOSTICS: -UNUSED_PARAMETER + +interface Test1 { + fun test1() {} +} +fun Test1.test1() {} + +interface Test2 { + fun test2(x: String) {} +} +fun Test2.test2(x: Any) {} + +interface Test3 { + fun test3(x: Any) {} +} +fun Test3.test3(x: String) {} +fun Test3.test3(x: T) {} + +interface Test4 { + fun test4(x: T) {} +} +fun Test4.test4(x: String) {} + +interface Test5 { + fun test5(x: T) {} +} +fun Test5.test5(x: T) {} + +interface Test6 { + fun > test6(x: T) {} +} +fun > Test6.test6(x: T) {} diff --git a/compiler/testData/diagnostics/tests/redeclarations/shadowedExtension/extensionFunShadowedByMemberFun.txt b/compiler/testData/diagnostics/tests/redeclarations/shadowedExtension/extensionFunShadowedByMemberFun.txt new file mode 100644 index 00000000000..11e3edfdb15 --- /dev/null +++ b/compiler/testData/diagnostics/tests/redeclarations/shadowedExtension/extensionFunShadowedByMemberFun.txt @@ -0,0 +1,51 @@ +package + +public fun Test1.test1(): kotlin.Unit +public fun Test2.test2(/*0*/ x: kotlin.Any): kotlin.Unit +public fun Test3.test3(/*0*/ x: T): kotlin.Unit +public fun Test3.test3(/*0*/ x: kotlin.String): kotlin.Unit +public fun Test4.test4(/*0*/ x: kotlin.String): kotlin.Unit +public fun Test5.test5(/*0*/ x: T): kotlin.Unit +public fun > Test6.test6(/*0*/ x: T): kotlin.Unit + +public interface Test1 { + 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 fun test1(): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +public interface Test2 { + 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 fun test2(/*0*/ x: kotlin.String): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +public interface Test3 { + 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 fun test3(/*0*/ x: kotlin.Any): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +public interface Test4 { + 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 fun test4(/*0*/ x: T): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +public interface Test5 { + 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 fun test5(/*0*/ x: T): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +public interface Test6 { + 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 fun > test6(/*0*/ x: T): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/testData/diagnostics/tests/redeclarations/shadowedExtension/extensionFunShadowedByMemberPropertyWithInvoke.kt b/compiler/testData/diagnostics/tests/redeclarations/shadowedExtension/extensionFunShadowedByMemberPropertyWithInvoke.kt new file mode 100644 index 00000000000..19a73c38b11 --- /dev/null +++ b/compiler/testData/diagnostics/tests/redeclarations/shadowedExtension/extensionFunShadowedByMemberPropertyWithInvoke.kt @@ -0,0 +1,18 @@ +// !DIAGNOSTICS: -UNUSED_PARAMETER + +interface WithInvoke { + operator fun invoke() + operator fun invoke(s: String) + operator fun invoke(x: T, y: Int) + fun invoke(i: Int) +} + +interface Test1 { + val test1: WithInvoke +} + +fun Test1.test1() {} +fun Test1.test1(s: String) {} +fun Test1.test1(i: Int) {} +fun Test1.test1(x: Any, y: Int) {} +fun Test1.test1(x: T, y: Int) {} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/redeclarations/shadowedExtension/extensionFunShadowedByMemberPropertyWithInvoke.txt b/compiler/testData/diagnostics/tests/redeclarations/shadowedExtension/extensionFunShadowedByMemberPropertyWithInvoke.txt new file mode 100644 index 00000000000..6f8a7d6427c --- /dev/null +++ b/compiler/testData/diagnostics/tests/redeclarations/shadowedExtension/extensionFunShadowedByMemberPropertyWithInvoke.txt @@ -0,0 +1,24 @@ +package + +public fun Test1.test1(): kotlin.Unit +public fun Test1.test1(/*0*/ x: T, /*1*/ y: kotlin.Int): kotlin.Unit +public fun Test1.test1(/*0*/ x: kotlin.Any, /*1*/ y: kotlin.Int): kotlin.Unit +public fun Test1.test1(/*0*/ i: kotlin.Int): kotlin.Unit +public fun Test1.test1(/*0*/ s: kotlin.String): kotlin.Unit + +public interface Test1 { + public abstract val test1: WithInvoke + 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 +} + +public interface WithInvoke { + 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 abstract operator fun invoke(): kotlin.Unit + public abstract operator fun invoke(/*0*/ x: T, /*1*/ y: kotlin.Int): kotlin.Unit + public abstract fun invoke(/*0*/ i: kotlin.Int): kotlin.Unit + public abstract operator fun invoke(/*0*/ s: kotlin.String): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/testData/diagnostics/tests/redeclarations/shadowedExtension/extensionFunShadowedBySynthesizedMemberFun.kt b/compiler/testData/diagnostics/tests/redeclarations/shadowedExtension/extensionFunShadowedBySynthesizedMemberFun.kt new file mode 100644 index 00000000000..ef71eb1d6e8 --- /dev/null +++ b/compiler/testData/diagnostics/tests/redeclarations/shadowedExtension/extensionFunShadowedBySynthesizedMemberFun.kt @@ -0,0 +1,5 @@ +// !DIAGNOSTICS: -UNUSED_PARAMETER + +data class DataClass(val x: Int) + +fun DataClass.component1() = 42 \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/redeclarations/shadowedExtension/extensionFunShadowedBySynthesizedMemberFun.txt b/compiler/testData/diagnostics/tests/redeclarations/shadowedExtension/extensionFunShadowedBySynthesizedMemberFun.txt new file mode 100644 index 00000000000..da55395761a --- /dev/null +++ b/compiler/testData/diagnostics/tests/redeclarations/shadowedExtension/extensionFunShadowedBySynthesizedMemberFun.txt @@ -0,0 +1,13 @@ +package + +public fun DataClass.component1(): kotlin.Int + +public final data class DataClass { + public constructor DataClass(/*0*/ x: kotlin.Int) + public final val x: kotlin.Int + public final operator /*synthesized*/ fun component1(): kotlin.Int + public final /*synthesized*/ fun copy(/*0*/ x: kotlin.Int = ...): DataClass + public open override /*1*/ /*synthesized*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*synthesized*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*synthesized*/ fun toString(): kotlin.String +} diff --git a/compiler/testData/diagnostics/tests/redeclarations/shadowedExtension/extensionFunVsMemberExtensionFun.kt b/compiler/testData/diagnostics/tests/redeclarations/shadowedExtension/extensionFunVsMemberExtensionFun.kt new file mode 100644 index 00000000000..8298c498e70 --- /dev/null +++ b/compiler/testData/diagnostics/tests/redeclarations/shadowedExtension/extensionFunVsMemberExtensionFun.kt @@ -0,0 +1,5 @@ +class C { + fun Int.foo() {} +} + +fun C.foo() {} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/redeclarations/shadowedExtension/extensionFunVsMemberExtensionFun.txt b/compiler/testData/diagnostics/tests/redeclarations/shadowedExtension/extensionFunVsMemberExtensionFun.txt new file mode 100644 index 00000000000..92274f01030 --- /dev/null +++ b/compiler/testData/diagnostics/tests/redeclarations/shadowedExtension/extensionFunVsMemberExtensionFun.txt @@ -0,0 +1,11 @@ +package + +public fun C.foo(): kotlin.Unit + +public final class C { + public constructor C() + 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 + public final fun kotlin.Int.foo(): kotlin.Unit +} diff --git a/compiler/testData/diagnostics/tests/redeclarations/shadowedExtension/extensionOnErrorType.kt b/compiler/testData/diagnostics/tests/redeclarations/shadowedExtension/extensionOnErrorType.kt new file mode 100644 index 00000000000..03781e5adfa --- /dev/null +++ b/compiler/testData/diagnostics/tests/redeclarations/shadowedExtension/extensionOnErrorType.kt @@ -0,0 +1,7 @@ +interface G { + fun foo() + val bar: Int +} + +fun G.foo() {} +val G.bar: Int get() = 42 \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/redeclarations/shadowedExtension/extensionOnErrorType.txt b/compiler/testData/diagnostics/tests/redeclarations/shadowedExtension/extensionOnErrorType.txt new file mode 100644 index 00000000000..928eb2ecdbb --- /dev/null +++ b/compiler/testData/diagnostics/tests/redeclarations/shadowedExtension/extensionOnErrorType.txt @@ -0,0 +1,12 @@ +package + +public val [ERROR : G].bar: kotlin.Int +public fun [ERROR : G].foo(): kotlin.Unit + +public interface G { + public abstract val bar: kotlin.Int + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public abstract fun foo(): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/testData/diagnostics/tests/redeclarations/shadowedExtension/extensionOnNullableReceiver.kt b/compiler/testData/diagnostics/tests/redeclarations/shadowedExtension/extensionOnNullableReceiver.kt new file mode 100644 index 00000000000..796aee5f4e0 --- /dev/null +++ b/compiler/testData/diagnostics/tests/redeclarations/shadowedExtension/extensionOnNullableReceiver.kt @@ -0,0 +1,7 @@ +interface Test { + fun foo() + val bar: Int +} + +fun Test?.foo() {} +val Test?.bar: Int get() = 42 \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/redeclarations/shadowedExtension/extensionOnNullableReceiver.txt b/compiler/testData/diagnostics/tests/redeclarations/shadowedExtension/extensionOnNullableReceiver.txt new file mode 100644 index 00000000000..d645ba7f493 --- /dev/null +++ b/compiler/testData/diagnostics/tests/redeclarations/shadowedExtension/extensionOnNullableReceiver.txt @@ -0,0 +1,12 @@ +package + +public val Test?.bar: kotlin.Int +public fun Test?.foo(): kotlin.Unit + +public interface Test { + public abstract val bar: kotlin.Int + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public abstract fun foo(): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/testData/diagnostics/tests/redeclarations/shadowedExtension/extensionPropertyShadowedByMemberProperty.kt b/compiler/testData/diagnostics/tests/redeclarations/shadowedExtension/extensionPropertyShadowedByMemberProperty.kt new file mode 100644 index 00000000000..06089846990 --- /dev/null +++ b/compiler/testData/diagnostics/tests/redeclarations/shadowedExtension/extensionPropertyShadowedByMemberProperty.kt @@ -0,0 +1,22 @@ +// !DIAGNOSTICS: -UNUSED_PARAMETER + +interface Test1 { + val test1: Int +} +val Test1.test1: Int get() = 42 + +interface Test2 { + var test2: Int +} +val Test2.test2: Int get() = 42 + +interface Test3 { + val test3: Int +} +var Test3.test3: Int get() = 42; set(v) {} + +interface Test4 { + val test4: Int +} +var Test4.test4: Int get() = 42; set(v) {} + diff --git a/compiler/testData/diagnostics/tests/redeclarations/shadowedExtension/extensionPropertyShadowedByMemberProperty.txt b/compiler/testData/diagnostics/tests/redeclarations/shadowedExtension/extensionPropertyShadowedByMemberProperty.txt new file mode 100644 index 00000000000..802e57b47fd --- /dev/null +++ b/compiler/testData/diagnostics/tests/redeclarations/shadowedExtension/extensionPropertyShadowedByMemberProperty.txt @@ -0,0 +1,34 @@ +package + +public val Test1.test1: kotlin.Int +public val Test2.test2: kotlin.Int +public var Test3.test3: kotlin.Int +public var Test4.test4: kotlin.Int + +public interface Test1 { + public abstract val test1: kotlin.Int + 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 +} + +public interface Test2 { + public abstract var test2: kotlin.Int + 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 +} + +public interface Test3 { + public abstract val test3: kotlin.Int + 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 +} + +public interface Test4 { + public abstract val test4: kotlin.Int + 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 +} diff --git a/compiler/testData/diagnostics/tests/redeclarations/shadowedExtension/extensionShadowedByDelegatedMember.kt b/compiler/testData/diagnostics/tests/redeclarations/shadowedExtension/extensionShadowedByDelegatedMember.kt new file mode 100644 index 00000000000..20e7c710b6f --- /dev/null +++ b/compiler/testData/diagnostics/tests/redeclarations/shadowedExtension/extensionShadowedByDelegatedMember.kt @@ -0,0 +1,16 @@ +// !DIAGNOSTICS: -UNUSED_PARAMETER + +interface IBase { + fun foo() + val bar: Int +} + +object Impl : IBase { + override fun foo() {} + override val bar: Int get() = 42 +} + +object Test : IBase by Impl + +fun Test.foo() {} +val Test.bar: Int get() = 42 \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/redeclarations/shadowedExtension/extensionShadowedByDelegatedMember.txt b/compiler/testData/diagnostics/tests/redeclarations/shadowedExtension/extensionShadowedByDelegatedMember.txt new file mode 100644 index 00000000000..24c4c3120ad --- /dev/null +++ b/compiler/testData/diagnostics/tests/redeclarations/shadowedExtension/extensionShadowedByDelegatedMember.txt @@ -0,0 +1,30 @@ +package + +public val Test.bar: kotlin.Int +public fun Test.foo(): kotlin.Unit + +public interface IBase { + public abstract val bar: kotlin.Int + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public abstract fun foo(): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +public object Impl : IBase { + private constructor Impl() + public open override /*1*/ val bar: kotlin.Int + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ fun foo(): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +public object Test : IBase { + private constructor Test() + public open override /*1*/ /*delegation*/ val bar: kotlin.Int + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*delegation*/ fun foo(): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/testData/diagnostics/tests/redeclarations/shadowedExtension/extensionVsNonPublicMember.kt b/compiler/testData/diagnostics/tests/redeclarations/shadowedExtension/extensionVsNonPublicMember.kt new file mode 100644 index 00000000000..7587fc5e14a --- /dev/null +++ b/compiler/testData/diagnostics/tests/redeclarations/shadowedExtension/extensionVsNonPublicMember.kt @@ -0,0 +1,47 @@ +class WithPublicInvoke { + public operator fun invoke() {} +} + +class WithInternalInvoke { + internal operator fun invoke() {} +} + +class WithProtectedInvoke { + protected operator fun invoke() {} +} + +class WithPrivateInvoke { + private operator fun invoke() {} +} + +class Test { + public fun publicFoo() {} + internal fun internalFoo() {} + protected fun protectedFoo() {} + private fun privateFoo() {} + + public val publicVal = 42 + internal val internalVal = 42 + protected val protectedVal = 42 + private val privateVal = 42 + + public val withPublicInvoke = WithPublicInvoke() + public val withInternalInvoke = WithInternalInvoke() + public val withProtectedInvoke = WithProtectedInvoke() + public val withPrivateInvoke = WithPrivateInvoke() +} + +private fun Test.publicFoo() {} +fun Test.internalFoo() {} +fun Test.protectedFoo() {} +fun Test.privateFoo() {} + +val Test.publicVal: Int get() = 42 +val Test.internalVal: Int get() = 42 +val Test.protectedVal: Int get() = 42 +val Test.privateVal: Int get() = 42 + +fun Test.withPublicInvoke() {} +fun Test.wihtInternalInvoke() {} +fun Test.withProtectedInvoke() {} +fun Test.withPrivateInvoke() {} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/redeclarations/shadowedExtension/extensionVsNonPublicMember.txt b/compiler/testData/diagnostics/tests/redeclarations/shadowedExtension/extensionVsNonPublicMember.txt new file mode 100644 index 00000000000..c31cc957efb --- /dev/null +++ b/compiler/testData/diagnostics/tests/redeclarations/shadowedExtension/extensionVsNonPublicMember.txt @@ -0,0 +1,65 @@ +package + +public val Test.internalVal: kotlin.Int +public val Test.privateVal: kotlin.Int +public val Test.protectedVal: kotlin.Int +public val Test.publicVal: kotlin.Int +public fun Test.internalFoo(): kotlin.Unit +public fun Test.privateFoo(): kotlin.Unit +public fun Test.protectedFoo(): kotlin.Unit +private fun Test.publicFoo(): kotlin.Unit +public fun Test.wihtInternalInvoke(): kotlin.Unit +public fun Test.withPrivateInvoke(): kotlin.Unit +public fun Test.withProtectedInvoke(): kotlin.Unit +public fun Test.withPublicInvoke(): kotlin.Unit + +public final class Test { + public constructor Test() + internal final val internalVal: kotlin.Int = 42 + private final val privateVal: kotlin.Int = 42 + protected final val protectedVal: kotlin.Int = 42 + public final val publicVal: kotlin.Int = 42 + public final val withInternalInvoke: WithInternalInvoke + public final val withPrivateInvoke: WithPrivateInvoke + public final val withProtectedInvoke: WithProtectedInvoke + public final val withPublicInvoke: WithPublicInvoke + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + internal final fun internalFoo(): kotlin.Unit + private final fun privateFoo(): kotlin.Unit + protected final fun protectedFoo(): kotlin.Unit + public final fun publicFoo(): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +public final class WithInternalInvoke { + public constructor WithInternalInvoke() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + internal final operator fun invoke(): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +public final class WithPrivateInvoke { + public constructor WithPrivateInvoke() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + private final operator fun invoke(): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +public final class WithProtectedInvoke { + public constructor WithProtectedInvoke() + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + protected final operator fun invoke(): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} + +public final class WithPublicInvoke { + public constructor WithPublicInvoke() + 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 final operator fun invoke(): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/testData/diagnostics/tests/redeclarations/shadowedExtension/localExtensionShadowedByMember.kt b/compiler/testData/diagnostics/tests/redeclarations/shadowedExtension/localExtensionShadowedByMember.kt new file mode 100644 index 00000000000..9c20634ca52 --- /dev/null +++ b/compiler/testData/diagnostics/tests/redeclarations/shadowedExtension/localExtensionShadowedByMember.kt @@ -0,0 +1,7 @@ +interface IFoo { + fun foo() +} + +fun outer() { + fun IFoo.foo() {} +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/redeclarations/shadowedExtension/localExtensionShadowedByMember.txt b/compiler/testData/diagnostics/tests/redeclarations/shadowedExtension/localExtensionShadowedByMember.txt new file mode 100644 index 00000000000..97403713b3c --- /dev/null +++ b/compiler/testData/diagnostics/tests/redeclarations/shadowedExtension/localExtensionShadowedByMember.txt @@ -0,0 +1,10 @@ +package + +public fun outer(): kotlin.Unit + +public interface IFoo { + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public abstract fun foo(): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/testData/diagnostics/tests/redeclarations/shadowedExtension/memberExtensionShadowedByMember.kt b/compiler/testData/diagnostics/tests/redeclarations/shadowedExtension/memberExtensionShadowedByMember.kt new file mode 100644 index 00000000000..8b3f7bc34ca --- /dev/null +++ b/compiler/testData/diagnostics/tests/redeclarations/shadowedExtension/memberExtensionShadowedByMember.kt @@ -0,0 +1,9 @@ +interface IFooBar { + fun foo() + val bar: Int +} + +class Host { + fun IFooBar.foo() {} + val IFooBar.bar: Int get() = 42 +} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/redeclarations/shadowedExtension/memberExtensionShadowedByMember.txt b/compiler/testData/diagnostics/tests/redeclarations/shadowedExtension/memberExtensionShadowedByMember.txt new file mode 100644 index 00000000000..4fb827193e1 --- /dev/null +++ b/compiler/testData/diagnostics/tests/redeclarations/shadowedExtension/memberExtensionShadowedByMember.txt @@ -0,0 +1,18 @@ +package + +public final class Host { + public constructor Host() + public final val IFooBar.bar: kotlin.Int + 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 + public final fun IFooBar.foo(): kotlin.Unit +} + +public interface IFooBar { + public abstract val bar: kotlin.Int + public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean + public abstract fun foo(): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/testData/diagnostics/tests/redeclarations/shadowedExtension/operatorExtensionVsNonOperatorMember.kt b/compiler/testData/diagnostics/tests/redeclarations/shadowedExtension/operatorExtensionVsNonOperatorMember.kt new file mode 100644 index 00000000000..35e3f25596d --- /dev/null +++ b/compiler/testData/diagnostics/tests/redeclarations/shadowedExtension/operatorExtensionVsNonOperatorMember.kt @@ -0,0 +1,5 @@ +interface Test { + fun invoke() +} + +operator fun Test.invoke() {} \ No newline at end of file diff --git a/compiler/testData/diagnostics/tests/redeclarations/shadowedExtension/operatorExtensionVsNonOperatorMember.txt b/compiler/testData/diagnostics/tests/redeclarations/shadowedExtension/operatorExtensionVsNonOperatorMember.txt new file mode 100644 index 00000000000..c77f47e570b --- /dev/null +++ b/compiler/testData/diagnostics/tests/redeclarations/shadowedExtension/operatorExtensionVsNonOperatorMember.txt @@ -0,0 +1,10 @@ +package + +public operator fun Test.invoke(): kotlin.Unit + +public interface Test { + 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 abstract fun invoke(): kotlin.Unit + public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String +} diff --git a/compiler/testData/diagnostics/tests/regressions/Jet69.kt b/compiler/testData/diagnostics/tests/regressions/Jet69.kt index 604c731552a..85a6bf396dc 100644 --- a/compiler/testData/diagnostics/tests/regressions/Jet69.kt +++ b/compiler/testData/diagnostics/tests/regressions/Jet69.kt @@ -2,7 +2,7 @@ class Command() {} fun parse(cmd: String): Command? { return null } -fun Any.equals(other : Any?) : Boolean = this === other +fun Any.equals(other : Any?) : Boolean = this === other fun main(args: Array) { val command = parse("") diff --git a/compiler/testData/diagnostics/tests/regressions/SpecififcityByReceiver.kt b/compiler/testData/diagnostics/tests/regressions/SpecififcityByReceiver.kt index 0885069eb25..782de6062e9 100644 --- a/compiler/testData/diagnostics/tests/regressions/SpecififcityByReceiver.kt +++ b/compiler/testData/diagnostics/tests/regressions/SpecififcityByReceiver.kt @@ -1,4 +1,4 @@ -fun Any.equals(other : Any?) : Boolean = true +fun Any.equals(other : Any?) : Boolean = true fun main(args: Array) { diff --git a/compiler/testData/diagnostics/tests/resolve/priority/memberVsLocalExt.kt b/compiler/testData/diagnostics/tests/resolve/priority/memberVsLocalExt.kt index 4142abaa394..68d46307516 100644 --- a/compiler/testData/diagnostics/tests/resolve/priority/memberVsLocalExt.kt +++ b/compiler/testData/diagnostics/tests/resolve/priority/memberVsLocalExt.kt @@ -7,7 +7,7 @@ class A { fun test(a: A) { - fun A.foo() = 4 + fun A.foo() = 4 a.foo() checkType { _() } diff --git a/compiler/testData/diagnostics/tests/resolve/priority/synthesizedMembersVsExtension.kt b/compiler/testData/diagnostics/tests/resolve/priority/synthesizedMembersVsExtension.kt index 1780db676c2..814df1d81a3 100644 --- a/compiler/testData/diagnostics/tests/resolve/priority/synthesizedMembersVsExtension.kt +++ b/compiler/testData/diagnostics/tests/resolve/priority/synthesizedMembersVsExtension.kt @@ -2,7 +2,7 @@ data class A(val foo: Int) -operator fun A.component1(): String = "" +operator fun A.component1(): String = "" fun test(a: A) { val (b) = a diff --git a/compiler/testData/diagnostics/testsWithJava8/targetedBuiltIns/unsupportedFeature.kt b/compiler/testData/diagnostics/testsWithJava8/targetedBuiltIns/unsupportedFeature.kt index 8b8b0735f9b..2d37d90c86c 100644 --- a/compiler/testData/diagnostics/testsWithJava8/targetedBuiltIns/unsupportedFeature.kt +++ b/compiler/testData/diagnostics/testsWithJava8/targetedBuiltIns/unsupportedFeature.kt @@ -12,7 +12,7 @@ class A1 : java.util.ArrayList() { class B : Throwable("", null, false, false) -fun Throwable.fillInStackTrace() = 1 +fun Throwable.fillInStackTrace() = 1 fun foo(x: List, y: Throwable) { x.stream() diff --git a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java index 5ee8127c51c..e5c589f3ede 100644 --- a/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java +++ b/compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestGenerated.java @@ -15885,6 +15885,93 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest { String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/redeclarations/typeParameterWithTwoBounds.kt"); doTest(fileName); } + + @TestMetadata("compiler/testData/diagnostics/tests/redeclarations/shadowedExtension") + @TestDataPath("$PROJECT_ROOT") + @RunWith(JUnit3RunnerWithInners.class) + public static class ShadowedExtension extends AbstractDiagnosticsTest { + public void testAllFilesPresentInShadowedExtension() throws Exception { + KotlinTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("compiler/testData/diagnostics/tests/redeclarations/shadowedExtension"), Pattern.compile("^(.+)\\.kt$"), TargetBackend.ANY, true); + } + + @TestMetadata("extensionFunShadowedByInnerClassConstructor.kt") + public void testExtensionFunShadowedByInnerClassConstructor() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/redeclarations/shadowedExtension/extensionFunShadowedByInnerClassConstructor.kt"); + doTest(fileName); + } + + @TestMetadata("extensionFunShadowedByMemberFun.kt") + public void testExtensionFunShadowedByMemberFun() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/redeclarations/shadowedExtension/extensionFunShadowedByMemberFun.kt"); + doTest(fileName); + } + + @TestMetadata("extensionFunShadowedByMemberPropertyWithInvoke.kt") + public void testExtensionFunShadowedByMemberPropertyWithInvoke() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/redeclarations/shadowedExtension/extensionFunShadowedByMemberPropertyWithInvoke.kt"); + doTest(fileName); + } + + @TestMetadata("extensionFunShadowedBySynthesizedMemberFun.kt") + public void testExtensionFunShadowedBySynthesizedMemberFun() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/redeclarations/shadowedExtension/extensionFunShadowedBySynthesizedMemberFun.kt"); + doTest(fileName); + } + + @TestMetadata("extensionFunVsMemberExtensionFun.kt") + public void testExtensionFunVsMemberExtensionFun() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/redeclarations/shadowedExtension/extensionFunVsMemberExtensionFun.kt"); + doTest(fileName); + } + + @TestMetadata("extensionOnErrorType.kt") + public void testExtensionOnErrorType() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/redeclarations/shadowedExtension/extensionOnErrorType.kt"); + doTest(fileName); + } + + @TestMetadata("extensionOnNullableReceiver.kt") + public void testExtensionOnNullableReceiver() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/redeclarations/shadowedExtension/extensionOnNullableReceiver.kt"); + doTest(fileName); + } + + @TestMetadata("extensionPropertyShadowedByMemberProperty.kt") + public void testExtensionPropertyShadowedByMemberProperty() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/redeclarations/shadowedExtension/extensionPropertyShadowedByMemberProperty.kt"); + doTest(fileName); + } + + @TestMetadata("extensionShadowedByDelegatedMember.kt") + public void testExtensionShadowedByDelegatedMember() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/redeclarations/shadowedExtension/extensionShadowedByDelegatedMember.kt"); + doTest(fileName); + } + + @TestMetadata("extensionVsNonPublicMember.kt") + public void testExtensionVsNonPublicMember() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/redeclarations/shadowedExtension/extensionVsNonPublicMember.kt"); + doTest(fileName); + } + + @TestMetadata("localExtensionShadowedByMember.kt") + public void testLocalExtensionShadowedByMember() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/redeclarations/shadowedExtension/localExtensionShadowedByMember.kt"); + doTest(fileName); + } + + @TestMetadata("memberExtensionShadowedByMember.kt") + public void testMemberExtensionShadowedByMember() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/redeclarations/shadowedExtension/memberExtensionShadowedByMember.kt"); + doTest(fileName); + } + + @TestMetadata("operatorExtensionVsNonOperatorMember.kt") + public void testOperatorExtensionVsNonOperatorMember() throws Exception { + String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/redeclarations/shadowedExtension/operatorExtensionVsNonOperatorMember.kt"); + doTest(fileName); + } + } } @TestMetadata("compiler/testData/diagnostics/tests/reflection") diff --git a/core/descriptors/src/org/jetbrains/kotlin/incremental/components/LookupLocation.kt b/core/descriptors/src/org/jetbrains/kotlin/incremental/components/LookupLocation.kt index a4daebdb4f1..a1b830fa371 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/incremental/components/LookupLocation.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/incremental/components/LookupLocation.kt @@ -40,7 +40,7 @@ enum class NoLookupLocation : LookupLocation { FROM_BACKEND, FROM_TEST, FROM_BUILTINS, - WHEN_CHECK_REDECLARATIONS, + WHEN_CHECK_DECLARATION_CONFLICTS, WHEN_CHECK_OVERRIDES, FOR_SCRIPT, FROM_REFLECTION, diff --git a/idea/testData/checker/ExtensionFunctions.kt b/idea/testData/checker/ExtensionFunctions.kt index 281d5fbb510..ad332cce69c 100644 --- a/idea/testData/checker/ExtensionFunctions.kt +++ b/idea/testData/checker/ExtensionFunctions.kt @@ -46,7 +46,7 @@ fun Int.foo() = this val foo : Int = 0 } - operator fun Any.equals(other : Any?) : Boolean = true + operator fun Any.equals(other : Any?) : Boolean = true fun Any?.equals1(other : Any?) : Boolean = true fun Any.equals2(other : Any?) : Boolean = true diff --git a/idea/testData/checker/regression/Jet69.kt b/idea/testData/checker/regression/Jet69.kt index 2768b807251..a83894fbebe 100644 --- a/idea/testData/checker/regression/Jet69.kt +++ b/idea/testData/checker/regression/Jet69.kt @@ -2,7 +2,7 @@ class Command() {} fun parse(cmd: String): Command? { return null } -fun Any.equals(other : Any?) : Boolean = this === other +fun Any.equals(other : Any?) : Boolean = this === other fun main(args: Array) { val command = parse("") diff --git a/idea/testData/checker/regression/SpecififcityByReceiver.kt b/idea/testData/checker/regression/SpecififcityByReceiver.kt index 67d6776baba..5e1c2d4e331 100644 --- a/idea/testData/checker/regression/SpecififcityByReceiver.kt +++ b/idea/testData/checker/regression/SpecififcityByReceiver.kt @@ -1,4 +1,4 @@ -fun Any.equals(other : Any?) : Boolean = true +fun Any.equals(other : Any?) : Boolean = true fun main(args: Array) {