[FIR] Drop visualizer module
This module was created to compare type resolve in K1 and K2. But overall, these tests contain a lot of bugs, and it is quite hard to use it.
This commit is contained in:
@@ -207,7 +207,6 @@
|
|||||||
/compiler/util-klib/ "Kotlin Native"
|
/compiler/util-klib/ "Kotlin Native"
|
||||||
/compiler/util-klib-abi/ "Kotlin Native"
|
/compiler/util-klib-abi/ "Kotlin Native"
|
||||||
/compiler/util-klib-metadata/ "Kotlin Native"
|
/compiler/util-klib-metadata/ "Kotlin Native"
|
||||||
/compiler/visualizer/ "Kotlin Compiler Core"
|
|
||||||
|
|
||||||
/core/builtins/ "Kotlin Compiler Core"
|
/core/builtins/ "Kotlin Compiler Core"
|
||||||
/core/compiler.common/ "Kotlin Compiler Core"
|
/core/compiler.common/ "Kotlin Compiler Core"
|
||||||
|
|||||||
@@ -702,10 +702,6 @@ tasks {
|
|||||||
dependsOn(":compiler:fir:fir2ir:nightlyTests")
|
dependsOn(":compiler:fir:fir2ir:nightlyTests")
|
||||||
}
|
}
|
||||||
|
|
||||||
register("compilerFrontendVisualizerTest") {
|
|
||||||
dependsOn("compiler:visualizer:test")
|
|
||||||
}
|
|
||||||
|
|
||||||
register("scriptingJvmTest") {
|
register("scriptingJvmTest") {
|
||||||
dependsOn("dist")
|
dependsOn("dist")
|
||||||
dependsOn(":kotlin-scripting-compiler:test")
|
dependsOn(":kotlin-scripting-compiler:test")
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ dependencies {
|
|||||||
testImplementation(projectTests(":compiler:fir:raw-fir:light-tree2fir"))
|
testImplementation(projectTests(":compiler:fir:raw-fir:light-tree2fir"))
|
||||||
testImplementation(projectTests(":compiler:fir:fir2ir"))
|
testImplementation(projectTests(":compiler:fir:fir2ir"))
|
||||||
testImplementation(projectTests(":compiler:fir:analysis-tests:legacy-fir-tests"))
|
testImplementation(projectTests(":compiler:fir:analysis-tests:legacy-fir-tests"))
|
||||||
testImplementation(projectTests(":compiler:visualizer"))
|
|
||||||
testImplementation(projectTests(":js:js.tests"))
|
testImplementation(projectTests(":js:js.tests"))
|
||||||
testImplementation(projectTests(":generators:test-generator"))
|
testImplementation(projectTests(":generators:test-generator"))
|
||||||
}
|
}
|
||||||
|
|||||||
-22
@@ -14,8 +14,6 @@ import org.jetbrains.kotlin.test.runners.ir.*
|
|||||||
import org.jetbrains.kotlin.test.runners.ir.interpreter.AbstractJvmIrInterpreterAfterFirPsi2IrTest
|
import org.jetbrains.kotlin.test.runners.ir.interpreter.AbstractJvmIrInterpreterAfterFirPsi2IrTest
|
||||||
import org.jetbrains.kotlin.test.runners.ir.interpreter.AbstractJvmIrInterpreterAfterPsi2IrTest
|
import org.jetbrains.kotlin.test.runners.ir.interpreter.AbstractJvmIrInterpreterAfterPsi2IrTest
|
||||||
import org.jetbrains.kotlin.test.utils.CUSTOM_TEST_DATA_EXTENSION_PATTERN
|
import org.jetbrains.kotlin.test.utils.CUSTOM_TEST_DATA_EXTENSION_PATTERN
|
||||||
import org.jetbrains.kotlin.visualizer.fir.AbstractFirVisualizerTest
|
|
||||||
import org.jetbrains.kotlin.visualizer.psi.AbstractPsiVisualizerTest
|
|
||||||
|
|
||||||
fun generateJUnit5CompilerTests(args: Array<String>, mainClassName: String?) {
|
fun generateJUnit5CompilerTests(args: Array<String>, mainClassName: String?) {
|
||||||
val excludedCustomTestdataPattern = CUSTOM_TEST_DATA_EXTENSION_PATTERN
|
val excludedCustomTestdataPattern = CUSTOM_TEST_DATA_EXTENSION_PATTERN
|
||||||
@@ -385,25 +383,5 @@ fun generateJUnit5CompilerTests(args: Array<String>, mainClassName: String?) {
|
|||||||
model("codegen/bytecodeText")
|
model("codegen/bytecodeText")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
testGroup("compiler/visualizer/tests-gen", "compiler/fir/raw-fir/psi2fir/testData") {
|
|
||||||
testClass<AbstractPsiVisualizerTest>("PsiVisualizerForRawFirDataGenerated") {
|
|
||||||
model("rawBuilder")
|
|
||||||
}
|
|
||||||
|
|
||||||
testClass<AbstractFirVisualizerTest>("FirVisualizerForRawFirDataGenerated") {
|
|
||||||
model("rawBuilder")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
testGroup("compiler/visualizer/tests-gen", "compiler/visualizer/testData") {
|
|
||||||
testClass<AbstractPsiVisualizerTest>("PsiVisualizerForUncommonCasesGenerated") {
|
|
||||||
model("uncommonCases/testFiles")
|
|
||||||
}
|
|
||||||
|
|
||||||
testClass<AbstractFirVisualizerTest>("FirVisualizerForUncommonCasesGenerated") {
|
|
||||||
model("uncommonCases/testFiles")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,53 +0,0 @@
|
|||||||
import org.jetbrains.kotlin.ideaExt.idea
|
|
||||||
|
|
||||||
plugins {
|
|
||||||
kotlin("jvm")
|
|
||||||
id("jps-compatible")
|
|
||||||
}
|
|
||||||
|
|
||||||
dependencies {
|
|
||||||
testCompileOnly(project(":compiler:fir:raw-fir:psi2fir"))
|
|
||||||
|
|
||||||
testImplementation(project(":compiler:visualizer:render-psi"))
|
|
||||||
testImplementation(project(":compiler:visualizer:render-fir"))
|
|
||||||
|
|
||||||
testApi(platform(libs.junit.bom))
|
|
||||||
testImplementation(libs.junit.jupiter.api)
|
|
||||||
testRuntimeOnly(libs.junit.jupiter.engine)
|
|
||||||
|
|
||||||
testApi(projectTests(":compiler:tests-compiler-utils"))
|
|
||||||
testApi(projectTests(":compiler:tests-common-new"))
|
|
||||||
testApi(projectTests(":compiler:test-infrastructure"))
|
|
||||||
testApi(projectTests(":compiler:fir:analysis-tests:legacy-fir-tests"))
|
|
||||||
testImplementation(projectTests(":generators:test-generator"))
|
|
||||||
|
|
||||||
testRuntimeOnly(commonDependency("org.jetbrains.intellij.deps.fastutil:intellij-deps-fastutil"))
|
|
||||||
testRuntimeOnly(commonDependency("org.jetbrains.intellij.deps.jna:jna"))
|
|
||||||
}
|
|
||||||
|
|
||||||
val generationRoot = projectDir.resolve("tests-gen")
|
|
||||||
|
|
||||||
sourceSets {
|
|
||||||
"main" { projectDefault() }
|
|
||||||
"test" {
|
|
||||||
projectDefault()
|
|
||||||
this.java.srcDir(generationRoot.name)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (kotlinBuildProperties.isInJpsBuildIdeaSync) {
|
|
||||||
apply(plugin = "idea")
|
|
||||||
idea {
|
|
||||||
this.module.generatedSourceDirs.add(generationRoot)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
projectTest(parallel = true, jUnitMode = JUnitMode.JUnit5) {
|
|
||||||
workingDir = rootDir
|
|
||||||
|
|
||||||
useJUnitPlatform()
|
|
||||||
}
|
|
||||||
|
|
||||||
testsJar()
|
|
||||||
|
|
||||||
val generateVisualizerTests by generator("org.jetbrains.kotlin.visualizer.GenerateVisualizerTestsKt")
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
plugins {
|
|
||||||
kotlin("jvm")
|
|
||||||
id("jps-compatible")
|
|
||||||
}
|
|
||||||
|
|
||||||
dependencies {
|
|
||||||
api(project(":compiler:frontend"))
|
|
||||||
compileOnly(intellijCore())
|
|
||||||
}
|
|
||||||
|
|
||||||
sourceSets {
|
|
||||||
"main" { projectDefault() }
|
|
||||||
"test" { }
|
|
||||||
}
|
|
||||||
@@ -1,65 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
|
||||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jetbrains.kotlin.compiler.visualizer
|
|
||||||
|
|
||||||
import com.intellij.openapi.util.TextRange
|
|
||||||
import kotlin.math.max
|
|
||||||
|
|
||||||
object Annotator {
|
|
||||||
private const val verticalLine = "│"
|
|
||||||
private const val comment = "//"
|
|
||||||
|
|
||||||
data class AnnotationInfo(val text: String, val range: TextRange)
|
|
||||||
|
|
||||||
private fun putAnnotationToLines(annotations: List<AnnotationInfo>, lineStart: Int, lineSize: Int): List<String> {
|
|
||||||
val annotationLines = mutableListOf(StringBuilder(comment + " ".repeat(lineSize - comment.length)))
|
|
||||||
val levelToOffset = mutableMapOf(0 to 0)
|
|
||||||
|
|
||||||
for (ann in annotations) {
|
|
||||||
val lastLevel = levelToOffset.values.takeWhile { ann.range.startOffset + ann.text.length >= it }.size
|
|
||||||
|
|
||||||
if (annotationLines.size <= lastLevel) {
|
|
||||||
annotationLines.add(StringBuilder(comment + " ".repeat(lineSize - comment.length)))
|
|
||||||
}
|
|
||||||
|
|
||||||
val startReplace = max(comment.length, ann.range.startOffset - lineStart)
|
|
||||||
annotationLines[lastLevel].replace(startReplace, startReplace + ann.text.length, ann.text)
|
|
||||||
|
|
||||||
for (i in 0 until lastLevel) {
|
|
||||||
if (annotationLines[i].getOrNull(startReplace) == ' ') { //to avoid char replacement for a multilevel annotation
|
|
||||||
annotationLines[i].replace(startReplace, startReplace + 1, verticalLine)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i in 1..lastLevel) {
|
|
||||||
levelToOffset[i] = ann.range.startOffset
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return annotationLines.map { it.trim().toString() }
|
|
||||||
}
|
|
||||||
|
|
||||||
fun annotate(text: String, annotation: Set<AnnotationInfo>): List<String> {
|
|
||||||
val lines = text.lines()
|
|
||||||
val resultLines = mutableListOf<String>()
|
|
||||||
var lineStartOffset = 0
|
|
||||||
for (line in lines) {
|
|
||||||
val lineEndOffset = lineStartOffset + line.length
|
|
||||||
val annotations = annotation
|
|
||||||
.filter { it.range.startOffset in lineStartOffset until lineEndOffset }
|
|
||||||
.sortedByDescending { it.range.startOffset }
|
|
||||||
|
|
||||||
if (annotations.isNotEmpty()) {
|
|
||||||
val annotationLines = putAnnotationToLines(annotations, lineStartOffset, line.length)
|
|
||||||
resultLines += annotationLines.asReversed()
|
|
||||||
}
|
|
||||||
resultLines.add(line)
|
|
||||||
|
|
||||||
lineStartOffset = lineEndOffset + 1
|
|
||||||
}
|
|
||||||
return resultLines
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-34
@@ -1,34 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
|
||||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jetbrains.kotlin.compiler.visualizer
|
|
||||||
|
|
||||||
import com.intellij.psi.PsiElement
|
|
||||||
|
|
||||||
abstract class BaseRenderer {
|
|
||||||
private val annotations = mutableSetOf<Annotator.AnnotationInfo>()
|
|
||||||
private val unnecessaryData = mapOf(
|
|
||||||
"kotlin/" to ""
|
|
||||||
)
|
|
||||||
|
|
||||||
open fun addAnnotation(annotationText: String, element: PsiElement?, deleteDuplicate: Boolean = true) {
|
|
||||||
if (element == null) return
|
|
||||||
annotations.removeIf { it.range.startOffset == element.textRange.startOffset && deleteDuplicate }
|
|
||||||
|
|
||||||
var textWithOutUnnecessaryData = annotationText
|
|
||||||
for ((key, value) in unnecessaryData) {
|
|
||||||
textWithOutUnnecessaryData = textWithOutUnnecessaryData.replace(key, value)
|
|
||||||
}
|
|
||||||
if (textWithOutUnnecessaryData != element.text && textWithOutUnnecessaryData.isNotEmpty()) {
|
|
||||||
annotations.add(Annotator.AnnotationInfo(textWithOutUnnecessaryData, element.textRange))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected fun getAnnotations(): Set<Annotator.AnnotationInfo> {
|
|
||||||
return annotations
|
|
||||||
}
|
|
||||||
|
|
||||||
abstract fun render(): String
|
|
||||||
}
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
plugins {
|
|
||||||
kotlin("jvm")
|
|
||||||
id("jps-compatible")
|
|
||||||
}
|
|
||||||
|
|
||||||
dependencies {
|
|
||||||
api(project(":compiler:fir:raw-fir:psi2fir"))
|
|
||||||
api(project(":compiler:fir:resolve"))
|
|
||||||
api(project(":compiler:visualizer:common"))
|
|
||||||
compileOnly(intellijCore())
|
|
||||||
}
|
|
||||||
|
|
||||||
sourceSets {
|
|
||||||
"main" { projectDefault() }
|
|
||||||
"test" { }
|
|
||||||
}
|
|
||||||
|
|
||||||
tasks.withType<org.jetbrains.kotlin.gradle.dsl.KotlinCompile<*>> {
|
|
||||||
kotlinOptions {
|
|
||||||
freeCompilerArgs += "-opt-in=org.jetbrains.kotlin.fir.symbols.SymbolInternals"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-904
@@ -1,904 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2022 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
|
||||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jetbrains.kotlin.compiler.visualizer
|
|
||||||
|
|
||||||
import com.intellij.psi.PsiElement
|
|
||||||
import org.jetbrains.kotlin.KtNodeTypes
|
|
||||||
import org.jetbrains.kotlin.descriptors.ClassKind
|
|
||||||
import org.jetbrains.kotlin.fir.*
|
|
||||||
import org.jetbrains.kotlin.fir.declarations.*
|
|
||||||
import org.jetbrains.kotlin.fir.declarations.utils.isLocal
|
|
||||||
import org.jetbrains.kotlin.fir.diagnostics.ConeDiagnostic
|
|
||||||
import org.jetbrains.kotlin.fir.expressions.*
|
|
||||||
import org.jetbrains.kotlin.fir.references.*
|
|
||||||
import org.jetbrains.kotlin.fir.renderer.ConeTypeRendererForDebugging
|
|
||||||
import org.jetbrains.kotlin.fir.resolve.defaultType
|
|
||||||
import org.jetbrains.kotlin.fir.resolve.fullyExpandedType
|
|
||||||
import org.jetbrains.kotlin.fir.resolve.toFirRegularClassSymbol
|
|
||||||
import org.jetbrains.kotlin.fir.symbols.FirBasedSymbol
|
|
||||||
import org.jetbrains.kotlin.fir.symbols.impl.*
|
|
||||||
import org.jetbrains.kotlin.fir.types.*
|
|
||||||
import org.jetbrains.kotlin.fir.visitors.FirVisitor
|
|
||||||
import org.jetbrains.kotlin.name.CallableId
|
|
||||||
import org.jetbrains.kotlin.name.ClassId
|
|
||||||
import org.jetbrains.kotlin.name.Name
|
|
||||||
import org.jetbrains.kotlin.psi
|
|
||||||
import org.jetbrains.kotlin.psi.*
|
|
||||||
import org.jetbrains.kotlin.psi.psiUtil.getChildOfType
|
|
||||||
import org.jetbrains.kotlin.psi.psiUtil.getChildrenOfType
|
|
||||||
import org.jetbrains.kotlin.renderer.replacePrefixesInTypeRepresentations
|
|
||||||
import org.jetbrains.kotlin.types.AbstractStrictEqualityTypeChecker
|
|
||||||
import org.jetbrains.kotlin.types.ConstantValueKind
|
|
||||||
import org.jetbrains.kotlin.util.capitalizeDecapitalize.toLowerCaseAsciiOnly
|
|
||||||
|
|
||||||
private const val ANONYMOUS_NAME = "<anonymous>"
|
|
||||||
private typealias Stack = MutableList<Pair<String, MutableList<String>>>
|
|
||||||
|
|
||||||
class FirVisualizer(private val firFile: FirFile) : BaseRenderer() {
|
|
||||||
private val implicitReceivers = mutableListOf<ConeKotlinType>()
|
|
||||||
|
|
||||||
private fun FirElement.render(): String = buildString { this@render.accept(FirRendererForVisualizer(), this) }
|
|
||||||
|
|
||||||
private val stack = mutableListOf("" to mutableListOf<String>())
|
|
||||||
|
|
||||||
private fun Stack.push(
|
|
||||||
levelName: String,
|
|
||||||
defaultValues: MutableList<String> = mutableListOf(),
|
|
||||||
) = this.add(levelName to defaultValues)
|
|
||||||
|
|
||||||
private fun Stack.pop() = this.removeAt(this.size - 1)
|
|
||||||
private fun Stack.addName(name: String) = this.last().second.add(name)
|
|
||||||
private fun Stack.addName(name: Name) = this.addName(name.asString())
|
|
||||||
private fun Stack.getPathByName(name: String): String {
|
|
||||||
if (name == ANONYMOUS_NAME) return ""
|
|
||||||
for ((reversedIndex, names) in this.asReversed().map { it.second }.withIndex()) {
|
|
||||||
if (names.contains(name)) {
|
|
||||||
return this.filterIndexed { index, _ -> index < this.size - reversedIndex && index > 0 }
|
|
||||||
.joinToString(separator = ".", postfix = ".") { it.first }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (name == "it") {
|
|
||||||
return this.subList(1, this.size)
|
|
||||||
.joinToString(separator = ".", postfix = ".") { it.first }
|
|
||||||
}
|
|
||||||
return "[NOT FOUND]."
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun addAnnotation(annotationText: String, element: PsiElement?, deleteDuplicate: Boolean) {
|
|
||||||
super.addAnnotation(annotationText, element, false)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun render(): String {
|
|
||||||
val map = mutableMapOf<PsiElement, MutableList<FirElement>>().apply { Psi2FirMapper(this).visitFile(firFile) }
|
|
||||||
map.keys.firstOrNull { it is KtFile }?.accept(PsiVisitor(map))
|
|
||||||
return Annotator.annotate(firFile.psi!!.text, getAnnotations()).joinToString("\n")
|
|
||||||
}
|
|
||||||
|
|
||||||
inner class PsiVisitor(private val map: Map<PsiElement, MutableList<FirElement>>) : KtVisitorVoid() {
|
|
||||||
private var lastCallWithLambda: String? = null
|
|
||||||
|
|
||||||
private inline fun <reified T> KtElement.firstOfType(): T? {
|
|
||||||
val firList = map[this]
|
|
||||||
return firList?.filterIsInstance<T>()?.firstOrNull()
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return rendered element or null if there is no such type
|
|
||||||
*/
|
|
||||||
private inline fun <reified T : FirElement> KtElement.firstOfTypeWithRender(
|
|
||||||
psi: PsiElement? = this,
|
|
||||||
getRendererElement: T.() -> FirElement = { this }
|
|
||||||
): FirElement? {
|
|
||||||
return firstOfType<T>()?.also { addAnnotation(it.getRendererElement().render(), psi) }
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return rendered element or null if there is no such type
|
|
||||||
*/
|
|
||||||
private inline fun <reified T : FirElement> KtElement.firstOfTypeWithLocalReplace(
|
|
||||||
psi: PsiElement? = this,
|
|
||||||
getName: T.() -> String
|
|
||||||
): FirElement? {
|
|
||||||
return firstOfType<T>()?.also { addAnnotation(it.render().replace("<local>/", stack.getPathByName(it.getName())), psi) }
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return first rendered element or null if there is no such type
|
|
||||||
*/
|
|
||||||
private inline fun <reified T : FirElement> KtElement.allOfTypeWithLocalReplace(
|
|
||||||
psi: PsiElement? = this,
|
|
||||||
getName: T.() -> String
|
|
||||||
): FirElement? {
|
|
||||||
val firList = map[this]
|
|
||||||
val firElements = firList?.filterIsInstance<T>()
|
|
||||||
if (firElements == null || firElements.isEmpty()) return null
|
|
||||||
firElements.forEach { addAnnotation(it.render().replace("<local>/", stack.getPathByName(it.getName())), psi) }
|
|
||||||
|
|
||||||
return firElements.first()
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun visitElement(element: PsiElement) {
|
|
||||||
element.acceptChildren(this)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun visitKtElement(element: KtElement) {
|
|
||||||
when (element) {
|
|
||||||
is KtClassInitializer, is KtSecondaryConstructor, is KtPrimaryConstructor, is KtSuperTypeCallEntry, is KtDelegatedSuperTypeEntry -> {
|
|
||||||
val valueParameters = element.getChildrenOfType<KtParameterList>()
|
|
||||||
valueParameters.flatMap { it.parameters }.forEach { stack.addName(it.nameAsSafeName) }
|
|
||||||
|
|
||||||
//add to init values from last block
|
|
||||||
//because when we are out of primary constructor information about properties will be removed
|
|
||||||
//is used in ClassInitializer block and in SuperTypeCallEntry
|
|
||||||
stack.push("<init>", stack.last().second)
|
|
||||||
element.acceptChildren(this)
|
|
||||||
stack.pop()
|
|
||||||
}
|
|
||||||
is KtClassOrObject -> {
|
|
||||||
if (element.isLocal) stack.addName((element.name ?: ANONYMOUS_NAME))
|
|
||||||
stack.push((element.name ?: ANONYMOUS_NAME))
|
|
||||||
element.acceptChildren(this)
|
|
||||||
stack.pop()
|
|
||||||
}
|
|
||||||
else -> element.acceptChildren(this)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun visitPackageDirective(directive: KtPackageDirective) {
|
|
||||||
//don't resolve package names
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun visitSuperExpression(expression: KtSuperExpression) {
|
|
||||||
//don't resolve super expression
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun visitThisExpression(expression: KtThisExpression) {
|
|
||||||
//don't resolve this expression
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun visitNamedFunction(function: KtNamedFunction) {
|
|
||||||
if (function.isLocal) stack.addName(function.name ?: ANONYMOUS_NAME)
|
|
||||||
stack.push((function.name ?: ANONYMOUS_NAME))
|
|
||||||
if (function.equalsToken != null) {
|
|
||||||
function.bodyExpression!!.firstOfTypeWithRender<FirReturnExpression>(function.equalsToken) { this.result.resolvedType.toFirResolvedTypeRef() }
|
|
||||||
?: function.firstOfTypeWithRender<FirCallableDeclaration>(function.equalsToken) { this.returnTypeRef }
|
|
||||||
}
|
|
||||||
super.visitNamedFunction(function)
|
|
||||||
stack.pop()
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun renderVariableType(variable: KtVariableDeclaration) {
|
|
||||||
stack.addName(variable.nameAsSafeName)
|
|
||||||
variable.firstOfTypeWithRender<FirVariable>(variable.nameIdentifier)
|
|
||||||
variable.acceptChildren(this)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun visitProperty(property: KtProperty) =
|
|
||||||
renderVariableType(property)
|
|
||||||
|
|
||||||
override fun visitDestructuringDeclarationEntry(multiDeclarationEntry: KtDestructuringDeclarationEntry) =
|
|
||||||
renderVariableType(multiDeclarationEntry)
|
|
||||||
|
|
||||||
override fun visitAnnotationEntry(annotationEntry: KtAnnotationEntry) {
|
|
||||||
annotationEntry.firstOfTypeWithRender<FirAnnotation>(annotationEntry.getChildOfType<KtConstructorCalleeExpression>())
|
|
||||||
super.visitAnnotationEntry(annotationEntry)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun visitConstructorCalleeExpression(constructorCalleeExpression: KtConstructorCalleeExpression) {
|
|
||||||
constructorCalleeExpression.firstOfTypeWithRender<FirDelegatedConstructorCall>()
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun visitParameter(parameter: KtParameter) {
|
|
||||||
stack.addName(parameter.nameAsSafeName)
|
|
||||||
if ((parameter.isLoopParameter && parameter.destructuringDeclaration == null) || parameter.ownerFunction is KtPropertyAccessor) {
|
|
||||||
parameter.firstOfTypeWithRender<FirVariable>(parameter.nameIdentifier)
|
|
||||||
}
|
|
||||||
super.visitParameter(parameter)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun visitTypeReference(typeReference: KtTypeReference) {
|
|
||||||
typeReference.firstOfTypeWithRender<FirTypeRef>()
|
|
||||||
super.visitTypeReference(typeReference)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun visitConstantExpression(expression: KtConstantExpression) {
|
|
||||||
expression.firstOfTypeWithRender<FirConstExpression<*>>()
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun visitReferenceExpression(expression: KtReferenceExpression) {
|
|
||||||
if (expression is KtOperationReferenceExpression) return
|
|
||||||
|
|
||||||
expression.firstOfTypeWithLocalReplace<FirResolvedNamedReference> { this.name.asString() }
|
|
||||||
?: expression.firstOfTypeWithLocalReplace<FirResolvedCallableReference> { this.name.asString() }
|
|
||||||
?: expression.firstOfTypeWithRender<FirResolvedQualifier>()
|
|
||||||
?: expression.firstOfTypeWithRender<FirElement>() //fallback for errors
|
|
||||||
super.visitReferenceExpression(expression)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun visitUnaryExpression(expression: KtUnaryExpression) {
|
|
||||||
if (expression.operationReference.getReferencedName() == "!!") {
|
|
||||||
expression.baseExpression?.accept(this)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
expression.allOfTypeWithLocalReplace<FirFunctionCall>(expression.operationReference) { this.calleeReference.name.asString() }
|
|
||||||
super.visitUnaryExpression(expression)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun visitBinaryExpression(expression: KtBinaryExpression) {
|
|
||||||
val operation = expression.operationReference
|
|
||||||
when {
|
|
||||||
operation.getReferencedName() == "?:" -> {
|
|
||||||
expression.left?.accept(this)
|
|
||||||
expression.right?.accept(this)
|
|
||||||
}
|
|
||||||
operation.getReferencedName() in setOf("==", "!=") -> {
|
|
||||||
expression.left?.accept(this)
|
|
||||||
expression.firstOfTypeWithRender<FirEqualityOperatorCall>(operation)
|
|
||||||
expression.right?.accept(this)
|
|
||||||
}
|
|
||||||
else -> {
|
|
||||||
expression.allOfTypeWithLocalReplace<FirFunctionCall>(operation) { this.calleeReference.name.asString() }
|
|
||||||
?: expression.firstOfTypeWithLocalReplace<FirVariableAssignment>(operation) { this.calleeReference.toString() }
|
|
||||||
super.visitBinaryExpression(expression)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun visitIfExpression(expression: KtIfExpression) {
|
|
||||||
expression.firstOfTypeWithRender<FirWhenExpression> { this.resolvedType.toFirResolvedTypeRef() }
|
|
||||||
super.visitIfExpression(expression)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun visitWhenExpression(expression: KtWhenExpression) {
|
|
||||||
expression.firstOfTypeWithRender<FirWhenExpression> { this.resolvedType.toFirResolvedTypeRef() }
|
|
||||||
super.visitWhenExpression(expression)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun visitDotQualifiedExpression(expression: KtDotQualifiedExpression) {
|
|
||||||
expression.firstOfTypeWithLocalReplace<FirFunctionCall>(expression.selectorExpression) { this.calleeReference.name.asString() }
|
|
||||||
super.visitDotQualifiedExpression(expression)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun visitCallExpression(expression: KtCallExpression) {
|
|
||||||
expression.firstOfTypeWithLocalReplace<FirFunctionCall> { this.calleeReference.name.asString() }
|
|
||||||
?: expression.firstOfTypeWithRender<FirArrayLiteral>()
|
|
||||||
expression.children.filter { it.node.elementType != KtNodeTypes.REFERENCE_EXPRESSION }.forEach { psi ->
|
|
||||||
when (psi) {
|
|
||||||
is KtLambdaArgument -> {
|
|
||||||
val firLambda = (psi.firstOfType<FirLambdaArgumentExpression>()?.expression as? FirAnonymousFunctionExpression)?.anonymousFunction
|
|
||||||
firLambda?.receiverParameter?.typeRef?.let {
|
|
||||||
lastCallWithLambda = psi.getLambdaExpression()?.firstOfType<FirLabel>()?.name
|
|
||||||
implicitReceivers += it.coneType
|
|
||||||
psi.accept(this)
|
|
||||||
implicitReceivers -= it.coneType
|
|
||||||
lastCallWithLambda = null
|
|
||||||
} ?: psi.accept(this)
|
|
||||||
}
|
|
||||||
else -> psi.accept(this)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun visitLambdaExpression(lambdaExpression: KtLambdaExpression) {
|
|
||||||
stack.push(ANONYMOUS_NAME)
|
|
||||||
lastCallWithLambda?.let { addAnnotation("$it@${implicitReceivers.size - 1}", lambdaExpression) }
|
|
||||||
super.visitLambdaExpression(lambdaExpression)
|
|
||||||
stack.pop()
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun visitArrayAccessExpression(expression: KtArrayAccessExpression) {
|
|
||||||
//this method explicitly accept children and prevent default fallback to other fir element
|
|
||||||
expression.acceptChildren(this)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun visitPropertyAccessor(accessor: KtPropertyAccessor) {
|
|
||||||
if (accessor.isSetter) {
|
|
||||||
stack.push("<set-${accessor.property.nameAsSafeName}>", mutableListOf("field"))
|
|
||||||
super.visitPropertyAccessor(accessor)
|
|
||||||
stack.pop()
|
|
||||||
} else {
|
|
||||||
super.visitPropertyAccessor(accessor)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun visitWhenEntry(ktWhenEntry: KtWhenEntry) {
|
|
||||||
ktWhenEntry.firstOfTypeWithRender<FirWhenBranch>(ktWhenEntry.expression) { this.result.resolvedType.toFirResolvedTypeRef() }
|
|
||||||
super.visitWhenEntry(ktWhenEntry)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun visitClassLiteralExpression(expression: KtClassLiteralExpression) {
|
|
||||||
expression.firstOfTypeWithRender<FirGetClassCall>()
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun visitPrefixExpression(expression: KtPrefixExpression) {
|
|
||||||
expression.firstOfTypeWithRender<FirConstExpression<*>>(expression.baseExpression) ?: super.visitPrefixExpression(expression)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
inner class FirRendererForVisualizer : FirVisitor<Unit, StringBuilder>() {
|
|
||||||
private val session = firFile.moduleData.session
|
|
||||||
private val filePackage = firFile.packageFqName.toString()
|
|
||||||
private val filePackageWithSlash = filePackage.replace(".", "/")
|
|
||||||
|
|
||||||
private fun ConeTypeProjection.tryToRenderConeAsFunctionTypeString(): String {
|
|
||||||
return buildString {
|
|
||||||
tryToRenderConeAsFunctionType(this@buildString)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun ConeTypeProjection.tryToRenderConeAsFunctionType(builder: StringBuilder) {
|
|
||||||
if (this !is ConeKotlinType) {
|
|
||||||
localTypeProjectionRenderer(builder)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
val projectionBuilder = StringBuilder()
|
|
||||||
ConeTypeRendererForDebugging(projectionBuilder).renderAsPossibleFunctionType(
|
|
||||||
this,
|
|
||||||
{ it.functionTypeKind(session) }
|
|
||||||
) {
|
|
||||||
localTypeProjectionRenderer(projectionBuilder)
|
|
||||||
}
|
|
||||||
builder.append(projectionBuilder.toString().removeCurrentFilePackage())
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun tryToSquashFlexibleType(lowerRendered: String, upperRendered: String): String? {
|
|
||||||
val simpleCollection = replacePrefixesInTypeRepresentations(
|
|
||||||
lowerRendered,
|
|
||||||
"kotlin/collections/Mutable",
|
|
||||||
upperRendered,
|
|
||||||
"kotlin/collections/",
|
|
||||||
"kotlin/collections/(Mutable)"
|
|
||||||
)
|
|
||||||
if (simpleCollection != null) return simpleCollection
|
|
||||||
|
|
||||||
val mutableEntry = replacePrefixesInTypeRepresentations(
|
|
||||||
lowerRendered,
|
|
||||||
"kotlin/collections/MutableMap.MutableEntry",
|
|
||||||
upperRendered,
|
|
||||||
"kotlin/collections/Map.Entry",
|
|
||||||
"kotlin/collections/(Mutable)Map.(Mutable)Entry"
|
|
||||||
)
|
|
||||||
if (mutableEntry != null) return mutableEntry
|
|
||||||
|
|
||||||
val array = replacePrefixesInTypeRepresentations(
|
|
||||||
lowerRendered,
|
|
||||||
"kotlin/Array<",
|
|
||||||
upperRendered,
|
|
||||||
"kotlin/Array<out ",
|
|
||||||
"kotlin/Array<(out) "
|
|
||||||
)
|
|
||||||
if (array != null) return array
|
|
||||||
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun ConeTypeProjection.localTypeProjectionRenderer(builder: StringBuilder) {
|
|
||||||
val nullabilitySuffix = when {
|
|
||||||
this is ConeKotlinType && this !is ConeErrorType -> nullability.suffix
|
|
||||||
else -> ""
|
|
||||||
}
|
|
||||||
|
|
||||||
when (this) {
|
|
||||||
is ConeKotlinTypeProjectionIn -> {
|
|
||||||
builder.append("in ")
|
|
||||||
type.tryToRenderConeAsFunctionType(builder)
|
|
||||||
}
|
|
||||||
is ConeKotlinTypeProjectionOut -> {
|
|
||||||
builder.append("out ")
|
|
||||||
type.tryToRenderConeAsFunctionType(builder)
|
|
||||||
}
|
|
||||||
is ConeStarProjection -> builder.append("*")
|
|
||||||
is ConeClassLikeType -> {
|
|
||||||
val type = this.fullyExpandedType(session)
|
|
||||||
if (type != this) {
|
|
||||||
type.tryToRenderConeAsFunctionType(builder)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
val classId = type.lookupTag.classId
|
|
||||||
when {
|
|
||||||
classId.isLocal -> builder.append(classId.shortClassName.asString().let { stack.getPathByName(it) + it })
|
|
||||||
else -> builder.append(classId.asString())
|
|
||||||
}
|
|
||||||
if (type.typeArguments.isNotEmpty()) {
|
|
||||||
builder.append("<")
|
|
||||||
for ((index, typeArgument) in type.typeArguments.withIndex()) {
|
|
||||||
if (index != 0) {
|
|
||||||
builder.append(", ")
|
|
||||||
}
|
|
||||||
typeArgument.tryToRenderConeAsFunctionType(builder)
|
|
||||||
}
|
|
||||||
builder.append(">")
|
|
||||||
}
|
|
||||||
builder.append(nullabilitySuffix)
|
|
||||||
}
|
|
||||||
is ConeLookupTagBasedType -> builder.append(lookupTag.name.asString() + nullabilitySuffix)
|
|
||||||
is ConeFlexibleType -> {
|
|
||||||
val lowerBuilder = StringBuilder()
|
|
||||||
lowerBound.tryToRenderConeAsFunctionType(lowerBuilder)
|
|
||||||
if (lowerBound.nullability == ConeNullability.NOT_NULL && upperBound.nullability == ConeNullability.NULLABLE &&
|
|
||||||
AbstractStrictEqualityTypeChecker
|
|
||||||
.strictEqualTypes(
|
|
||||||
session.typeContext,
|
|
||||||
lowerBound,
|
|
||||||
upperBound.withNullability(ConeNullability.NOT_NULL, session.typeContext)
|
|
||||||
)
|
|
||||||
) {
|
|
||||||
builder.append(lowerBuilder)
|
|
||||||
} else {
|
|
||||||
val upperBuilder = StringBuilder()
|
|
||||||
upperBound.tryToRenderConeAsFunctionType(upperBuilder)
|
|
||||||
builder.append(
|
|
||||||
tryToSquashFlexibleType(lowerBuilder.toString(), upperBuilder.toString()) ?: "$lowerBuilder..$upperBuilder"
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
is ConeIntersectionType -> {
|
|
||||||
intersectedTypes.map { it.renderForDebugging().replace("/", ".").replace("kotlin.", "") }.sorted()
|
|
||||||
.joinToString(separator = " & ", prefix = "{", postfix = "}")
|
|
||||||
}
|
|
||||||
else -> builder.append((this as ConeKotlinType).renderForDebugging())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun String.removeCurrentFilePackage(): String {
|
|
||||||
val withoutPackage = this.replaceFirst("$filePackage.", "").replaceFirst("$filePackageWithSlash/", "")
|
|
||||||
|
|
||||||
return withoutPackage.let { if (it.startsWith("/")) it.substring(1) else it }
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun ClassId.getWithoutCurrentPackage() = this.asString().removeCurrentFilePackage()
|
|
||||||
|
|
||||||
private fun <T : FirElement> renderListInTriangles(list: List<T>, data: StringBuilder, withSpace: Boolean = false) {
|
|
||||||
if (list.isNotEmpty()) {
|
|
||||||
list.joinTo(data, separator = ", ", prefix = "<", postfix = ">") {
|
|
||||||
it.render()
|
|
||||||
}
|
|
||||||
if (withSpace) data.append(" ")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun renderImplicitReceiver(symbol: FirBasedSymbol<*>, psi: PsiElement?) {
|
|
||||||
val receiverType = (symbol.fir as? FirCallableDeclaration)?.dispatchReceiverType ?: return
|
|
||||||
val implicitReceiverIndex = implicitReceivers.indexOf(receiverType)
|
|
||||||
if (implicitReceiverIndex != -1) addAnnotation("this@$implicitReceiverIndex", psi)
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun renderConstructorSymbol(symbol: FirConstructorSymbol, data: StringBuilder) {
|
|
||||||
data.append("constructor ")
|
|
||||||
data.append(getSymbolId(symbol))
|
|
||||||
renderListInTriangles(symbol.fir.typeParameters, data)
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun renderField(field: FirField, data: StringBuilder) {
|
|
||||||
val original = field.unwrapFakeOverridesOrDelegated()
|
|
||||||
if (original.isVal) data.append("val ") else if (original.isVar) data.append("var ")
|
|
||||||
|
|
||||||
data.append("(")
|
|
||||||
original.dispatchReceiverType?.tryToRenderConeAsFunctionType(data)
|
|
||||||
data.append(").")
|
|
||||||
.append(original.name)
|
|
||||||
.append(": ")
|
|
||||||
original.returnTypeRef.coneType.tryToRenderConeAsFunctionType(data)
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun renderVariable(variable: FirVariable, data: StringBuilder) {
|
|
||||||
when {
|
|
||||||
variable is FirEnumEntry -> {
|
|
||||||
data.append("enum entry ")
|
|
||||||
variable.returnTypeRef.accept(this, data)
|
|
||||||
data.append(".${variable.name}")
|
|
||||||
return
|
|
||||||
}
|
|
||||||
variable !is FirValueParameter || variable.name.asString() == "e" /* hack to match render with psi */ -> when {
|
|
||||||
variable.isVar -> data.append("var ")
|
|
||||||
variable.isVal -> data.append("val ")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
val returnType = if ((variable as? FirValueParameter)?.isVararg == true) {
|
|
||||||
data.append("vararg ")
|
|
||||||
variable.returnTypeRef.coneType.arrayElementType()
|
|
||||||
} else {
|
|
||||||
variable.returnTypeRef.coneType
|
|
||||||
}
|
|
||||||
|
|
||||||
val receiver = when (variable) {
|
|
||||||
is FirField -> variable.dispatchReceiverType?.tryToRenderConeAsFunctionTypeString()
|
|
||||||
else -> getSymbolId(variable.symbol)
|
|
||||||
}
|
|
||||||
|
|
||||||
data.append(receiver)
|
|
||||||
.append(variable.symbol.callableId.callableName)
|
|
||||||
.append(": ")
|
|
||||||
returnType?.tryToRenderConeAsFunctionType(data)
|
|
||||||
data.append((variable as? FirValueParameter)?.defaultValue?.let { " = ..." } ?: "")
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun renderPropertySymbol(symbol: FirPropertySymbol, data: StringBuilder) {
|
|
||||||
val fir = symbol.fir.unwrapFakeOverridesOrDelegated()
|
|
||||||
data.append(if (fir.isVar) "var" else "val").append(" ")
|
|
||||||
renderListInTriangles(fir.typeParameters, data, withSpace = true)
|
|
||||||
|
|
||||||
val receiver = fir.receiverParameter?.typeRef?.render()
|
|
||||||
when {
|
|
||||||
receiver != null -> data.append(receiver).append(".").append(symbol.callableId.callableName)
|
|
||||||
fir.dispatchReceiverType != null -> {
|
|
||||||
val dispatchReceiver = fir.dispatchReceiverType?.tryToRenderConeAsFunctionTypeString()
|
|
||||||
data.append("($dispatchReceiver)").append(".").append(symbol.callableId.callableName)
|
|
||||||
}
|
|
||||||
else -> {
|
|
||||||
val name = symbol.callableId.let { if (it.packageName.asString().isEmpty()) it.callableName else it }
|
|
||||||
data.append(name.toString().removeCurrentFilePackage())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
data.append(": ").append(fir.returnTypeRef.render())
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun renderFunctionSymbol(symbol: FirNamedFunctionSymbol, data: StringBuilder, call: FirFunctionCall? = null) {
|
|
||||||
data.append("fun ")
|
|
||||||
val fir = symbol.fir.unwrapFakeOverridesOrDelegated()
|
|
||||||
renderListInTriangles(fir.typeParameters, data, true)
|
|
||||||
|
|
||||||
val id = getSymbolId(symbol)
|
|
||||||
val callableName = symbol.callableId.callableName
|
|
||||||
val receiverParameterType = fir.receiverParameter?.typeRef
|
|
||||||
|
|
||||||
if (call == null) {
|
|
||||||
// call is null for callable reference
|
|
||||||
if (receiverParameterType == null) {
|
|
||||||
symbol.callableId.className?.let { data.append("($it).$callableName") } ?: data.append(callableName)
|
|
||||||
} else {
|
|
||||||
data.append("${receiverParameterType.render()}.$callableName")
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
var withExtensionFunctionType = false
|
|
||||||
|
|
||||||
val extensionReceiver = call.extensionReceiver
|
|
||||||
val dispatchReceiver = call.dispatchReceiver
|
|
||||||
when {
|
|
||||||
extensionReceiver != null -> {
|
|
||||||
// render type from symbol because this way it will be consistent with psi render
|
|
||||||
fir.receiverParameter?.accept(this, data)
|
|
||||||
data.append(".").append(callableName)
|
|
||||||
}
|
|
||||||
dispatchReceiver?.resolvedType?.isExtensionFunctionType == true-> {
|
|
||||||
withExtensionFunctionType = true
|
|
||||||
fir.valueParameters.first().returnTypeRef.accept(this, data)
|
|
||||||
data.append(".").append(callableName)
|
|
||||||
}
|
|
||||||
dispatchReceiver != null -> {
|
|
||||||
data.append("(")
|
|
||||||
val dispatch = fir.dispatchReceiverType!!.tryToRenderConeAsFunctionTypeString()
|
|
||||||
.let { if (it.endsWith("!")) it.dropLast(1) else it } // this hack drop flexible annotation for receiver
|
|
||||||
data.append(dispatch).append(").").append(callableName)
|
|
||||||
}
|
|
||||||
else -> {
|
|
||||||
data.append(id)
|
|
||||||
if (symbol.callableId.className != null) data.append(".")
|
|
||||||
data.append(callableName)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
renderListInTriangles(call.typeArguments, data)
|
|
||||||
val valueParameters = fir.valueParameters.let { if (withExtensionFunctionType) it.drop(1) else it }
|
|
||||||
visitValueParameters(valueParameters, data)
|
|
||||||
data.append(": ")
|
|
||||||
fir.returnTypeRef.accept(this, data)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun visitElement(element: FirElement, data: StringBuilder) {
|
|
||||||
element.acceptChildren(this, data)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun visitErrorNamedReference(errorNamedReference: FirErrorNamedReference, data: StringBuilder) {
|
|
||||||
data.append(errorNamedReference.name)
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun visitConstructor(call: FirResolvable, data: StringBuilder) {
|
|
||||||
when (val calleeReference = call.calleeReference) {
|
|
||||||
!is FirResolvedNamedReference -> data.append("[ERROR: Unresolved]")
|
|
||||||
else -> visitConstructor(calleeReference.resolvedSymbol.fir as FirConstructor, data)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun visitConstructor(constructor: FirConstructor, data: StringBuilder) {
|
|
||||||
renderConstructorSymbol(constructor.symbol, data)
|
|
||||||
visitValueParameters(constructor.unwrapFakeOverridesOrDelegated().valueParameters, data)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun visitTypeParameterRef(typeParameterRef: FirTypeParameterRef, data: StringBuilder) {
|
|
||||||
visitTypeParameter(typeParameterRef.symbol.fir, data)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun visitOuterClassTypeParameterRef(outerClassTypeParameterRef: FirOuterClassTypeParameterRef, data: StringBuilder) {
|
|
||||||
visitTypeParameterRef(outerClassTypeParameterRef, data)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun visitConstructedClassTypeParameterRef(constructedClassTypeParameterRef: FirConstructedClassTypeParameterRef, data: StringBuilder
|
|
||||||
) {
|
|
||||||
visitTypeParameterRef(constructedClassTypeParameterRef, data)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun visitTypeParameter(typeParameter: FirTypeParameter, data: StringBuilder) {
|
|
||||||
data.append(typeParameter.name)
|
|
||||||
val bounds = typeParameter.bounds.filterNot { it.render() == "kotlin/Any?" }
|
|
||||||
if (bounds.isNotEmpty()) {
|
|
||||||
data.append(" : ")
|
|
||||||
bounds.joinTo(data, separator = ", ") { it.render() }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun visitBackingFieldReference(backingFieldReference: FirBackingFieldReference, data: StringBuilder) {
|
|
||||||
val firProperty = backingFieldReference.resolvedSymbol.fir
|
|
||||||
data.append(if (firProperty.isVar) "var " else "val ")
|
|
||||||
.append(stack.getPathByName("field"))
|
|
||||||
.append("field: ")
|
|
||||||
.append(firProperty.returnTypeRef.render())
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun visitProperty(property: FirProperty, data: StringBuilder) {
|
|
||||||
if (property.isLocal) {
|
|
||||||
visitVariable(property, data)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
data.append(property.returnTypeRef.render())
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun visitValueParameters(valueParameters: List<FirValueParameter>, data: StringBuilder) {
|
|
||||||
valueParameters.joinTo(data, separator = ", ", prefix = "(", postfix = ")") {
|
|
||||||
it.render()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun visitValueParameter(valueParameter: FirValueParameter, data: StringBuilder) {
|
|
||||||
if (valueParameter.isVararg) {
|
|
||||||
data.append("vararg ")
|
|
||||||
valueParameter.returnTypeRef.coneType.arrayElementType()?.localTypeProjectionRenderer(data)
|
|
||||||
} else {
|
|
||||||
valueParameter.returnTypeRef.accept(this, data)
|
|
||||||
}
|
|
||||||
valueParameter.defaultValue?.let { data.append(" = ...") }
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun visitVariable(variable: FirVariable, data: StringBuilder) {
|
|
||||||
data.append(variable.returnTypeRef.render())
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun visitNamedReference(namedReference: FirNamedReference, data: StringBuilder) {
|
|
||||||
if (namedReference is FirErrorNamedReference) {
|
|
||||||
data.append(namedReference.diagnostic.dump())
|
|
||||||
return
|
|
||||||
}
|
|
||||||
visitElement(namedReference, data)
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun ConeDiagnostic.dump(): String {
|
|
||||||
return "[ERROR : ${reason}]"
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun visitResolvedNamedReference(resolvedNamedReference: FirResolvedNamedReference, data: StringBuilder) {
|
|
||||||
val symbol = resolvedNamedReference.resolvedSymbol
|
|
||||||
renderImplicitReceiver(symbol, resolvedNamedReference.source.psi)
|
|
||||||
when {
|
|
||||||
symbol is FirPropertySymbol && !symbol.fir.isLocal -> renderPropertySymbol(symbol, data)
|
|
||||||
symbol is FirNamedFunctionSymbol -> {
|
|
||||||
val fir = symbol.fir
|
|
||||||
data.append(stack.getPathByName(resolvedNamedReference.name.asString()))
|
|
||||||
.append(resolvedNamedReference.name)
|
|
||||||
.append(": ")
|
|
||||||
fir.dispatchReceiverType?.tryToRenderConeAsFunctionType(data)
|
|
||||||
}
|
|
||||||
symbol is FirFieldSymbol -> renderField(symbol.fir, data)
|
|
||||||
else -> (symbol.fir as? FirVariable)?.let { renderVariable(it, data) }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun visitResolvedErrorReference(resolvedErrorReference: FirResolvedErrorReference, data: StringBuilder) {
|
|
||||||
visitResolvedNamedReference(resolvedErrorReference, data)
|
|
||||||
data.append(resolvedErrorReference.diagnostic.dump())
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun visitResolvedCallableReference(resolvedCallableReference: FirResolvedCallableReference, data: StringBuilder) {
|
|
||||||
when (val symbol = resolvedCallableReference.resolvedSymbol) {
|
|
||||||
is FirPropertySymbol -> renderPropertySymbol(symbol, data)
|
|
||||||
is FirFieldSymbol -> renderField(symbol.fir, data)
|
|
||||||
is FirConstructorSymbol -> visitConstructor(symbol.fir, data)
|
|
||||||
is FirNamedFunctionSymbol -> {
|
|
||||||
renderFunctionSymbol(symbol, data)
|
|
||||||
|
|
||||||
val fir = symbol.fir
|
|
||||||
visitValueParameters(fir.valueParameters, data)
|
|
||||||
data.append(": ")
|
|
||||||
fir.returnTypeRef.accept(this, data)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun visitAnnotationCall(annotationCall: FirAnnotationCall, data: StringBuilder) {
|
|
||||||
visitConstructor(annotationCall, data)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun visitAnnotation(annotation: FirAnnotation, data: StringBuilder) {}
|
|
||||||
|
|
||||||
override fun visitDelegatedConstructorCall(delegatedConstructorCall: FirDelegatedConstructorCall, data: StringBuilder) {
|
|
||||||
val coneClassType = delegatedConstructorCall.constructedTypeRef.coneTypeSafe<ConeClassLikeType>()
|
|
||||||
if (coneClassType != null) {
|
|
||||||
visitConstructor(delegatedConstructorCall, data)
|
|
||||||
} else {
|
|
||||||
data.append("[ERROR : ${delegatedConstructorCall.constructedTypeRef.render()}]")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun visitComparisonExpression(comparisonExpression: FirComparisonExpression, data: StringBuilder) {
|
|
||||||
data.append("CMP(${comparisonExpression.operation.operator}, ")
|
|
||||||
comparisonExpression.compareToCall.accept(this, data)
|
|
||||||
data.append(")")
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun visitTypeOperatorCall(typeOperatorCall: FirTypeOperatorCall, data: StringBuilder) {
|
|
||||||
//skip rendering for as/as?/is/!is
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun visitAssignmentOperatorStatement(assignmentOperatorStatement: FirAssignmentOperatorStatement, data: StringBuilder) {
|
|
||||||
data.append("assignment operator statement ${assignmentOperatorStatement.operation}")
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun visitEqualityOperatorCall(equalityOperatorCall: FirEqualityOperatorCall, data: StringBuilder) {
|
|
||||||
data.append("EQ operator call")
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun visitSafeCallExpression(safeCallExpression: FirSafeCallExpression, data: StringBuilder) {
|
|
||||||
safeCallExpression.receiver.accept(this, data)
|
|
||||||
data.append("?.{ ")
|
|
||||||
safeCallExpression.selector.accept(this, data)
|
|
||||||
data.append(" }")
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun visitCheckedSafeCallSubject(checkedSafeCallSubject: FirCheckedSafeCallSubject, data: StringBuilder) {
|
|
||||||
data.append("\$subj\$")
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun visitImplicitInvokeCall(implicitInvokeCall: FirImplicitInvokeCall, data: StringBuilder) {
|
|
||||||
visitFunctionCall(implicitInvokeCall, data)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun visitFunctionCall(functionCall: FirFunctionCall, data: StringBuilder) {
|
|
||||||
when (val callee = functionCall.calleeReference) {
|
|
||||||
is FirResolvedNamedReference -> {
|
|
||||||
if (functionCall.explicitReceiver == null) {
|
|
||||||
renderImplicitReceiver(callee.resolvedSymbol, functionCall.source.psi)
|
|
||||||
}
|
|
||||||
when (callee.resolvedSymbol) {
|
|
||||||
is FirConstructorSymbol -> visitConstructor(callee.resolvedSymbol.fir as FirConstructor, data)
|
|
||||||
else -> renderFunctionSymbol(callee.resolvedSymbol as FirNamedFunctionSymbol, data, functionCall)
|
|
||||||
}
|
|
||||||
if (callee is FirResolvedErrorReference) {
|
|
||||||
data.append(callee.diagnostic.dump())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
is FirErrorNamedReference -> data.append(callee.diagnostic.dump())
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun <T> visitConstExpression(constExpression: FirConstExpression<T>, data: StringBuilder) {
|
|
||||||
when (constExpression.kind) {
|
|
||||||
ConstantValueKind.String -> return
|
|
||||||
ConstantValueKind.Null -> constExpression.resolvedType.tryToRenderConeAsFunctionType(data)
|
|
||||||
else -> data.append(constExpression.kind)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun visitResolvedQualifier(resolvedQualifier: FirResolvedQualifier, data: StringBuilder) {
|
|
||||||
val fir = resolvedQualifier.symbol?.fir
|
|
||||||
when {
|
|
||||||
fir is FirRegularClass && fir.classKind != ClassKind.ENUM_CLASS && fir.companionObjectSymbol?.defaultType() == resolvedQualifier.coneTypeSafe() -> {
|
|
||||||
data.append("companion object ")
|
|
||||||
data.append(resolvedQualifier.resolvedType.toFirResolvedTypeRef().render()).append(": ")
|
|
||||||
data.append(fir.symbol.classId.asString().removeCurrentFilePackage())
|
|
||||||
}
|
|
||||||
fir is FirClass -> {
|
|
||||||
data.append(fir.classKind.name.toLowerCaseAsciiOnly().replace("_", " ")).append(" ")
|
|
||||||
data.append(fir.symbol.classId.asString().removeCurrentFilePackage())
|
|
||||||
renderListInTriangles(fir.typeParameters, data)
|
|
||||||
val superTypes = fir.superTypeRefs
|
|
||||||
.map { it.render() }
|
|
||||||
.filter { it != "kotlin/Any" }
|
|
||||||
.sorted()
|
|
||||||
if (superTypes.isNotEmpty()) superTypes.joinTo(data, prefix = ": ", separator = ", ")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun visitVariableAssignment(variableAssignment: FirVariableAssignment, data: StringBuilder) {
|
|
||||||
//data.append("variable assignment")
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun visitStarProjection(starProjection: FirStarProjection, data: StringBuilder) {
|
|
||||||
data.append("*")
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun visitTypeProjectionWithVariance(typeProjectionWithVariance: FirTypeProjectionWithVariance, data: StringBuilder) {
|
|
||||||
val variance = typeProjectionWithVariance.variance.label
|
|
||||||
if (variance.isNotEmpty()) data.append("$variance ")
|
|
||||||
typeProjectionWithVariance.typeRef.accept(this, data)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun visitResolvedTypeRef(resolvedTypeRef: FirResolvedTypeRef, data: StringBuilder) {
|
|
||||||
resolvedTypeRef.type.tryToRenderConeAsFunctionType(data)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun visitErrorTypeRef(errorTypeRef: FirErrorTypeRef, data: StringBuilder) {
|
|
||||||
data.append("[ERROR : ${errorTypeRef.diagnostic.reason}]")
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun visitTypeRefWithNullability(typeRefWithNullability: FirTypeRefWithNullability, data: StringBuilder) {
|
|
||||||
if (typeRefWithNullability.isMarkedNullable) {
|
|
||||||
data.append("?")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun visitGetClassCall(getClassCall: FirGetClassCall, data: StringBuilder) {
|
|
||||||
getClassCall.argument.accept(this, data)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun visitArrayLiteral(arrayLiteral: FirArrayLiteral, data: StringBuilder) {
|
|
||||||
val name = arrayLiteral.resolvedType.classId!!.shortClassName.asString()
|
|
||||||
val typeArguments = arrayLiteral.resolvedType.typeArguments
|
|
||||||
val typeParameters = if (typeArguments.isEmpty()) "" else " <T>"
|
|
||||||
data.append("fun$typeParameters ${name.replaceFirstChar(Char::lowercaseChar)}Of")
|
|
||||||
typeArguments.firstOrNull()?.let {
|
|
||||||
data.append("<")
|
|
||||||
it.tryToRenderConeAsFunctionType(data)
|
|
||||||
data.append(">")
|
|
||||||
}
|
|
||||||
val valueParameter = name.replace("Array", "").takeIf { it.isNotEmpty() } ?: "T"
|
|
||||||
data.append("(vararg $valueParameter): $name${typeParameters.trim()}") // TODO change "T" to concrete type is array is primitive
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun FirBasedSymbol<*>.isLocalDeclaration(): Boolean {
|
|
||||||
return when (val fir = this.fir) {
|
|
||||||
is FirConstructor -> fir.returnTypeRef.coneType.isLocal()
|
|
||||||
is FirCallableDeclaration -> {
|
|
||||||
fir.dispatchReceiverClassLookupTagOrNull()?.toFirRegularClassSymbol(session)?.isLocal ?: false
|
|
||||||
}
|
|
||||||
else -> false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun ConeKotlinType.isLocal(): Boolean {
|
|
||||||
if (this !is ConeClassLikeType) return false
|
|
||||||
return this.lookupTag.toFirRegularClassSymbol(session)?.isLocal == true
|
|
||||||
}
|
|
||||||
|
|
||||||
// id == packageName + className
|
|
||||||
private fun getSymbolId(symbol: FirBasedSymbol<*>?): String {
|
|
||||||
return when (symbol) {
|
|
||||||
is FirCallableSymbol<*> -> {
|
|
||||||
if (symbol.isLocalDeclaration()) {
|
|
||||||
val callableName = symbol.callableId.callableName.asString()
|
|
||||||
stack.getPathByName(callableName) + callableName
|
|
||||||
} else {
|
|
||||||
symbol.callableId.withoutName().removeCurrentFilePackage()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
is FirClassLikeSymbol<*> -> symbol.classId.getWithoutCurrentPackage()
|
|
||||||
else -> ""
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun CallableId.withoutName(): String {
|
|
||||||
return buildString {
|
|
||||||
append(packageName.asString().replace('.', '/'))
|
|
||||||
append("/")
|
|
||||||
if (className != null) {
|
|
||||||
append(className)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-38
@@ -1,38 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
|
||||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jetbrains.kotlin.compiler.visualizer
|
|
||||||
|
|
||||||
import com.intellij.psi.PsiElement
|
|
||||||
import org.jetbrains.kotlin.fir.FirElement
|
|
||||||
import org.jetbrains.kotlin.fir.expressions.FirCallableReferenceAccess
|
|
||||||
import org.jetbrains.kotlin.fir.psi
|
|
||||||
import org.jetbrains.kotlin.fir.visitors.FirVisitorVoid
|
|
||||||
import org.jetbrains.kotlin.psi
|
|
||||||
import org.jetbrains.kotlin.psi.KtCallableReferenceExpression
|
|
||||||
|
|
||||||
class Psi2FirMapper(val map: MutableMap<PsiElement, MutableList<FirElement>>) : FirVisitorVoid() {
|
|
||||||
override fun visitElement(element: FirElement) {
|
|
||||||
val psi = element.psi
|
|
||||||
if (psi != null) {
|
|
||||||
if (map.putIfAbsent(psi, mutableListOf(element)) != null) {
|
|
||||||
map[psi]?.add(element)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
element.acceptChildren(this)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun visitCallableReferenceAccess(callableReferenceAccess: FirCallableReferenceAccess) {
|
|
||||||
callableReferenceAccess.extensionReceiver?.let { visitElement(it) }
|
|
||||||
callableReferenceAccess.dispatchReceiver?.let { visitElement(it) }
|
|
||||||
callableReferenceAccess.explicitReceiver?.let { visitElement(it) }
|
|
||||||
|
|
||||||
val psi = (callableReferenceAccess.calleeReference.psi as? KtCallableReferenceExpression)?.children?.last()
|
|
||||||
?: return callableReferenceAccess.calleeReference.accept(this)
|
|
||||||
if (map.putIfAbsent(psi, mutableListOf(callableReferenceAccess.calleeReference)) != null) {
|
|
||||||
map[psi]?.add(callableReferenceAccess.calleeReference)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
plugins {
|
|
||||||
kotlin("jvm")
|
|
||||||
id("jps-compatible")
|
|
||||||
}
|
|
||||||
|
|
||||||
dependencies {
|
|
||||||
api(project(":compiler:visualizer:common"))
|
|
||||||
compileOnly(intellijCore())
|
|
||||||
}
|
|
||||||
|
|
||||||
sourceSets {
|
|
||||||
"main" { projectDefault() }
|
|
||||||
"test" { }
|
|
||||||
}
|
|
||||||
-596
@@ -1,596 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
|
||||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jetbrains.kotlin.compiler.visualizer
|
|
||||||
|
|
||||||
import com.intellij.psi.PsiElement
|
|
||||||
import org.jetbrains.kotlin.KtNodeTypes
|
|
||||||
import org.jetbrains.kotlin.analyzer.AnalysisResult
|
|
||||||
import org.jetbrains.kotlin.builtins.KotlinBuiltIns
|
|
||||||
import org.jetbrains.kotlin.compiler.visualizer.Annotator.annotate
|
|
||||||
import org.jetbrains.kotlin.descriptors.*
|
|
||||||
import org.jetbrains.kotlin.descriptors.impl.AnonymousFunctionDescriptor
|
|
||||||
import org.jetbrains.kotlin.descriptors.impl.TypeAliasConstructorDescriptor
|
|
||||||
import org.jetbrains.kotlin.name.FqName
|
|
||||||
import org.jetbrains.kotlin.name.SpecialNames
|
|
||||||
import org.jetbrains.kotlin.psi.*
|
|
||||||
import org.jetbrains.kotlin.psi.psiUtil.getChildOfType
|
|
||||||
import org.jetbrains.kotlin.renderer.ClassifierNamePolicy
|
|
||||||
import org.jetbrains.kotlin.renderer.DescriptorRenderer
|
|
||||||
import org.jetbrains.kotlin.renderer.ParameterNameRenderingPolicy
|
|
||||||
import org.jetbrains.kotlin.renderer.render
|
|
||||||
import org.jetbrains.kotlin.resolve.BindingContext.*
|
|
||||||
import org.jetbrains.kotlin.resolve.bindingContextUtil.getAbbreviatedTypeOrType
|
|
||||||
import org.jetbrains.kotlin.resolve.calls.util.getCall
|
|
||||||
import org.jetbrains.kotlin.resolve.calls.util.getResolvedCall
|
|
||||||
import org.jetbrains.kotlin.resolve.calls.util.getType
|
|
||||||
import org.jetbrains.kotlin.resolve.calls.model.ResolvedCall
|
|
||||||
import org.jetbrains.kotlin.resolve.calls.tasks.ExplicitReceiverKind
|
|
||||||
import org.jetbrains.kotlin.resolve.calls.util.isSingleUnderscore
|
|
||||||
import org.jetbrains.kotlin.resolve.descriptorUtil.declaresOrInheritsDefaultValue
|
|
||||||
import org.jetbrains.kotlin.resolve.descriptorUtil.fqNameUnsafe
|
|
||||||
import org.jetbrains.kotlin.resolve.scopes.receivers.ReceiverValue
|
|
||||||
import org.jetbrains.kotlin.types.*
|
|
||||||
import org.jetbrains.kotlin.types.expressions.DoubleColonLHS
|
|
||||||
import java.util.*
|
|
||||||
|
|
||||||
class PsiVisualizer(private val file: KtFile, analysisResult: AnalysisResult) : BaseRenderer() {
|
|
||||||
private val bindingContext = analysisResult.bindingContext
|
|
||||||
private val filePackage = file.packageFqName.toString().replace(".", "/")
|
|
||||||
private val argumentsLabel = "<PLACE-FOR-ARGUMENTS>"
|
|
||||||
|
|
||||||
val descriptorRenderer = PsiDescriptorRenderer()
|
|
||||||
|
|
||||||
override fun render(): String {
|
|
||||||
file.accept(Renderer())
|
|
||||||
return annotate(file.text, getAnnotations()).joinToString("\n")
|
|
||||||
}
|
|
||||||
|
|
||||||
inner class Renderer : KtVisitorVoid() {
|
|
||||||
private val implicitReceivers = mutableListOf<ReceiverValue>()
|
|
||||||
private var lastCallWithLambda = ""
|
|
||||||
|
|
||||||
private fun renderType(type: KotlinType?): String {
|
|
||||||
return type?.let { descriptorRenderer.renderType(it) } ?: "[ERROR: unknown type]"
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun renderType(descriptor: CallableDescriptor?): String {
|
|
||||||
return renderType(descriptor?.returnType)
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun renderType(expression: KtExpression?): String {
|
|
||||||
return renderType(expression?.let { bindingContext.getType(it) })
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun visitElement(element: PsiElement) {
|
|
||||||
element.acceptChildren(this)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun visitKtElement(element: KtElement) {
|
|
||||||
element.acceptChildren(this)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun visitPackageDirective(directive: KtPackageDirective) {
|
|
||||||
//don't resolve package names
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun visitSuperExpression(expression: KtSuperExpression) {
|
|
||||||
//don't resolve super expression
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun visitThisExpression(expression: KtThisExpression) {
|
|
||||||
//don't resolve this expression
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun visitNamedFunction(function: KtNamedFunction) {
|
|
||||||
if (function.bodyExpression != null && function.equalsToken != null) {
|
|
||||||
addAnnotation(renderType(function.bodyExpression!!.getType(bindingContext)), function.equalsToken!!)
|
|
||||||
}
|
|
||||||
super.visitNamedFunction(function)
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun renderVariableType(variable: KtVariableDeclaration) {
|
|
||||||
val descriptor = bindingContext[VARIABLE, variable]
|
|
||||||
if (variable.isSingleUnderscore) return
|
|
||||||
addAnnotation(renderType(descriptor), variable.nameIdentifier!!)
|
|
||||||
variable.acceptChildren(this)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun visitProperty(property: KtProperty) =
|
|
||||||
renderVariableType(property)
|
|
||||||
|
|
||||||
override fun visitDestructuringDeclarationEntry(multiDeclarationEntry: KtDestructuringDeclarationEntry) =
|
|
||||||
renderVariableType(multiDeclarationEntry)
|
|
||||||
|
|
||||||
override fun visitParameter(parameter: KtParameter) {
|
|
||||||
if ((parameter.isLoopParameter && parameter.destructuringDeclaration == null) || parameter.ownerFunction is KtPropertyAccessor) {
|
|
||||||
addAnnotation(renderType(bindingContext[VALUE_PARAMETER, parameter]?.returnType), parameter.nameIdentifier!!)
|
|
||||||
}
|
|
||||||
super.visitParameter(parameter)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun visitTypeReference(typeReference: KtTypeReference) {
|
|
||||||
if (typeReference.text.isEmpty()) {
|
|
||||||
return super.visitTypeReference(typeReference)
|
|
||||||
}
|
|
||||||
|
|
||||||
val hasResolvedCall = with(object : KtVisitorVoid() {
|
|
||||||
var hasCall: Boolean = false
|
|
||||||
override fun visitKtElement(element: KtElement) {
|
|
||||||
if (!hasCall) {
|
|
||||||
element.getResolvedCall(bindingContext)?.let {
|
|
||||||
hasCall = true
|
|
||||||
element.accept(this@Renderer)
|
|
||||||
} ?: element.acceptChildren(this)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}) {
|
|
||||||
typeReference.accept(this)
|
|
||||||
this.hasCall
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!hasResolvedCall) {
|
|
||||||
val type = typeReference.getAbbreviatedTypeOrType(bindingContext)
|
|
||||||
addAnnotation(renderType(type), typeReference)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun visitConstantExpression(expression: KtConstantExpression) {
|
|
||||||
addAnnotation(renderType(expression), expression)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun visitConstructorCalleeExpression(constructorCalleeExpression: KtConstructorCalleeExpression) {
|
|
||||||
// this is hack for JvmField annotation, for some reason it is not represented as KtAnnotationEntry
|
|
||||||
if (constructorCalleeExpression.text == "JvmField") {
|
|
||||||
return addAnnotation("constructor jvm/JvmField()", constructorCalleeExpression)
|
|
||||||
}
|
|
||||||
super.visitConstructorCalleeExpression(constructorCalleeExpression)
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun renderCall(expression: KtExpression, renderOn: PsiElement = expression): ResolvedCall<out CallableDescriptor>? {
|
|
||||||
val call = expression.getCall(bindingContext)
|
|
||||||
val resolvedCall = expression.getResolvedCall(bindingContext)
|
|
||||||
if (call == null) {
|
|
||||||
return null
|
|
||||||
} else if (resolvedCall == null) {
|
|
||||||
addAnnotation("[ERROR: not resolved]", expression)
|
|
||||||
return null
|
|
||||||
}
|
|
||||||
|
|
||||||
fun addReceiverAnnotation(receiver: ReceiverValue?, receiverKind: ExplicitReceiverKind) {
|
|
||||||
if (receiver != null && resolvedCall.explicitReceiverKind != receiverKind) {
|
|
||||||
val index = implicitReceivers.indexOf(receiver)
|
|
||||||
if (index != -1) {
|
|
||||||
addAnnotation("this@$index", expression, deleteDuplicate = false)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
addReceiverAnnotation(resolvedCall.extensionReceiver, ExplicitReceiverKind.EXTENSION_RECEIVER)
|
|
||||||
addReceiverAnnotation(resolvedCall.dispatchReceiver, ExplicitReceiverKind.DISPATCH_RECEIVER)
|
|
||||||
|
|
||||||
val descriptor = resolvedCall.candidateDescriptor.let {
|
|
||||||
if (it is TypeAliasConstructorDescriptor) it.underlyingConstructorDescriptor else it
|
|
||||||
}
|
|
||||||
val typeArguments = resolvedCall.typeArguments
|
|
||||||
.takeIf { it.isNotEmpty() }
|
|
||||||
?.values?.joinToString(", ", "<", ">") { renderType(it) } ?: ""
|
|
||||||
val annotation = descriptorRenderer.render(descriptor).replace(argumentsLabel, typeArguments)
|
|
||||||
addAnnotation(annotation, renderOn, deleteDuplicate = false)
|
|
||||||
|
|
||||||
return resolvedCall
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun visitDotQualifiedExpression(expression: KtDotQualifiedExpression) {
|
|
||||||
val descriptor = bindingContext[QUALIFIER, expression]?.descriptor
|
|
||||||
if (descriptor is ClassDescriptor && descriptor.kind == ClassKind.ENUM_ENTRY) {
|
|
||||||
// if not here, enum entry will be processed as KtSimpleNameExpression
|
|
||||||
// at this point it is easier to get corresponding qualifier
|
|
||||||
addAnnotation(descriptorRenderer.render(descriptor), expression.selectorExpression)
|
|
||||||
}
|
|
||||||
super.visitDotQualifiedExpression(expression)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun visitSimpleNameExpression(expression: KtSimpleNameExpression) {
|
|
||||||
val descriptor = bindingContext[QUALIFIER, expression]?.descriptor
|
|
||||||
if (descriptor != null) {
|
|
||||||
addAnnotation(descriptorRenderer.render(descriptor), expression)
|
|
||||||
} else {
|
|
||||||
renderCall(expression)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun visitBinaryExpression(expression: KtBinaryExpression) {
|
|
||||||
val opName = expression.operationReference.getReferencedName()
|
|
||||||
if (opName == "==" || opName == "!=") {
|
|
||||||
addAnnotation("EQ operator call", expression.operationReference)
|
|
||||||
expression.left?.accept(this)
|
|
||||||
expression.right?.accept(this)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
expression.left?.takeIf { it.node.elementType == KtNodeTypes.ARRAY_ACCESS_EXPRESSION && opName == "=" }?.let {
|
|
||||||
renderCall(it, expression.operationReference)
|
|
||||||
}
|
|
||||||
super.visitBinaryExpression(expression)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun visitIfExpression(expression: KtIfExpression) {
|
|
||||||
addAnnotation(renderType(expression), expression.ifKeyword)
|
|
||||||
super.visitIfExpression(expression)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun visitWhenExpression(expression: KtWhenExpression) {
|
|
||||||
addAnnotation(renderType(expression), expression.whenKeyword)
|
|
||||||
super.visitWhenExpression(expression)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun visitWhenEntry(ktWhenEntry: KtWhenEntry) {
|
|
||||||
addAnnotation(renderType(ktWhenEntry.expression), ktWhenEntry.expression!!)
|
|
||||||
super.visitWhenEntry(ktWhenEntry)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun visitLambdaExpression(lambdaExpression: KtLambdaExpression) {
|
|
||||||
val descriptor = bindingContext[DECLARATION_TO_DESCRIPTOR, lambdaExpression.functionLiteral] as AnonymousFunctionDescriptor
|
|
||||||
val extensionReceiver = descriptor.extensionReceiverParameter ?: return super.visitLambdaExpression(lambdaExpression)
|
|
||||||
addAnnotation("$lastCallWithLambda@${implicitReceivers.size}", lambdaExpression)
|
|
||||||
|
|
||||||
implicitReceivers += extensionReceiver.value
|
|
||||||
super.visitLambdaExpression(lambdaExpression)
|
|
||||||
implicitReceivers -= extensionReceiver.value
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun visitCallExpression(expression: KtCallExpression) {
|
|
||||||
val resolvedCall = renderCall(expression) ?: return super.visitCallExpression(expression)
|
|
||||||
|
|
||||||
if (expression.getChildOfType<KtLambdaArgument>() != null) {
|
|
||||||
lastCallWithLambda = resolvedCall.resultingDescriptor.name.asString()
|
|
||||||
}
|
|
||||||
for (child in expression.children) {
|
|
||||||
if (child.node.elementType != KtNodeTypes.REFERENCE_EXPRESSION) {
|
|
||||||
child.accept(this)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun visitClassLiteralExpression(expression: KtClassLiteralExpression) {
|
|
||||||
val doubleColonLhs = bindingContext[DOUBLE_COLON_LHS, expression.receiverExpression]
|
|
||||||
doubleColonLhs?.takeIf { it is DoubleColonLHS.Type }?.let {
|
|
||||||
addAnnotation(descriptorRenderer.render(it.type.constructor.declarationDescriptor!!), expression)
|
|
||||||
} ?: super.visitClassLiteralExpression(expression)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun visitPrefixExpression(expression: KtPrefixExpression) {
|
|
||||||
val opName = expression.operationReference.getReferencedName()
|
|
||||||
if (expression.baseExpression?.node?.elementType == KtNodeTypes.INTEGER_CONSTANT && opName == "-") {
|
|
||||||
return expression.baseExpression!!.accept(this)
|
|
||||||
}
|
|
||||||
super.visitPrefixExpression(expression)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
inner class PsiDescriptorRenderer(
|
|
||||||
private val needToRenderSpecialFun: Boolean = false
|
|
||||||
) : DeclarationDescriptorVisitor<Unit, StringBuilder> {
|
|
||||||
private val typeRenderer: DescriptorRenderer = DescriptorRenderer.withOptions {
|
|
||||||
withDefinedIn = false
|
|
||||||
modifiers = emptySet()
|
|
||||||
classifierNamePolicy = object : ClassifierNamePolicy {
|
|
||||||
override fun renderClassifier(classifier: ClassifierDescriptor, renderer: DescriptorRenderer): String {
|
|
||||||
if (classifier.name == SpecialNames.NO_NAME_PROVIDED) return "<anonymous>"
|
|
||||||
return renderFqName(classifier)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
includeAdditionalModifiers = false
|
|
||||||
parameterNameRenderingPolicy = ParameterNameRenderingPolicy.NONE
|
|
||||||
parameterNamesInFunctionalTypes = false
|
|
||||||
|
|
||||||
withoutTypeParameters = true
|
|
||||||
renderUnabbreviatedType = false
|
|
||||||
renderTypeExpansions = true
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun CallableDescriptor.isSpecial(): Boolean {
|
|
||||||
return this.name.asString().contains("SPECIAL-FUNCTION")
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun DeclarationDescriptor.resolveFakeOverride(): DeclarationDescriptor {
|
|
||||||
fun CallableMemberDescriptor.isFakeOverrideOrDelegate(): Boolean {
|
|
||||||
return kind == CallableMemberDescriptor.Kind.FAKE_OVERRIDE || kind == CallableMemberDescriptor.Kind.DELEGATION
|
|
||||||
}
|
|
||||||
|
|
||||||
var current = this as? CallableMemberDescriptor
|
|
||||||
while (current != null && current.isFakeOverrideOrDelegate()) {
|
|
||||||
current = current.overriddenDescriptors.singleOrNull { !it.isFakeOverrideOrDelegate() }
|
|
||||||
?: current.overriddenDescriptors.firstOrNull()
|
|
||||||
}
|
|
||||||
return current ?: this
|
|
||||||
}
|
|
||||||
|
|
||||||
fun render(declarationDescriptor: DeclarationDescriptor): String {
|
|
||||||
if (declarationDescriptor is CallableDescriptor && declarationDescriptor.isSpecial()) {
|
|
||||||
return if (needToRenderSpecialFun) this.renderSpecialFunction(declarationDescriptor) else ""
|
|
||||||
}
|
|
||||||
return buildString {
|
|
||||||
declarationDescriptor.resolveFakeOverride().original.accept(this@PsiDescriptorRenderer, this)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun renderType(type: KotlinType): String {
|
|
||||||
return typeRenderer.renderType(type)
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun renderName(descriptor: DeclarationDescriptor, hasReceiver: Boolean = false): String {
|
|
||||||
return if (hasReceiver) {
|
|
||||||
descriptor.name.asString()
|
|
||||||
} else {
|
|
||||||
renderFqName(descriptor)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun renderFqName(descriptor: DeclarationDescriptor, removeCurrentPackage: Boolean = true): String {
|
|
||||||
if (descriptor is TypeParameterDescriptor) return descriptor.name.render()
|
|
||||||
val fqName = qualifierNameCombine(descriptor)
|
|
||||||
return if (removeCurrentPackage) removeCurrentFilePackage(fqName) else fqName
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun qualifierNameCombine(descriptor: DeclarationDescriptor): String {
|
|
||||||
val nameString = descriptor.name.render().let { if (it == SpecialNames.NO_NAME_PROVIDED.asString()) "<anonymous>" else it }
|
|
||||||
if (nameString == FqName.ROOT.toString()) return ""
|
|
||||||
|
|
||||||
val containingDeclaration = descriptor.containingDeclaration
|
|
||||||
val qualifier = qualifierName(containingDeclaration)
|
|
||||||
val separator =
|
|
||||||
if (containingDeclaration is PackageFragmentDescriptor || containingDeclaration is PackageViewDescriptor) "/" else "."
|
|
||||||
return if (qualifier != "") qualifier + separator + nameString else nameString
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun qualifierName(descriptor: DeclarationDescriptor?): String = when (descriptor) {
|
|
||||||
is ModuleDescriptor, null -> ""
|
|
||||||
is PackageFragmentDescriptor, is PackageViewDescriptor -> descriptor.fqNameUnsafe.render().replace(".", "/")
|
|
||||||
else -> qualifierNameCombine(descriptor)
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun removeCurrentFilePackage(fqName: String): String {
|
|
||||||
return if (fqName.startsWith(filePackage) && !fqName.substring(filePackage.length + 1).contains("/")) {
|
|
||||||
fqName.replaceFirst("$filePackage/", "")
|
|
||||||
} else {
|
|
||||||
fqName
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun renderReceiver(descriptor: CallableDescriptor, data: StringBuilder): ReceiverParameterDescriptor? {
|
|
||||||
return descriptor.extensionReceiverParameter?.also {
|
|
||||||
visitReceiverParameterDescriptor(it, data)
|
|
||||||
data.append(".")
|
|
||||||
} ?: descriptor.dispatchReceiverParameter?.also {
|
|
||||||
data.append("(")
|
|
||||||
visitReceiverParameterDescriptor(it, data)
|
|
||||||
data.append(").")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun renderSuperTypes(klass: ClassDescriptor, builder: StringBuilder) {
|
|
||||||
if (KotlinBuiltIns.isNothing(klass.defaultType)) return
|
|
||||||
|
|
||||||
val supertypes = klass.typeConstructor.supertypes
|
|
||||||
.filter { !KotlinBuiltIns.isAnyOrNullableAny(it) }
|
|
||||||
.map { renderType(it) }
|
|
||||||
.sorted()
|
|
||||||
|
|
||||||
if (supertypes.isEmpty()) return
|
|
||||||
supertypes.joinTo(builder, prefix = ": ", separator = ", ")
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun renderValueParameter(
|
|
||||||
parameter: ValueParameterDescriptor, includeNames: Boolean, data: StringBuilder, topLevel: Boolean
|
|
||||||
) {
|
|
||||||
renderVariable(parameter, includeNames, data, topLevel)
|
|
||||||
if (parameter.declaresOrInheritsDefaultValue()) {
|
|
||||||
data.append(" = ...")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun renderVariable(variable: VariableDescriptor, includeName: Boolean, data: StringBuilder, topLevel: Boolean) {
|
|
||||||
val realType = variable.type
|
|
||||||
|
|
||||||
val varargElementType = (variable as? ValueParameterDescriptor)?.varargElementType
|
|
||||||
val typeToRender = varargElementType ?: realType
|
|
||||||
if (varargElementType != null) data.append("vararg ")
|
|
||||||
|
|
||||||
if (topLevel && variable !is ValueParameterDescriptor) data.append(if (variable.isVar) "var" else "val").append(" ")
|
|
||||||
if (includeName) {
|
|
||||||
data.append(renderName(variable)).append(": ")
|
|
||||||
}
|
|
||||||
|
|
||||||
data.append(renderType(typeToRender))
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun renderSpecialFunction(descriptor: CallableDescriptor): String {
|
|
||||||
val descriptorName = descriptor.name.asString()
|
|
||||||
val name = when {
|
|
||||||
descriptorName.contains("ELVIS") -> "?:"
|
|
||||||
descriptorName.contains("EXCLEXCL") -> "!!"
|
|
||||||
else -> "UNKNOWN"
|
|
||||||
}
|
|
||||||
val valueParameters = buildString { visitValueParameters(descriptor.valueParameters, this) }
|
|
||||||
val returnType = descriptor.returnType?.let { renderType(it) } ?: "[ERROR: unknown type]"
|
|
||||||
|
|
||||||
return "fun $name $valueParameters: $returnType"
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun visitPackageFragmentDescriptor(descriptor: PackageFragmentDescriptor, data: StringBuilder) {
|
|
||||||
//data.append("package-fragment ${renderFqName(descriptor, removeCurrentPackage = false)}")
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun visitPackageViewDescriptor(descriptor: PackageViewDescriptor, data: StringBuilder) {
|
|
||||||
// don't render package because support the same logic in fir is very hard
|
|
||||||
//data.append("package ${renderFqName(descriptor, removeCurrentPackage = false)}")
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun visitVariableDescriptor(variable: VariableDescriptor, data: StringBuilder) {
|
|
||||||
renderVariable(variable, true, data, true)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun visitFunctionDescriptor(function: FunctionDescriptor, data: StringBuilder) {
|
|
||||||
data.append("fun ")
|
|
||||||
|
|
||||||
visitTypeParameters(function.typeParameters, data)
|
|
||||||
if (function.typeParameters.isNotEmpty()) data.append(" ")
|
|
||||||
|
|
||||||
//render receiver
|
|
||||||
val receiver = renderReceiver(function, data)
|
|
||||||
|
|
||||||
//render name
|
|
||||||
data.append(renderName(function, receiver != null))
|
|
||||||
|
|
||||||
//render type arguments
|
|
||||||
data.append(argumentsLabel)
|
|
||||||
|
|
||||||
//render value parameters
|
|
||||||
visitValueParameters(function.valueParameters, data)
|
|
||||||
|
|
||||||
//render return type
|
|
||||||
val returnType = function.returnType
|
|
||||||
data.append(": ").append(if (returnType == null) "[NULL]" else renderType(returnType))
|
|
||||||
|
|
||||||
renderWhereSuffix(function.typeParameters, data)
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun renderWhereSuffix(typeParameters: List<TypeParameterDescriptor>, data: StringBuilder) {
|
|
||||||
val upperBoundStrings = ArrayList<String>(0)
|
|
||||||
|
|
||||||
for (typeParameter in typeParameters) {
|
|
||||||
typeParameter.upperBounds
|
|
||||||
.drop(1) // first parameter is rendered by renderTypeParameter
|
|
||||||
.mapTo(upperBoundStrings) { renderName(typeParameter) + " : " + renderType(it) }
|
|
||||||
}
|
|
||||||
|
|
||||||
if (upperBoundStrings.isNotEmpty()) {
|
|
||||||
data.append(" where ")
|
|
||||||
upperBoundStrings.joinTo(data, ", ")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun visitTypeParameters(typeParameters: List<TypeParameterDescriptor>, data: StringBuilder) {
|
|
||||||
if (typeParameters.isNotEmpty()) {
|
|
||||||
data.append("<")
|
|
||||||
val iterator = typeParameters.iterator()
|
|
||||||
while (iterator.hasNext()) {
|
|
||||||
val typeParameterDescriptor = iterator.next()
|
|
||||||
visitTypeParameterDescriptor(typeParameterDescriptor, data)
|
|
||||||
if (iterator.hasNext()) {
|
|
||||||
data.append(", ")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
data.append(">")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun visitTypeParameterDescriptor(typeParameter: TypeParameterDescriptor, data: StringBuilder) {
|
|
||||||
data.append(renderName(typeParameter, true))
|
|
||||||
val upperBoundsCount = typeParameter.upperBounds.size
|
|
||||||
if (upperBoundsCount >= 1) {
|
|
||||||
val upperBound = typeParameter.upperBounds.iterator().next()
|
|
||||||
if (!KotlinBuiltIns.isDefaultBound(upperBound)) {
|
|
||||||
data.append(" : ").append(renderType(upperBound))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun visitClassDescriptor(klass: ClassDescriptor, data: StringBuilder) {
|
|
||||||
data.append(DescriptorRenderer.getClassifierKindPrefix(klass)).append(" ")
|
|
||||||
|
|
||||||
//render name
|
|
||||||
data.append(renderName(klass))
|
|
||||||
|
|
||||||
if (klass.kind == ClassKind.ENUM_ENTRY) return
|
|
||||||
|
|
||||||
visitTypeParameters(klass.declaredTypeParameters, data)
|
|
||||||
|
|
||||||
renderSuperTypes(klass, data)
|
|
||||||
renderWhereSuffix(klass.declaredTypeParameters, data)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun visitTypeAliasDescriptor(typeAlias: TypeAliasDescriptor, data: StringBuilder) {
|
|
||||||
data.append("typealias").append(" ")
|
|
||||||
data.append(renderName(typeAlias))
|
|
||||||
|
|
||||||
visitTypeParameters(typeAlias.declaredTypeParameters, data)
|
|
||||||
|
|
||||||
data.append(" = ").append(renderType(typeAlias.underlyingType))
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun visitModuleDeclaration(descriptor: ModuleDescriptor, data: StringBuilder) {
|
|
||||||
data.append(renderName(descriptor))
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun visitConstructorDescriptor(constructor: ConstructorDescriptor, data: StringBuilder) {
|
|
||||||
data.append("constructor").append(" ")
|
|
||||||
|
|
||||||
val classDescriptor = constructor.containingDeclaration
|
|
||||||
|
|
||||||
data.append(renderName(classDescriptor))
|
|
||||||
visitTypeParameters(constructor.typeParameters, data)
|
|
||||||
|
|
||||||
visitValueParameters(constructor.valueParameters, data)
|
|
||||||
|
|
||||||
renderWhereSuffix(constructor.typeParameters, data)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun visitScriptDescriptor(scriptDescriptor: ScriptDescriptor, data: StringBuilder) {
|
|
||||||
visitClassDescriptor(scriptDescriptor, data)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun visitPropertyDescriptor(property: PropertyDescriptor, data: StringBuilder) {
|
|
||||||
data.append(if (property.isVar) "var" else "val").append(" ")
|
|
||||||
|
|
||||||
if (property !is SyntheticPropertyDescriptor) {
|
|
||||||
visitTypeParameters(property.typeParameters, data)
|
|
||||||
if (property.typeParameters.isNotEmpty()) data.append(" ")
|
|
||||||
}
|
|
||||||
|
|
||||||
//render receiver
|
|
||||||
val receiver = when (property) {
|
|
||||||
is SyntheticPropertyDescriptor -> renderReceiver(property.getMethod, data)
|
|
||||||
else -> renderReceiver(property, data)
|
|
||||||
}
|
|
||||||
|
|
||||||
//render name
|
|
||||||
data.append(renderName(property, receiver != null))
|
|
||||||
|
|
||||||
//render return type
|
|
||||||
data.append(": ").append(renderType(property.type))
|
|
||||||
|
|
||||||
renderWhereSuffix(property.typeParameters, data)
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun visitValueParameters(parameters: List<ValueParameterDescriptor>, data: StringBuilder) {
|
|
||||||
data.append("(")
|
|
||||||
for ((index, parameter) in parameters.withIndex()) {
|
|
||||||
renderValueParameter(parameter, false, data, false)
|
|
||||||
if (index != parameters.size - 1) {
|
|
||||||
data.append(", ")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
data.append(")")
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun visitValueParameterDescriptor(parameter: ValueParameterDescriptor, data: StringBuilder) {
|
|
||||||
renderValueParameter(parameter, true, data, true)
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun visitPropertyGetterDescriptor(descriptor: PropertyGetterDescriptor, data: StringBuilder) {
|
|
||||||
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun visitPropertySetterDescriptor(descriptor: PropertySetterDescriptor, data: StringBuilder) {
|
|
||||||
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun visitReceiverParameterDescriptor(descriptor: ReceiverParameterDescriptor, data: StringBuilder) {
|
|
||||||
data.append(renderType(descriptor.type))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,4 +0,0 @@
|
|||||||
open class A
|
|
||||||
|
|
||||||
|
|
||||||
class B : A
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
abstract class A {
|
|
||||||
abstract class Nested
|
|
||||||
}
|
|
||||||
|
|
||||||
typealias TA = A
|
|
||||||
|
|
||||||
// constructor A()
|
|
||||||
// │
|
|
||||||
class B : TA() {
|
|
||||||
// constructor A.Nested()
|
|
||||||
// │
|
|
||||||
class NestedInB : Nested()
|
|
||||||
}
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
package p
|
|
||||||
|
|
||||||
abstract class My {
|
|
||||||
// constructor My()
|
|
||||||
// │
|
|
||||||
abstract class NestedOne : My() {
|
|
||||||
// constructor My.NestedOne()
|
|
||||||
// │
|
|
||||||
abstract class NestedTwo : NestedOne() {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// constructor My()
|
|
||||||
// │
|
|
||||||
class Your : My() {
|
|
||||||
// constructor My.NestedOne()
|
|
||||||
// │
|
|
||||||
class NestedThree : NestedOne()
|
|
||||||
}
|
|
||||||
@@ -1,85 +0,0 @@
|
|||||||
// FIR_IGNORE
|
|
||||||
//constructor annotation/Target(vararg annotation/AnnotationTarget)
|
|
||||||
//│
|
|
||||||
@Target(
|
|
||||||
// enum class annotation/AnnotationTarget: Enum<annotation/AnnotationTarget>
|
|
||||||
// │ enum entry annotation/AnnotationTarget.CLASS
|
|
||||||
// │ │
|
|
||||||
AnnotationTarget.CLASS,
|
|
||||||
// enum class annotation/AnnotationTarget: Enum<annotation/AnnotationTarget>
|
|
||||||
// │ enum entry annotation/AnnotationTarget.PROPERTY
|
|
||||||
// │ │
|
|
||||||
AnnotationTarget.PROPERTY,
|
|
||||||
// enum class annotation/AnnotationTarget: Enum<annotation/AnnotationTarget>
|
|
||||||
// │ enum entry annotation/AnnotationTarget.LOCAL_VARIABLE
|
|
||||||
// │ │
|
|
||||||
AnnotationTarget.LOCAL_VARIABLE,
|
|
||||||
// enum class annotation/AnnotationTarget: Enum<annotation/AnnotationTarget>
|
|
||||||
// │ enum entry annotation/AnnotationTarget.VALUE_PARAMETER
|
|
||||||
// │ │
|
|
||||||
AnnotationTarget.VALUE_PARAMETER,
|
|
||||||
// enum class annotation/AnnotationTarget: Enum<annotation/AnnotationTarget>
|
|
||||||
// │ enum entry annotation/AnnotationTarget.CONSTRUCTOR
|
|
||||||
// │ │
|
|
||||||
AnnotationTarget.CONSTRUCTOR,
|
|
||||||
// enum class annotation/AnnotationTarget: Enum<annotation/AnnotationTarget>
|
|
||||||
// │ enum entry annotation/AnnotationTarget.FUNCTION
|
|
||||||
// │ │
|
|
||||||
AnnotationTarget.FUNCTION,
|
|
||||||
// enum class annotation/AnnotationTarget: Enum<annotation/AnnotationTarget>
|
|
||||||
// │ enum entry annotation/AnnotationTarget.TYPE
|
|
||||||
// │ │
|
|
||||||
AnnotationTarget.TYPE
|
|
||||||
) annotation class base
|
|
||||||
|
|
||||||
//constructor base()
|
|
||||||
//│
|
|
||||||
@base annotation class derived
|
|
||||||
|
|
||||||
//constructor base() constructor base()
|
|
||||||
//│ │
|
|
||||||
@base class correct(@base val x: Int) {
|
|
||||||
// constructor base() Int
|
|
||||||
// │ │
|
|
||||||
@base constructor(): this(0)
|
|
||||||
}
|
|
||||||
|
|
||||||
//constructor base()
|
|
||||||
//│
|
|
||||||
@base enum class My {
|
|
||||||
// constructor base()
|
|
||||||
// │
|
|
||||||
@base FIRST,
|
|
||||||
// constructor base()
|
|
||||||
// │
|
|
||||||
@base SECOND
|
|
||||||
}
|
|
||||||
|
|
||||||
//constructor base()
|
|
||||||
//│ constructor base()
|
|
||||||
//│ │ constructor base()
|
|
||||||
//│ │ │
|
|
||||||
@base fun foo(@base y: @base Int): Int {
|
|
||||||
// constructor base()
|
|
||||||
// │ constructor base()
|
|
||||||
// │ │ constructor base()
|
|
||||||
// │ │ │ Int
|
|
||||||
// │ │ │ │ foo.bar.z: Int
|
|
||||||
// │ │ │ │ │ fun (Int).plus(Int): Int
|
|
||||||
// │ │ │ │ │ │ Int
|
|
||||||
// │ │ │ │ │ │ │
|
|
||||||
@base fun bar(@base z: @base Int) = z + 1
|
|
||||||
// constructor base()
|
|
||||||
// │ fun foo.bar(Int): Int
|
|
||||||
// │ Int │ foo.y: Int
|
|
||||||
// │ │ │ │
|
|
||||||
@base val local = bar(y)
|
|
||||||
// val foo.local: Int
|
|
||||||
// │
|
|
||||||
return local
|
|
||||||
}
|
|
||||||
|
|
||||||
//constructor base()
|
|
||||||
//│ Int Int
|
|
||||||
//│ │ │
|
|
||||||
@base val z = 0
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
// FIR_IGNORE
|
|
||||||
package a.b
|
|
||||||
|
|
||||||
class C<T, out S> {
|
|
||||||
inner class D<R, in P> {
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
interface Test {
|
|
||||||
// C<out CharSequence, *>.D<in collections/List<*>, *>
|
|
||||||
// │ C<out CharSequence, *>.D<in collections/List<*>, *>
|
|
||||||
// │ │
|
|
||||||
val x: a.b.C<out CharSequence, *>.D<in List<*>, *>
|
|
||||||
}
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
object A {
|
|
||||||
constructor()
|
|
||||||
init {}
|
|
||||||
}
|
|
||||||
|
|
||||||
enum class B {
|
|
||||||
// constructor B()
|
|
||||||
// │
|
|
||||||
X() {
|
|
||||||
constructor()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class C {
|
|
||||||
companion object {
|
|
||||||
constructor()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Any
|
|
||||||
// │
|
|
||||||
val anonObject = object {
|
|
||||||
constructor()
|
|
||||||
}
|
|
||||||
-30
@@ -1,30 +0,0 @@
|
|||||||
// FIR_IGNORE
|
|
||||||
private fun resolveAccessorCall(
|
|
||||||
// [ERROR : PropertyDescriptor]
|
|
||||||
// │
|
|
||||||
suspendPropertyDescriptor: PropertyDescriptor,
|
|
||||||
// [ERROR : TranslationContext]
|
|
||||||
// │
|
|
||||||
context: TranslationContext
|
|
||||||
// [ERROR : ResolvedCall<PropertyDescriptor>]<[ERROR : PropertyDescriptor]>
|
|
||||||
// │
|
|
||||||
): ResolvedCall<PropertyDescriptor> {
|
|
||||||
// [ERROR : ResolvedCall<PropertyDescriptor>]<[ERROR : PropertyDescriptor]>
|
|
||||||
// │
|
|
||||||
return object : ResolvedCall<PropertyDescriptor> {
|
|
||||||
// [ERROR : <ERROR PROPERTY TYPE>]
|
|
||||||
// │ [ERROR: not resolved]
|
|
||||||
// │ │ [ERROR: not resolved]
|
|
||||||
// │ │ │
|
|
||||||
override fun getStatus() = ResolutionStatus.SUCCESS
|
|
||||||
|
|
||||||
// [ERROR : PropertyDescriptor]
|
|
||||||
// │ resolveAccessorCall.suspendPropertyDescriptor: [ERROR : PropertyDescriptor]
|
|
||||||
// │ │
|
|
||||||
override fun getCandidateDescriptor() = suspendPropertyDescriptor
|
|
||||||
// [ERROR : PropertyDescriptor]
|
|
||||||
// │ resolveAccessorCall.suspendPropertyDescriptor: [ERROR : PropertyDescriptor]
|
|
||||||
// │ │
|
|
||||||
override fun getResultingDescriptor() = suspendPropertyDescriptor
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-17
@@ -1,17 +0,0 @@
|
|||||||
// FIR_IGNORE
|
|
||||||
fun test1(s: String?) contract [returnsNotNull()] {
|
|
||||||
// [ERROR: not resolved]
|
|
||||||
// │
|
|
||||||
contract {
|
|
||||||
// [ERROR: not resolved]
|
|
||||||
// │ [ERROR: not resolved]
|
|
||||||
// │ │ test1.s: String?
|
|
||||||
// │ │ │ EQ operator call
|
|
||||||
// │ │ │ │ Nothing?
|
|
||||||
// │ │ │ │ │
|
|
||||||
returns() implies (s != null)
|
|
||||||
}
|
|
||||||
// fun test1(String?): Unit
|
|
||||||
// │
|
|
||||||
test1()
|
|
||||||
}
|
|
||||||
-60
@@ -1,60 +0,0 @@
|
|||||||
// new contracts syntax for property accessors
|
|
||||||
class MyClass {
|
|
||||||
// Int Int
|
|
||||||
// │ │
|
|
||||||
var myInt: Int = 0
|
|
||||||
// Int
|
|
||||||
// │
|
|
||||||
get() contract [returnsNotNull()] = 1
|
|
||||||
// Int
|
|
||||||
// │
|
|
||||||
set(value) {
|
|
||||||
// var MyClass.<set-myInt>.field: Int
|
|
||||||
// │ MyClass.<set-myInt>.value: Int
|
|
||||||
// │ │ fun (Int).times(Int): Int
|
|
||||||
// │ │ │ Int
|
|
||||||
// │ │ │ │
|
|
||||||
field = value * 10
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class AnotherClass(multiplier: Int) {
|
|
||||||
// Int Int
|
|
||||||
// │ │
|
|
||||||
var anotherInt: Int = 0
|
|
||||||
// Int
|
|
||||||
// │
|
|
||||||
get() contract [returnsNotNull()] = 1
|
|
||||||
// Int
|
|
||||||
// │
|
|
||||||
set(value) contract [returns()] {
|
|
||||||
// var AnotherClass.<set-anotherInt>.field: Int
|
|
||||||
// │ AnotherClass.<set-anotherInt>.value: Int
|
|
||||||
// │ │ [ERROR: not resolved]
|
|
||||||
// │ │ │ [ERROR: not resolved]
|
|
||||||
// │ │ │ │
|
|
||||||
field = value * multiplier
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class SomeClass(multiplier: Int?) {
|
|
||||||
// Int Int
|
|
||||||
// │ │
|
|
||||||
var someInt: Int = 0
|
|
||||||
// Int
|
|
||||||
// │
|
|
||||||
get() contract [returnsNotNull()] = 1
|
|
||||||
// EQ operator call
|
|
||||||
// Int │ [ERROR: unknown type]
|
|
||||||
// │ │ │
|
|
||||||
set(value) contract [returns() implies (value != null)] {
|
|
||||||
// SomeClass.<set-someInt>.value: Int
|
|
||||||
// │ [ERROR: not resolved]
|
|
||||||
// │ │
|
|
||||||
value ?: throw NullArgumentException()
|
|
||||||
// var SomeClass.<set-someInt>.field: Int
|
|
||||||
// │ SomeClass.<set-someInt>.value: Int
|
|
||||||
// │ │
|
|
||||||
field = value
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-16
@@ -1,16 +0,0 @@
|
|||||||
// FIR_IGNORE
|
|
||||||
// new contracts syntax for simple functions
|
|
||||||
// EQ operator call
|
|
||||||
// [ERROR : MyClass]? │ [ERROR: unknown type] [ERROR: unknown type]
|
|
||||||
// │ │ │ │
|
|
||||||
fun test1(s: MyClass?) contract [returns() implies (s != null), returns() implies (s is MySubClass)] {
|
|
||||||
// [ERROR: not resolved]
|
|
||||||
// │
|
|
||||||
test_1()
|
|
||||||
}
|
|
||||||
|
|
||||||
fun test2() contract [returnsNotNull()] {
|
|
||||||
// fun test2(): Unit
|
|
||||||
// │
|
|
||||||
test2()
|
|
||||||
}
|
|
||||||
Vendored
-126
@@ -1,126 +0,0 @@
|
|||||||
// FIR_IGNORE
|
|
||||||
// Should have raw description
|
|
||||||
fun test_1() {
|
|
||||||
// [ERROR: not resolved]
|
|
||||||
// │
|
|
||||||
contract {
|
|
||||||
// [ERROR: not resolved]
|
|
||||||
// │
|
|
||||||
callsInPlace()
|
|
||||||
}
|
|
||||||
// fun test_1(): Unit
|
|
||||||
// │
|
|
||||||
test_1()
|
|
||||||
}
|
|
||||||
|
|
||||||
fun test_2() {
|
|
||||||
// fun contracts/contract(contracts/ContractBuilder.() -> Unit): Unit
|
|
||||||
// │ contract@0
|
|
||||||
// │ │
|
|
||||||
kotlin.contracts.contract {
|
|
||||||
// fun <R> (contracts/ContractBuilder).callsInPlace<???>(Function<R>, contracts/InvocationKind = ...): contracts/CallsInPlace
|
|
||||||
// this@0
|
|
||||||
// │
|
|
||||||
callsInPlace()
|
|
||||||
// fun <R> (contracts/ContractBuilder).callsInPlace<???>(Function<R>, contracts/InvocationKind = ...): contracts/CallsInPlace
|
|
||||||
// this@0
|
|
||||||
// │
|
|
||||||
callsInPlace()
|
|
||||||
}
|
|
||||||
// fun test_2(): Unit
|
|
||||||
// │
|
|
||||||
test_2()
|
|
||||||
}
|
|
||||||
|
|
||||||
// Int Int
|
|
||||||
// │ │
|
|
||||||
var test_3: Int = 1
|
|
||||||
get() {
|
|
||||||
// [ERROR: not resolved]
|
|
||||||
// │
|
|
||||||
contract {
|
|
||||||
// [ERROR: not resolved]
|
|
||||||
// │
|
|
||||||
callsInPlace()
|
|
||||||
}
|
|
||||||
// Int
|
|
||||||
// │
|
|
||||||
return 1
|
|
||||||
}
|
|
||||||
// Int
|
|
||||||
// │
|
|
||||||
set(value) {
|
|
||||||
// fun contracts/contract(contracts/ContractBuilder.() -> Unit): Unit
|
|
||||||
// │ contract@0
|
|
||||||
// │ │
|
|
||||||
kotlin.contracts.contract {
|
|
||||||
// fun <R> (contracts/ContractBuilder).callsInPlace<???>(Function<R>, contracts/InvocationKind = ...): contracts/CallsInPlace
|
|
||||||
// this@0
|
|
||||||
// │
|
|
||||||
callsInPlace()
|
|
||||||
// fun <R> (contracts/ContractBuilder).callsInPlace<???>(Function<R>, contracts/InvocationKind = ...): contracts/CallsInPlace
|
|
||||||
// this@0
|
|
||||||
// │
|
|
||||||
callsInPlace()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun test_4() {
|
|
||||||
// [ERROR: not resolved]
|
|
||||||
// │
|
|
||||||
contract()
|
|
||||||
// fun test_4(): Unit
|
|
||||||
// │
|
|
||||||
test_4()
|
|
||||||
}
|
|
||||||
|
|
||||||
// should not have raw description
|
|
||||||
|
|
||||||
fun test_5() {
|
|
||||||
// fun test_5(): Unit
|
|
||||||
// │
|
|
||||||
test_5()
|
|
||||||
// [ERROR: not resolved]
|
|
||||||
// │
|
|
||||||
contract()
|
|
||||||
}
|
|
||||||
|
|
||||||
fun test_6() {
|
|
||||||
// [ERROR: not resolved]
|
|
||||||
// │ [ERROR: not resolved]
|
|
||||||
// │ │ [ERROR: not resolved]
|
|
||||||
// │ │ │ [ERROR: not resolved]
|
|
||||||
// │ │ │ │
|
|
||||||
aaa.bbb.ccc.contract {
|
|
||||||
|
|
||||||
}
|
|
||||||
// fun test_6(): Unit
|
|
||||||
// │
|
|
||||||
test_6()
|
|
||||||
}
|
|
||||||
|
|
||||||
fun test_7() {
|
|
||||||
// [ERROR: not resolved]
|
|
||||||
// │ [ERROR: not resolved]
|
|
||||||
// │ │
|
|
||||||
contracts.contract {
|
|
||||||
|
|
||||||
}
|
|
||||||
// fun test_7(): Unit
|
|
||||||
// │
|
|
||||||
test_7()
|
|
||||||
}
|
|
||||||
|
|
||||||
fun test_8() {
|
|
||||||
// [ERROR: not resolved]
|
|
||||||
// │ [ERROR: not resolved]
|
|
||||||
// │ │ [ERROR: not resolved]
|
|
||||||
// │ │ │ [ERROR: not resolved]
|
|
||||||
// │ │ │ │
|
|
||||||
aaa.kotlin.contracts.contract {
|
|
||||||
|
|
||||||
}
|
|
||||||
// fun test_8(): Unit
|
|
||||||
// │
|
|
||||||
test_8()
|
|
||||||
}
|
|
||||||
@@ -1,31 +0,0 @@
|
|||||||
import kotlin.properties.ReadWriteProperty
|
|
||||||
import kotlin.reflect.KProperty
|
|
||||||
|
|
||||||
// fun <T> lazy<Int>(() -> T): Lazy<T>
|
|
||||||
// │ Int
|
|
||||||
// │ │ fun (Int).plus(Int): Int
|
|
||||||
// Int │ │ │ Int
|
|
||||||
// │ │ │ │ │
|
|
||||||
val x: Int by lazy { 1 + 2 }
|
|
||||||
|
|
||||||
// properties/ReadWriteProperty<Any?, Int>
|
|
||||||
// │ properties/ReadWriteProperty<Any?, Int>
|
|
||||||
// │ │
|
|
||||||
val delegate = object: ReadWriteProperty<Any?, Int> {
|
|
||||||
// reflect/KProperty<*>
|
|
||||||
// │ Int
|
|
||||||
// │ │ Int
|
|
||||||
// │ │ │
|
|
||||||
override fun getValue(thisRef: Any?, property: KProperty<*>): Int = 1
|
|
||||||
// reflect/KProperty<*>
|
|
||||||
// │
|
|
||||||
override fun setValue(thisRef: Any?, property: KProperty<*>, value: Int) {}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Int val delegate: properties/ReadWriteProperty<Any?, Int>
|
|
||||||
// │ │
|
|
||||||
val value by delegate
|
|
||||||
|
|
||||||
// Int val delegate: properties/ReadWriteProperty<Any?, Int>
|
|
||||||
// │ │
|
|
||||||
var variable by delegate
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
open class Base<T>(val x: T)
|
|
||||||
|
|
||||||
// constructor Base<T>(T)
|
|
||||||
// │ Derived.<init>.x: T
|
|
||||||
// │ │
|
|
||||||
class Derived<T : Any>(x: T) : Base<T>(x)
|
|
||||||
|
|
||||||
// Derived<T>
|
|
||||||
// │ constructor Derived<T : Any>(T)
|
|
||||||
// │ │ create.x: T
|
|
||||||
// │ │ │
|
|
||||||
fun <T : Any> create(x: T): Derived<T> = Derived(x)
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
fun test() {
|
|
||||||
// <anonymous>
|
|
||||||
// │
|
|
||||||
val x = object {}
|
|
||||||
}
|
|
||||||
@@ -1,81 +0,0 @@
|
|||||||
import my.println
|
|
||||||
|
|
||||||
enum class Order {
|
|
||||||
FIRST,
|
|
||||||
SECOND,
|
|
||||||
THIRD
|
|
||||||
}
|
|
||||||
|
|
||||||
enum class Planet(val m: Double, internal val r: Double) {
|
|
||||||
// constructor Planet(Double, Double)
|
|
||||||
// │Double
|
|
||||||
// ││ Double
|
|
||||||
// ││ │
|
|
||||||
MERCURY(1.0, 2.0) {
|
|
||||||
override fun sayHello() {
|
|
||||||
// fun io/println(Any?): Unit
|
|
||||||
// │
|
|
||||||
println("Hello!!!")
|
|
||||||
}
|
|
||||||
},
|
|
||||||
// constructor Planet(Double, Double)
|
|
||||||
// │Double
|
|
||||||
// ││ Double
|
|
||||||
// ││ │
|
|
||||||
VENERA(3.0, 4.0) {
|
|
||||||
override fun sayHello() {
|
|
||||||
// fun io/println(Any?): Unit
|
|
||||||
// │
|
|
||||||
println("Ola!!!")
|
|
||||||
}
|
|
||||||
},
|
|
||||||
// constructor Planet(Double, Double)
|
|
||||||
// │Double
|
|
||||||
// ││ Double
|
|
||||||
// ││ │
|
|
||||||
EARTH(5.0, 6.0) {
|
|
||||||
override fun sayHello() {
|
|
||||||
// fun io/println(Any?): Unit
|
|
||||||
// │
|
|
||||||
println("Privet!!!")
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// val (Planet.Companion).G: Double
|
|
||||||
// │ fun (Double).times(Double): Double
|
|
||||||
// │ │ val (Planet).m: Double
|
|
||||||
// │ │ │ fun (Double).div(Double): Double
|
|
||||||
// │ │ │ │ val (Planet).r: Double
|
|
||||||
// │ │ │ │ │ fun (Double).times(Double): Double
|
|
||||||
// Double │ │ │ │ │ │ val (Planet).r: Double
|
|
||||||
// │ │ │ │ │ │ │ │
|
|
||||||
val g: Double = G * m / (r * r)
|
|
||||||
|
|
||||||
abstract fun sayHello()
|
|
||||||
|
|
||||||
companion object {
|
|
||||||
// Double
|
|
||||||
// │ Double
|
|
||||||
// │ │
|
|
||||||
const val G = 6.67e-11
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
enum class PseudoInsn(val signature: String = "()V") {
|
|
||||||
FIX_STACK_BEFORE_JUMP,
|
|
||||||
// constructor PseudoInsn(String = ...)
|
|
||||||
// │
|
|
||||||
FAKE_ALWAYS_TRUE_IFEQ("()I"),
|
|
||||||
// constructor PseudoInsn(String = ...)
|
|
||||||
// │
|
|
||||||
FAKE_ALWAYS_FALSE_IFEQ("()I"),
|
|
||||||
SAVE_STACK_BEFORE_TRY,
|
|
||||||
RESTORE_STACK_IN_TRY_CATCH,
|
|
||||||
STORE_NOT_NULL,
|
|
||||||
// constructor PseudoInsn(String = ...)
|
|
||||||
// │
|
|
||||||
AS_NOT_NULL("(Ljava/lang/Object;)Ljava/lang/Object;")
|
|
||||||
;
|
|
||||||
|
|
||||||
fun emit() {}
|
|
||||||
}
|
|
||||||
@@ -1,30 +0,0 @@
|
|||||||
interface Some
|
|
||||||
|
|
||||||
object O1 : Some
|
|
||||||
|
|
||||||
object O2 : Some
|
|
||||||
|
|
||||||
enum class SomeEnum(val x: Some) {
|
|
||||||
// constructor SomeEnum(Some)
|
|
||||||
// │object O1: Some
|
|
||||||
// ││
|
|
||||||
FIRST(O1) {
|
|
||||||
// Boolean
|
|
||||||
// │ Boolean
|
|
||||||
// │ │
|
|
||||||
override fun check(y: Some): Boolean = true
|
|
||||||
},
|
|
||||||
// constructor SomeEnum(Some)
|
|
||||||
// │object O2: Some
|
|
||||||
// ││
|
|
||||||
SECOND(O2) {
|
|
||||||
// Boolean
|
|
||||||
// │ SomeEnum.SECOND.check.y: Some
|
|
||||||
// │ │ EQ operator call
|
|
||||||
// │ │ │ object O2: Some
|
|
||||||
// │ │ │ │
|
|
||||||
override fun check(y: Some): Boolean = y == O2
|
|
||||||
};
|
|
||||||
|
|
||||||
abstract fun check(y: Some): Boolean
|
|
||||||
}
|
|
||||||
@@ -1,17 +0,0 @@
|
|||||||
expect class MyClass
|
|
||||||
|
|
||||||
expect fun foo(): String
|
|
||||||
|
|
||||||
// Int
|
|
||||||
// │
|
|
||||||
expect val x: Int
|
|
||||||
|
|
||||||
actual class MyClass
|
|
||||||
|
|
||||||
// String
|
|
||||||
// │
|
|
||||||
actual fun foo() = "Hello"
|
|
||||||
|
|
||||||
// Int Int
|
|
||||||
// │ │
|
|
||||||
actual val x = 42
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
external class External
|
|
||||||
|
|
||||||
external fun foo(): String
|
|
||||||
|
|
||||||
// Int
|
|
||||||
// │
|
|
||||||
external val x: Int
|
|
||||||
|
|
||||||
class NotExternal {
|
|
||||||
external fun bar(): String
|
|
||||||
// Int
|
|
||||||
// │
|
|
||||||
var y: Int
|
|
||||||
external get
|
|
||||||
// Int
|
|
||||||
// │
|
|
||||||
set(value) {}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Int
|
|
||||||
// │
|
|
||||||
var z: Int
|
|
||||||
external get
|
|
||||||
external set
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
// T fun (() -> R).invoke(): R
|
|
||||||
// │ │
|
|
||||||
fun <T> simpleRun(f: () -> T): T = f()
|
|
||||||
|
|
||||||
// collections/List<T>
|
|
||||||
// │
|
|
||||||
fun <T, R> List<T>.simpleMap(f: (T) -> R): R {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
// Unit
|
|
||||||
// │ simpleWith.t: T
|
|
||||||
// │ │ fun P1.invoke(): R
|
|
||||||
// │ │ │
|
|
||||||
fun <T> simpleWith(t: T, f: T.() -> Unit): Unit = t.f()
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
// FIR_IGNORE
|
|
||||||
interface Any
|
|
||||||
|
|
||||||
// T?
|
|
||||||
// │
|
|
||||||
inline fun <reified T : Any> Any.safeAs(): T? = this as? T
|
|
||||||
|
|
||||||
abstract class Summator {
|
|
||||||
abstract fun <T> plus(first: T, second: T): T
|
|
||||||
}
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
// Nothing
|
|
||||||
// │ fun TODO(): Nothing
|
|
||||||
// │ │
|
|
||||||
fun <T> genericFoo(): T = TODO()
|
|
||||||
|
|
||||||
// T fun <T> genericFoo<T>(): T
|
|
||||||
// │ │
|
|
||||||
val <T> T.generic: T get() = genericFoo()
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
abstract class Base(val s: String)
|
|
||||||
|
|
||||||
class Outer {
|
|
||||||
// constructor Base(String)
|
|
||||||
// │ Outer.Derived.<init>.s: String
|
|
||||||
// │ │
|
|
||||||
class Derived(s: String) : Base(s)
|
|
||||||
|
|
||||||
// constructor Base(String)
|
|
||||||
// │
|
|
||||||
object Obj : Base("")
|
|
||||||
}
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
class NoPrimary {
|
|
||||||
// String
|
|
||||||
// │
|
|
||||||
val x: String
|
|
||||||
|
|
||||||
constructor(x: String) {
|
|
||||||
// val (NoPrimary).x: String
|
|
||||||
// │ NoPrimary.<init>.x: String
|
|
||||||
// │ │
|
|
||||||
this.x = x
|
|
||||||
}
|
|
||||||
|
|
||||||
constructor(): this("")
|
|
||||||
}
|
|
||||||
@@ -1,39 +0,0 @@
|
|||||||
interface SomeInterface {
|
|
||||||
fun foo(x: Int, y: String): String
|
|
||||||
|
|
||||||
// Boolean
|
|
||||||
// │
|
|
||||||
val bar: Boolean
|
|
||||||
}
|
|
||||||
|
|
||||||
class SomeClass : SomeInterface {
|
|
||||||
// Int Int
|
|
||||||
// │ │
|
|
||||||
private val baz = 42
|
|
||||||
|
|
||||||
override fun foo(x: Int, y: String): String {
|
|
||||||
// SomeClass.foo.y: String
|
|
||||||
// │ fun (String).plus(Any?): String
|
|
||||||
// │ │ SomeClass.foo.x: Int
|
|
||||||
// │ │ │ fun (String).plus(Any?): String
|
|
||||||
// │ │ │ │ val (SomeClass).baz: Int
|
|
||||||
// │ │ │ │ │
|
|
||||||
return y + x + baz
|
|
||||||
}
|
|
||||||
|
|
||||||
// Boolean
|
|
||||||
// │
|
|
||||||
override var bar: Boolean
|
|
||||||
// Boolean
|
|
||||||
// │
|
|
||||||
get() = true
|
|
||||||
// Boolean
|
|
||||||
// │
|
|
||||||
set(value) {}
|
|
||||||
|
|
||||||
// Double
|
|
||||||
// │
|
|
||||||
lateinit var fau: Double
|
|
||||||
}
|
|
||||||
|
|
||||||
inline class InlineClass
|
|
||||||
@@ -1,3 +0,0 @@
|
|||||||
fun foo() {}
|
|
||||||
|
|
||||||
suspend fun bar() {}
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
interface B
|
|
||||||
|
|
||||||
typealias C = B
|
|
||||||
|
|
||||||
// B
|
|
||||||
// │
|
|
||||||
class D : C
|
|
||||||
@@ -1,9 +0,0 @@
|
|||||||
open class A
|
|
||||||
|
|
||||||
interface B<S, T : A>
|
|
||||||
|
|
||||||
typealias C<T> = B<T, A>
|
|
||||||
|
|
||||||
// B<A, A>
|
|
||||||
// │
|
|
||||||
class D : C<A>
|
|
||||||
-28
@@ -1,28 +0,0 @@
|
|||||||
// FIR_IGNORE
|
|
||||||
package test
|
|
||||||
|
|
||||||
interface Some
|
|
||||||
|
|
||||||
abstract class My<T : Some> {
|
|
||||||
inner class T
|
|
||||||
|
|
||||||
// T
|
|
||||||
// │
|
|
||||||
abstract val x: T
|
|
||||||
|
|
||||||
abstract fun foo(arg: T)
|
|
||||||
|
|
||||||
// [ERROR : T]
|
|
||||||
// │ [ERROR : T]
|
|
||||||
// │ │
|
|
||||||
abstract val y: My.T
|
|
||||||
|
|
||||||
// [ERROR : T]
|
|
||||||
// │ [ERROR : T]
|
|
||||||
// │ │
|
|
||||||
abstract val z: test.My.T
|
|
||||||
|
|
||||||
// [ERROR : T]
|
|
||||||
// │
|
|
||||||
class Some : T()
|
|
||||||
}
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
interface List<out T : Any> {
|
|
||||||
operator fun get(index: Int): T
|
|
||||||
|
|
||||||
infix fun concat(other: List<T>): List<T>
|
|
||||||
}
|
|
||||||
|
|
||||||
typealias StringList = List<out String>
|
|
||||||
typealias AnyList = List<*>
|
|
||||||
|
|
||||||
abstract class AbstractList<out T : Any> : List<T>
|
|
||||||
|
|
||||||
// constructor AbstractList<T : Any>()
|
|
||||||
// │
|
|
||||||
class SomeList : AbstractList<Int>() {
|
|
||||||
// Int
|
|
||||||
// │ Int
|
|
||||||
// │ │
|
|
||||||
override fun get(index: Int): Int = 42
|
|
||||||
|
|
||||||
// SomeList
|
|
||||||
// │
|
|
||||||
override fun concat(other: List<Int>): List<Int> = this
|
|
||||||
}
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
interface A
|
|
||||||
interface B
|
|
||||||
|
|
||||||
class C<T> where T : A, T : B {
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,52 +0,0 @@
|
|||||||
//constructor annotation/Target(vararg annotation/AnnotationTarget)
|
|
||||||
//│ enum class annotation/AnnotationTarget: Enum<annotation/AnnotationTarget>
|
|
||||||
//│ │ enum entry annotation/AnnotationTarget.EXPRESSION
|
|
||||||
//│ │ │ enum class annotation/AnnotationTarget: Enum<annotation/AnnotationTarget>
|
|
||||||
//│ │ │ │ enum entry annotation/AnnotationTarget.LOCAL_VARIABLE
|
|
||||||
//│ │ │ │ │
|
|
||||||
@Target(AnnotationTarget.EXPRESSION, AnnotationTarget.LOCAL_VARIABLE)
|
|
||||||
//constructor annotation/Retention(annotation/AnnotationRetention = ...)
|
|
||||||
//│ enum class annotation/AnnotationRetention: Enum<annotation/AnnotationRetention>
|
|
||||||
//│ │ enum entry annotation/AnnotationRetention.SOURCE
|
|
||||||
//│ │ │
|
|
||||||
@Retention(AnnotationRetention.SOURCE)
|
|
||||||
annotation class Ann
|
|
||||||
|
|
||||||
fun foo(arg: Int): Int {
|
|
||||||
// constructor Ann()
|
|
||||||
// │ foo.arg: Int
|
|
||||||
// │ │ EQ operator call
|
|
||||||
// Unit │ │ │ Int
|
|
||||||
// │ │ │ │ │
|
|
||||||
if (@Ann arg == 0) {
|
|
||||||
// constructor Ann()
|
|
||||||
// │ Int
|
|
||||||
// │ │
|
|
||||||
@Ann return 1
|
|
||||||
}
|
|
||||||
// constructor Ann()
|
|
||||||
// │ Unit
|
|
||||||
// │ │ foo.arg: Int
|
|
||||||
// │ │ │ EQ operator call
|
|
||||||
// │ │ │ │ Int
|
|
||||||
// │ │ │ │ │
|
|
||||||
@Ann if (arg == 1) {
|
|
||||||
// constructor Ann()
|
|
||||||
// │ Int
|
|
||||||
// │ │
|
|
||||||
return (@Ann 1)
|
|
||||||
}
|
|
||||||
// Int
|
|
||||||
// │
|
|
||||||
return 42
|
|
||||||
}
|
|
||||||
|
|
||||||
data class Two(val x: Int, val y: Int)
|
|
||||||
|
|
||||||
fun bar(two: Two) {
|
|
||||||
// constructor Ann()
|
|
||||||
// │ constructor Ann()
|
|
||||||
// │ Int │ Int bar.two: Two
|
|
||||||
// │ │ │ │ │
|
|
||||||
val (@Ann x, @Ann y) = two
|
|
||||||
}
|
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
// Int Int
|
|
||||||
// │ │
|
|
||||||
val p = 0
|
|
||||||
// Int
|
|
||||||
// │ Int
|
|
||||||
// │ │
|
|
||||||
fun foo() = 1
|
|
||||||
|
|
||||||
class Wrapper(val v: IntArray)
|
|
||||||
|
|
||||||
// Int
|
|
||||||
// │ test.a: IntArray
|
|
||||||
// │ │ Int
|
|
||||||
// │ │ │ fun (Int).plus(Int): Int
|
|
||||||
// │ │ │ │ test.a: IntArray
|
|
||||||
// │ │ │ │ │ val p: Int
|
|
||||||
// │ │ │ │ │ │ fun (Int).plus(Int): Int
|
|
||||||
// │ │ │ │ │ │ │ test.a: IntArray
|
|
||||||
// │ │ │ │ │ │ │ │ fun foo(): Int
|
|
||||||
// │ │ │ │ │ │ │ │ │ fun (Int).plus(Int): Int
|
|
||||||
// │ │ │ │ │ │ │ │ │ │ test.w: Wrapper
|
|
||||||
// │ │ │ │ │ │ │ │ │ │ │ val (Wrapper).v: IntArray
|
|
||||||
// │ │ │ │ │ │ │ │ │ │ │ │ Int
|
|
||||||
// │ │ │ │ │ │ │ │ │ │ │ │ │
|
|
||||||
fun test(a: IntArray, w: Wrapper) = a[0] + a[p] + a[foo()] + w.v[0]
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
fun test() {
|
|
||||||
// IntArray
|
|
||||||
// │ fun intArrayOf(vararg Int): IntArray
|
|
||||||
// │ │ Int
|
|
||||||
// │ │ │ Int
|
|
||||||
// │ │ │ │ Int
|
|
||||||
// │ │ │ │ │
|
|
||||||
val x = intArrayOf(1, 2, 3)
|
|
||||||
// val test.x: IntArray
|
|
||||||
// │ Int
|
|
||||||
// │ │ fun (IntArray).set(Int, Int): Unit
|
|
||||||
// │ │ │ Int
|
|
||||||
// │ │ │ │
|
|
||||||
x[1] = 0
|
|
||||||
}
|
|
||||||
|
|
||||||
// Int
|
|
||||||
// │ Int
|
|
||||||
// │ │
|
|
||||||
fun foo() = 1
|
|
||||||
|
|
||||||
fun test2() {
|
|
||||||
// fun intArrayOf(vararg Int): IntArray
|
|
||||||
// │ Int
|
|
||||||
// │ │ Int
|
|
||||||
// │ │ │ Int
|
|
||||||
// │ │ │ │ fun foo(): Int
|
|
||||||
// │ │ │ │ │ fun (IntArray).set(Int, Int): Unit
|
|
||||||
// │ │ │ │ │ │ Int
|
|
||||||
// │ │ │ │ │ │ │
|
|
||||||
intArrayOf(1, 2, 3)[foo()] = 1
|
|
||||||
}
|
|
||||||
@@ -1,92 +0,0 @@
|
|||||||
// FIR_IGNORE
|
|
||||||
// WITH_STDLIB
|
|
||||||
// foo.a: Int
|
|
||||||
// │ fun (Int).compareTo(Int): Int
|
|
||||||
// │ │ foo.b: Int
|
|
||||||
// Int │ │ │ foo.a: Int
|
|
||||||
// │ Int │ │ │ │ foo.b: Int
|
|
||||||
// │ │ │ │ │ │ │
|
|
||||||
fun foo(a: Int, b: Int) = if (a > b) a else b
|
|
||||||
|
|
||||||
fun bar(a: Double, b: Double): Double {
|
|
||||||
// Nothing
|
|
||||||
// │ bar.a: Double
|
|
||||||
// │ │ fun (Double).compareTo(Double): Int
|
|
||||||
// │ │ │ bar.b: Double
|
|
||||||
// │ │ │ │
|
|
||||||
if (a > b) {
|
|
||||||
// fun io/println(Double): Unit
|
|
||||||
// │ bar.a: Double
|
|
||||||
// │ │
|
|
||||||
println(a)
|
|
||||||
// bar.a: Double
|
|
||||||
// │
|
|
||||||
return a
|
|
||||||
} else {
|
|
||||||
// fun io/println(Double): Unit
|
|
||||||
// │ bar.b: Double
|
|
||||||
// │ │
|
|
||||||
println(b)
|
|
||||||
// bar.b: Double
|
|
||||||
// │
|
|
||||||
return b
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun baz(a: Long, b: Long): Long {
|
|
||||||
// Nothing
|
|
||||||
// │
|
|
||||||
when {
|
|
||||||
// baz.a: Long
|
|
||||||
// │ fun (Long).compareTo(Long): Int
|
|
||||||
// │ │ baz.b: Long
|
|
||||||
// │ │ │ Nothing
|
|
||||||
// │ │ │ │
|
|
||||||
a > b -> {
|
|
||||||
// fun io/println(Long): Unit
|
|
||||||
// │ baz.a: Long
|
|
||||||
// │ │
|
|
||||||
println(a)
|
|
||||||
// baz.a: Long
|
|
||||||
// │
|
|
||||||
return a
|
|
||||||
}
|
|
||||||
// Nothing
|
|
||||||
// │ baz.b: Long
|
|
||||||
// │ │
|
|
||||||
else -> return b
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun grade(g: Int): String {
|
|
||||||
// String
|
|
||||||
// │ grade.g: Int
|
|
||||||
// │ │
|
|
||||||
return when (g) {
|
|
||||||
// Int
|
|
||||||
// │ Int String
|
|
||||||
// │ │ │
|
|
||||||
6, 7 -> "Outstanding"
|
|
||||||
// Int String
|
|
||||||
// │ │
|
|
||||||
5 -> "Excellent"
|
|
||||||
// Int String
|
|
||||||
// │ │
|
|
||||||
4 -> "Good"
|
|
||||||
// Int String
|
|
||||||
// │ │
|
|
||||||
3 -> "Mediocre"
|
|
||||||
// fun (ranges/IntRange).contains(Int): Boolean
|
|
||||||
// │ Int
|
|
||||||
// │ │fun (Int).rangeTo(Int): ranges/IntRange
|
|
||||||
// │ ││ Int String
|
|
||||||
// │ ││ │ │
|
|
||||||
in 1..2 -> "Fail"
|
|
||||||
// String
|
|
||||||
// │
|
|
||||||
is Number -> "Number"
|
|
||||||
// String
|
|
||||||
// │
|
|
||||||
else -> "Unknown"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,58 +0,0 @@
|
|||||||
// FIR_IGNORE
|
|
||||||
class A {
|
|
||||||
fun foo() {}
|
|
||||||
// Int Int
|
|
||||||
// │ │
|
|
||||||
val bar = 0
|
|
||||||
}
|
|
||||||
|
|
||||||
fun A.qux() {}
|
|
||||||
|
|
||||||
fun baz() {}
|
|
||||||
|
|
||||||
// reflect/KFunction0<Unit>
|
|
||||||
// │ constructor A()
|
|
||||||
// │ │ fun (A).foo(): Unit
|
|
||||||
// │ │ │
|
|
||||||
val test1 = A()::foo
|
|
||||||
|
|
||||||
// reflect/KProperty0<Int>
|
|
||||||
// │ constructor A()
|
|
||||||
// │ │ val (A).bar: Int
|
|
||||||
// │ │ │
|
|
||||||
val test2 = A()::bar
|
|
||||||
|
|
||||||
// reflect/KFunction0<Unit>
|
|
||||||
// │ constructor A()
|
|
||||||
// │ │ fun A.qux(): Unit
|
|
||||||
// │ │ │
|
|
||||||
val test3 = A()::qux
|
|
||||||
|
|
||||||
// reflect/KFunction1<A, Unit>
|
|
||||||
// │ class A
|
|
||||||
// │ │ fun (A).foo(): Unit
|
|
||||||
// │ │ │
|
|
||||||
val test4 = A::foo
|
|
||||||
|
|
||||||
// reflect/KProperty1<A, Int>
|
|
||||||
// │ class A
|
|
||||||
// │ │ val (A).bar: Int
|
|
||||||
// │ │ │
|
|
||||||
val test5 = A::bar
|
|
||||||
|
|
||||||
// reflect/KFunction1<A, Unit>
|
|
||||||
// │ class A
|
|
||||||
// │ │ fun A.qux(): Unit
|
|
||||||
// │ │ │
|
|
||||||
val test6 = A::qux
|
|
||||||
|
|
||||||
// reflect/KFunction0<Unit>
|
|
||||||
// │ fun baz(): Unit
|
|
||||||
// │ │
|
|
||||||
val test7 = ::baz
|
|
||||||
|
|
||||||
// reflect/KFunction1<A?, Unit>
|
|
||||||
// │ class A
|
|
||||||
// │ │ fun (A).foo(): Unit
|
|
||||||
// │ │ │
|
|
||||||
val test8 = A?::foo
|
|
||||||
@@ -1,72 +0,0 @@
|
|||||||
// WITH_STDLIB
|
|
||||||
// fun (Int).plus(Int): Int
|
|
||||||
// Int │ distance.y: Int
|
|
||||||
// │ │ │
|
|
||||||
infix fun Int.distance(y: Int) = this + y
|
|
||||||
|
|
||||||
// Int
|
|
||||||
// │ Int
|
|
||||||
// │ │ fun Int.distance(Int): Int
|
|
||||||
// │ │ │ Int
|
|
||||||
// │ │ │ │
|
|
||||||
fun test(): Int = 3 distance 4
|
|
||||||
|
|
||||||
// Int
|
|
||||||
// │ Int
|
|
||||||
// │ │ fun Int.distance(Int): Int
|
|
||||||
// │ │ │ Int
|
|
||||||
// │ │ │ │
|
|
||||||
fun testRegular(): Int = 3.distance(4)
|
|
||||||
|
|
||||||
class My(var x: Int) {
|
|
||||||
// Int
|
|
||||||
// │ var (My).x: Int
|
|
||||||
// │ │
|
|
||||||
operator fun invoke() = x
|
|
||||||
|
|
||||||
fun foo() {}
|
|
||||||
|
|
||||||
// My
|
|
||||||
// │ constructor My(Int)
|
|
||||||
// │ │ var (My).x: Int
|
|
||||||
// │ │ │
|
|
||||||
fun copy() = My(x)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Int
|
|
||||||
// │ constructor My(Int)
|
|
||||||
// │ fun (My).invoke(): Int
|
|
||||||
// │ │ Int
|
|
||||||
// │ │ │
|
|
||||||
fun testInvoke(): Int = My(13)()
|
|
||||||
|
|
||||||
fun testQualified(first: My, second: My?) {
|
|
||||||
// fun io/println(Int): Unit
|
|
||||||
// │ testQualified.first: My
|
|
||||||
// │ │ var (My).x: Int
|
|
||||||
// │ │ │
|
|
||||||
println(first.x)
|
|
||||||
// fun io/println(Any?): Unit
|
|
||||||
// │ testQualified.second: My?
|
|
||||||
// │ │ var (My).x: Int
|
|
||||||
// │ │ │
|
|
||||||
println(second?.x)
|
|
||||||
// testQualified.first: My
|
|
||||||
// │ fun (My).foo(): Unit
|
|
||||||
// │ │
|
|
||||||
first.foo()
|
|
||||||
// testQualified.second: My?
|
|
||||||
// │ fun (My).foo(): Unit
|
|
||||||
// │ │
|
|
||||||
second?.foo()
|
|
||||||
// testQualified.first: My
|
|
||||||
// │ fun (My).copy(): My
|
|
||||||
// │ │ fun (My).foo(): Unit
|
|
||||||
// │ │ │
|
|
||||||
first.copy().foo()
|
|
||||||
// testQualified.first: My
|
|
||||||
// │ var (My).x: Int
|
|
||||||
// │ │ Int
|
|
||||||
// │ │ │
|
|
||||||
first.x = 42
|
|
||||||
}
|
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
// WITH_STDLIB
|
|
||||||
package test
|
|
||||||
|
|
||||||
class A
|
|
||||||
|
|
||||||
fun test() {
|
|
||||||
// class A
|
|
||||||
// │
|
|
||||||
A::class
|
|
||||||
// class A
|
|
||||||
// │
|
|
||||||
test.A::class
|
|
||||||
// constructor A()
|
|
||||||
// │
|
|
||||||
A()::class
|
|
||||||
|
|
||||||
// class A val <T> reflect/KClass<T>.java: java/lang/Class<T>
|
|
||||||
// │ │
|
|
||||||
A::class.java
|
|
||||||
// class A val <T> reflect/KClass<T>.java: java/lang/Class<T>
|
|
||||||
// │ │
|
|
||||||
test.A::class.java
|
|
||||||
// constructor A()
|
|
||||||
// │ val <T> reflect/KClass<T>.java: java/lang/Class<T>
|
|
||||||
// │ │
|
|
||||||
A()::class.java
|
|
||||||
}
|
|
||||||
@@ -1,34 +0,0 @@
|
|||||||
annotation class Ann1(val arr: IntArray)
|
|
||||||
|
|
||||||
annotation class Ann2(val arr: DoubleArray)
|
|
||||||
|
|
||||||
annotation class Ann3(val arr: Array<String>)
|
|
||||||
|
|
||||||
//constructor Ann1(IntArray)
|
|
||||||
//│
|
|
||||||
@Ann1([])
|
|
||||||
//constructor Ann2(DoubleArray)
|
|
||||||
//│
|
|
||||||
@Ann2([])
|
|
||||||
//constructor Ann3(Array<String>)
|
|
||||||
//│
|
|
||||||
@Ann3([])
|
|
||||||
class Zero
|
|
||||||
|
|
||||||
//constructor Ann1(IntArray)
|
|
||||||
//│ Int
|
|
||||||
//│ │ Int
|
|
||||||
//│ │ │
|
|
||||||
@Ann1([1, 2])
|
|
||||||
class First
|
|
||||||
|
|
||||||
//constructor Ann2(DoubleArray)
|
|
||||||
//│ Double
|
|
||||||
//│ │
|
|
||||||
@Ann2([3.14])
|
|
||||||
class Second
|
|
||||||
|
|
||||||
//constructor Ann3(Array<String>)
|
|
||||||
//│
|
|
||||||
@Ann3(["Alpha", "Omega"])
|
|
||||||
class Third
|
|
||||||
@@ -1,28 +0,0 @@
|
|||||||
data class Some(val first: Int, val second: Double, val third: String)
|
|
||||||
|
|
||||||
fun foo(some: Some) {
|
|
||||||
// Int
|
|
||||||
// │ Double
|
|
||||||
// │ │ String foo.some: Some
|
|
||||||
// │ │ │ │
|
|
||||||
var (x, y, z: String) = some
|
|
||||||
|
|
||||||
// var foo.x: Int
|
|
||||||
// │fun (Int).inc(): Int
|
|
||||||
// ││
|
|
||||||
x++
|
|
||||||
// var foo.y: Double
|
|
||||||
// │ fun (Double).times(Double): Double
|
|
||||||
// │ │ Double
|
|
||||||
// │ │ │
|
|
||||||
y *= 2.0
|
|
||||||
// var foo.z: String
|
|
||||||
// │
|
|
||||||
z = ""
|
|
||||||
}
|
|
||||||
|
|
||||||
fun bar(some: Some) {
|
|
||||||
// Int String bar.some: Some
|
|
||||||
// │ │ │
|
|
||||||
val (a, _, `_`) = some
|
|
||||||
}
|
|
||||||
@@ -1,89 +0,0 @@
|
|||||||
fun foo() {
|
|
||||||
// Int
|
|
||||||
// │fun (Int).rangeTo(Int): ranges/IntRange
|
|
||||||
// Int ││ Int
|
|
||||||
// │ ││ │
|
|
||||||
for (i in 1..10) {
|
|
||||||
// fun io/println(Int): Unit
|
|
||||||
// │ val foo.i: Int
|
|
||||||
// │ │
|
|
||||||
println(i)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun fooLabeled() {
|
|
||||||
// fun io/println(Any?): Unit
|
|
||||||
// │
|
|
||||||
println("!!!")
|
|
||||||
// Int
|
|
||||||
// │fun (Int).rangeTo(Int): ranges/IntRange
|
|
||||||
// Int ││ Int
|
|
||||||
// │ ││ │
|
|
||||||
label@ for (i in 1..10) {
|
|
||||||
// Unit
|
|
||||||
// │ val fooLabeled.i: Int
|
|
||||||
// │ │ EQ operator call
|
|
||||||
// │ │ │ Int
|
|
||||||
// │ │ │ │
|
|
||||||
if (i == 5) continue@label
|
|
||||||
// fun io/println(Int): Unit
|
|
||||||
// │ val fooLabeled.i: Int
|
|
||||||
// │ │
|
|
||||||
println(i)
|
|
||||||
}
|
|
||||||
// fun io/println(Any?): Unit
|
|
||||||
// │
|
|
||||||
println("!!!")
|
|
||||||
}
|
|
||||||
|
|
||||||
// collections/List<String>
|
|
||||||
// │
|
|
||||||
fun bar(list: List<String>) {
|
|
||||||
// bar.list: collections/List<String>
|
|
||||||
// │ fun (collections/List<E>).subList(Int, Int): collections/List<E>
|
|
||||||
// │ │ Int
|
|
||||||
// String │ │ │ Int
|
|
||||||
// │ │ │ │ │
|
|
||||||
for (element in list.subList(0, 10)) {
|
|
||||||
// fun io/println(Any?): Unit
|
|
||||||
// │ val bar.element: String
|
|
||||||
// │ │
|
|
||||||
println(element)
|
|
||||||
}
|
|
||||||
// bar.list: collections/List<String>
|
|
||||||
// │ fun (collections/List<E>).subList(Int, Int): collections/List<E>
|
|
||||||
// │ │ fun io/println(Any?): Unit
|
|
||||||
// String │ │ Int Int │ val bar.element: String
|
|
||||||
// │ │ │ │ │ │ │
|
|
||||||
for (element in list.subList(10, 20)) println(element)
|
|
||||||
}
|
|
||||||
|
|
||||||
data class Some(val x: Int, val y: Int)
|
|
||||||
|
|
||||||
// collections/Set<Some>
|
|
||||||
// │
|
|
||||||
fun baz(set: Set<Some>) {
|
|
||||||
// Int
|
|
||||||
// │ Int baz.set: collections/Set<Some>
|
|
||||||
// │ │ │
|
|
||||||
for ((x, y) in set) {
|
|
||||||
// fun io/println(Any?): Unit
|
|
||||||
// │ val baz.x: Int
|
|
||||||
// │ │ val baz.y: Int
|
|
||||||
// │ │ │
|
|
||||||
println("x = $x y = $y")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// collections/List<Some>
|
|
||||||
// │
|
|
||||||
fun withParameter(list: List<Some>) {
|
|
||||||
// Some withParameter.list: collections/List<Some>
|
|
||||||
// │ │
|
|
||||||
for (s: Some in list) {
|
|
||||||
// fun io/println(Any?): Unit
|
|
||||||
// │ val withParameter.s: Some
|
|
||||||
// │ │
|
|
||||||
println(s)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
// Nothing?
|
|
||||||
// │ Nothing?
|
|
||||||
// │ │
|
|
||||||
fun <T> nullableValue(): T? = null
|
|
||||||
|
|
||||||
fun test() {
|
|
||||||
// Int?
|
|
||||||
// │ fun <T> nullableValue<Int>(): T?
|
|
||||||
// │ │
|
|
||||||
val n = nullableValue<Int>()
|
|
||||||
// Double?
|
|
||||||
// │ fun <T> nullableValue<Double>(): T?
|
|
||||||
// │ │
|
|
||||||
val x = nullableValue<Double>()
|
|
||||||
// String?
|
|
||||||
// │ fun <T> nullableValue<String>(): T?
|
|
||||||
// │ │
|
|
||||||
val s = nullableValue<String>()
|
|
||||||
}
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
// FIR_IGNORE
|
|
||||||
// collections/Collection<Int>
|
|
||||||
// │ Boolean
|
|
||||||
// │ │
|
|
||||||
fun foo(x: Int, y: Int, c: Collection<Int>) =
|
|
||||||
// foo.x: Int
|
|
||||||
// │ fun (collections/Collection<E>).contains(E): Boolean
|
|
||||||
// │ │ foo.c: collections/Collection<Int>
|
|
||||||
// │ │ │ foo.y: Int
|
|
||||||
// │ │ │ │ fun (collections/Collection<E>).contains(E): Boolean
|
|
||||||
// │ │ │ │ │ foo.c: collections/Collection<Int>
|
|
||||||
// │ │ │ │ │ │
|
|
||||||
x in c && y !in c
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
// FIR_IGNORE
|
|
||||||
fun test(e: Int.() -> String) {
|
|
||||||
// String
|
|
||||||
// │ Int
|
|
||||||
// │ │ fun P1.invoke(): R
|
|
||||||
// │ │ │
|
|
||||||
val s = 3.e()
|
|
||||||
// String
|
|
||||||
// │ Int
|
|
||||||
// │ │ fun P1.invoke(): R
|
|
||||||
// │ │ │test.e: Int.() -> String
|
|
||||||
// │ │ ││
|
|
||||||
val ss = 3.(e)()
|
|
||||||
}
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
class WithInit(x: Int) {
|
|
||||||
// Int
|
|
||||||
// │
|
|
||||||
val x: Int
|
|
||||||
|
|
||||||
init {
|
|
||||||
// val (WithInit).x: Int
|
|
||||||
// │ WithInit.<init>.x: Int
|
|
||||||
// │ │
|
|
||||||
this.x = x
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
// FIR_IGNORE
|
|
||||||
fun main() {
|
|
||||||
// [ERROR: not resolved]
|
|
||||||
// │ [ERROR: not resolved]
|
|
||||||
// │ │ [ERROR: not resolved]
|
|
||||||
// │ │ │
|
|
||||||
{ length } foo { bar() }
|
|
||||||
}
|
|
||||||
@@ -1,97 +0,0 @@
|
|||||||
// FIR_IGNORE
|
|
||||||
// WITH_STDLIB
|
|
||||||
data class Tuple(val x: Int, val y: Int)
|
|
||||||
|
|
||||||
// Int
|
|
||||||
// │ fun ((P1) -> R).invoke(P1): R
|
|
||||||
// │ │ constructor Tuple(Int, Int)
|
|
||||||
// │ │ │ Int
|
|
||||||
// │ │ │ │ Int
|
|
||||||
// │ │ │ │ │
|
|
||||||
inline fun use(f: (Tuple) -> Int) = f(Tuple(1, 2))
|
|
||||||
|
|
||||||
fun foo(): Int {
|
|
||||||
// (Tuple) -> Int
|
|
||||||
// │
|
|
||||||
val l1 = { t: Tuple ->
|
|
||||||
// foo.<anonymous>.t: Tuple
|
|
||||||
// Int │ val (Tuple).x: Int
|
|
||||||
// │ │ │
|
|
||||||
val x = t.x
|
|
||||||
// foo.<anonymous>.t: Tuple
|
|
||||||
// Int │ val (Tuple).y: Int
|
|
||||||
// │ │ │
|
|
||||||
val y = t.y
|
|
||||||
// val foo.<anonymous>.x: Int
|
|
||||||
// │ fun (Int).plus(Int): Int
|
|
||||||
// │ │ val foo.<anonymous>.y: Int
|
|
||||||
// │ │ │
|
|
||||||
x + y
|
|
||||||
}
|
|
||||||
// fun use((Tuple) -> Int): Int
|
|
||||||
// │ val foo.<anonymous>.x: Int
|
|
||||||
// │ Int │ fun (Int).plus(Int): Int
|
|
||||||
// │ │ Int │ │ val foo.<anonymous>.y: Int
|
|
||||||
// │ │ │ │ │ │
|
|
||||||
use { (x, y) -> x + y }
|
|
||||||
|
|
||||||
// fun use((Tuple) -> Int): Int
|
|
||||||
// │
|
|
||||||
return use {
|
|
||||||
// Unit
|
|
||||||
// │ foo.<anonymous>.it: Tuple
|
|
||||||
// │ │ val (Tuple).x: Int
|
|
||||||
// │ │ │ EQ operator call
|
|
||||||
// │ │ │ │ Int Int
|
|
||||||
// │ │ │ │ │ │
|
|
||||||
if (it.x == 0) return@foo 0
|
|
||||||
// foo.<anonymous>.it: Tuple
|
|
||||||
// │ val (Tuple).y: Int
|
|
||||||
// │ │
|
|
||||||
return@use it.y
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun bar(): Int {
|
|
||||||
// fun use((Tuple) -> Int): Int
|
|
||||||
// │
|
|
||||||
return use lambda@{
|
|
||||||
// Unit
|
|
||||||
// │ bar.<anonymous>.it: Tuple
|
|
||||||
// │ │ val (Tuple).x: Int
|
|
||||||
// │ │ │ EQ operator call
|
|
||||||
// │ │ │ │ Int Int
|
|
||||||
// │ │ │ │ │ │
|
|
||||||
if (it.x == 0) return@bar 0
|
|
||||||
// bar.<anonymous>.it: Tuple
|
|
||||||
// │ val (Tuple).y: Int
|
|
||||||
// │ │
|
|
||||||
return@lambda it.y
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// collections/List<Int>
|
|
||||||
// │
|
|
||||||
fun test(list: List<Int>) {
|
|
||||||
// collections/MutableMap<Int, String>
|
|
||||||
// │ fun <K, V> collections/mutableMapOf<Int, String>(): collections/MutableMap<K, V>
|
|
||||||
// │ │
|
|
||||||
val map = mutableMapOf<Int, String>()
|
|
||||||
// test.list: collections/List<Int>
|
|
||||||
// │ fun <T> collections/Iterable<T>.forEach<Int>((T) -> Unit): Unit
|
|
||||||
// │ │ val test.map: collections/MutableMap<Int, String>
|
|
||||||
// │ │ │ fun <K, V> collections/MutableMap<K, V>.getOrPut<Int, String>(K, () -> V): V
|
|
||||||
// │ │ │ │ test.<anonymous>.it: Int
|
|
||||||
// │ │ │ │ │ fun <T> collections/mutableListOf<???>(): collections/MutableList<T>
|
|
||||||
// │ │ │ │ │ │ fun (String).plus(Any?): String
|
|
||||||
// │ │ │ │ │ │ │
|
|
||||||
list.forEach { map.getOrPut(it, { mutableListOf() }) += "" }
|
|
||||||
}
|
|
||||||
|
|
||||||
// () -> Unit
|
|
||||||
// │
|
|
||||||
val simple = { }
|
|
||||||
|
|
||||||
// () -> Int Int
|
|
||||||
// │ │
|
|
||||||
val another = { 42 }
|
|
||||||
-20
@@ -1,20 +0,0 @@
|
|||||||
// FIR_IGNORE
|
|
||||||
// T fun (() -> R).invoke(): R
|
|
||||||
// │ │
|
|
||||||
fun <T> run(block: () -> T): T = block()
|
|
||||||
|
|
||||||
fun test_1() {
|
|
||||||
// fun <T> run<Unit>(() -> T): T
|
|
||||||
// │
|
|
||||||
run { return@run }
|
|
||||||
// fun <T> run<???>(() -> T): T
|
|
||||||
// │
|
|
||||||
run { return }
|
|
||||||
}
|
|
||||||
|
|
||||||
fun test_2() {
|
|
||||||
// fun <T> run<Int>(() -> T): T
|
|
||||||
// │ Int
|
|
||||||
// │ │
|
|
||||||
run(fun (): Int { return 1 })
|
|
||||||
}
|
|
||||||
@@ -1,48 +0,0 @@
|
|||||||
fun withLocals(p: Int): Int {
|
|
||||||
class Local(val pp: Int) {
|
|
||||||
// Int
|
|
||||||
// │ val (withLocals.Local).pp: Int
|
|
||||||
// │ │ fun (Int).minus(Int): Int
|
|
||||||
// │ │ │ withLocals.p: Int
|
|
||||||
// │ │ │ │
|
|
||||||
fun diff() = pp - p
|
|
||||||
}
|
|
||||||
|
|
||||||
// constructor withLocals.Local(Int)
|
|
||||||
// Int │ Int fun (withLocals.Local).diff(): Int
|
|
||||||
// │ │ │ │
|
|
||||||
val x = Local(42).diff()
|
|
||||||
|
|
||||||
fun sum(y: Int, z: Int, f: (Int, Int) -> Int): Int {
|
|
||||||
// val withLocals.x: Int
|
|
||||||
// │ fun (Int).plus(Int): Int
|
|
||||||
// │ │ fun ((P1, P2) -> R).invoke(P1, P2): R
|
|
||||||
// │ │ │ withLocals.sum.y: Int
|
|
||||||
// │ │ │ │ withLocals.sum.z: Int
|
|
||||||
// │ │ │ │ │
|
|
||||||
return x + f(y, z)
|
|
||||||
}
|
|
||||||
|
|
||||||
// Int constructor Any()
|
|
||||||
// │ │
|
|
||||||
val code = (object : Any() {
|
|
||||||
// Int
|
|
||||||
// │ fun (Any).hashCode(): Int
|
|
||||||
// │ │
|
|
||||||
fun foo() = hashCode()
|
|
||||||
// fun (<anonymous>).foo(): Int
|
|
||||||
// │
|
|
||||||
}).foo()
|
|
||||||
|
|
||||||
// fun withLocals.sum(Int, Int, (Int, Int) -> Int): Int
|
|
||||||
// │ val withLocals.code: Int
|
|
||||||
// │ │ constructor withLocals.Local(Int)
|
|
||||||
// │ │ │ Int
|
|
||||||
// │ │ │ │ fun (withLocals.Local).diff(): Int
|
|
||||||
// │ │ │ │ │ Int
|
|
||||||
// │ │ │ │ │ │ withLocals.<anonymous>.x: Int
|
|
||||||
// │ │ │ │ │ │ │ fun (Int).plus(Int): Int
|
|
||||||
// │ │ │ │ │ │ │ │ withLocals.<anonymous>.y: Int
|
|
||||||
// │ │ │ │ │ │ │ │ │
|
|
||||||
return sum(code, Local(1).diff(), fun(x: Int, y: Int) = x + y)
|
|
||||||
}
|
|
||||||
@@ -1,45 +0,0 @@
|
|||||||
// WITH_STDLIB
|
|
||||||
fun simple() {
|
|
||||||
// Int Int
|
|
||||||
// │ │
|
|
||||||
var x = 10
|
|
||||||
// var simple.x: Int
|
|
||||||
// │ fun (Int).plus(Int): Int
|
|
||||||
// │ │ Int
|
|
||||||
// │ │ │
|
|
||||||
x += 20
|
|
||||||
// var simple.x: Int
|
|
||||||
// │ fun (Int).minus(Int): Int
|
|
||||||
// │ │ Int
|
|
||||||
// │ │ │
|
|
||||||
x -= 5
|
|
||||||
// var simple.x: Int
|
|
||||||
// │ fun (Int).div(Int): Int
|
|
||||||
// │ │ Int
|
|
||||||
// │ │ │
|
|
||||||
x /= 5
|
|
||||||
// var simple.x: Int
|
|
||||||
// │ fun (Int).times(Int): Int
|
|
||||||
// │ │ Int
|
|
||||||
// │ │ │
|
|
||||||
x *= 10
|
|
||||||
}
|
|
||||||
|
|
||||||
// collections/List<String>
|
|
||||||
// │
|
|
||||||
fun List<String>.modify() {
|
|
||||||
// fun <T> collections/Collection<T>.plus<String>(T): collections/List<T>
|
|
||||||
// │
|
|
||||||
this += "Alpha"
|
|
||||||
// fun <T> collections/Collection<T>.plus<String>(T): collections/List<T>
|
|
||||||
// │
|
|
||||||
this += "Omega"
|
|
||||||
}
|
|
||||||
|
|
||||||
fun Any.modify() {
|
|
||||||
// collections/List<Int>
|
|
||||||
// │ fun <T> collections/Collection<T>.plus<Int>(T): collections/List<T>
|
|
||||||
// │ │ Int
|
|
||||||
// │ │ │
|
|
||||||
(this as List<Int>) += 42
|
|
||||||
}
|
|
||||||
@@ -1,26 +0,0 @@
|
|||||||
// Boolean Double
|
|
||||||
// │ │
|
|
||||||
fun foo(first: String = "", second: Boolean = true, third: Double = 3.1415) {}
|
|
||||||
|
|
||||||
fun test() {
|
|
||||||
// fun foo(String = ..., Boolean = ..., Double = ...): Unit
|
|
||||||
// │
|
|
||||||
foo()
|
|
||||||
// fun foo(String = ..., Boolean = ..., Double = ...): Unit
|
|
||||||
// │ Boolean
|
|
||||||
// │ │ Double
|
|
||||||
// │ │ │
|
|
||||||
foo("Alpha", false, 2.71)
|
|
||||||
// fun foo(String = ..., Boolean = ..., Double = ...): Unit
|
|
||||||
// │ Boolean
|
|
||||||
// │ │
|
|
||||||
foo(first = "Hello", second = true)
|
|
||||||
// fun foo(String = ..., Boolean = ..., Double = ...): Unit
|
|
||||||
// │ fun (Double).unaryMinus(): Double
|
|
||||||
// │ │Double
|
|
||||||
// │ ││
|
|
||||||
foo(third = -1.0, first = "123")
|
|
||||||
// fun foo(String = ..., Boolean = ..., Double = ...): Unit
|
|
||||||
// │
|
|
||||||
foo(= "")
|
|
||||||
}
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
// Int
|
|
||||||
// │ orFourtyTwo.arg: Int?
|
|
||||||
// │ │ Int
|
|
||||||
// │ │ │
|
|
||||||
fun orFourtyTwo(arg: Int?) = arg ?: 42
|
|
||||||
|
|
||||||
// Int
|
|
||||||
// │ bang.arg: Int?
|
|
||||||
// │ │
|
|
||||||
fun bang(arg: Int?) = arg!!
|
|
||||||
-5
@@ -1,5 +0,0 @@
|
|||||||
fun test() {
|
|
||||||
// class Array<T>: java/io/Serializable, Cloneable
|
|
||||||
// │
|
|
||||||
Array<String>::class
|
|
||||||
}
|
|
||||||
@@ -1,7 +0,0 @@
|
|||||||
fun foo() {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
fun bar(): String {
|
|
||||||
return "Hello"
|
|
||||||
}
|
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
interface A {
|
|
||||||
fun foo() {}
|
|
||||||
}
|
|
||||||
|
|
||||||
interface B {
|
|
||||||
fun foo() {}
|
|
||||||
fun bar() {}
|
|
||||||
}
|
|
||||||
|
|
||||||
class C : A, B {
|
|
||||||
override fun bar() {
|
|
||||||
// fun (B).bar(): Unit
|
|
||||||
// │
|
|
||||||
super.bar()
|
|
||||||
}
|
|
||||||
|
|
||||||
override fun foo() {
|
|
||||||
// fun (A).foo(): Unit
|
|
||||||
// │
|
|
||||||
super<A>.foo()
|
|
||||||
// fun (B).foo(): Unit
|
|
||||||
// │
|
|
||||||
super<B>.foo()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,43 +0,0 @@
|
|||||||
class Some {
|
|
||||||
// Int
|
|
||||||
// │ Int
|
|
||||||
// │ │
|
|
||||||
fun foo(): Int = 1
|
|
||||||
|
|
||||||
fun bar(): Int {
|
|
||||||
// fun (Some).foo(): Int
|
|
||||||
// │
|
|
||||||
return this.foo()
|
|
||||||
}
|
|
||||||
|
|
||||||
// Some
|
|
||||||
// │
|
|
||||||
val instance: Some
|
|
||||||
get() = this@Some
|
|
||||||
|
|
||||||
fun String.extension(): Int {
|
|
||||||
// fun (Some).bar(): Int
|
|
||||||
// │ fun (Int).plus(Int): Int
|
|
||||||
// │ │ val (String).length: Int
|
|
||||||
// │ │ │
|
|
||||||
return this@Some.bar() + this.length
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Int fun (Some).bar(): Int
|
|
||||||
// │ │
|
|
||||||
fun Some.extension() = this.bar()
|
|
||||||
|
|
||||||
fun test(some: Some): Int {
|
|
||||||
// fun <T, R> with<Some, Int>(T, T.() -> R): R
|
|
||||||
// │ test.some: Some
|
|
||||||
// │ │ with@0
|
|
||||||
// │ │ │
|
|
||||||
return with(some) {
|
|
||||||
// fun (Some).foo(): Int
|
|
||||||
// │ fun (Int).plus(Int): Int
|
|
||||||
// │ │ fun Some.extension(): Int
|
|
||||||
// │ │ │
|
|
||||||
this.foo() + this@with.extension()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
// WITH_STDLIB
|
|
||||||
fun some() {
|
|
||||||
try {
|
|
||||||
// constructor KotlinNullPointerException()
|
|
||||||
// │
|
|
||||||
throw KotlinNullPointerException()
|
|
||||||
// java/lang/RuntimeException
|
|
||||||
// │
|
|
||||||
} catch (e: RuntimeException) {
|
|
||||||
// fun io/println(Any?): Unit
|
|
||||||
// │
|
|
||||||
println("Runtime exception")
|
|
||||||
// java/lang/Exception
|
|
||||||
// │
|
|
||||||
} catch (e: Exception) {
|
|
||||||
// fun io/println(Any?): Unit
|
|
||||||
// │
|
|
||||||
println("Some exception")
|
|
||||||
} finally {
|
|
||||||
// fun io/println(Any?): Unit
|
|
||||||
// │
|
|
||||||
println("finally")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
// FIR_IGNORE
|
|
||||||
interface IThing
|
|
||||||
|
|
||||||
// Boolean
|
|
||||||
// │ test1.x: Any
|
|
||||||
// │ │
|
|
||||||
fun test1(x: Any) = x is IThing
|
|
||||||
// Boolean
|
|
||||||
// │ test2.x: Any
|
|
||||||
// │ │
|
|
||||||
fun test2(x: Any) = x !is IThing
|
|
||||||
// IThing
|
|
||||||
// │ test3.x: Any
|
|
||||||
// │ │
|
|
||||||
fun test3(x: Any) = x as IThing
|
|
||||||
// IThing?
|
|
||||||
// │ test4.x: Any
|
|
||||||
// │ │
|
|
||||||
fun test4(x: Any) = x as? IThing
|
|
||||||
@@ -1,79 +0,0 @@
|
|||||||
// FIR_IGNORE
|
|
||||||
// WITH_STDLIB
|
|
||||||
fun test() {
|
|
||||||
// Int Int
|
|
||||||
// │ │
|
|
||||||
var x = 0
|
|
||||||
// var test.x: Int
|
|
||||||
// Int │fun (Int).inc(): Int
|
|
||||||
// │ ││
|
|
||||||
val x1 = x++
|
|
||||||
// fun (Int).inc(): Int
|
|
||||||
// Int │ var test.x: Int
|
|
||||||
// │ │ │
|
|
||||||
val x2 = ++x
|
|
||||||
// fun (Int).dec(): Int
|
|
||||||
// Int │ var test.x: Int
|
|
||||||
// │ │ │
|
|
||||||
val x3 = --x
|
|
||||||
// var test.x: Int
|
|
||||||
// Int │fun (Int).dec(): Int
|
|
||||||
// │ ││
|
|
||||||
val x4 = x--
|
|
||||||
// Unit
|
|
||||||
// │ fun (Boolean).not(): Boolean
|
|
||||||
// │ │ var test.x: Int
|
|
||||||
// │ │ │ EQ operator call
|
|
||||||
// │ │ │ │ Int
|
|
||||||
// │ │ │ │ │
|
|
||||||
if (!(x == 0)) {
|
|
||||||
// fun io/println(Any?): Unit
|
|
||||||
// │
|
|
||||||
println("000")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class X(val i: Int)
|
|
||||||
|
|
||||||
fun test2(x: X) {
|
|
||||||
// test2.x: X
|
|
||||||
// │ val (X).i: Int
|
|
||||||
// Int │ │fun (Int).inc(): Int
|
|
||||||
// │ │ ││
|
|
||||||
val x1 = x.i++
|
|
||||||
// fun (Int).inc(): Int
|
|
||||||
// │ test2.x: X
|
|
||||||
// Int │ │ val (X).i: Int
|
|
||||||
// │ │ │ │
|
|
||||||
val x2 = ++x.i
|
|
||||||
}
|
|
||||||
|
|
||||||
fun test3(arr: Array<Int>) {
|
|
||||||
// test3.arr: Array<Int>
|
|
||||||
// │ Int
|
|
||||||
// Int │ │ fun (Int).inc(): Int
|
|
||||||
// │ │ │ │
|
|
||||||
val x1 = arr[0]++
|
|
||||||
// fun (Int).inc(): Int
|
|
||||||
// │ test3.arr: Array<Int>
|
|
||||||
// Int │ │ Int
|
|
||||||
// │ │ │ │
|
|
||||||
val x2 = ++arr[1]
|
|
||||||
}
|
|
||||||
|
|
||||||
class Y(val arr: Array<Int>)
|
|
||||||
|
|
||||||
fun test4(y: Y) {
|
|
||||||
// test4.y: Y
|
|
||||||
// │ val (Y).arr: Array<Int>
|
|
||||||
// │ │ Int
|
|
||||||
// Int │ │ │ fun (Int).inc(): Int
|
|
||||||
// │ │ │ │ │
|
|
||||||
val x1 = y.arr[0]++
|
|
||||||
// fun (Int).inc(): Int
|
|
||||||
// │ test4.y: Y
|
|
||||||
// │ │ val (Y).arr: Array<Int>
|
|
||||||
// Int │ │ │ Int
|
|
||||||
// │ │ │ │ │
|
|
||||||
val x2 = ++y.arr[1]
|
|
||||||
}
|
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
fun foo() {
|
|
||||||
// Int Int
|
|
||||||
// │ │
|
|
||||||
val x = 1
|
|
||||||
// val foo.x: Int
|
|
||||||
// │ fun (Int).plus(Int): Int
|
|
||||||
// Int │ │ Int
|
|
||||||
// │ │ │ │
|
|
||||||
var y = x + 1
|
|
||||||
// var foo.y: Int
|
|
||||||
// │ fun (Int).times(Int): Int
|
|
||||||
// Int │ │ Int
|
|
||||||
// │ │ │ │
|
|
||||||
val z = y * 2
|
|
||||||
// var foo.y: Int
|
|
||||||
// │ var foo.y: Int
|
|
||||||
// │ │ fun (Int).plus(Int): Int
|
|
||||||
// │ │ │ val foo.z: Int
|
|
||||||
// │ │ │ │
|
|
||||||
y = y + z
|
|
||||||
// var foo.y: Int
|
|
||||||
// │ fun (Int).minus(Int): Int
|
|
||||||
// Int │ │ val foo.x: Int
|
|
||||||
// │ │ │ │
|
|
||||||
val w = y - x
|
|
||||||
// val foo.w: Int
|
|
||||||
// │
|
|
||||||
return w
|
|
||||||
}
|
|
||||||
@@ -1,62 +0,0 @@
|
|||||||
// WITH_STDLIB
|
|
||||||
fun foo(limit: Int) {
|
|
||||||
// Int Int
|
|
||||||
// │ │
|
|
||||||
var k = 0
|
|
||||||
// var foo.k: Int
|
|
||||||
// │ fun (Int).compareTo(Int): Int
|
|
||||||
// │ │ foo.limit: Int
|
|
||||||
// │ │ │
|
|
||||||
some@ while (k < limit) {
|
|
||||||
// var foo.k: Int
|
|
||||||
// │fun (Int).inc(): Int
|
|
||||||
// ││
|
|
||||||
k++
|
|
||||||
// fun io/println(Int): Unit
|
|
||||||
// │ var foo.k: Int
|
|
||||||
// │ │
|
|
||||||
println(k)
|
|
||||||
// var foo.k: Int
|
|
||||||
// │ EQ operator call
|
|
||||||
// │ │ Int
|
|
||||||
// │ │ │
|
|
||||||
while (k == 13) {
|
|
||||||
// var foo.k: Int
|
|
||||||
// │fun (Int).inc(): Int
|
|
||||||
// ││
|
|
||||||
k++
|
|
||||||
// Unit
|
|
||||||
// │ var foo.k: Int
|
|
||||||
// │ │ fun (Int).compareTo(Int): Int
|
|
||||||
// │ │ │ foo.limit: Int
|
|
||||||
// │ │ │ │
|
|
||||||
if (k < limit) break@some
|
|
||||||
// Unit
|
|
||||||
// │ var foo.k: Int
|
|
||||||
// │ │ fun (Int).compareTo(Int): Int
|
|
||||||
// │ │ │ foo.limit: Int
|
|
||||||
// │ │ │ │
|
|
||||||
if (k > limit) continue
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun bar(limit: Int) {
|
|
||||||
// Int bar.limit: Int
|
|
||||||
// │ │
|
|
||||||
var k = limit
|
|
||||||
do {
|
|
||||||
// var bar.k: Int
|
|
||||||
// │fun (Int).dec(): Int
|
|
||||||
// ││
|
|
||||||
k--
|
|
||||||
// fun io/println(Int): Unit
|
|
||||||
// │ var bar.k: Int
|
|
||||||
// │ │
|
|
||||||
println(k)
|
|
||||||
// var bar.k: Int
|
|
||||||
// │ fun (Int).compareTo(Int): Int
|
|
||||||
// │ │ Int
|
|
||||||
// │ │ │
|
|
||||||
} while (k >= 0)
|
|
||||||
}
|
|
||||||
@@ -1,55 +0,0 @@
|
|||||||
// FIR_IGNORE
|
|
||||||
data class Vector(val x: Int, val y: Int) {
|
|
||||||
// Vector
|
|
||||||
// │ constructor Vector(Int, Int)
|
|
||||||
// │ │ val (Vector).x: Int
|
|
||||||
// │ │ │ fun (Int).plus(Int): Int
|
|
||||||
// │ │ │ │ Vector.plus.other: Vector
|
|
||||||
// │ │ │ │ │ val (Vector).x: Int
|
|
||||||
// │ │ │ │ │ │ val (Vector).y: Int
|
|
||||||
// │ │ │ │ │ │ │ fun (Int).plus(Int): Int
|
|
||||||
// │ │ │ │ │ │ │ │ Vector.plus.other: Vector
|
|
||||||
// │ │ │ │ │ │ │ │ │ val (Vector).y: Int
|
|
||||||
// │ │ │ │ │ │ │ │ │ │
|
|
||||||
fun plus(other: Vector): Vector = Vector(x + other.x, y + other.y)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun main() {
|
|
||||||
// Vector
|
|
||||||
// │ constructor Vector(Int, Int)
|
|
||||||
// │ │ Int
|
|
||||||
// │ │ │ Int
|
|
||||||
// │ │ │ │
|
|
||||||
val a = Vector(1, 2)
|
|
||||||
// Vector
|
|
||||||
// │ constructor Vector(Int, Int)
|
|
||||||
// │ │ Int
|
|
||||||
// │ │ │ Int
|
|
||||||
// │ │ │ │
|
|
||||||
val b = Vector(-1, 10)
|
|
||||||
|
|
||||||
// fun io/println(Any?): Unit
|
|
||||||
// │ val main.a: Vector
|
|
||||||
// │ │ val main.b: Vector
|
|
||||||
// │ │ │ fun (Vector).toString(): String
|
|
||||||
// │ │ │ │
|
|
||||||
println("a = $a, b = ${b.toString()}")
|
|
||||||
// fun io/println(Any?): Unit
|
|
||||||
// │ fun (String).plus(Any?): String
|
|
||||||
// │ │ val main.a: Vector
|
|
||||||
// │ │ │ fun (Vector).plus(Vector): Vector
|
|
||||||
// │ │ │ │ val main.b: Vector
|
|
||||||
// │ │ │ │ │
|
|
||||||
println("a + b = " + (a + b))
|
|
||||||
// fun io/println(Any?): Unit
|
|
||||||
// │ val main.a: Vector
|
|
||||||
// │ │ fun (Vector).hashCode(): Int
|
|
||||||
// │ │ │
|
|
||||||
println("a hash - ${a.hashCode()}")
|
|
||||||
|
|
||||||
// val main.a: Vector
|
|
||||||
// │ fun (Vector).equals(Any?): Boolean
|
|
||||||
// fun io/println(Any?): Unit │ │ val main.b: Vector
|
|
||||||
// │ │ │ │
|
|
||||||
println("a is equal to b ${a.equals(b)}")
|
|
||||||
}
|
|
||||||
@@ -1,41 +0,0 @@
|
|||||||
interface Base {
|
|
||||||
fun printMessage()
|
|
||||||
fun printMessageLine()
|
|
||||||
}
|
|
||||||
|
|
||||||
class BaseImpl(val x: Int) : Base {
|
|
||||||
// fun io/print(Int): Unit
|
|
||||||
// │ val (BaseImpl).x: Int
|
|
||||||
// │ │
|
|
||||||
override fun printMessage() { print(x) }
|
|
||||||
// fun io/println(Int): Unit
|
|
||||||
// │ val (BaseImpl).x: Int
|
|
||||||
// │ │
|
|
||||||
override fun printMessageLine() { println(x) }
|
|
||||||
}
|
|
||||||
|
|
||||||
// Derived.<init>.b: Base
|
|
||||||
// │
|
|
||||||
class Derived(b: Base) : Base by b {
|
|
||||||
// fun io/print(Any?): Unit
|
|
||||||
// │
|
|
||||||
override fun printMessage() { print("abc") }
|
|
||||||
}
|
|
||||||
|
|
||||||
fun main() {
|
|
||||||
// BaseImpl
|
|
||||||
// │ constructor BaseImpl(Int)
|
|
||||||
// │ │ Int
|
|
||||||
// │ │ │
|
|
||||||
val b = BaseImpl(10)
|
|
||||||
// constructor Derived(Base)
|
|
||||||
// │ val main.b: BaseImpl
|
|
||||||
// │ │ fun (Derived).printMessage(): Unit
|
|
||||||
// │ │ │
|
|
||||||
Derived(b).printMessage()
|
|
||||||
// constructor Derived(Base)
|
|
||||||
// │ val main.b: BaseImpl
|
|
||||||
// │ │ fun (Base).printMessageLine(): Unit
|
|
||||||
// │ │ │
|
|
||||||
Derived(b).printMessageLine()
|
|
||||||
}
|
|
||||||
@@ -1,94 +0,0 @@
|
|||||||
package p
|
|
||||||
|
|
||||||
class A {
|
|
||||||
// Int Int
|
|
||||||
// │ │
|
|
||||||
val aProp = 10
|
|
||||||
fun call() {}
|
|
||||||
}
|
|
||||||
|
|
||||||
class B {
|
|
||||||
// Int Int
|
|
||||||
// │ │
|
|
||||||
val bProp = 1
|
|
||||||
}
|
|
||||||
|
|
||||||
fun foo(a: Int, b: Int): Int {
|
|
||||||
// fun <T, R> with<A, Int>(T, T.() -> R): R
|
|
||||||
// │ constructor A()
|
|
||||||
// │ │ with@0
|
|
||||||
// │ │ │
|
|
||||||
with(A()) {
|
|
||||||
// val (A).aProp: Int
|
|
||||||
// this@0
|
|
||||||
// │
|
|
||||||
aProp
|
|
||||||
// fun (A).call(): Unit
|
|
||||||
// this@0
|
|
||||||
// │
|
|
||||||
call()
|
|
||||||
|
|
||||||
// fun <T, R> with<B, Int>(T, T.() -> R): R
|
|
||||||
// │ constructor B()
|
|
||||||
// │ │ with@1
|
|
||||||
// │ │ │
|
|
||||||
with(B()) {
|
|
||||||
// val (A).aProp: Int
|
|
||||||
// this@0
|
|
||||||
// │
|
|
||||||
aProp
|
|
||||||
// val (B).bProp: Int
|
|
||||||
// this@1
|
|
||||||
// │
|
|
||||||
bProp
|
|
||||||
// val (A).aProp: Int
|
|
||||||
// this@0
|
|
||||||
// │
|
|
||||||
aProp
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// fun <T, R> with<A, Int>(T, T.() -> R): R
|
|
||||||
// │ constructor A()
|
|
||||||
// │ │ with@0
|
|
||||||
// │ │ │
|
|
||||||
with(A()) {
|
|
||||||
// val (A).aProp: Int
|
|
||||||
// this@0
|
|
||||||
// │
|
|
||||||
aProp
|
|
||||||
|
|
||||||
// fun <T, R> with<B, Int>(T, T.() -> R): R
|
|
||||||
// │ constructor B()
|
|
||||||
// │ │ with@1
|
|
||||||
// │ │ │
|
|
||||||
with(B()) {
|
|
||||||
// val (A).aProp: Int
|
|
||||||
// this@0
|
|
||||||
// │
|
|
||||||
aProp
|
|
||||||
// val (B).bProp: Int
|
|
||||||
// this@1
|
|
||||||
// │
|
|
||||||
bProp
|
|
||||||
}
|
|
||||||
|
|
||||||
// fun <T, R> with<B, Int>(T, T.() -> R): R
|
|
||||||
// │ constructor B()
|
|
||||||
// │ │ with@1
|
|
||||||
// │ │ │
|
|
||||||
with(B()) {
|
|
||||||
// val (A).aProp: Int
|
|
||||||
// this@0
|
|
||||||
// │
|
|
||||||
aProp
|
|
||||||
// val (B).bProp: Int
|
|
||||||
// this@1
|
|
||||||
// │
|
|
||||||
bProp
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// foo.a: Int
|
|
||||||
// │
|
|
||||||
return a
|
|
||||||
}
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
// FIR_IGNORE
|
|
||||||
package org.jetbrains.kotlin.test
|
|
||||||
|
|
||||||
// collections/List<Int>
|
|
||||||
// │ fun <T> collections/listOf<Int>(vararg T): collections/List<T>
|
|
||||||
// │ │ Int
|
|
||||||
// │ │ │ Int
|
|
||||||
// │ │ │ │ Int
|
|
||||||
// │ │ │ │ │
|
|
||||||
val listOfInt = listOf(1, 2, 3)
|
|
||||||
// java/util/ArrayList<Int>
|
|
||||||
// │ constructor java/util/ArrayList<E : Any!>()
|
|
||||||
// │ │
|
|
||||||
val javaList = java.util.ArrayList<Int>()
|
|
||||||
|
|
||||||
// java/util/ArrayList<Int>
|
|
||||||
// │
|
|
||||||
fun move(): java.util.ArrayList<Int> {
|
|
||||||
// Int val listOfInt: collections/List<Int>
|
|
||||||
// │ │
|
|
||||||
for (elem in listOfInt) {
|
|
||||||
// val javaList: java/util/ArrayList<Int>
|
|
||||||
// │ fun (java/util/ArrayList<E>).add(E): Boolean
|
|
||||||
// │ │ val move.elem: Int
|
|
||||||
// │ │ │
|
|
||||||
javaList.add(elem)
|
|
||||||
}
|
|
||||||
|
|
||||||
// val javaList: java/util/ArrayList<Int>
|
|
||||||
// │
|
|
||||||
return javaList
|
|
||||||
}
|
|
||||||
@@ -1,55 +0,0 @@
|
|||||||
class A(val a: Int) {
|
|
||||||
override fun equals(other: Any?): Boolean {
|
|
||||||
// Unit
|
|
||||||
// │ A.equals.other: Any?
|
|
||||||
// │ │ Boolean
|
|
||||||
// │ │ │
|
|
||||||
if (other !is A) return false
|
|
||||||
// val (A).a: Int
|
|
||||||
// │ EQ operator call
|
|
||||||
// │ │ A.equals.other: Any?
|
|
||||||
// │ │ │ val (A).a: Int
|
|
||||||
// │ │ │ │
|
|
||||||
return this.a == other.a
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
open class B(val b: Int) {
|
|
||||||
override fun equals(other: Any?): Boolean {
|
|
||||||
// Unit
|
|
||||||
// │ B.equals.other: Any?
|
|
||||||
// │ │ Boolean
|
|
||||||
// │ │ │
|
|
||||||
if (other !is B) return false
|
|
||||||
// val (B).b: Int
|
|
||||||
// │ EQ operator call
|
|
||||||
// │ │ B.equals.other: Any?
|
|
||||||
// │ │ │ val (B).b: Int
|
|
||||||
// │ │ │ │
|
|
||||||
return this.b == other.b
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// constructor B(Int)
|
|
||||||
// │ C.<init>.c: Int
|
|
||||||
// │ │
|
|
||||||
class C(c: Int): B(c) {}
|
|
||||||
|
|
||||||
// constructor A(Int)
|
|
||||||
// │ EQ operator call
|
|
||||||
// │ │ constructor A(Int)
|
|
||||||
// Boolean │ Int │ │ Int
|
|
||||||
// │ │ │ │ │ │
|
|
||||||
val areEqual = A(10) == A(11)
|
|
||||||
// constructor C(Int)
|
|
||||||
// │ EQ operator call
|
|
||||||
// │ │ constructor C(Int)
|
|
||||||
// Boolean │ Int │ │ Int
|
|
||||||
// │ │ │ │ │ │
|
|
||||||
val areEqual2 = C(10) == C(11)
|
|
||||||
// constructor A(Int)
|
|
||||||
// │ EQ operator call
|
|
||||||
// │ │ constructor C(Int)
|
|
||||||
// Boolean │ Int │ │ Int
|
|
||||||
// │ │ │ │ │ │
|
|
||||||
val areEqual3 = A(10) == C(11)
|
|
||||||
@@ -1,83 +0,0 @@
|
|||||||
package org.jetbrains.kotlin.test
|
|
||||||
|
|
||||||
// Int Int
|
|
||||||
// │ │
|
|
||||||
val p1 = 10
|
|
||||||
// Double Double
|
|
||||||
// │ │
|
|
||||||
val p2: Double = 1.0
|
|
||||||
// Float Float
|
|
||||||
// │ │
|
|
||||||
val p3: Float = 2.5f
|
|
||||||
// String
|
|
||||||
// │
|
|
||||||
val p4 = "some string"
|
|
||||||
|
|
||||||
// Double
|
|
||||||
// │ val p1: Int
|
|
||||||
// │ │ fun (Int).plus(Double): Double
|
|
||||||
// │ │ │ val p2: Double
|
|
||||||
// │ │ │ │
|
|
||||||
val p5 = p1 + p2
|
|
||||||
// Double
|
|
||||||
// │ val p1: Int
|
|
||||||
// │ │ fun (Int).times(Double): Double
|
|
||||||
// │ │ │ val p2: Double
|
|
||||||
// │ │ │ │ fun (Double).plus(Double): Double
|
|
||||||
// │ │ │ │ │ val p5: Double
|
|
||||||
// │ │ │ │ │ │ fun (Double).minus(Float): Double
|
|
||||||
// │ │ │ │ │ │ │ val p3: Float
|
|
||||||
// │ │ │ │ │ │ │ │
|
|
||||||
val p6 = p1 * p2 + (p5 - p3)
|
|
||||||
|
|
||||||
// Float
|
|
||||||
// │
|
|
||||||
val withGetter
|
|
||||||
// val p1: Int
|
|
||||||
// │ fun (Int).times(Float): Float
|
|
||||||
// │ │ val p3: Float
|
|
||||||
// │ │ │
|
|
||||||
get() = p1 * p3
|
|
||||||
|
|
||||||
// String
|
|
||||||
// │
|
|
||||||
var withSetter
|
|
||||||
// val p4: String
|
|
||||||
// │
|
|
||||||
get() = p4
|
|
||||||
// String <set-withSetter>.value: String
|
|
||||||
// │ │
|
|
||||||
set(value) = value
|
|
||||||
|
|
||||||
// Boolean
|
|
||||||
// │
|
|
||||||
val withGetter2: Boolean
|
|
||||||
get() {
|
|
||||||
// Boolean
|
|
||||||
// │
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
// String
|
|
||||||
// │
|
|
||||||
var withSetter2: String
|
|
||||||
get() = "1"
|
|
||||||
// String
|
|
||||||
// │
|
|
||||||
set(value) {
|
|
||||||
// var <set-withSetter2>.field: String
|
|
||||||
// │ <set-withSetter2>.value: String
|
|
||||||
// │ │ fun (String).plus(Any?): String
|
|
||||||
// │ │ │
|
|
||||||
field = value + "!"
|
|
||||||
}
|
|
||||||
|
|
||||||
// String
|
|
||||||
// │
|
|
||||||
private val privateGetter: String = "cba"
|
|
||||||
get
|
|
||||||
|
|
||||||
// String
|
|
||||||
// │
|
|
||||||
var privateSetter: String = "abc"
|
|
||||||
private set
|
|
||||||
@@ -1,27 +0,0 @@
|
|||||||
fun Int.addOne(): Int {
|
|
||||||
// fun (Int).plus(Int): Int
|
|
||||||
// │ Int
|
|
||||||
// │ │
|
|
||||||
return this + 1
|
|
||||||
}
|
|
||||||
|
|
||||||
// Int
|
|
||||||
// │
|
|
||||||
val Int.repeat: Int
|
|
||||||
get() = this
|
|
||||||
|
|
||||||
fun main() {
|
|
||||||
// Int Int
|
|
||||||
// │ │
|
|
||||||
val i = 2
|
|
||||||
// val main.i: Int
|
|
||||||
// │ fun Int.addOne(): Int
|
|
||||||
// │ │
|
|
||||||
i.addOne()
|
|
||||||
// val main.i: Int
|
|
||||||
// │ val Int.repeat: Int
|
|
||||||
// │ │ fun (Int).times(Int): Int
|
|
||||||
// Int │ │ │ Int
|
|
||||||
// │ │ │ │ │
|
|
||||||
val p = i.repeat * 2
|
|
||||||
}
|
|
||||||
@@ -1,25 +0,0 @@
|
|||||||
package org.jetbrains.kotlin.test
|
|
||||||
|
|
||||||
abstract class Base<T>(var x: T) {
|
|
||||||
abstract fun replace(newValue: T)
|
|
||||||
}
|
|
||||||
|
|
||||||
// constructor Base<T>(T)
|
|
||||||
// │ Derived.<init>.x: Int
|
|
||||||
// │ │
|
|
||||||
class Derived(x: Int): Base<Int>(x) {
|
|
||||||
override fun replace(newValue: Int) {
|
|
||||||
// var (Base<T>).x: T
|
|
||||||
// │ Derived.replace.newValue: Int
|
|
||||||
// │ │
|
|
||||||
x = newValue
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun test() {
|
|
||||||
// constructor Derived(Int)
|
|
||||||
// │ fun (Derived).replace(Int): Unit
|
|
||||||
// │ Int │ Int
|
|
||||||
// │ │ │ │
|
|
||||||
Derived(10).replace(20)
|
|
||||||
}
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
interface Source<out T> {
|
|
||||||
fun nextT(): T
|
|
||||||
}
|
|
||||||
|
|
||||||
fun demo(strs: Source<String>) {
|
|
||||||
// Source<Any> demo.strs: Source<String>
|
|
||||||
// │ │
|
|
||||||
val objects: Source<Any> = strs
|
|
||||||
}
|
|
||||||
|
|
||||||
interface Comparable<in T> {
|
|
||||||
operator fun compareTo(other: T): Int
|
|
||||||
}
|
|
||||||
|
|
||||||
fun demo(x: Comparable<Number>) {
|
|
||||||
// demo.x: Comparable<Number>
|
|
||||||
// │ fun (Comparable<T>).compareTo(T): Int
|
|
||||||
// │ │ Double
|
|
||||||
// │ │ │
|
|
||||||
x.compareTo(1.0)
|
|
||||||
// Comparable<Double> demo.x: Comparable<Number>
|
|
||||||
// │ │
|
|
||||||
val y: Comparable<Double> = x
|
|
||||||
}
|
|
||||||
@@ -1,29 +0,0 @@
|
|||||||
// FIR_IGNORE
|
|
||||||
// collections/List<T> collections/List<String>
|
|
||||||
// │ │
|
|
||||||
fun <T> copyWhenGreater(list: List<T>, threshold: T): List<String>
|
|
||||||
where T : CharSequence,
|
|
||||||
T : Comparable<T> {
|
|
||||||
// copyWhenGreater.list: collections/List<T>
|
|
||||||
// │ fun <T> collections/Iterable<T>.filter<T>((T) -> Boolean): collections/List<T>
|
|
||||||
// │ │ copyWhenGreater.<anonymous>.it: T
|
|
||||||
// │ │ │ fun (Comparable<T>).compareTo(T): Int
|
|
||||||
// │ │ │ │ copyWhenGreater.threshold: T
|
|
||||||
// │ │ │ │ │ fun <T, R> collections/Iterable<T>.map<T, String>((T) -> R): collections/List<R>
|
|
||||||
// │ │ │ │ │ │ copyWhenGreater.<anonymous>.it: T
|
|
||||||
// │ │ │ │ │ │ │ fun (Any).toString(): String
|
|
||||||
// │ │ │ │ │ │ │ │
|
|
||||||
return list.filter { it > threshold }.map { it.toString() }
|
|
||||||
}
|
|
||||||
|
|
||||||
fun main() {
|
|
||||||
// collections/List<String>
|
|
||||||
// │ fun <T> collections/listOf<String>(vararg T): collections/List<T>
|
|
||||||
// │ │
|
|
||||||
val list = listOf("1", "2", "3")
|
|
||||||
// collections/List<String>
|
|
||||||
// │ fun <T : CharSequence> copyWhenGreater<String>(collections/List<T>, T): collections/List<String> where T : Comparable<T>
|
|
||||||
// │ │ val main.list: collections/List<String>
|
|
||||||
// │ │ │
|
|
||||||
val copy = copyWhenGreater(list, "2")
|
|
||||||
}
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
data class Vector(val x: Int, val y: Int) {
|
|
||||||
fun plus(other: Vector): Vector = Vector(x + other.x, y + other.y)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun main() {
|
|
||||||
val a = Vector(1, 2)
|
|
||||||
val b = Vector(-1, 10)
|
|
||||||
|
|
||||||
println("a = $a, b = ${b.toString()}")
|
|
||||||
println("a + b = " + (a + b))
|
|
||||||
println("a hash - ${a.hashCode()}")
|
|
||||||
|
|
||||||
println("a is equal to b ${a.equals(b)}")
|
|
||||||
}
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
interface Base {
|
|
||||||
fun printMessage()
|
|
||||||
fun printMessageLine()
|
|
||||||
}
|
|
||||||
|
|
||||||
class BaseImpl(val x: Int) : Base {
|
|
||||||
override fun printMessage() { print(x) }
|
|
||||||
override fun printMessageLine() { println(x) }
|
|
||||||
}
|
|
||||||
|
|
||||||
class Derived(b: Base) : Base by b {
|
|
||||||
override fun printMessage() { print("abc") }
|
|
||||||
}
|
|
||||||
|
|
||||||
fun main() {
|
|
||||||
val b = BaseImpl(10)
|
|
||||||
Derived(b).printMessage()
|
|
||||||
Derived(b).printMessageLine()
|
|
||||||
}
|
|
||||||
@@ -1,38 +0,0 @@
|
|||||||
package p
|
|
||||||
|
|
||||||
class A {
|
|
||||||
val aProp = 10
|
|
||||||
fun call() {}
|
|
||||||
}
|
|
||||||
|
|
||||||
class B {
|
|
||||||
val bProp = 1
|
|
||||||
}
|
|
||||||
|
|
||||||
fun foo(a: Int, b: Int): Int {
|
|
||||||
with(A()) {
|
|
||||||
aProp
|
|
||||||
call()
|
|
||||||
|
|
||||||
with(B()) {
|
|
||||||
aProp
|
|
||||||
bProp
|
|
||||||
aProp
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
with(A()) {
|
|
||||||
aProp
|
|
||||||
|
|
||||||
with(B()) {
|
|
||||||
aProp
|
|
||||||
bProp
|
|
||||||
}
|
|
||||||
|
|
||||||
with(B()) {
|
|
||||||
aProp
|
|
||||||
bProp
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return a
|
|
||||||
}
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
package org.jetbrains.kotlin.test
|
|
||||||
|
|
||||||
val listOfInt = listOf(1, 2, 3)
|
|
||||||
val javaList = java.util.ArrayList<Int>()
|
|
||||||
|
|
||||||
fun move(): java.util.ArrayList<Int> {
|
|
||||||
for (elem in listOfInt) {
|
|
||||||
javaList.add(elem)
|
|
||||||
}
|
|
||||||
|
|
||||||
return javaList
|
|
||||||
}
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
class A(val a: Int) {
|
|
||||||
override fun equals(other: Any?): Boolean {
|
|
||||||
if (other !is A) return false
|
|
||||||
return this.a == other.a
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
open class B(val b: Int) {
|
|
||||||
override fun equals(other: Any?): Boolean {
|
|
||||||
if (other !is B) return false
|
|
||||||
return this.b == other.b
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
class C(c: Int): B(c) {}
|
|
||||||
|
|
||||||
val areEqual = A(10) == A(11)
|
|
||||||
val areEqual2 = C(10) == C(11)
|
|
||||||
val areEqual3 = A(10) == C(11)
|
|
||||||
@@ -1,34 +0,0 @@
|
|||||||
package org.jetbrains.kotlin.test
|
|
||||||
|
|
||||||
val p1 = 10
|
|
||||||
val p2: Double = 1.0
|
|
||||||
val p3: Float = 2.5f
|
|
||||||
val p4 = "some string"
|
|
||||||
|
|
||||||
val p5 = p1 + p2
|
|
||||||
val p6 = p1 * p2 + (p5 - p3)
|
|
||||||
|
|
||||||
val withGetter
|
|
||||||
get() = p1 * p3
|
|
||||||
|
|
||||||
var withSetter
|
|
||||||
get() = p4
|
|
||||||
set(value) = value
|
|
||||||
|
|
||||||
val withGetter2: Boolean
|
|
||||||
get() {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
|
|
||||||
var withSetter2: String
|
|
||||||
get() = "1"
|
|
||||||
set(value) {
|
|
||||||
field = value + "!"
|
|
||||||
}
|
|
||||||
|
|
||||||
private val privateGetter: String = "cba"
|
|
||||||
get
|
|
||||||
|
|
||||||
var privateSetter: String = "abc"
|
|
||||||
private set
|
|
||||||
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
fun Int.addOne(): Int {
|
|
||||||
return this + 1
|
|
||||||
}
|
|
||||||
|
|
||||||
val Int.repeat: Int
|
|
||||||
get() = this
|
|
||||||
|
|
||||||
fun main() {
|
|
||||||
val i = 2
|
|
||||||
i.addOne()
|
|
||||||
val p = i.repeat * 2
|
|
||||||
}
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
package org.jetbrains.kotlin.test
|
|
||||||
|
|
||||||
abstract class Base<T>(var x: T) {
|
|
||||||
abstract fun replace(newValue: T)
|
|
||||||
}
|
|
||||||
|
|
||||||
class Derived(x: Int): Base<Int>(x) {
|
|
||||||
override fun replace(newValue: Int) {
|
|
||||||
x = newValue
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun test() {
|
|
||||||
Derived(10).replace(20)
|
|
||||||
}
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
interface Source<out T> {
|
|
||||||
fun nextT(): T
|
|
||||||
}
|
|
||||||
|
|
||||||
fun demo(strs: Source<String>) {
|
|
||||||
val objects: Source<Any> = strs
|
|
||||||
}
|
|
||||||
|
|
||||||
interface Comparable<in T> {
|
|
||||||
operator fun compareTo(other: T): Int
|
|
||||||
}
|
|
||||||
|
|
||||||
fun demo(x: Comparable<Number>) {
|
|
||||||
x.compareTo(1.0)
|
|
||||||
val y: Comparable<Double> = x
|
|
||||||
}
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
fun <T> copyWhenGreater(list: List<T>, threshold: T): List<String>
|
|
||||||
where T : CharSequence,
|
|
||||||
T : Comparable<T> {
|
|
||||||
return list.filter { it > threshold }.map { it.toString() }
|
|
||||||
}
|
|
||||||
|
|
||||||
fun main() {
|
|
||||||
val list = listOf("1", "2", "3")
|
|
||||||
val copy = copyWhenGreater(list, "2")
|
|
||||||
}
|
|
||||||
Generated
-668
@@ -1,668 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
|
||||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jetbrains.kotlin.visualizer.fir;
|
|
||||||
|
|
||||||
import com.intellij.testFramework.TestDataPath;
|
|
||||||
import org.jetbrains.kotlin.test.util.KtTestUtil;
|
|
||||||
import org.jetbrains.kotlin.test.TestMetadata;
|
|
||||||
import org.junit.jupiter.api.Nested;
|
|
||||||
import org.junit.jupiter.api.Test;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.util.regex.Pattern;
|
|
||||||
|
|
||||||
/** This class is generated by {@link org.jetbrains.kotlin.test.generators.GenerateCompilerTestsKt}. DO NOT MODIFY MANUALLY */
|
|
||||||
@SuppressWarnings("all")
|
|
||||||
@TestMetadata("compiler/fir/raw-fir/psi2fir/testData/rawBuilder")
|
|
||||||
@TestDataPath("$PROJECT_ROOT")
|
|
||||||
public class FirVisualizerForRawFirDataGenerated extends AbstractFirVisualizerTest {
|
|
||||||
@Test
|
|
||||||
public void testAllFilesPresentInRawBuilder() throws Exception {
|
|
||||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/raw-fir/psi2fir/testData/rawBuilder"), Pattern.compile("^(.+)\\.kt$"), null, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nested
|
|
||||||
@TestMetadata("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations")
|
|
||||||
@TestDataPath("$PROJECT_ROOT")
|
|
||||||
public class Declarations {
|
|
||||||
@Test
|
|
||||||
public void testAllFilesPresentInDeclarations() throws Exception {
|
|
||||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations"), Pattern.compile("^(.+)\\.kt$"), null, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("annotation.kt")
|
|
||||||
public void testAnnotation() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/annotation.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("annotationOnField.kt")
|
|
||||||
public void testAnnotationOnField() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/annotationOnField.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("annotationOnProperty.kt")
|
|
||||||
public void testAnnotationOnProperty() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/annotationOnProperty.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("annotationsOnNullableParenthesizedTypes.kt")
|
|
||||||
public void testAnnotationsOnNullableParenthesizedTypes() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/annotationsOnNullableParenthesizedTypes.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("annotationsOnParenthesizedTypes.kt")
|
|
||||||
public void testAnnotationsOnParenthesizedTypes() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/annotationsOnParenthesizedTypes.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("classWithWrongSuperCall.kt")
|
|
||||||
public void testClassWithWrongSuperCall() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/classWithWrongSuperCall.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("complexTypes.kt")
|
|
||||||
public void testComplexTypes() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/complexTypes.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("constructorInObject.kt")
|
|
||||||
public void testConstructorInObject() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/constructorInObject.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("constructorOfAnonymousObject.kt")
|
|
||||||
public void testConstructorOfAnonymousObject() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/constructorOfAnonymousObject.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("contextReceivers.kt")
|
|
||||||
public void testContextReceivers() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/contextReceivers.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("danglingAnnotationsClassLevel.kt")
|
|
||||||
public void testDanglingAnnotationsClassLevel() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/danglingAnnotationsClassLevel.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("danglingAnnotationsFileLevel.kt")
|
|
||||||
public void testDanglingAnnotationsFileLevel() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/danglingAnnotationsFileLevel.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("delegates.kt")
|
|
||||||
public void testDelegates() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/delegates.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("derivedClass.kt")
|
|
||||||
public void testDerivedClass() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/derivedClass.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("emptyAnonymousObject.kt")
|
|
||||||
public void testEmptyAnonymousObject() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/emptyAnonymousObject.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("enums.kt")
|
|
||||||
public void testEnums() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/enums.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("enums2.kt")
|
|
||||||
public void testEnums2() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/enums2.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("enums3.kt")
|
|
||||||
public void testEnums3() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/enums3.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("expectActual.kt")
|
|
||||||
public void testExpectActual() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/expectActual.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("expectClassesAndFunctions.kt")
|
|
||||||
public void testExpectClassesAndFunctions() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/expectClassesAndFunctions.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("expectNestedAnnotationClassWithConstructorParameter.kt")
|
|
||||||
public void testExpectNestedAnnotationClassWithConstructorParameter() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/expectNestedAnnotationClassWithConstructorParameter.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("expectNestedClassMembers.kt")
|
|
||||||
public void testExpectNestedClassMembers() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/expectNestedClassMembers.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("expectNestedEnumClassGeneratedMembers.kt")
|
|
||||||
public void testExpectNestedEnumClassGeneratedMembers() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/expectNestedEnumClassGeneratedMembers.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("external.kt")
|
|
||||||
public void testExternal() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/external.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("F.kt")
|
|
||||||
public void testF() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/F.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("functionTypes.kt")
|
|
||||||
public void testFunctionTypes() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/functionTypes.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("genericFunctions.kt")
|
|
||||||
public void testGenericFunctions() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/genericFunctions.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("genericProperty.kt")
|
|
||||||
public void testGenericProperty() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/genericProperty.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("initBlockWithDeclarations.kt")
|
|
||||||
public void testInitBlockWithDeclarations() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/initBlockWithDeclarations.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("invalidDestructing.kt")
|
|
||||||
public void testInvalidDestructing() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/invalidDestructing.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("nestedClass.kt")
|
|
||||||
public void testNestedClass() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/nestedClass.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("NestedOfAliasedType.kt")
|
|
||||||
public void testNestedOfAliasedType() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/NestedOfAliasedType.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("NestedSuperType.kt")
|
|
||||||
public void testNestedSuperType() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/NestedSuperType.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("noPrimaryConstructor.kt")
|
|
||||||
public void testNoPrimaryConstructor() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/noPrimaryConstructor.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("propertyWithBackingField.kt")
|
|
||||||
public void testPropertyWithBackingField() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/propertyWithBackingField.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("propertyWithBackingFieldDifferentTypes.kt")
|
|
||||||
public void testPropertyWithBackingFieldDifferentTypes() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/propertyWithBackingFieldDifferentTypes.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("simpleClass.kt")
|
|
||||||
public void testSimpleClass() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/simpleClass.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("simpleFun.kt")
|
|
||||||
public void testSimpleFun() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/simpleFun.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("simpleTypeAlias.kt")
|
|
||||||
public void testSimpleTypeAlias() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/simpleTypeAlias.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("splitModifierList.kt")
|
|
||||||
public void testSplitModifierList() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/splitModifierList.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("suspendFunctionTypes.kt")
|
|
||||||
public void testSuspendFunctionTypes() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/suspendFunctionTypes.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("typeAliasWithGeneric.kt")
|
|
||||||
public void testTypeAliasWithGeneric() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/typeAliasWithGeneric.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("typeParameterVsNested.kt")
|
|
||||||
public void testTypeParameterVsNested() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/typeParameterVsNested.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("typeParameters.kt")
|
|
||||||
public void testTypeParameters() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/typeParameters.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("where.kt")
|
|
||||||
public void testWhere() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/where.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nested
|
|
||||||
@TestMetadata("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/contracts")
|
|
||||||
@TestDataPath("$PROJECT_ROOT")
|
|
||||||
public class Contracts {
|
|
||||||
@Test
|
|
||||||
public void testAllFilesPresentInContracts() throws Exception {
|
|
||||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/contracts"), Pattern.compile("^(.+)\\.kt$"), null, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nested
|
|
||||||
@TestMetadata("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/contracts/newSyntax")
|
|
||||||
@TestDataPath("$PROJECT_ROOT")
|
|
||||||
public class NewSyntax {
|
|
||||||
@Test
|
|
||||||
public void testAllFilesPresentInNewSyntax() throws Exception {
|
|
||||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/contracts/newSyntax"), Pattern.compile("^(.+)\\.kt$"), null, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("functionWithBothOldAndNewSyntaxContractDescription.kt")
|
|
||||||
public void testFunctionWithBothOldAndNewSyntaxContractDescription() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/contracts/newSyntax/functionWithBothOldAndNewSyntaxContractDescription.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("propertyAccessorsContractDescription.kt")
|
|
||||||
public void testPropertyAccessorsContractDescription() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/contracts/newSyntax/propertyAccessorsContractDescription.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("simpleFunctionsContractDescription.kt")
|
|
||||||
public void testSimpleFunctionsContractDescription() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/contracts/newSyntax/simpleFunctionsContractDescription.kt");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nested
|
|
||||||
@TestMetadata("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/contracts/oldSyntax")
|
|
||||||
@TestDataPath("$PROJECT_ROOT")
|
|
||||||
public class OldSyntax {
|
|
||||||
@Test
|
|
||||||
public void testAllFilesPresentInOldSyntax() throws Exception {
|
|
||||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/contracts/oldSyntax"), Pattern.compile("^(.+)\\.kt$"), null, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("contractDescription.kt")
|
|
||||||
public void testContractDescription() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/contracts/oldSyntax/contractDescription.kt");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nested
|
|
||||||
@TestMetadata("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/noParameterType")
|
|
||||||
@TestDataPath("$PROJECT_ROOT")
|
|
||||||
public class NoParameterType {
|
|
||||||
@Test
|
|
||||||
public void testAllFilesPresentInNoParameterType() throws Exception {
|
|
||||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/noParameterType"), Pattern.compile("^(.+)\\.kt$"), null, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("noParameterTypRefInCatch.kt")
|
|
||||||
public void testNoParameterTypRefInCatch() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/noParameterType/noParameterTypRefInCatch.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("noParameterTypRefInFuncionalType.kt")
|
|
||||||
public void testNoParameterTypRefInFuncionalType() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/noParameterType/noParameterTypRefInFuncionalType.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("noParameterTypRefInFunction.kt")
|
|
||||||
public void testNoParameterTypRefInFunction() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/noParameterType/noParameterTypRefInFunction.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("noParameterTypRefInLambda.kt")
|
|
||||||
public void testNoParameterTypRefInLambda() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/noParameterType/noParameterTypRefInLambda.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("noParameterTypRefInPrimaryConstructor.kt")
|
|
||||||
public void testNoParameterTypRefInPrimaryConstructor() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/noParameterType/noParameterTypRefInPrimaryConstructor.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("noParameterTypRefInPrimaryConstructorWithVararg.kt")
|
|
||||||
public void testNoParameterTypRefInPrimaryConstructorWithVararg() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/noParameterType/noParameterTypRefInPrimaryConstructorWithVararg.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("noParameterTypRefInPrimaryConsturctorVal.kt")
|
|
||||||
public void testNoParameterTypRefInPrimaryConsturctorVal() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/noParameterType/noParameterTypRefInPrimaryConsturctorVal.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("noParameterTypRefInPrimaryConsturctorValWithVararg.kt")
|
|
||||||
public void testNoParameterTypRefInPrimaryConsturctorValWithVararg() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/noParameterType/noParameterTypRefInPrimaryConsturctorValWithVararg.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("noParameterTypRefInSecondaryConstructor.kt")
|
|
||||||
public void testNoParameterTypRefInSecondaryConstructor() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/noParameterType/noParameterTypRefInSecondaryConstructor.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("noParameterTypRefInSetter.kt")
|
|
||||||
public void testNoParameterTypRefInSetter() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/noParameterType/noParameterTypRefInSetter.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("uncompletedTypRefInPrimaryConstructorWithVararg.kt")
|
|
||||||
public void testUncompletedTypRefInPrimaryConstructorWithVararg() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/noParameterType/uncompletedTypRefInPrimaryConstructorWithVararg.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("uncompletedTypRefInPrimaryConsturctorValWithVararg.kt")
|
|
||||||
public void testUncompletedTypRefInPrimaryConsturctorValWithVararg() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/noParameterType/uncompletedTypRefInPrimaryConsturctorValWithVararg.kt");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nested
|
|
||||||
@TestMetadata("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions")
|
|
||||||
@TestDataPath("$PROJECT_ROOT")
|
|
||||||
public class Expressions {
|
|
||||||
@Test
|
|
||||||
public void testAllFilesPresentInExpressions() throws Exception {
|
|
||||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions"), Pattern.compile("^(.+)\\.kt$"), null, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("annotated.kt")
|
|
||||||
public void testAnnotated() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/annotated.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("arrayAccess.kt")
|
|
||||||
public void testArrayAccess() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/arrayAccess.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("arrayAssignment.kt")
|
|
||||||
public void testArrayAssignment() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/arrayAssignment.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("branches.kt")
|
|
||||||
public void testBranches() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/branches.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("callableReferences.kt")
|
|
||||||
public void testCallableReferences() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/callableReferences.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("calls.kt")
|
|
||||||
public void testCalls() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/calls.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("cascadeIf.kt")
|
|
||||||
public void testCascadeIf() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/cascadeIf.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("classReference.kt")
|
|
||||||
public void testClassReference() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/classReference.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("collectionLiterals.kt")
|
|
||||||
public void testCollectionLiterals() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/collectionLiterals.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("destructuring.kt")
|
|
||||||
public void testDestructuring() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/destructuring.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("for.kt")
|
|
||||||
public void testFor() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/for.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("genericCalls.kt")
|
|
||||||
public void testGenericCalls() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/genericCalls.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("in.kt")
|
|
||||||
public void testIn() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/in.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("inBrackets.kt")
|
|
||||||
public void testInBrackets() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/inBrackets.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("init.kt")
|
|
||||||
public void testInit() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/init.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("invalidWhen.kt")
|
|
||||||
public void testInvalidWhen() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/invalidWhen.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("labelForInfix.kt")
|
|
||||||
public void testLabelForInfix() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/labelForInfix.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("lambda.kt")
|
|
||||||
public void testLambda() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/lambda.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("lambdaAndAnonymousFunction.kt")
|
|
||||||
public void testLambdaAndAnonymousFunction() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/lambdaAndAnonymousFunction.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("localDeclarationWithExpression.kt")
|
|
||||||
public void testLocalDeclarationWithExpression() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/localDeclarationWithExpression.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("locals.kt")
|
|
||||||
public void testLocals() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/locals.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("modifications.kt")
|
|
||||||
public void testModifications() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/modifications.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("namedArgument.kt")
|
|
||||||
public void testNamedArgument() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/namedArgument.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("nullability.kt")
|
|
||||||
public void testNullability() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/nullability.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("qualifierWithTypeArguments.kt")
|
|
||||||
public void testQualifierWithTypeArguments() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/qualifierWithTypeArguments.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("safeCallsWithAssignment.kt")
|
|
||||||
public void testSafeCallsWithAssignment() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/safeCallsWithAssignment.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("safeCallsWithAugmentedAssignment.kt")
|
|
||||||
public void testSafeCallsWithAugmentedAssignment() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/safeCallsWithAugmentedAssignment.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("safeCallsWithUnaryOperators.kt")
|
|
||||||
public void testSafeCallsWithUnaryOperators() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/safeCallsWithUnaryOperators.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("simpleReturns.kt")
|
|
||||||
public void testSimpleReturns() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/simpleReturns.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("super.kt")
|
|
||||||
public void testSuper() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/super.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("these.kt")
|
|
||||||
public void testThese() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/these.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("try.kt")
|
|
||||||
public void testTry() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/try.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("typeOperators.kt")
|
|
||||||
public void testTypeOperators() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/typeOperators.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("unary.kt")
|
|
||||||
public void testUnary() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/unary.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("variables.kt")
|
|
||||||
public void testVariables() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/variables.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("while.kt")
|
|
||||||
public void testWhile() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/while.kt");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-86
@@ -1,86 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
|
||||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jetbrains.kotlin.visualizer.fir;
|
|
||||||
|
|
||||||
import com.intellij.testFramework.TestDataPath;
|
|
||||||
import org.jetbrains.kotlin.test.util.KtTestUtil;
|
|
||||||
import org.jetbrains.kotlin.test.TestMetadata;
|
|
||||||
import org.junit.jupiter.api.Nested;
|
|
||||||
import org.junit.jupiter.api.Test;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.util.regex.Pattern;
|
|
||||||
|
|
||||||
/** This class is generated by {@link org.jetbrains.kotlin.test.generators.GenerateCompilerTestsKt}. DO NOT MODIFY MANUALLY */
|
|
||||||
@SuppressWarnings("all")
|
|
||||||
@TestMetadata("compiler/visualizer/testData/uncommonCases/testFiles")
|
|
||||||
@TestDataPath("$PROJECT_ROOT")
|
|
||||||
public class FirVisualizerForUncommonCasesGenerated extends AbstractFirVisualizerTest {
|
|
||||||
@Test
|
|
||||||
public void testAllFilesPresentInTestFiles() throws Exception {
|
|
||||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/visualizer/testData/uncommonCases/testFiles"), Pattern.compile("^(.+)\\.kt$"), null, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("dataClass.kt")
|
|
||||||
public void testDataClass() throws Exception {
|
|
||||||
runTest("compiler/visualizer/testData/uncommonCases/testFiles/dataClass.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("delegation.kt")
|
|
||||||
public void testDelegation() throws Exception {
|
|
||||||
runTest("compiler/visualizer/testData/uncommonCases/testFiles/delegation.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("innerWith.kt")
|
|
||||||
public void testInnerWith() throws Exception {
|
|
||||||
runTest("compiler/visualizer/testData/uncommonCases/testFiles/innerWith.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("lists.kt")
|
|
||||||
public void testLists() throws Exception {
|
|
||||||
runTest("compiler/visualizer/testData/uncommonCases/testFiles/lists.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("overrideEquals.kt")
|
|
||||||
public void testOverrideEquals() throws Exception {
|
|
||||||
runTest("compiler/visualizer/testData/uncommonCases/testFiles/overrideEquals.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("properties.kt")
|
|
||||||
public void testProperties() throws Exception {
|
|
||||||
runTest("compiler/visualizer/testData/uncommonCases/testFiles/properties.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("receiver.kt")
|
|
||||||
public void testReceiver() throws Exception {
|
|
||||||
runTest("compiler/visualizer/testData/uncommonCases/testFiles/receiver.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("superTypes.kt")
|
|
||||||
public void testSuperTypes() throws Exception {
|
|
||||||
runTest("compiler/visualizer/testData/uncommonCases/testFiles/superTypes.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("variance.kt")
|
|
||||||
public void testVariance() throws Exception {
|
|
||||||
runTest("compiler/visualizer/testData/uncommonCases/testFiles/variance.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("where.kt")
|
|
||||||
public void testWhere() throws Exception {
|
|
||||||
runTest("compiler/visualizer/testData/uncommonCases/testFiles/where.kt");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-668
@@ -1,668 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
|
||||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jetbrains.kotlin.visualizer.psi;
|
|
||||||
|
|
||||||
import com.intellij.testFramework.TestDataPath;
|
|
||||||
import org.jetbrains.kotlin.test.util.KtTestUtil;
|
|
||||||
import org.jetbrains.kotlin.test.TestMetadata;
|
|
||||||
import org.junit.jupiter.api.Nested;
|
|
||||||
import org.junit.jupiter.api.Test;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.util.regex.Pattern;
|
|
||||||
|
|
||||||
/** This class is generated by {@link org.jetbrains.kotlin.test.generators.GenerateCompilerTestsKt}. DO NOT MODIFY MANUALLY */
|
|
||||||
@SuppressWarnings("all")
|
|
||||||
@TestMetadata("compiler/fir/raw-fir/psi2fir/testData/rawBuilder")
|
|
||||||
@TestDataPath("$PROJECT_ROOT")
|
|
||||||
public class PsiVisualizerForRawFirDataGenerated extends AbstractPsiVisualizerTest {
|
|
||||||
@Test
|
|
||||||
public void testAllFilesPresentInRawBuilder() throws Exception {
|
|
||||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/raw-fir/psi2fir/testData/rawBuilder"), Pattern.compile("^(.+)\\.kt$"), null, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nested
|
|
||||||
@TestMetadata("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations")
|
|
||||||
@TestDataPath("$PROJECT_ROOT")
|
|
||||||
public class Declarations {
|
|
||||||
@Test
|
|
||||||
public void testAllFilesPresentInDeclarations() throws Exception {
|
|
||||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations"), Pattern.compile("^(.+)\\.kt$"), null, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("annotation.kt")
|
|
||||||
public void testAnnotation() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/annotation.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("annotationOnField.kt")
|
|
||||||
public void testAnnotationOnField() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/annotationOnField.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("annotationOnProperty.kt")
|
|
||||||
public void testAnnotationOnProperty() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/annotationOnProperty.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("annotationsOnNullableParenthesizedTypes.kt")
|
|
||||||
public void testAnnotationsOnNullableParenthesizedTypes() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/annotationsOnNullableParenthesizedTypes.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("annotationsOnParenthesizedTypes.kt")
|
|
||||||
public void testAnnotationsOnParenthesizedTypes() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/annotationsOnParenthesizedTypes.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("classWithWrongSuperCall.kt")
|
|
||||||
public void testClassWithWrongSuperCall() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/classWithWrongSuperCall.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("complexTypes.kt")
|
|
||||||
public void testComplexTypes() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/complexTypes.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("constructorInObject.kt")
|
|
||||||
public void testConstructorInObject() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/constructorInObject.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("constructorOfAnonymousObject.kt")
|
|
||||||
public void testConstructorOfAnonymousObject() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/constructorOfAnonymousObject.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("contextReceivers.kt")
|
|
||||||
public void testContextReceivers() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/contextReceivers.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("danglingAnnotationsClassLevel.kt")
|
|
||||||
public void testDanglingAnnotationsClassLevel() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/danglingAnnotationsClassLevel.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("danglingAnnotationsFileLevel.kt")
|
|
||||||
public void testDanglingAnnotationsFileLevel() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/danglingAnnotationsFileLevel.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("delegates.kt")
|
|
||||||
public void testDelegates() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/delegates.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("derivedClass.kt")
|
|
||||||
public void testDerivedClass() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/derivedClass.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("emptyAnonymousObject.kt")
|
|
||||||
public void testEmptyAnonymousObject() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/emptyAnonymousObject.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("enums.kt")
|
|
||||||
public void testEnums() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/enums.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("enums2.kt")
|
|
||||||
public void testEnums2() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/enums2.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("enums3.kt")
|
|
||||||
public void testEnums3() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/enums3.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("expectActual.kt")
|
|
||||||
public void testExpectActual() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/expectActual.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("expectClassesAndFunctions.kt")
|
|
||||||
public void testExpectClassesAndFunctions() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/expectClassesAndFunctions.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("expectNestedAnnotationClassWithConstructorParameter.kt")
|
|
||||||
public void testExpectNestedAnnotationClassWithConstructorParameter() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/expectNestedAnnotationClassWithConstructorParameter.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("expectNestedClassMembers.kt")
|
|
||||||
public void testExpectNestedClassMembers() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/expectNestedClassMembers.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("expectNestedEnumClassGeneratedMembers.kt")
|
|
||||||
public void testExpectNestedEnumClassGeneratedMembers() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/expectNestedEnumClassGeneratedMembers.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("external.kt")
|
|
||||||
public void testExternal() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/external.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("F.kt")
|
|
||||||
public void testF() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/F.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("functionTypes.kt")
|
|
||||||
public void testFunctionTypes() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/functionTypes.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("genericFunctions.kt")
|
|
||||||
public void testGenericFunctions() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/genericFunctions.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("genericProperty.kt")
|
|
||||||
public void testGenericProperty() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/genericProperty.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("initBlockWithDeclarations.kt")
|
|
||||||
public void testInitBlockWithDeclarations() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/initBlockWithDeclarations.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("invalidDestructing.kt")
|
|
||||||
public void testInvalidDestructing() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/invalidDestructing.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("nestedClass.kt")
|
|
||||||
public void testNestedClass() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/nestedClass.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("NestedOfAliasedType.kt")
|
|
||||||
public void testNestedOfAliasedType() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/NestedOfAliasedType.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("NestedSuperType.kt")
|
|
||||||
public void testNestedSuperType() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/NestedSuperType.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("noPrimaryConstructor.kt")
|
|
||||||
public void testNoPrimaryConstructor() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/noPrimaryConstructor.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("propertyWithBackingField.kt")
|
|
||||||
public void testPropertyWithBackingField() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/propertyWithBackingField.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("propertyWithBackingFieldDifferentTypes.kt")
|
|
||||||
public void testPropertyWithBackingFieldDifferentTypes() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/propertyWithBackingFieldDifferentTypes.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("simpleClass.kt")
|
|
||||||
public void testSimpleClass() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/simpleClass.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("simpleFun.kt")
|
|
||||||
public void testSimpleFun() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/simpleFun.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("simpleTypeAlias.kt")
|
|
||||||
public void testSimpleTypeAlias() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/simpleTypeAlias.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("splitModifierList.kt")
|
|
||||||
public void testSplitModifierList() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/splitModifierList.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("suspendFunctionTypes.kt")
|
|
||||||
public void testSuspendFunctionTypes() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/suspendFunctionTypes.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("typeAliasWithGeneric.kt")
|
|
||||||
public void testTypeAliasWithGeneric() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/typeAliasWithGeneric.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("typeParameterVsNested.kt")
|
|
||||||
public void testTypeParameterVsNested() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/typeParameterVsNested.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("typeParameters.kt")
|
|
||||||
public void testTypeParameters() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/typeParameters.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("where.kt")
|
|
||||||
public void testWhere() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/where.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nested
|
|
||||||
@TestMetadata("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/contracts")
|
|
||||||
@TestDataPath("$PROJECT_ROOT")
|
|
||||||
public class Contracts {
|
|
||||||
@Test
|
|
||||||
public void testAllFilesPresentInContracts() throws Exception {
|
|
||||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/contracts"), Pattern.compile("^(.+)\\.kt$"), null, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nested
|
|
||||||
@TestMetadata("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/contracts/newSyntax")
|
|
||||||
@TestDataPath("$PROJECT_ROOT")
|
|
||||||
public class NewSyntax {
|
|
||||||
@Test
|
|
||||||
public void testAllFilesPresentInNewSyntax() throws Exception {
|
|
||||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/contracts/newSyntax"), Pattern.compile("^(.+)\\.kt$"), null, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("functionWithBothOldAndNewSyntaxContractDescription.kt")
|
|
||||||
public void testFunctionWithBothOldAndNewSyntaxContractDescription() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/contracts/newSyntax/functionWithBothOldAndNewSyntaxContractDescription.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("propertyAccessorsContractDescription.kt")
|
|
||||||
public void testPropertyAccessorsContractDescription() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/contracts/newSyntax/propertyAccessorsContractDescription.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("simpleFunctionsContractDescription.kt")
|
|
||||||
public void testSimpleFunctionsContractDescription() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/contracts/newSyntax/simpleFunctionsContractDescription.kt");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nested
|
|
||||||
@TestMetadata("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/contracts/oldSyntax")
|
|
||||||
@TestDataPath("$PROJECT_ROOT")
|
|
||||||
public class OldSyntax {
|
|
||||||
@Test
|
|
||||||
public void testAllFilesPresentInOldSyntax() throws Exception {
|
|
||||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/contracts/oldSyntax"), Pattern.compile("^(.+)\\.kt$"), null, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("contractDescription.kt")
|
|
||||||
public void testContractDescription() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/contracts/oldSyntax/contractDescription.kt");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nested
|
|
||||||
@TestMetadata("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/noParameterType")
|
|
||||||
@TestDataPath("$PROJECT_ROOT")
|
|
||||||
public class NoParameterType {
|
|
||||||
@Test
|
|
||||||
public void testAllFilesPresentInNoParameterType() throws Exception {
|
|
||||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/noParameterType"), Pattern.compile("^(.+)\\.kt$"), null, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("noParameterTypRefInCatch.kt")
|
|
||||||
public void testNoParameterTypRefInCatch() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/noParameterType/noParameterTypRefInCatch.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("noParameterTypRefInFuncionalType.kt")
|
|
||||||
public void testNoParameterTypRefInFuncionalType() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/noParameterType/noParameterTypRefInFuncionalType.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("noParameterTypRefInFunction.kt")
|
|
||||||
public void testNoParameterTypRefInFunction() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/noParameterType/noParameterTypRefInFunction.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("noParameterTypRefInLambda.kt")
|
|
||||||
public void testNoParameterTypRefInLambda() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/noParameterType/noParameterTypRefInLambda.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("noParameterTypRefInPrimaryConstructor.kt")
|
|
||||||
public void testNoParameterTypRefInPrimaryConstructor() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/noParameterType/noParameterTypRefInPrimaryConstructor.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("noParameterTypRefInPrimaryConstructorWithVararg.kt")
|
|
||||||
public void testNoParameterTypRefInPrimaryConstructorWithVararg() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/noParameterType/noParameterTypRefInPrimaryConstructorWithVararg.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("noParameterTypRefInPrimaryConsturctorVal.kt")
|
|
||||||
public void testNoParameterTypRefInPrimaryConsturctorVal() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/noParameterType/noParameterTypRefInPrimaryConsturctorVal.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("noParameterTypRefInPrimaryConsturctorValWithVararg.kt")
|
|
||||||
public void testNoParameterTypRefInPrimaryConsturctorValWithVararg() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/noParameterType/noParameterTypRefInPrimaryConsturctorValWithVararg.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("noParameterTypRefInSecondaryConstructor.kt")
|
|
||||||
public void testNoParameterTypRefInSecondaryConstructor() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/noParameterType/noParameterTypRefInSecondaryConstructor.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("noParameterTypRefInSetter.kt")
|
|
||||||
public void testNoParameterTypRefInSetter() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/noParameterType/noParameterTypRefInSetter.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("uncompletedTypRefInPrimaryConstructorWithVararg.kt")
|
|
||||||
public void testUncompletedTypRefInPrimaryConstructorWithVararg() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/noParameterType/uncompletedTypRefInPrimaryConstructorWithVararg.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("uncompletedTypRefInPrimaryConsturctorValWithVararg.kt")
|
|
||||||
public void testUncompletedTypRefInPrimaryConsturctorValWithVararg() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/noParameterType/uncompletedTypRefInPrimaryConsturctorValWithVararg.kt");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Nested
|
|
||||||
@TestMetadata("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions")
|
|
||||||
@TestDataPath("$PROJECT_ROOT")
|
|
||||||
public class Expressions {
|
|
||||||
@Test
|
|
||||||
public void testAllFilesPresentInExpressions() throws Exception {
|
|
||||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions"), Pattern.compile("^(.+)\\.kt$"), null, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("annotated.kt")
|
|
||||||
public void testAnnotated() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/annotated.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("arrayAccess.kt")
|
|
||||||
public void testArrayAccess() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/arrayAccess.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("arrayAssignment.kt")
|
|
||||||
public void testArrayAssignment() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/arrayAssignment.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("branches.kt")
|
|
||||||
public void testBranches() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/branches.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("callableReferences.kt")
|
|
||||||
public void testCallableReferences() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/callableReferences.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("calls.kt")
|
|
||||||
public void testCalls() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/calls.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("cascadeIf.kt")
|
|
||||||
public void testCascadeIf() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/cascadeIf.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("classReference.kt")
|
|
||||||
public void testClassReference() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/classReference.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("collectionLiterals.kt")
|
|
||||||
public void testCollectionLiterals() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/collectionLiterals.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("destructuring.kt")
|
|
||||||
public void testDestructuring() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/destructuring.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("for.kt")
|
|
||||||
public void testFor() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/for.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("genericCalls.kt")
|
|
||||||
public void testGenericCalls() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/genericCalls.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("in.kt")
|
|
||||||
public void testIn() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/in.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("inBrackets.kt")
|
|
||||||
public void testInBrackets() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/inBrackets.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("init.kt")
|
|
||||||
public void testInit() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/init.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("invalidWhen.kt")
|
|
||||||
public void testInvalidWhen() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/invalidWhen.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("labelForInfix.kt")
|
|
||||||
public void testLabelForInfix() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/labelForInfix.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("lambda.kt")
|
|
||||||
public void testLambda() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/lambda.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("lambdaAndAnonymousFunction.kt")
|
|
||||||
public void testLambdaAndAnonymousFunction() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/lambdaAndAnonymousFunction.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("localDeclarationWithExpression.kt")
|
|
||||||
public void testLocalDeclarationWithExpression() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/localDeclarationWithExpression.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("locals.kt")
|
|
||||||
public void testLocals() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/locals.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("modifications.kt")
|
|
||||||
public void testModifications() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/modifications.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("namedArgument.kt")
|
|
||||||
public void testNamedArgument() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/namedArgument.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("nullability.kt")
|
|
||||||
public void testNullability() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/nullability.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("qualifierWithTypeArguments.kt")
|
|
||||||
public void testQualifierWithTypeArguments() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/qualifierWithTypeArguments.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("safeCallsWithAssignment.kt")
|
|
||||||
public void testSafeCallsWithAssignment() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/safeCallsWithAssignment.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("safeCallsWithAugmentedAssignment.kt")
|
|
||||||
public void testSafeCallsWithAugmentedAssignment() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/safeCallsWithAugmentedAssignment.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("safeCallsWithUnaryOperators.kt")
|
|
||||||
public void testSafeCallsWithUnaryOperators() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/safeCallsWithUnaryOperators.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("simpleReturns.kt")
|
|
||||||
public void testSimpleReturns() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/simpleReturns.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("super.kt")
|
|
||||||
public void testSuper() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/super.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("these.kt")
|
|
||||||
public void testThese() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/these.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("try.kt")
|
|
||||||
public void testTry() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/try.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("typeOperators.kt")
|
|
||||||
public void testTypeOperators() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/typeOperators.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("unary.kt")
|
|
||||||
public void testUnary() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/unary.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("variables.kt")
|
|
||||||
public void testVariables() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/variables.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("while.kt")
|
|
||||||
public void testWhile() throws Exception {
|
|
||||||
runTest("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/while.kt");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-86
@@ -1,86 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2023 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
|
||||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jetbrains.kotlin.visualizer.psi;
|
|
||||||
|
|
||||||
import com.intellij.testFramework.TestDataPath;
|
|
||||||
import org.jetbrains.kotlin.test.util.KtTestUtil;
|
|
||||||
import org.jetbrains.kotlin.test.TestMetadata;
|
|
||||||
import org.junit.jupiter.api.Nested;
|
|
||||||
import org.junit.jupiter.api.Test;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.util.regex.Pattern;
|
|
||||||
|
|
||||||
/** This class is generated by {@link org.jetbrains.kotlin.test.generators.GenerateCompilerTestsKt}. DO NOT MODIFY MANUALLY */
|
|
||||||
@SuppressWarnings("all")
|
|
||||||
@TestMetadata("compiler/visualizer/testData/uncommonCases/testFiles")
|
|
||||||
@TestDataPath("$PROJECT_ROOT")
|
|
||||||
public class PsiVisualizerForUncommonCasesGenerated extends AbstractPsiVisualizerTest {
|
|
||||||
@Test
|
|
||||||
public void testAllFilesPresentInTestFiles() throws Exception {
|
|
||||||
KtTestUtil.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/visualizer/testData/uncommonCases/testFiles"), Pattern.compile("^(.+)\\.kt$"), null, true);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("dataClass.kt")
|
|
||||||
public void testDataClass() throws Exception {
|
|
||||||
runTest("compiler/visualizer/testData/uncommonCases/testFiles/dataClass.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("delegation.kt")
|
|
||||||
public void testDelegation() throws Exception {
|
|
||||||
runTest("compiler/visualizer/testData/uncommonCases/testFiles/delegation.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("innerWith.kt")
|
|
||||||
public void testInnerWith() throws Exception {
|
|
||||||
runTest("compiler/visualizer/testData/uncommonCases/testFiles/innerWith.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("lists.kt")
|
|
||||||
public void testLists() throws Exception {
|
|
||||||
runTest("compiler/visualizer/testData/uncommonCases/testFiles/lists.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("overrideEquals.kt")
|
|
||||||
public void testOverrideEquals() throws Exception {
|
|
||||||
runTest("compiler/visualizer/testData/uncommonCases/testFiles/overrideEquals.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("properties.kt")
|
|
||||||
public void testProperties() throws Exception {
|
|
||||||
runTest("compiler/visualizer/testData/uncommonCases/testFiles/properties.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("receiver.kt")
|
|
||||||
public void testReceiver() throws Exception {
|
|
||||||
runTest("compiler/visualizer/testData/uncommonCases/testFiles/receiver.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("superTypes.kt")
|
|
||||||
public void testSuperTypes() throws Exception {
|
|
||||||
runTest("compiler/visualizer/testData/uncommonCases/testFiles/superTypes.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("variance.kt")
|
|
||||||
public void testVariance() throws Exception {
|
|
||||||
runTest("compiler/visualizer/testData/uncommonCases/testFiles/variance.kt");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
@TestMetadata("where.kt")
|
|
||||||
public void testWhere() throws Exception {
|
|
||||||
runTest("compiler/visualizer/testData/uncommonCases/testFiles/where.kt");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
-91
@@ -1,91 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
|
||||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jetbrains.kotlin.visualizer
|
|
||||||
|
|
||||||
import org.jetbrains.kotlin.compiler.visualizer.FirVisualizer
|
|
||||||
import org.jetbrains.kotlin.compiler.visualizer.PsiVisualizer
|
|
||||||
import org.jetbrains.kotlin.platform.jvm.JvmPlatforms
|
|
||||||
import org.jetbrains.kotlin.test.Constructor
|
|
||||||
import org.jetbrains.kotlin.test.TestConfiguration
|
|
||||||
import org.jetbrains.kotlin.test.TestRunner
|
|
||||||
import org.jetbrains.kotlin.test.builders.testConfiguration
|
|
||||||
import org.jetbrains.kotlin.test.directives.ConfigurationDirectives
|
|
||||||
import org.jetbrains.kotlin.test.frontend.classic.ClassicFrontendFacade
|
|
||||||
import org.jetbrains.kotlin.test.frontend.fir.FirFrontendFacade
|
|
||||||
import org.jetbrains.kotlin.test.model.*
|
|
||||||
import org.jetbrains.kotlin.test.runners.AbstractKotlinCompilerTest
|
|
||||||
import org.jetbrains.kotlin.test.services.*
|
|
||||||
import org.jetbrains.kotlin.test.services.configuration.CommonEnvironmentConfigurator
|
|
||||||
import org.jetbrains.kotlin.test.services.configuration.JvmEnvironmentConfigurator
|
|
||||||
import org.jetbrains.kotlin.test.services.impl.TemporaryDirectoryManagerImpl
|
|
||||||
import org.jetbrains.kotlin.test.services.sourceProviders.AdditionalDiagnosticsSourceFilesProvider
|
|
||||||
import org.jetbrains.kotlin.test.services.sourceProviders.CodegenHelpersSourceFilesProvider
|
|
||||||
import org.jetbrains.kotlin.test.services.sourceProviders.CoroutineHelpersSourceFilesProvider
|
|
||||||
|
|
||||||
abstract class AbstractVisualizerBlackBoxTest {
|
|
||||||
private fun <O : ResultingArtifact.FrontendOutput<O>> createConfiguration(
|
|
||||||
filePath: String,
|
|
||||||
frontendKind: FrontendKind<O>,
|
|
||||||
frontendFacade: Constructor<FrontendFacade<O>>
|
|
||||||
): TestConfiguration = testConfiguration(filePath) {
|
|
||||||
assertions = JUnit5Assertions
|
|
||||||
testInfo = KotlinTestInfo("_undefined_", "_testUndefined_", setOf())
|
|
||||||
startingArtifactFactory = { ResultingArtifact.Source() }
|
|
||||||
|
|
||||||
useAdditionalService<TemporaryDirectoryManager>(::TemporaryDirectoryManagerImpl)
|
|
||||||
useSourcePreprocessor(*AbstractKotlinCompilerTest.defaultPreprocessors.toTypedArray())
|
|
||||||
useDirectives(*AbstractKotlinCompilerTest.defaultDirectiveContainers.toTypedArray())
|
|
||||||
|
|
||||||
globalDefaults {
|
|
||||||
targetPlatform = JvmPlatforms.defaultJvmPlatform
|
|
||||||
dependencyKind = DependencyKind.Source
|
|
||||||
frontend = frontendKind
|
|
||||||
}
|
|
||||||
|
|
||||||
defaultDirectives {
|
|
||||||
+ConfigurationDirectives.WITH_STDLIB
|
|
||||||
}
|
|
||||||
|
|
||||||
useConfigurators(
|
|
||||||
::CommonEnvironmentConfigurator,
|
|
||||||
::JvmEnvironmentConfigurator,
|
|
||||||
)
|
|
||||||
|
|
||||||
useAdditionalSourceProviders(
|
|
||||||
::AdditionalDiagnosticsSourceFilesProvider,
|
|
||||||
::CoroutineHelpersSourceFilesProvider,
|
|
||||||
::CodegenHelpersSourceFilesProvider
|
|
||||||
)
|
|
||||||
|
|
||||||
facadeStep(frontendFacade)
|
|
||||||
}
|
|
||||||
|
|
||||||
fun runTest(filePath: String) {
|
|
||||||
lateinit var psiRenderResult: String
|
|
||||||
lateinit var firRenderResult: String
|
|
||||||
|
|
||||||
val psiConfiguration = createConfiguration(filePath, FrontendKinds.ClassicFrontend, ::ClassicFrontendFacade)
|
|
||||||
TestRunner(psiConfiguration).runTest(filePath) { testConfiguration ->
|
|
||||||
testConfiguration.testServices.moduleStructure.modules.forEach { psiModule ->
|
|
||||||
val psiArtifact = testConfiguration.testServices.dependencyProvider.getArtifact(psiModule, FrontendKinds.ClassicFrontend)
|
|
||||||
val psiRenderer = psiArtifact.ktFiles.values.firstOrNull()?.let { PsiVisualizer(it, psiArtifact.analysisResult) }
|
|
||||||
psiRenderResult = psiRenderer?.render()?.trim() ?: ""
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
val firConfiguration = createConfiguration(filePath, FrontendKinds.FIR, ::FirFrontendFacade)
|
|
||||||
TestRunner(firConfiguration).runTest(filePath) { testConfiguration ->
|
|
||||||
testConfiguration.testServices.moduleStructure.modules.forEach { firModule ->
|
|
||||||
val firArtifact = testConfiguration.testServices.dependencyProvider.getArtifact(firModule, FrontendKinds.FIR)
|
|
||||||
val firRenderer = firArtifact.mainFirFiles.values.firstOrNull()?.let { FirVisualizer(it) }
|
|
||||||
firRenderResult = firRenderer?.render()?.trim() ?: ""
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
psiConfiguration.testServices.assertions.assertEquals(psiRenderResult, firRenderResult)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1,69 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
|
||||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package org.jetbrains.kotlin.visualizer
|
|
||||||
|
|
||||||
import org.jetbrains.kotlin.platform.jvm.JvmPlatforms
|
|
||||||
import org.jetbrains.kotlin.test.Constructor
|
|
||||||
import org.jetbrains.kotlin.test.builders.TestConfigurationBuilder
|
|
||||||
import org.jetbrains.kotlin.test.directives.ConfigurationDirectives
|
|
||||||
import org.jetbrains.kotlin.test.frontend.classic.ClassicFrontendFacade
|
|
||||||
import org.jetbrains.kotlin.test.frontend.fir.FirFrontendFacade
|
|
||||||
import org.jetbrains.kotlin.test.model.DependencyKind
|
|
||||||
import org.jetbrains.kotlin.test.model.FrontendKind
|
|
||||||
import org.jetbrains.kotlin.test.model.FrontendOutputHandler
|
|
||||||
import org.jetbrains.kotlin.test.runners.AbstractKotlinCompilerTest
|
|
||||||
import org.jetbrains.kotlin.test.services.configuration.CommonEnvironmentConfigurator
|
|
||||||
import org.jetbrains.kotlin.test.services.configuration.JvmEnvironmentConfigurator
|
|
||||||
|
|
||||||
abstract class AbstractVisualizerTest : AbstractKotlinCompilerTest() {
|
|
||||||
abstract val handler: Constructor<FrontendOutputHandler<*>>
|
|
||||||
abstract val frontendKind: FrontendKind<*>
|
|
||||||
|
|
||||||
override fun TestConfigurationBuilder.configuration() {
|
|
||||||
globalDefaults {
|
|
||||||
frontend = frontendKind
|
|
||||||
targetPlatform = JvmPlatforms.defaultJvmPlatform
|
|
||||||
dependencyKind = DependencyKind.Source
|
|
||||||
}
|
|
||||||
|
|
||||||
useConfigurators(
|
|
||||||
::CommonEnvironmentConfigurator,
|
|
||||||
::JvmEnvironmentConfigurator,
|
|
||||||
)
|
|
||||||
// TODO
|
|
||||||
// useFrontendFacades(
|
|
||||||
// ::FirFrontendFacade,
|
|
||||||
// ::ClassicFrontendFacade
|
|
||||||
// )
|
|
||||||
// useFrontendHandlers(handler)
|
|
||||||
|
|
||||||
defaultDirectives {
|
|
||||||
+ConfigurationDirectives.WITH_STDLIB
|
|
||||||
}
|
|
||||||
|
|
||||||
forTestsMatching("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/declarations/*") {
|
|
||||||
defaultDirectives {
|
|
||||||
VisualizerDirectives.TEST_FILE_PATH with "fir/raw-fir/psi2fir"
|
|
||||||
VisualizerDirectives.EXPECTED_FILE_PATH with "visualizer"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
forTestsMatching("compiler/fir/raw-fir/psi2fir/testData/rawBuilder/expressions/*") {
|
|
||||||
defaultDirectives {
|
|
||||||
VisualizerDirectives.TEST_FILE_PATH with "fir/raw-fir/psi2fir"
|
|
||||||
VisualizerDirectives.EXPECTED_FILE_PATH with "visualizer"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
forTestsMatching("compiler/visualizer/testData/uncommonCases/*") {
|
|
||||||
defaultDirectives {
|
|
||||||
VisualizerDirectives.TEST_FILE_PATH with "uncommonCases/testFiles"
|
|
||||||
VisualizerDirectives.EXPECTED_FILE_PATH with "uncommonCases/resultFiles"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user