Include file name for package-level members in diagnostics

This commit is contained in:
Dmitry Petrov
2017-05-25 13:12:41 +03:00
parent 7979663e6c
commit a86fe89aae
19 changed files with 47 additions and 24 deletions
@@ -45,6 +45,7 @@ class SignatureDumpingBuilderFactory(
modifiers -= DescriptorRendererModifier.VISIBILITY
}
val TYPE_RENDERER = DescriptorRenderer.withOptions {
withSourceFileForTopLevel = false
modifiers -= DescriptorRendererModifier.VISIBILITY
}
}
@@ -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
}
+2 -2
View File
@@ -1,7 +1,7 @@
compiler/testData/cli/jvm/conflictingOverloads.kt:1:1: error: conflicting overloads: public fun a(): List<Int> defined in root package, public fun a(): List<String> defined in root package
compiler/testData/cli/jvm/conflictingOverloads.kt:1:1: error: conflicting overloads: public fun a(): List<Int> defined in root package in file conflictingOverloads.kt, public fun a(): List<String> defined in root package in file conflictingOverloads.kt
fun a(): List<Int> = null!!
^
compiler/testData/cli/jvm/conflictingOverloads.kt:2:1: error: conflicting overloads: public fun a(): List<Int> defined in root package, public fun a(): List<String> defined in root package
compiler/testData/cli/jvm/conflictingOverloads.kt:2:1: error: conflicting overloads: public fun a(): List<Int> defined in root package in file conflictingOverloads.kt, public fun a(): List<String> defined in root package in file conflictingOverloads.kt
fun a(): List<String> = null!!
^
COMPILATION_ERROR
+4 -4
View File
@@ -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 <get-b>(): Int defined in root package
fun getB(): Int defined in root package
fun <get-b>(): 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 <get-b>(): Int defined in root package
fun getB(): Int defined in root package
fun <get-b>(): 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):
@@ -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();
}
@@ -178,6 +178,7 @@ enum class AnnotationArgumentsRenderingPolicy(
interface DescriptorRendererOptions {
var classifierNamePolicy: ClassifierNamePolicy
var withDefinedIn: Boolean
var withSourceFileForTopLevel: Boolean
var modifiers: Set<DescriptorRendererModifier>
var startFromName: Boolean
var startFromDeclarationKeyword: Boolean
@@ -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)
}
}
}
}
@@ -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<DescriptorRendererModifier> by property(DescriptorRendererModifier.DEFAULTS)
override var startFromName by property(false)
override var startFromDeclarationKeyword by property(false)
@@ -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 {
@@ -4,8 +4,8 @@
package test
<error descr="[CONFLICTING_JVM_DECLARATIONS] Platform declaration clash: The following declarations have the same JVM signature (getX()I):
fun <get-x>(): Int defined in test
fun getX(): Int defined in test">val x</error> = 1
fun <get-x>(): Int defined in test in file topLevelMultifileRuntime.kt
fun getX(): Int defined in test in file topLevelMultifileRuntime.kt">val x</error> = 1
<error descr="[CONFLICTING_JVM_DECLARATIONS] Platform declaration clash: The following declarations have the same JVM signature (getX()I):
fun <get-x>(): Int defined in test
fun getX(): Int defined in test">fun getX()</error> = 1
fun <get-x>(): Int defined in test in file topLevelMultifileRuntime.kt
fun getX(): Int defined in test in file topLevelMultifileRuntime.kt">fun getX()</error> = 1
+1 -1
View File
@@ -2,4 +2,4 @@ open class A<T>()
class G<T>()
class B : A<<error descr="[WRONG_NUMBER_OF_TYPE_ARGUMENTS] One type argument expected for class G<T> defined in root package">G</error>>()
class B : A<<error descr="[WRONG_NUMBER_OF_TYPE_ARGUMENTS] One type argument expected for class G<T> defined in root package in file kt9887.kt">G</error>>()
@@ -1,2 +1,2 @@
<!-- conflictingOverloadsDefaultPackage1 -->
Conflicting overloads: public fun foo(x: Int): Int defined in root package, public fun foo(y: Int): Int defined in root package
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
@@ -1,2 +1,2 @@
<!-- conflictingOverloadsDefaultPackage2 -->
Conflicting overloads: public fun foo(x: Int): Int defined in root package, public fun foo(y: Int): Int defined in root package
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
@@ -1,2 +1,2 @@
<!-- constructorsRedeclarationTopLevel1 -->
Conflicting overloads: public fun Element(x: String): Unit defined in root package, public constructor Element(x: String) defined in Element
Conflicting overloads: public fun Element(x: String): Unit defined in root package in file constructorsRedeclarationTopLevel.kt, public constructor Element(x: String) defined in Element
@@ -1,2 +1,2 @@
<!-- constructorsRedeclarationTopLevel2 -->
Conflicting overloads: public fun Element(x: String): Unit defined in root package, public constructor Element(x: String) defined in Element
Conflicting overloads: public fun Element(x: String): Unit defined in root package in file constructorsRedeclarationTopLevel.kt, public constructor Element(x: String) defined in Element
@@ -4,9 +4,9 @@ None of the following functions can be called with the arguments supplied.
<ul>
<li>foo(<font color=red><b>T</b></font>, Any, MutableList<`<font color=red><b>T</b></font>>, MutableList<`<font color=red><b>T</b></font>>)<br/>
<i>where</i> <font color=red><b>T</b></font><i> cannot be inferred</i><i> for </i><br/>
<b>fun</b> <`T> foo(t: T, a: Any, lt: MutableList<`T>, lr: MutableList<`T>): Int <i>defined in</i> p</li>
<b>fun</b> <`T> foo(t: T, a: Any, lt: MutableList<`T>, lr: MutableList<`T>): Int <i>defined in</i> p <i>in file</i> noneApplicableGeneric.kt</li>
<li>foo(Int, <font color=red><b>R</b></font>, MutableList<`Int>, MutableList<`<font color=red><b>R</b></font>>)<br/>
<i>where</i> <font color=red><b>R</b></font><i> cannot be inferred</i>; T = Int<i> for </i><br/>
<b>fun</b> <`T, R> foo(t: T, r: R, lt: MutableList<`T>, lr: MutableList<`R>): Int <i>defined in</i> p</li>
<b>fun</b> <`T, R> foo(t: T, r: R, lt: MutableList<`T>, lr: MutableList<`R>): Int <i>defined in</i> p <i>in file</i> noneApplicableGeneric.kt</li>
</ul>
</html>
+3 -3
View File
@@ -1,5 +1,5 @@
<!-- noneApplicableTxt1 -->
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
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
@@ -3,7 +3,7 @@
Overload resolution ambiguity. All these functions match.
<ul>
<li><b>public</b> <b>fun</b> <`T> foo(b: a.b.String, t: ???): Unit <i>defined in</i> a.b</li>
<li><b>public</b> <b>fun</b> foo(i: Int): Unit <i>defined in</i> a.b</li>
<li><b>public</b> <b>fun</b> foo(i: Int): Unit <i>defined in</i> a.b <i>in file</i> overloadResolutionAmbiguityHtml.kt</li>
<li><b>public</b> <b>fun</b> <`T> foo(a: kotlin.String, t: ???): Unit <i>defined in</i> a.b</li>
</ul>
</html>
@@ -1,5 +1,5 @@
<!-- overloadResolutionAmbiguityTxt1 -->
Overload resolution ambiguity:
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 overloadResolutionAmbiguityTxt.kt
public fun <T> foo(a: kotlin.String, t: ???): Unit defined in a.b