[Test] Support RENDER_DIAGNOSTICS_FULL_TEXT directive for FIR tests

This commit is contained in:
Brian Norman
2023-06-01 09:27:06 -05:00
committed by Space Team
parent 22a5dd7f29
commit 48484368c7
30 changed files with 174 additions and 1 deletions
@@ -0,0 +1,7 @@
/exceptionFromInterpreter_ir.kt:(174,179): warning: Division by zero
/exceptionFromInterpreter_ir.kt:(205,210): warning: Division by zero
/exceptionFromInterpreter_ir.kt:(243,264): error: Const 'val' initializer should be a constant value
/exceptionFromInterpreter_ir.kt:(313,318): warning: Division by zero
@@ -0,0 +1 @@
/test.kt:(154,158): error: Overload resolution ambiguity between candidates: [static field SOME: String = String(Some), static enum entry SOME: SomeEnum]
@@ -0,0 +1 @@
/test.kt:(160,164): error: Overload resolution ambiguity between candidates: [static field SOME: String = String(Some), static enum entry SOME: SomeEnum]
@@ -0,0 +1 @@
/kt47986Default.fir.kt:(175,183): error: Not enough information to infer type variable K
@@ -0,0 +1 @@
/kt47986Disabled.fir.kt:(249,257): error: Not enough information to infer type variable K
@@ -0,0 +1 @@
/kt47986_2.fir.kt:(187,195): error: Not enough information to infer type variable K
@@ -0,0 +1 @@
/kt47986_3.fir.kt:(181,189): error: Not enough information to infer type variable K
@@ -0,0 +1 @@
/kt51464.fir.kt:(298,307): error: Not enough information to infer type variable R
@@ -0,0 +1 @@
/kt45461.kt:(245,252): warning: Type argument for a type parameter S can't be inferred because it has incompatible upper bounds: kotlin/String, kotlin/Int (multiple incompatible classes). This will become an error in a future release
@@ -0,0 +1 @@
/kt45461_12.kt:(296,303): warning: Type argument for a type parameter S can't be inferred because it has incompatible upper bounds: kotlin/String, K (multiple incompatible classes: kotlin/String, kotlin/Number). This will become an error in a future release
@@ -0,0 +1,3 @@
/kt45461_2.kt:(253,260): warning: Type argument for a type parameter S can't be inferred because it has incompatible upper bounds: kotlin/String, K (multiple incompatible classes: kotlin/String, kotlin/Int). This will become an error in a future release
/kt45461_2.kt:(198,201): warning: 'kotlin/Int' is a final type, and thus a value of the type parameter is predetermined
@@ -0,0 +1,5 @@
/kt45461_25.fir.kt:(176,180): warning: Unchecked cast: kotlin/Nothing? to S
/kt45461_25.fir.kt:(276,283): error: Type argument for a type parameter S can't be inferred because it has incompatible upper bounds: kotlin/String, K (multiple incompatible classes: kotlin/String, kotlin/Int)
/kt45461_25.fir.kt:(206,209): warning: 'kotlin/Int' is a final type, and thus a value of the type parameter is predetermined
@@ -0,0 +1,3 @@
/kt45461_26.fir.kt:(176,180): warning: Unchecked cast: kotlin/Nothing? to S
/kt45461_26.fir.kt:(224,232): warning: 'Out<kotlin/Int>' is a final type, and thus a value of the type parameter is predetermined
@@ -0,0 +1 @@
/kt45461_5.kt:(269,276): warning: Type argument for a type parameter S can't be inferred because it has incompatible upper bounds: kotlin/String, K (multiple incompatible classes: kotlin/String, kotlin/Number). This will become an error in a future release
@@ -0,0 +1,5 @@
/kt48765.kt:(282,285): warning: Type argument for a type parameter T can't be inferred because it has incompatible upper bounds: kotlin/String, kotlin/Number (multiple incompatible classes). This will become an error in a future release
/kt48765.kt:(379,383): warning: Unchecked cast: kotlin/String to T
/kt48765.kt:(345,351): warning: 'kotlin/String' is a final type, and thus a value of the type parameter is predetermined
@@ -0,0 +1 @@
/kt48935.kt:(240,262): warning: Type argument for a type parameter T has possible incompatible upper bounds: Base, DoesNotImplementBase (final class and interface)
@@ -0,0 +1 @@
/kt49661.kt:(251,252): warning: Type argument for a type parameter T can't be inferred because it has incompatible upper bounds: Foo, kotlin/Int (multiple incompatible classes). This will become an error in a future release
@@ -0,0 +1 @@
/selectFromCovariantAndContravariantTypes.kt:(335,344): warning: Type argument for a type parameter V can't be inferred because it has incompatible upper bounds: A, B (multiple incompatible classes). This will become an error in a future release
@@ -0,0 +1,3 @@
/main.kt:(98,103): error: Argument type mismatch: actual type is V but @EnhancedNullability V & Any was expected
/main.kt:(119,120): error: Argument type mismatch: actual type is kotlin/collections/List<V> but ft<@EnhancedNullability kotlin/collections/MutableList<@EnhancedNullability V & Any>, @EnhancedNullability kotlin/collections/List<@EnhancedNullability V & Any>> was expected
@@ -0,0 +1,3 @@
/main.kt:(72,80): error: 'takeV' overrides nothing
/main.kt:(137,145): error: 'takeVList' overrides nothing
@@ -0,0 +1,3 @@
/B.kt:(133,134): error: Smart cast to 'kotlin/String' is impossible, because 'this@R|/Derived|.R|/Base.x|' is a public API property declared in different module
/B.kt:(265,268): error: Smart cast to 'kotlin/String' is impossible, because 'R|<local>/i|.R|/Base.x|' is a public API property declared in different module
@@ -0,0 +1,7 @@
/labelClashes.fir.kt:(84,87): error: Unresolved reference: inc
/labelClashes.fir.kt:(151,154): error: Unresolved reference: inc
/labelClashes.fir.kt:(268,271): error: Unresolved reference: foo
/labelClashes.fir.kt:(331,334): error: Unresolved reference: foo
@@ -0,0 +1 @@
/upperBoundViolated2.fir.kt:(111,123): error: Type argument is not within its bounds: should be subtype of 'kotlin/collections/List<kotlin/CharSequence>'
@@ -10,8 +10,10 @@ import org.jetbrains.kotlin.*
import org.jetbrains.kotlin.checkers.diagnostics.factories.DebugInfoDiagnosticFactory0
import org.jetbrains.kotlin.checkers.diagnostics.factories.DebugInfoDiagnosticFactory1
import org.jetbrains.kotlin.checkers.utils.TypeOfCall
import org.jetbrains.kotlin.cli.common.messages.AnalyzerWithCompilerReport
import org.jetbrains.kotlin.diagnostics.*
import org.jetbrains.kotlin.diagnostics.rendering.Renderers
import org.jetbrains.kotlin.diagnostics.rendering.RootDiagnosticRendererFactory
import org.jetbrains.kotlin.fir.*
import org.jetbrains.kotlin.fir.analysis.diagnostics.FirErrors
import org.jetbrains.kotlin.fir.builder.FirSyntaxErrors
@@ -48,7 +50,9 @@ import org.jetbrains.kotlin.test.model.TestModule
import org.jetbrains.kotlin.test.runners.lightTreeSyntaxDiagnosticsReporterHolder
import org.jetbrains.kotlin.test.services.*
import org.jetbrains.kotlin.test.utils.AbstractTwoAttributesMetaInfoProcessor
import org.jetbrains.kotlin.test.utils.MultiModuleInfoDumper
import org.jetbrains.kotlin.util.OperatorNameConventions
import org.jetbrains.kotlin.util.capitalizeDecapitalize.toLowerCaseAsciiOnly
@OptIn(SymbolInternals::class)
class FirDiagnosticsHandler(testServices: TestServices) : FirAnalysisHandler(testServices) {
@@ -64,6 +68,16 @@ class FirDiagnosticsHandler(testServices: TestServices) : FirAnalysisHandler(tes
override val additionalServices: List<ServiceRegistrationData> =
listOf(service(::DiagnosticsService))
private val dumper: MultiModuleInfoDumper = MultiModuleInfoDumper(moduleHeaderTemplate = "// -- Module: <%s> --")
override fun processAfterAllModules(someAssertionWasFailed: Boolean) {
if (dumper.isEmpty()) return
val resultDump = dumper.generateResultingDump()
val testDataFile = testServices.moduleStructure.originalTestDataFiles.first()
val expectedFile = testDataFile.parentFile.resolve("${testDataFile.nameWithoutFirExtension}.fir.diag.txt")
assertions.assertEqualsToFile(expectedFile, resultDump)
}
override fun processModule(module: TestModule, info: FirOutputArtifact) {
for (part in info.partsForDependsOnModules) {
val diagnosticsPerFile = part.firAnalyzerFacade.runCheckers()
@@ -92,6 +106,7 @@ class FirDiagnosticsHandler(testServices: TestServices) : FirAnalysisHandler(tes
globalMetadataInfoHandler.addMetadataInfosForFile(file, diagnosticsMetadataInfos)
collectSyntaxDiagnostics(currentModule, file, firFile, lightTreeEnabled, lightTreeComparingModeEnabled, forceRenderArguments)
collectDebugInfoDiagnostics(currentModule, file, firFile, lightTreeEnabled, lightTreeComparingModeEnabled)
checkFullDiagnosticRender(module, diagnostics, file)
}
}
}
@@ -323,7 +338,18 @@ class FirDiagnosticsHandler(testServices: TestServices) : FirAnalysisHandler(tes
else -> null
}
override fun processAfterAllModules(someAssertionWasFailed: Boolean) {}
private fun checkFullDiagnosticRender(module: TestModule, diagnostics: List<KtDiagnostic>, file: TestFile) {
if (DiagnosticsDirectives.RENDER_DIAGNOSTICS_FULL_TEXT !in module.directives) return
if (diagnostics.isEmpty()) return
val reportedDiagnostics = diagnostics.map {
val severity = AnalyzerWithCompilerReport.convertSeverity(it.severity).toString().toLowerCaseAsciiOnly()
val message = RootDiagnosticRendererFactory(it).render(it)
"/${file.name}:${it.textRanges.first()}: $severity: $message"
}
dumper.builderForModule(module).appendLine(reportedDiagnostics.joinToString(separator = "\n\n"))
}
}
fun List<KtDiagnostic>.diagnosticCodeMetaInfos(
@@ -0,0 +1,7 @@
/incorrectUsage.fir.kt:(396,397): error:
/incorrectUsage.fir.kt:(390,395): error: None of the following functions are applicable: [fun assign(v: String): Unit, fun assign(v: StringProperty): Unit]
/incorrectUsage.fir.kt:(542,543): error:
/incorrectUsage.fir.kt:(536,541): error: None of the following functions are applicable: [fun assign(v: String): Unit, fun assign(v: StringProperty): Unit]
@@ -0,0 +1,13 @@
/localVariables.fir.kt:(401,409): error: Val cannot be reassigned
/localVariables.fir.kt:(412,418): error: Assignment type mismatch: actual type is kotlin/String but StringProperty was expected
/localVariables.fir.kt:(521,529): error: Val cannot be reassigned
/localVariables.fir.kt:(673,679): error: Assignment type mismatch: actual type is kotlin/String but StringProperty was expected
/localVariables.fir.kt:(917,925): error: Val cannot be reassigned
/localVariables.fir.kt:(928,934): error: Assignment type mismatch: actual type is kotlin/String but StringProperty was expected
/localVariables.fir.kt:(995,1003): error: Val cannot be reassigned
@@ -0,0 +1,13 @@
/methodDeclaration.fir.kt:(119,125): error:
/methodDeclaration.fir.kt:(206,212): error:
/methodDeclaration.fir.kt:(328,334): error:
/methodDeclaration.fir.kt:(572,573): error:
/methodDeclaration.fir.kt:(594,595): error:
/methodDeclaration.fir.kt:(870,875): error: Val cannot be reassigned
/methodDeclaration.fir.kt:(878,880): error: Assignment type mismatch: actual type is kotlin/Int but IntProperty was expected
@@ -0,0 +1,19 @@
/noAnnotation.fir.kt:(424,429): error: Val cannot be reassigned
/noAnnotation.fir.kt:(432,436): error: Assignment type mismatch: actual type is kotlin/String but StringProperty was expected
/noAnnotation.fir.kt:(446,451): error: Val cannot be reassigned
/noAnnotation.fir.kt:(500,505): error: Val cannot be reassigned
/noAnnotation.fir.kt:(508,512): error: Assignment type mismatch: actual type is kotlin/String but StringProperty was expected
/noAnnotation.fir.kt:(544,549): error: Val cannot be reassigned
/noAnnotation.fir.kt:(588,593): error: Val cannot be reassigned
/noAnnotation.fir.kt:(596,598): error: Assignment type mismatch: actual type is kotlin/Int but StringProperty was expected
/noAnnotation.fir.kt:(624,629): error: Val cannot be reassigned
/noAnnotation.fir.kt:(632,634): error: Assignment type mismatch: actual type is kotlin/Int but StringProperty was expected
@@ -0,0 +1,37 @@
/otherOperators.fir.kt:(456,458): error: Unresolved reference: plusAssign
/otherOperators.fir.kt:(502,504): error: Unresolved reference: plusAssign
/otherOperators.fir.kt:(560,562): error: Unresolved reference: compareTo
/otherOperators.fir.kt:(606,608): error: Unresolved reference: compareTo
/otherOperators.fir.kt:(664,666): error: Unresolved reference: compareTo
/otherOperators.fir.kt:(710,712): error: Unresolved reference: compareTo
/otherOperators.fir.kt:(769,772): error: No set method providing array access
/otherOperators.fir.kt:(817,820): error: No set method providing array access
/otherOperators.fir.kt:(882,888): error: No set method providing array access
/otherOperators.fir.kt:(933,939): error: No set method providing array access
/otherOperators.fir.kt:(1003,1012): error: No set method providing array access
/otherOperators.fir.kt:(1057,1066): error: No set method providing array access
/otherOperators.fir.kt:(1131,1133): error: Unresolved reference: +=
/otherOperators.fir.kt:(1180,1182): error: Unresolved reference: +=
/otherOperators.fir.kt:(1325,1328): error: No set method providing array access
/otherOperators.fir.kt:(1431,1437): error: Variable expected
/otherOperators.fir.kt:(1477,1483): error: Variable expected
/otherOperators.fir.kt:(1128,1129): error: Too many arguments for public final fun /StringProperty.get(): R|kotlin/String|
/otherOperators.fir.kt:(1177,1178): error: Too many arguments for public final fun /StringProperty.get(): R|kotlin/String|
@@ -0,0 +1,5 @@
/plusAssignPrecedence.fir.kt:(2202,2204): error: Unresolved reference: plusAssign
/plusAssignPrecedence.fir.kt:(2227,2229): error: Unresolved reference: plusAssign
/plusAssignPrecedence.fir.kt:(2308,2310): error: Ambiguity between assign operator candidates: [fun plus(v: String): StringPropertyWithPlusAndPlusAssign, fun plusAssign(v: String): Unit]