diff --git a/compiler/backend/src/org/jetbrains/kotlin/codegen/state/SignatureDumpingBuilderFactory.kt b/compiler/backend/src/org/jetbrains/kotlin/codegen/state/SignatureDumpingBuilderFactory.kt index 37b7a785adc..12929772fcf 100644 --- a/compiler/backend/src/org/jetbrains/kotlin/codegen/state/SignatureDumpingBuilderFactory.kt +++ b/compiler/backend/src/org/jetbrains/kotlin/codegen/state/SignatureDumpingBuilderFactory.kt @@ -45,6 +45,7 @@ class SignatureDumpingBuilderFactory( modifiers -= DescriptorRendererModifier.VISIBILITY } val TYPE_RENDERER = DescriptorRenderer.withOptions { + withSourceFileForTopLevel = false modifiers -= DescriptorRendererModifier.VISIBILITY } } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/resolve/source/PsiSourceElement.kt b/compiler/frontend/src/org/jetbrains/kotlin/resolve/source/PsiSourceElement.kt index 065f1813e37..dbed094594f 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/resolve/source/PsiSourceElement.kt +++ b/compiler/frontend/src/org/jetbrains/kotlin/resolve/source/PsiSourceElement.kt @@ -33,4 +33,6 @@ class PsiSourceFile(val psiFile: PsiFile): SourceFile { override fun hashCode(): Int = psiFile.hashCode() override fun toString(): String = psiFile.virtualFile.path + + override fun getName(): String? = psiFile.virtualFile?.name } diff --git a/compiler/testData/cli/jvm/conflictingOverloads.out b/compiler/testData/cli/jvm/conflictingOverloads.out index acd1aa4bc55..e2e7d4aa321 100644 --- a/compiler/testData/cli/jvm/conflictingOverloads.out +++ b/compiler/testData/cli/jvm/conflictingOverloads.out @@ -1,7 +1,7 @@ -compiler/testData/cli/jvm/conflictingOverloads.kt:1:1: error: conflicting overloads: public fun a(): List defined in root package, public fun a(): List defined in root package +compiler/testData/cli/jvm/conflictingOverloads.kt:1:1: error: conflicting overloads: public fun a(): List defined in root package in file conflictingOverloads.kt, public fun a(): List defined in root package in file conflictingOverloads.kt fun a(): List = null!! ^ -compiler/testData/cli/jvm/conflictingOverloads.kt:2:1: error: conflicting overloads: public fun a(): List defined in root package, public fun a(): List defined in root package +compiler/testData/cli/jvm/conflictingOverloads.kt:2:1: error: conflicting overloads: public fun a(): List defined in root package in file conflictingOverloads.kt, public fun a(): List defined in root package in file conflictingOverloads.kt fun a(): List = null!! ^ COMPILATION_ERROR \ No newline at end of file diff --git a/compiler/testData/cli/jvm/signatureClash.out b/compiler/testData/cli/jvm/signatureClash.out index b752c606f2d..387b231a4f6 100644 --- a/compiler/testData/cli/jvm/signatureClash.out +++ b/compiler/testData/cli/jvm/signatureClash.out @@ -14,13 +14,13 @@ compiler/testData/cli/jvm/signatureClash.kt:9:5: error: platform declaration cla val a: Int = 1 ^ compiler/testData/cli/jvm/signatureClash.kt:12:1: error: platform declaration clash: The following declarations have the same JVM signature (getB()I): - fun (): Int defined in root package - fun getB(): Int defined in root package + fun (): Int defined in root package in file signatureClash.kt + fun getB(): Int defined in root package in file signatureClash.kt fun getB(): Int = 1 ^ compiler/testData/cli/jvm/signatureClash.kt:13:1: error: platform declaration clash: The following declarations have the same JVM signature (getB()I): - fun (): Int defined in root package - fun getB(): Int defined in root package + fun (): Int defined in root package in file signatureClash.kt + fun getB(): Int defined in root package in file signatureClash.kt val b: Int = 1 ^ compiler/testData/cli/jvm/signatureClash.kt:19:7: error: platform declaration clash: The following declarations have the same JVM signature (getTr()I): diff --git a/core/descriptors/src/org/jetbrains/kotlin/descriptors/SourceFile.java b/core/descriptors/src/org/jetbrains/kotlin/descriptors/SourceFile.java index 7baa91d94b3..a0c9d2069e4 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/descriptors/SourceFile.java +++ b/core/descriptors/src/org/jetbrains/kotlin/descriptors/SourceFile.java @@ -16,6 +16,17 @@ package org.jetbrains.kotlin.descriptors; +import org.jetbrains.annotations.Nullable; + public interface SourceFile { - SourceFile NO_SOURCE_FILE = new SourceFile() {}; + SourceFile NO_SOURCE_FILE = new SourceFile() { + @Nullable + @Override + public String getName() { + return null; + } + }; + + @Nullable + String getName(); } diff --git a/core/descriptors/src/org/jetbrains/kotlin/renderer/DescriptorRenderer.kt b/core/descriptors/src/org/jetbrains/kotlin/renderer/DescriptorRenderer.kt index 4b90d4f6c5b..245cd34d131 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/renderer/DescriptorRenderer.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/renderer/DescriptorRenderer.kt @@ -178,6 +178,7 @@ enum class AnnotationArgumentsRenderingPolicy( interface DescriptorRendererOptions { var classifierNamePolicy: ClassifierNamePolicy var withDefinedIn: Boolean + var withSourceFileForTopLevel: Boolean var modifiers: Set var startFromName: Boolean var startFromDeclarationKeyword: Boolean diff --git a/core/descriptors/src/org/jetbrains/kotlin/renderer/DescriptorRendererImpl.kt b/core/descriptors/src/org/jetbrains/kotlin/renderer/DescriptorRendererImpl.kt index f5eb5264fa3..a698013d7a1 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/renderer/DescriptorRendererImpl.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/renderer/DescriptorRendererImpl.kt @@ -383,6 +383,14 @@ internal class DescriptorRendererImpl( append(" ").append(renderMessage("defined in")).append(" ") val fqName = DescriptorUtils.getFqName(containingDeclaration) append(if (fqName.isRoot) "root package" else renderFqName(fqName)) + + if (withSourceFileForTopLevel && + containingDeclaration is PackageFragmentDescriptor && + descriptor is DeclarationDescriptorWithSource) { + descriptor.source.containingFile.name?.let { sourceFileName -> + append(" ").append(renderMessage("in file")).append(" ").append(sourceFileName) + } + } } } diff --git a/core/descriptors/src/org/jetbrains/kotlin/renderer/DescriptorRendererOptionsImpl.kt b/core/descriptors/src/org/jetbrains/kotlin/renderer/DescriptorRendererOptionsImpl.kt index 1091b8dfc67..8dcc4241903 100644 --- a/core/descriptors/src/org/jetbrains/kotlin/renderer/DescriptorRendererOptionsImpl.kt +++ b/core/descriptors/src/org/jetbrains/kotlin/renderer/DescriptorRendererOptionsImpl.kt @@ -67,6 +67,7 @@ internal class DescriptorRendererOptionsImpl : DescriptorRendererOptions { override var classifierNamePolicy: ClassifierNamePolicy by property(ClassifierNamePolicy.SOURCE_CODE_QUALIFIED) override var withDefinedIn by property(true) + override var withSourceFileForTopLevel by property(true) override var modifiers: Set by property(DescriptorRendererModifier.DEFAULTS) override var startFromName by property(false) override var startFromDeclarationKeyword by property(false) diff --git a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/highlighter/IdeRenderers.kt b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/highlighter/IdeRenderers.kt index 3647676cf23..edb2b704e92 100644 --- a/idea/idea-analysis/src/org/jetbrains/kotlin/idea/highlighter/IdeRenderers.kt +++ b/idea/idea-analysis/src/org/jetbrains/kotlin/idea/highlighter/IdeRenderers.kt @@ -24,7 +24,6 @@ import org.jetbrains.kotlin.resolve.MemberComparator import org.jetbrains.kotlin.resolve.calls.inference.InferenceErrorData import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall import org.jetbrains.kotlin.resolve.jvm.diagnostics.ConflictingJvmDeclarationsData -import kotlin.comparisons.compareBy object IdeRenderers { diff --git a/idea/testData/checker/duplicateJvmSignature/functionAndProperty/topLevelMultifileRuntime.kt b/idea/testData/checker/duplicateJvmSignature/functionAndProperty/topLevelMultifileRuntime.kt index 9fca59ebab6..80d6b6cf485 100644 --- a/idea/testData/checker/duplicateJvmSignature/functionAndProperty/topLevelMultifileRuntime.kt +++ b/idea/testData/checker/duplicateJvmSignature/functionAndProperty/topLevelMultifileRuntime.kt @@ -4,8 +4,8 @@ package test val x = 1 + fun (): Int defined in test in file topLevelMultifileRuntime.kt + fun getX(): Int defined in test in file topLevelMultifileRuntime.kt">val x = 1 fun getX() = 1 + fun (): Int defined in test in file topLevelMultifileRuntime.kt + fun getX(): Int defined in test in file topLevelMultifileRuntime.kt">fun getX() = 1 diff --git a/idea/testData/checker/regression/kt9887.kt b/idea/testData/checker/regression/kt9887.kt index a1b076a4684..be47483dbea 100644 --- a/idea/testData/checker/regression/kt9887.kt +++ b/idea/testData/checker/regression/kt9887.kt @@ -2,4 +2,4 @@ open class A() class G() -class B : A<G>() \ No newline at end of file +class B : A<G>() \ No newline at end of file diff --git a/idea/testData/diagnosticMessage/conflictingOverloadsDefaultPackage1.txt b/idea/testData/diagnosticMessage/conflictingOverloadsDefaultPackage1.txt index 3a3b139fa62..aba60bddda9 100644 --- a/idea/testData/diagnosticMessage/conflictingOverloadsDefaultPackage1.txt +++ b/idea/testData/diagnosticMessage/conflictingOverloadsDefaultPackage1.txt @@ -1,2 +1,2 @@ -Conflicting overloads: public fun foo(x: Int): Int defined in root package, public fun foo(y: Int): Int defined in root package \ No newline at end of file +Conflicting overloads: public fun foo(x: Int): Int defined in root package in file conflictingOverloadsDefaultPackage.kt, public fun foo(y: Int): Int defined in root package in file conflictingOverloadsDefaultPackage.kt \ No newline at end of file diff --git a/idea/testData/diagnosticMessage/conflictingOverloadsDefaultPackage2.txt b/idea/testData/diagnosticMessage/conflictingOverloadsDefaultPackage2.txt index c717e1e525e..2217fe06dc9 100644 --- a/idea/testData/diagnosticMessage/conflictingOverloadsDefaultPackage2.txt +++ b/idea/testData/diagnosticMessage/conflictingOverloadsDefaultPackage2.txt @@ -1,2 +1,2 @@ -Conflicting overloads: public fun foo(x: Int): Int defined in root package, public fun foo(y: Int): Int defined in root package \ No newline at end of file +Conflicting overloads: public fun foo(x: Int): Int defined in root package in file conflictingOverloadsDefaultPackage.kt, public fun foo(y: Int): Int defined in root package in file conflictingOverloadsDefaultPackage.kt \ No newline at end of file diff --git a/idea/testData/diagnosticMessage/constructorsRedeclarationTopLevel1.txt b/idea/testData/diagnosticMessage/constructorsRedeclarationTopLevel1.txt index 461b2e88f11..afc94ada068 100644 --- a/idea/testData/diagnosticMessage/constructorsRedeclarationTopLevel1.txt +++ b/idea/testData/diagnosticMessage/constructorsRedeclarationTopLevel1.txt @@ -1,2 +1,2 @@ -Conflicting overloads: public fun Element(x: String): Unit defined in root package, public constructor Element(x: String) defined in Element \ No newline at end of file +Conflicting overloads: public fun Element(x: String): Unit defined in root package in file constructorsRedeclarationTopLevel.kt, public constructor Element(x: String) defined in Element \ No newline at end of file diff --git a/idea/testData/diagnosticMessage/constructorsRedeclarationTopLevel2.txt b/idea/testData/diagnosticMessage/constructorsRedeclarationTopLevel2.txt index 34db820434d..967d8b682df 100644 --- a/idea/testData/diagnosticMessage/constructorsRedeclarationTopLevel2.txt +++ b/idea/testData/diagnosticMessage/constructorsRedeclarationTopLevel2.txt @@ -1,2 +1,2 @@ -Conflicting overloads: public fun Element(x: String): Unit defined in root package, public constructor Element(x: String) defined in Element \ No newline at end of file +Conflicting overloads: public fun Element(x: String): Unit defined in root package in file constructorsRedeclarationTopLevel.kt, public constructor Element(x: String) defined in Element \ No newline at end of file diff --git a/idea/testData/diagnosticMessage/noneApplicableGeneric1.html b/idea/testData/diagnosticMessage/noneApplicableGeneric1.html index eb44484b372..105d90f4aa4 100644 --- a/idea/testData/diagnosticMessage/noneApplicableGeneric1.html +++ b/idea/testData/diagnosticMessage/noneApplicableGeneric1.html @@ -4,9 +4,9 @@ None of the following functions can be called with the arguments supplied.
  • foo(T, Any, MutableList<`T>, MutableList<`T>)
    where T cannot be inferred for
    - fun <`T> foo(t: T, a: Any, lt: MutableList<`T>, lr: MutableList<`T>): Int defined in p
  • + fun <`T> foo(t: T, a: Any, lt: MutableList<`T>, lr: MutableList<`T>): Int defined in p in file noneApplicableGeneric.kt
  • foo(Int, R, MutableList<`Int>, MutableList<`R>)
    where R cannot be inferred; T = Int for
    - fun <`T, R> foo(t: T, r: R, lt: MutableList<`T>, lr: MutableList<`R>): Int defined in p
  • + fun <`T, R> foo(t: T, r: R, lt: MutableList<`T>, lr: MutableList<`R>): Int defined in p in file noneApplicableGeneric.kt
\ No newline at end of file diff --git a/idea/testData/diagnosticMessage/noneApplicableTxt1.txt b/idea/testData/diagnosticMessage/noneApplicableTxt1.txt index 3ceb80f3e78..a41e14776c2 100644 --- a/idea/testData/diagnosticMessage/noneApplicableTxt1.txt +++ b/idea/testData/diagnosticMessage/noneApplicableTxt1.txt @@ -1,5 +1,5 @@ None of the following functions can be called with the arguments supplied: -public fun foo(b: a.b.String): Unit defined in a.b -public fun foo(i: Int): Unit defined in a.b -public fun foo(a: kotlin.String): Unit defined in a.b \ No newline at end of file +public fun foo(b: a.b.String): Unit defined in a.b in file noneApplicableTxt.kt +public fun foo(i: Int): Unit defined in a.b in file noneApplicableTxt.kt +public fun foo(a: kotlin.String): Unit defined in a.b in file noneApplicableTxt.kt \ No newline at end of file diff --git a/idea/testData/diagnosticMessage/overloadResolutionAmbiguityHtml1.html b/idea/testData/diagnosticMessage/overloadResolutionAmbiguityHtml1.html index 30ee43babd2..26ceb028937 100644 --- a/idea/testData/diagnosticMessage/overloadResolutionAmbiguityHtml1.html +++ b/idea/testData/diagnosticMessage/overloadResolutionAmbiguityHtml1.html @@ -3,7 +3,7 @@ Overload resolution ambiguity. All these functions match.
  • public fun <`T> foo(b: a.b.String, t: ???): Unit defined in a.b
  • -
  • public fun foo(i: Int): Unit defined in a.b
  • +
  • public fun foo(i: Int): Unit defined in a.b in file overloadResolutionAmbiguityHtml.kt
  • public fun <`T> foo(a: kotlin.String, t: ???): Unit defined in a.b
\ No newline at end of file diff --git a/idea/testData/diagnosticMessage/overloadResolutionAmbiguityTxt1.txt b/idea/testData/diagnosticMessage/overloadResolutionAmbiguityTxt1.txt index 976c8db7227..82df8f335f1 100644 --- a/idea/testData/diagnosticMessage/overloadResolutionAmbiguityTxt1.txt +++ b/idea/testData/diagnosticMessage/overloadResolutionAmbiguityTxt1.txt @@ -1,5 +1,5 @@ Overload resolution ambiguity: public fun foo(b: a.b.String, t: ???): Unit defined in a.b -public fun foo(i: Int): Unit defined in a.b +public fun foo(i: Int): Unit defined in a.b in file overloadResolutionAmbiguityTxt.kt public fun foo(a: kotlin.String, t: ???): Unit defined in a.b \ No newline at end of file