No parameter names in type of lambda expression and anonymous function
This commit is contained in:
+4
-13
@@ -28,7 +28,6 @@ import org.jetbrains.kotlin.descriptors.impl.SimpleFunctionDescriptorImpl
|
||||
import org.jetbrains.kotlin.diagnostics.DiagnosticUtils
|
||||
import org.jetbrains.kotlin.diagnostics.Errors
|
||||
import org.jetbrains.kotlin.diagnostics.Errors.*
|
||||
import org.jetbrains.kotlin.name.SpecialNames
|
||||
import org.jetbrains.kotlin.psi.*
|
||||
import org.jetbrains.kotlin.psi.psiUtil.getAnnotationEntries
|
||||
import org.jetbrains.kotlin.resolve.*
|
||||
@@ -123,25 +122,17 @@ internal class FunctionsTypingVisitor(facade: ExpressionTypingInternals) : Expre
|
||||
return createTypeInfo(components.dataFlowAnalyzer.checkStatementType(function, context), context)
|
||||
}
|
||||
else {
|
||||
return components.dataFlowAnalyzer.createCheckedTypeInfo(functionDescriptor.createFunctionType(context), context, function)
|
||||
return components.dataFlowAnalyzer.createCheckedTypeInfo(functionDescriptor.createFunctionType(), context, function)
|
||||
}
|
||||
}
|
||||
|
||||
private fun SimpleFunctionDescriptor.createFunctionType(context: ExpressionTypingContext): KotlinType? {
|
||||
val bindingContext = context.trace.bindingContext
|
||||
val parameterNames = valueParameters.map {
|
||||
// do not include auto-created 'it' into the type signature
|
||||
if (bindingContext[BindingContext.AUTO_CREATED_IT, it] != true)
|
||||
it.name
|
||||
else
|
||||
SpecialNames.NO_NAME_PROVIDED
|
||||
}
|
||||
private fun SimpleFunctionDescriptor.createFunctionType(): KotlinType? {
|
||||
return createFunctionType(
|
||||
components.builtIns,
|
||||
Annotations.EMPTY,
|
||||
extensionReceiverParameter?.type,
|
||||
valueParameters.map { it.type },
|
||||
parameterNames,
|
||||
null,
|
||||
returnType ?: return null
|
||||
)
|
||||
}
|
||||
@@ -160,7 +151,7 @@ internal class FunctionsTypingVisitor(facade: ExpressionTypingInternals) : Expre
|
||||
val safeReturnType = computeReturnType(expression, context, functionDescriptor, functionTypeExpected)
|
||||
functionDescriptor.setReturnType(safeReturnType)
|
||||
|
||||
val resultType = functionDescriptor.createFunctionType(context)!!
|
||||
val resultType = functionDescriptor.createFunctionType()!!
|
||||
if (functionTypeExpected) {
|
||||
// all checks were done before
|
||||
return createTypeInfo(resultType, context)
|
||||
|
||||
@@ -7,8 +7,8 @@ fun foo() {
|
||||
}
|
||||
}
|
||||
---------------------
|
||||
1 <v0>: Int NEW: r(1) -> <v0>
|
||||
{ x: Int -> val y = x + a use(a) } <v1>: {<: (x: Int) -> Array<out Any?>} NEW: r({ x: Int -> val y = x + a use(a) }) -> <v1>
|
||||
1 <v0>: Int NEW: r(1) -> <v0>
|
||||
{ x: Int -> val y = x + a use(a) } <v1>: {<: (Int) -> Array<out Any?>} NEW: r({ x: Int -> val y = x + a use(a) }) -> <v1>
|
||||
=====================
|
||||
== anonymous_0 ==
|
||||
{ x: Int ->
|
||||
|
||||
@@ -8,11 +8,11 @@ fun foo() {
|
||||
"after"
|
||||
}
|
||||
---------------------
|
||||
"before" <v0>: * NEW: r("before") -> <v0>
|
||||
1 <v1>: Int NEW: r(1) -> <v1>
|
||||
{ x: Int -> val a = x + b } <v2>: {<: (x: Int) -> Unit} NEW: r({ x: Int -> val a = x + b }) -> <v2>
|
||||
"after" <v3>: * NEW: r("after") -> <v3>
|
||||
{ "before" val b = 1 val f = { x: Int -> val a = x + b } "after" } <v3>: * COPY
|
||||
"before" <v0>: * NEW: r("before") -> <v0>
|
||||
1 <v1>: Int NEW: r(1) -> <v1>
|
||||
{ x: Int -> val a = x + b } <v2>: {<: (Int) -> Unit} NEW: r({ x: Int -> val a = x + b }) -> <v2>
|
||||
"after" <v3>: * NEW: r("after") -> <v3>
|
||||
{ "before" val b = 1 val f = { x: Int -> val a = x + b } "after" } <v3>: * COPY
|
||||
=====================
|
||||
== anonymous_0 ==
|
||||
{ x: Int ->
|
||||
|
||||
@@ -4,8 +4,8 @@ fun test() {
|
||||
val g = fun foo(n: Int) = 2
|
||||
}
|
||||
---------------------
|
||||
fun(n: Int): Int { return 1 } <v0>: {<: (n: Int) -> Int} NEW: r(fun(n: Int): Int { return 1 }) -> <v0>
|
||||
fun foo(n: Int) = 2 <v1>: {<: (n: Int) -> Int} NEW: r(fun foo(n: Int) = 2) -> <v1>
|
||||
fun(n: Int): Int { return 1 } <v0>: {<: (Int) -> Int} NEW: r(fun(n: Int): Int { return 1 }) -> <v0>
|
||||
fun foo(n: Int) = 2 <v1>: {<: (Int) -> Int} NEW: r(fun foo(n: Int) = 2) -> <v1>
|
||||
=====================
|
||||
== anonymous_0 ==
|
||||
fun(n: Int): Int { return 1 }
|
||||
|
||||
@@ -2,7 +2,7 @@ package
|
||||
|
||||
public val bar: (???) -> kotlin.Unit
|
||||
public val la: (???) -> kotlin.Unit
|
||||
public val las: (a: kotlin.Int) -> kotlin.Unit
|
||||
public val las: (kotlin.Int) -> kotlin.Unit
|
||||
public fun test(/*0*/ a: [ERROR : Type annotation was missing for parameter a]): kotlin.Unit
|
||||
|
||||
public final class A {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package
|
||||
|
||||
public val bar: (g: kotlin.Int) -> kotlin.Unit
|
||||
public val bar: (kotlin.Int) -> kotlin.Unit
|
||||
public fun test(/*0*/ @ann() p: kotlin.Int): kotlin.Unit
|
||||
|
||||
public final annotation class ann : kotlin.Annotation {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package
|
||||
|
||||
public val bar: (p: kotlin.Int) -> kotlin.Unit
|
||||
public val bas: (p: kotlin.IntArray) -> kotlin.Unit
|
||||
public fun gar(): (p: kotlin.Int) -> kotlin.Unit
|
||||
public fun gas(): (p: kotlin.IntArray) -> kotlin.Unit
|
||||
public val bar: (kotlin.Int) -> kotlin.Unit
|
||||
public val bas: (kotlin.IntArray) -> kotlin.Unit
|
||||
public fun gar(): (kotlin.Int) -> kotlin.Unit
|
||||
public fun gas(): (kotlin.IntArray) -> kotlin.Unit
|
||||
public fun outer(/*0*/ b: kotlin.Any?): kotlin.Unit
|
||||
|
||||
+1
-1
@@ -1,3 +1,3 @@
|
||||
package
|
||||
|
||||
public val foo: (a: kotlin.Int) -> kotlin.String
|
||||
public val foo: (kotlin.Int) -> kotlin.String
|
||||
|
||||
+3
-3
@@ -1,9 +1,9 @@
|
||||
package
|
||||
|
||||
public val extension_generic_fun: T.(t: T) -> T
|
||||
public val generic_fun: (t: T) -> T
|
||||
public val extension_generic_fun: T.(T) -> T
|
||||
public val generic_fun: (T) -> T
|
||||
public fun devNull(/*0*/ a: kotlin.Any?): kotlin.Unit
|
||||
public fun fun_with_where(): T.(t: T) -> T
|
||||
public fun fun_with_where(): T.(T) -> T
|
||||
public fun outer(): kotlin.Unit
|
||||
|
||||
public interface A {
|
||||
|
||||
+2
-2
@@ -3,7 +3,7 @@ package
|
||||
public val </*0*/ T> T.fromVal: () -> T
|
||||
public fun devNull(/*0*/ a: kotlin.Any?): kotlin.Unit
|
||||
public fun </*0*/ O> outer(): kotlin.Unit
|
||||
public fun </*0*/ T> parameter(): (t: T) -> T
|
||||
public fun </*0*/ T> parameter(): (T) -> T
|
||||
public fun </*0*/ T> receiver(): T.() -> T
|
||||
public fun </*0*/ T> returnType(): () -> T
|
||||
|
||||
@@ -11,7 +11,7 @@ public final class Outer</*0*/ O> {
|
||||
public constructor Outer</*0*/ O>()
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public final fun </*0*/ T> parameter(): (t: T) -> T
|
||||
public final fun </*0*/ T> parameter(): (T) -> T
|
||||
public final fun </*0*/ T> receiver(): T.() -> T
|
||||
public final fun </*0*/ T> returnType(): () -> T
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
package
|
||||
|
||||
public val newSyntax: (a: kotlin.Int) -> kotlin.Unit
|
||||
public val newSyntax: (kotlin.Int) -> kotlin.Unit
|
||||
public val newSyntax1: (???, ???) -> kotlin.Unit
|
||||
public val newSyntax2: (a: kotlin.Int, b: kotlin.Int) -> kotlin.Unit
|
||||
public val newSyntax3: (???, b: kotlin.Int) -> kotlin.Unit
|
||||
public val newSyntax4: (a: kotlin.Int, ???) -> kotlin.Unit
|
||||
public val newSyntax2: (kotlin.Int, kotlin.Int) -> kotlin.Unit
|
||||
public val newSyntax3: (???, kotlin.Int) -> kotlin.Unit
|
||||
public val newSyntax4: (kotlin.Int, ???) -> kotlin.Unit
|
||||
public val none: () -> kotlin.Unit
|
||||
public val parameterWithFunctionType: (a: ((kotlin.Int) -> kotlin.Int) -> [ERROR : No type element]) -> kotlin.Unit
|
||||
public val parameterWithFunctionType: (((kotlin.Int) -> kotlin.Int) -> [ERROR : No type element]) -> kotlin.Unit
|
||||
public val parenthesizedParameters: (???) -> kotlin.Unit
|
||||
public val parenthesizedParameters2: (???) -> kotlin.Unit
|
||||
public val receiver: () -> ???
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
package
|
||||
|
||||
public val a: (i: kotlin.Int) -> kotlin.String
|
||||
public val a: (kotlin.Int) -> kotlin.String
|
||||
public val b: kotlin.String
|
||||
public val flag: kotlin.Boolean = true
|
||||
public fun </*0*/ T> foo(/*0*/ f: (kotlin.Int) -> T): T
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package
|
||||
|
||||
public val a: (it: kotlin.Int?) -> kotlin.Int?
|
||||
public val a: (kotlin.Int?) -> kotlin.Int?
|
||||
public val b: kotlin.Int?
|
||||
public val c: kotlin.Int
|
||||
public fun </*0*/ R> let(/*0*/ f: (kotlin.Int?) -> R): R
|
||||
|
||||
@@ -4,7 +4,7 @@ public fun box(): kotlin.String
|
||||
|
||||
public final class X</*0*/ T> {
|
||||
public constructor X</*0*/ T>()
|
||||
public final val check: (a: kotlin.Any) -> kotlin.Boolean
|
||||
public final val check: (kotlin.Any) -> kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
package
|
||||
|
||||
public val </*0*/ T : kotlin.Int.() -> kotlin.String> bar: (x: kotlin.Int) -> kotlin.String
|
||||
public val </*0*/ T : kotlin.Int.() -> kotlin.String> bar: (kotlin.Int) -> kotlin.String
|
||||
public fun </*0*/ T : kotlin.Int.() -> kotlin.String> foo(): kotlin.Unit
|
||||
|
||||
public final class A</*0*/ T : kotlin.Double.(kotlin.Int) -> kotlin.Unit> {
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
package
|
||||
|
||||
public val </*0*/ T : (kotlin.Int) -> kotlin.String> bar: (x: kotlin.Int) -> kotlin.String
|
||||
public val </*0*/ T : (kotlin.Int) -> kotlin.String> bar: (kotlin.Int) -> kotlin.String
|
||||
public fun </*0*/ T : (kotlin.Int) -> kotlin.String> foo(): kotlin.Unit
|
||||
|
||||
public final class A</*0*/ T : () -> kotlin.Unit, /*1*/ U : (kotlin.Int) -> kotlin.Double, /*2*/ V : (T, U) -> U> {
|
||||
|
||||
@@ -18,7 +18,7 @@ Type inference failed:
|
||||
<td style="white-space:nowrap;"></td>
|
||||
<td style="white-space:nowrap;"></td>
|
||||
<td style="white-space:nowrap;"><b>(</b></td>
|
||||
<td align="right" style="white-space:nowrap;"><font color=red><b>(x: Int) → Int</b></font></td>
|
||||
<td align="right" style="white-space:nowrap;"><font color=red><b>(Int) → Int</b></font></td>
|
||||
<td style="white-space:nowrap;"><b>)</b></td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
@@ -6,6 +6,6 @@ fun call() {
|
||||
}
|
||||
|
||||
/*
|
||||
Text: (<highlight>String</highlight>, String), Disabled: false, Strikeout: false, Green: true
|
||||
Text: (<highlight>name: String</highlight>, value: Int), Disabled: false, Strikeout: false, Green: false
|
||||
Text: (<highlight>s: String</highlight>, s1: String), Disabled: false, Strikeout: false, Green: true
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user