FIR: Fix visitors/transformers and testData
This commit is contained in:
@@ -49,7 +49,7 @@ FILE: access.kt
|
||||
lval a: R|kotlin/Int| = Int(10)
|
||||
lval b: R|kotlin/Int| = R|<local>/a|
|
||||
lval d: R|kotlin/String| = String()
|
||||
lval c: <ERROR TYPE: Unresolved name: c> = <Unresolved name: c>#
|
||||
lval c: <ERROR TYPE REF: Unresolved name: c> = <Unresolved name: c>#
|
||||
<Unresolved name: abc>#()
|
||||
public final fun bcd(): R|kotlin/Unit| {
|
||||
}
|
||||
|
||||
@@ -10,7 +10,7 @@ FILE: dispatchReceiver.kt
|
||||
public get(): R|Base|
|
||||
public set(value: R|Base|): R|kotlin/Unit|
|
||||
|
||||
public final fun check(): <ERROR TYPE: cycle> {
|
||||
public final fun check(): <ERROR TYPE REF: cycle> {
|
||||
^check R|/My.delegate|.R|/My.check|()
|
||||
}
|
||||
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
FILE: localImplicitBodies.kt
|
||||
public final fun foo(): R|kotlin/Unit| {
|
||||
lval x: <ERROR TYPE: No result type for initializer> = object : {
|
||||
lval x: <ERROR TYPE REF: No result type for initializer> = object : {
|
||||
public constructor(): super<R|kotlin/Any|>()
|
||||
|
||||
public final fun sss(): <ERROR TYPE: Unresolved name: abc> {
|
||||
public final fun sss(): <ERROR TYPE REF: Unresolved name: abc> {
|
||||
^sss <Unresolved name: abc>#()
|
||||
}
|
||||
|
||||
@@ -13,5 +13,5 @@ FILE: localImplicitBodies.kt
|
||||
|
||||
}
|
||||
|
||||
lval g: <ERROR TYPE: Unresolved name: abc> = R|<local>/x|.R|/sss|()
|
||||
lval g: <ERROR TYPE REF: Unresolved name: abc> = R|<local>/x|.R|/sss|()
|
||||
}
|
||||
|
||||
@@ -661,7 +661,7 @@ class FirRenderer(builder: StringBuilder) : FirVisitorVoid() {
|
||||
|
||||
override fun visitErrorTypeRef(errorTypeRef: FirErrorTypeRef) {
|
||||
visitTypeRef(errorTypeRef)
|
||||
print("<ERROR TYPE: ${errorTypeRef.reason}>")
|
||||
print("<ERROR TYPE REF: ${errorTypeRef.reason}>")
|
||||
}
|
||||
|
||||
override fun visitImplicitTypeRef(implicitTypeRef: FirImplicitTypeRef) {
|
||||
@@ -702,7 +702,6 @@ class FirRenderer(builder: StringBuilder) : FirVisitorVoid() {
|
||||
}
|
||||
|
||||
|
||||
|
||||
override fun visitResolvedTypeRef(resolvedTypeRef: FirResolvedTypeRef) {
|
||||
resolvedTypeRef.annotations.renderAnnotations()
|
||||
print("R|")
|
||||
|
||||
+8
-8
@@ -28,6 +28,10 @@ abstract class FirTransformer<in D> : FirVisitor<CompositeTransformResult<FirEle
|
||||
return transformDeclaration(callableDeclaration, data)
|
||||
}
|
||||
|
||||
open fun transformCallableMemberDeclaration(callableMemberDeclaration: FirCallableMemberDeclaration, data: D): CompositeTransformResult<FirDeclaration> {
|
||||
return transformDeclaration(callableMemberDeclaration, data)
|
||||
}
|
||||
|
||||
open fun transformDeclarationWithBody(declarationWithBody: FirDeclarationWithBody, data: D): CompositeTransformResult<FirDeclaration> {
|
||||
return transformDeclaration(declarationWithBody, data)
|
||||
}
|
||||
@@ -76,10 +80,6 @@ abstract class FirTransformer<in D> : FirVisitor<CompositeTransformResult<FirEle
|
||||
return transformNamedDeclaration(memberDeclaration, data)
|
||||
}
|
||||
|
||||
open fun transformCallableMemberDeclaration(callableMemberDeclaration: FirCallableMemberDeclaration, data: D): CompositeTransformResult<FirDeclaration> {
|
||||
return transformMemberDeclaration(callableMemberDeclaration, data)
|
||||
}
|
||||
|
||||
open fun transformClassLikeDeclaration(classLikeDeclaration: FirClassLikeDeclaration, data: D): CompositeTransformResult<FirDeclaration> {
|
||||
return transformMemberDeclaration(classLikeDeclaration, data)
|
||||
}
|
||||
@@ -340,10 +340,6 @@ abstract class FirTransformer<in D> : FirVisitor<CompositeTransformResult<FirEle
|
||||
return transformTypeRef(delegatedTypeRef, data)
|
||||
}
|
||||
|
||||
open fun transformErrorTypeRef(errorTypeRef: FirErrorTypeRef, data: D): CompositeTransformResult<FirTypeRef> {
|
||||
return transformTypeRef(errorTypeRef, data)
|
||||
}
|
||||
|
||||
open fun transformImplicitTypeRef(implicitTypeRef: FirImplicitTypeRef, data: D): CompositeTransformResult<FirTypeRef> {
|
||||
return transformTypeRef(implicitTypeRef, data)
|
||||
}
|
||||
@@ -364,6 +360,10 @@ abstract class FirTransformer<in D> : FirVisitor<CompositeTransformResult<FirEle
|
||||
return transformTypeRefWithNullability(resolvedTypeRef, data)
|
||||
}
|
||||
|
||||
open fun transformErrorTypeRef(errorTypeRef: FirErrorTypeRef, data: D): CompositeTransformResult<FirTypeRef> {
|
||||
return transformResolvedTypeRef(errorTypeRef, data)
|
||||
}
|
||||
|
||||
open fun transformResolvedFunctionTypeRef(resolvedFunctionTypeRef: FirResolvedFunctionTypeRef, data: D): CompositeTransformResult<FirTypeRef> {
|
||||
return transformResolvedTypeRef(resolvedFunctionTypeRef, data)
|
||||
}
|
||||
|
||||
@@ -28,6 +28,10 @@ abstract class FirVisitor<out R, in D> {
|
||||
return visitDeclaration(callableDeclaration, data)
|
||||
}
|
||||
|
||||
open fun visitCallableMemberDeclaration(callableMemberDeclaration: FirCallableMemberDeclaration, data: D): R {
|
||||
return visitDeclaration(callableMemberDeclaration, data)
|
||||
}
|
||||
|
||||
open fun visitDeclarationWithBody(declarationWithBody: FirDeclarationWithBody, data: D): R {
|
||||
return visitDeclaration(declarationWithBody, data)
|
||||
}
|
||||
@@ -76,10 +80,6 @@ abstract class FirVisitor<out R, in D> {
|
||||
return visitNamedDeclaration(memberDeclaration, data)
|
||||
}
|
||||
|
||||
open fun visitCallableMemberDeclaration(callableMemberDeclaration: FirCallableMemberDeclaration, data: D): R {
|
||||
return visitMemberDeclaration(callableMemberDeclaration, data)
|
||||
}
|
||||
|
||||
open fun visitClassLikeDeclaration(classLikeDeclaration: FirClassLikeDeclaration, data: D): R {
|
||||
return visitMemberDeclaration(classLikeDeclaration, data)
|
||||
}
|
||||
@@ -340,10 +340,6 @@ abstract class FirVisitor<out R, in D> {
|
||||
return visitTypeRef(delegatedTypeRef, data)
|
||||
}
|
||||
|
||||
open fun visitErrorTypeRef(errorTypeRef: FirErrorTypeRef, data: D): R {
|
||||
return visitTypeRef(errorTypeRef, data)
|
||||
}
|
||||
|
||||
open fun visitImplicitTypeRef(implicitTypeRef: FirImplicitTypeRef, data: D): R {
|
||||
return visitTypeRef(implicitTypeRef, data)
|
||||
}
|
||||
@@ -364,6 +360,10 @@ abstract class FirVisitor<out R, in D> {
|
||||
return visitTypeRefWithNullability(resolvedTypeRef, data)
|
||||
}
|
||||
|
||||
open fun visitErrorTypeRef(errorTypeRef: FirErrorTypeRef, data: D): R {
|
||||
return visitResolvedTypeRef(errorTypeRef, data)
|
||||
}
|
||||
|
||||
open fun visitResolvedFunctionTypeRef(resolvedFunctionTypeRef: FirResolvedFunctionTypeRef, data: D): R {
|
||||
return visitResolvedTypeRef(resolvedFunctionTypeRef, data)
|
||||
}
|
||||
|
||||
+8
-8
@@ -28,6 +28,10 @@ abstract class FirVisitorVoid : FirVisitor<Unit, Nothing?>() {
|
||||
visitDeclaration(callableDeclaration, null)
|
||||
}
|
||||
|
||||
open fun visitCallableMemberDeclaration(callableMemberDeclaration: FirCallableMemberDeclaration) {
|
||||
visitDeclaration(callableMemberDeclaration, null)
|
||||
}
|
||||
|
||||
open fun visitDeclarationWithBody(declarationWithBody: FirDeclarationWithBody) {
|
||||
visitDeclaration(declarationWithBody, null)
|
||||
}
|
||||
@@ -76,10 +80,6 @@ abstract class FirVisitorVoid : FirVisitor<Unit, Nothing?>() {
|
||||
visitNamedDeclaration(memberDeclaration, null)
|
||||
}
|
||||
|
||||
open fun visitCallableMemberDeclaration(callableMemberDeclaration: FirCallableMemberDeclaration) {
|
||||
visitMemberDeclaration(callableMemberDeclaration, null)
|
||||
}
|
||||
|
||||
open fun visitClassLikeDeclaration(classLikeDeclaration: FirClassLikeDeclaration) {
|
||||
visitMemberDeclaration(classLikeDeclaration, null)
|
||||
}
|
||||
@@ -340,10 +340,6 @@ abstract class FirVisitorVoid : FirVisitor<Unit, Nothing?>() {
|
||||
visitTypeRef(delegatedTypeRef, null)
|
||||
}
|
||||
|
||||
open fun visitErrorTypeRef(errorTypeRef: FirErrorTypeRef) {
|
||||
visitTypeRef(errorTypeRef, null)
|
||||
}
|
||||
|
||||
open fun visitImplicitTypeRef(implicitTypeRef: FirImplicitTypeRef) {
|
||||
visitTypeRef(implicitTypeRef, null)
|
||||
}
|
||||
@@ -364,6 +360,10 @@ abstract class FirVisitorVoid : FirVisitor<Unit, Nothing?>() {
|
||||
visitTypeRefWithNullability(resolvedTypeRef, null)
|
||||
}
|
||||
|
||||
open fun visitErrorTypeRef(errorTypeRef: FirErrorTypeRef) {
|
||||
visitResolvedTypeRef(errorTypeRef, null)
|
||||
}
|
||||
|
||||
open fun visitResolvedFunctionTypeRef(resolvedFunctionTypeRef: FirResolvedFunctionTypeRef) {
|
||||
visitResolvedTypeRef(resolvedFunctionTypeRef, null)
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
package org.jetbrains.kotlin.fir
|
||||
|
||||
import com.intellij.openapi.fileEditor.FileDocumentManager
|
||||
import com.intellij.psi.PsiElement
|
||||
import org.jetbrains.kotlin.fir.declarations.FirFile
|
||||
import org.jetbrains.kotlin.fir.types.ConeClassErrorType
|
||||
import org.jetbrains.kotlin.fir.types.ConeKotlinErrorType
|
||||
@@ -71,12 +72,30 @@ fun doFirResolveTestBench(
|
||||
|
||||
firFiles.forEach {
|
||||
it.accept(object : FirVisitorVoid() {
|
||||
|
||||
fun reportProblem(problem: String, psi: PsiElement) {
|
||||
val document = try {
|
||||
fileDocumentManager.getDocument(psi.containingFile.virtualFile)
|
||||
} catch (t: Throwable) {
|
||||
throw Exception("for file ${psi.containingFile}", t)
|
||||
}
|
||||
val line = (document?.getLineNumber(psi.startOffset) ?: 0)
|
||||
val char = psi.startOffset - (document?.getLineStartOffset(line) ?: 0)
|
||||
val report = "u: ${psi.containingFile?.virtualFile?.path}: (${line + 1}:$char): $problem"
|
||||
errorTypesReports[problem] = report
|
||||
}
|
||||
override fun visitElement(element: FirElement) {
|
||||
element.acceptChildren(this)
|
||||
}
|
||||
|
||||
override fun visitTypeRef(typeRef: FirTypeRef) {
|
||||
unresolvedTypes++
|
||||
|
||||
if (typeRef.psi != null) {
|
||||
val psi = typeRef.psi!!
|
||||
val problem = typeRef.renderWithType()
|
||||
reportProblem(problem, psi)
|
||||
}
|
||||
}
|
||||
|
||||
override fun visitResolvedTypeRef(resolvedTypeRef: FirResolvedTypeRef) {
|
||||
@@ -88,16 +107,7 @@ fun doFirResolveTestBench(
|
||||
} else {
|
||||
val psi = resolvedTypeRef.psi!!
|
||||
val problem = "$type with psi `${psi.text}`"
|
||||
val document = try {
|
||||
fileDocumentManager.getDocument(psi.containingFile.virtualFile)
|
||||
} catch (t: Throwable) {
|
||||
throw Exception("for file ${psi.containingFile}", t)
|
||||
}
|
||||
val line = document?.getLineNumber(psi.startOffset) ?: 0
|
||||
val char = psi.startOffset - (document?.getLineStartOffset(line) ?: 0)
|
||||
val report = "e: ${psi.containingFile?.virtualFile?.path}: ($line:$char): $problem"
|
||||
errorTypesReports[problem] = report
|
||||
errorTypes++
|
||||
reportProblem(problem, psi)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user