FIR: partial function type resolve + some rendering fixes
This commit is contained in:
+5
@@ -25,6 +25,7 @@ import org.jetbrains.kotlin.name.FqName
|
||||
|
||||
open class FirTypeResolveTransformer : FirTransformer<Nothing?>() {
|
||||
override fun <E : FirElement> transformElement(element: E, data: Nothing?): CompositeTransformResult<E> {
|
||||
@Suppress("UNCHECKED_CAST")
|
||||
return (element.transformChildren(this, data) as E).compose()
|
||||
}
|
||||
|
||||
@@ -112,6 +113,10 @@ open class FirTypeResolveTransformer : FirTransformer<Nothing?>() {
|
||||
return transformType(type, typeResolver.resolveType(type, scope, position = FirPosition.OTHER))
|
||||
}
|
||||
|
||||
override fun transformFunctionType(functionType: FirFunctionType, data: Nothing?): CompositeTransformResult<FirType> {
|
||||
return (functionType.transformChildren(this, data) as FirType).compose()
|
||||
}
|
||||
|
||||
private fun transformType(type: FirType, resolvedType: ConeKotlinType): CompositeTransformResult<FirType> {
|
||||
return FirResolvedTypeImpl(
|
||||
type.session,
|
||||
|
||||
@@ -14,6 +14,7 @@ import org.jetbrains.kotlin.fir.symbols.ConeSymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirTypeParameterSymbol
|
||||
import org.jetbrains.kotlin.fir.types.*
|
||||
import org.jetbrains.kotlin.fir.visitors.FirVisitorVoid
|
||||
import org.jetbrains.kotlin.name.SpecialNames
|
||||
import org.jetbrains.kotlin.types.Variance
|
||||
import org.jetbrains.kotlin.utils.Printer
|
||||
|
||||
@@ -92,6 +93,7 @@ class FirRenderer(builder: StringBuilder) : FirVisitorVoid() {
|
||||
visitMemberDeclaration(callableMember)
|
||||
val receiverType = callableMember.receiverType
|
||||
if (receiverType != null) {
|
||||
print(" ")
|
||||
receiverType.accept(this)
|
||||
print(".")
|
||||
}
|
||||
@@ -324,7 +326,9 @@ class FirRenderer(builder: StringBuilder) : FirVisitorVoid() {
|
||||
if (valueParameter.isVararg) {
|
||||
print("vararg ")
|
||||
}
|
||||
print(valueParameter.name.toString() + ": ")
|
||||
if (valueParameter.name != SpecialNames.NO_NAME_PROVIDED) {
|
||||
print(valueParameter.name.toString() + ": ")
|
||||
}
|
||||
valueParameter.returnType.accept(this)
|
||||
valueParameter.defaultValue?.let {
|
||||
print(" = ")
|
||||
@@ -399,7 +403,7 @@ class FirRenderer(builder: StringBuilder) : FirVisitorVoid() {
|
||||
print(".")
|
||||
}
|
||||
functionType.valueParameters.renderParameters()
|
||||
print(": ")
|
||||
print(" -> ")
|
||||
functionType.returnType.accept(this)
|
||||
print(" )")
|
||||
visitTypeWithNullability(functionType)
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
FILE: functionTypes.kt
|
||||
<T> public? final? function simpleRun(f: ( (<no name provided>: T): Unit )): Unit {
|
||||
<T> public? final? function simpleRun(f: ( (T) -> Unit )): Unit {
|
||||
STUB
|
||||
}
|
||||
<T, R> public? final? function simpleMapList<T>.(f: ( (<no name provided>: T): R )): R {
|
||||
<T, R> public? final? function simpleMap List<T>.(f: ( (T) -> R )): R {
|
||||
}
|
||||
<T> public? final? function simpleWith(t: T, f: ( T.(): Unit )): Unit {
|
||||
<T> public? final? function simpleWith(t: T, f: ( T.() -> Unit )): Unit {
|
||||
STUB
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
FILE: genericFunctions.kt
|
||||
public? abstract interface Any() {
|
||||
}
|
||||
<reified T : Any> public? final? inline function safeAsAny.(): T? {
|
||||
<reified T : Any> public? final? inline function safeAs Any.(): T? {
|
||||
STUB
|
||||
}
|
||||
public? abstract class Summator() {
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@ FILE: lists.kt
|
||||
}
|
||||
public? abstract class MyMutableStringList() : R/kotlin/collections/MutableList<kotlin/String>/ {
|
||||
}
|
||||
public? final? function convertR/kotlin/collections/List<kotlin/String>/.(): R/MyStringList/ {
|
||||
public? final? function convert R/kotlin/collections/List<kotlin/String>/.(): R/MyStringList/ {
|
||||
STUB
|
||||
}
|
||||
public? final? function ret(l: R/kotlin/collections/MutableList<kotlin/String>/): R/MyMutableStringList/ {
|
||||
|
||||
@@ -0,0 +1,8 @@
|
||||
fun <T> simpleRun(f: (T) -> Unit): Unit = f()
|
||||
|
||||
fun <T, R> List<T>.simpleMap(f: (T) -> R): R {
|
||||
|
||||
}
|
||||
|
||||
fun <T> simpleWith(t: T, f: T.() -> Unit): Unit = t.f()
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
FILE: functionTypes.kt
|
||||
<T> public? final? function simpleRun(f: ( (R/T/) -> R/kotlin/Unit/ )): R/kotlin/Unit/ {
|
||||
STUB
|
||||
}
|
||||
<T, R> public? final? function simpleMap R/kotlin/collections/List<T>/.(f: ( (R/T/) -> R/R/ )): R/R/ {
|
||||
}
|
||||
<T> public? final? function simpleWith(t: R/T/, f: ( R/T/.() -> R/kotlin/Unit/ )): R/kotlin/Unit/ {
|
||||
STUB
|
||||
}
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
FILE: genericFunctions.kt
|
||||
public? abstract interface Any() {
|
||||
}
|
||||
<reified T : Any> public? final? inline function safeAsR/Any/.(): R/T/ {
|
||||
<reified T : Any> public? final? inline function safeAs R/Any/.(): R/T/ {
|
||||
STUB
|
||||
}
|
||||
public? abstract class Summator() {
|
||||
|
||||
@@ -39,6 +39,12 @@ public class FirResolveTestCaseGenerated extends AbstractFirResolveTestCase {
|
||||
runTest("compiler/testData/fir/resolve/F.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("functionTypes.kt")
|
||||
public void testFunctionTypes() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/fir/resolve/functionTypes.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("genericFunctions.kt")
|
||||
public void testGenericFunctions() throws Exception {
|
||||
runTest("compiler/testData/fir/resolve/genericFunctions.kt");
|
||||
|
||||
Reference in New Issue
Block a user