FIR resolve: add partial support of extension lambda calls
Here we introduce ONLY_IMPLICIT_RECEIVER tower level to support extension lambda calls on local variables, and soften extension receiver checks to make such extensions visible & applicable. Also here we try to map arguments twice for functional types
This commit is contained in:
+30
-13
@@ -9,16 +9,15 @@ import org.jetbrains.kotlin.fir.FirSession
|
||||
import org.jetbrains.kotlin.fir.declarations.FirRegularClass
|
||||
import org.jetbrains.kotlin.fir.declarations.isInner
|
||||
import org.jetbrains.kotlin.fir.resolve.BodyResolveComponents
|
||||
import org.jetbrains.kotlin.fir.resolve.calls.TowerDataKind.EMPTY
|
||||
import org.jetbrains.kotlin.fir.resolve.calls.TowerDataKind.TOWER_LEVEL
|
||||
import org.jetbrains.kotlin.fir.resolve.calls.TowerDataKind.*
|
||||
import org.jetbrains.kotlin.fir.resolve.transformers.ReturnTypeCalculator
|
||||
import org.jetbrains.kotlin.fir.scopes.FirScope
|
||||
import org.jetbrains.kotlin.fir.scopes.ProcessorAction.NONE
|
||||
import org.jetbrains.kotlin.fir.scopes.impl.FirLocalScope
|
||||
|
||||
enum class TowerDataKind {
|
||||
EMPTY,
|
||||
TOWER_LEVEL
|
||||
EMPTY, // Corresponds to stub tower level which is replaced by receiver-related level
|
||||
TOWER_LEVEL // Corresponds to real tower level which may process elements itself
|
||||
}
|
||||
|
||||
class FirTowerResolver(
|
||||
@@ -46,10 +45,23 @@ class FirTowerResolver(
|
||||
// }
|
||||
towerDataConsumer.consume(
|
||||
TOWER_LEVEL,
|
||||
MemberScopeTowerLevel(session, components, implicitReceiverValue, scopeSession = components.scopeSession),
|
||||
MemberScopeTowerLevel(session, components, dispatchReceiver = implicitReceiverValue, scopeSession = components.scopeSession),
|
||||
group++
|
||||
)
|
||||
|
||||
// class Foo {
|
||||
// fun foo(block: Foo.() -> Unit) {
|
||||
// block()
|
||||
// }
|
||||
// }
|
||||
// invokeExtension on local variable
|
||||
towerDataConsumer.consume(
|
||||
EMPTY,
|
||||
TowerScopeLevel.OnlyImplicitReceiver(implicitReceiverValue),
|
||||
group++
|
||||
)
|
||||
//TowerData.OnlyImplicitReceiver(implicitReceiver).process()?.let { return it }
|
||||
|
||||
// Same receiver is dispatch & extension
|
||||
// class Foo {
|
||||
// fun Foo.bar() {}
|
||||
@@ -57,18 +69,23 @@ class FirTowerResolver(
|
||||
// }
|
||||
towerDataConsumer.consume(
|
||||
TOWER_LEVEL,
|
||||
MemberScopeTowerLevel(session, components, implicitReceiverValue, implicitReceiverValue, components.scopeSession),
|
||||
MemberScopeTowerLevel(
|
||||
session, components,
|
||||
dispatchReceiver = implicitReceiverValue,
|
||||
implicitExtensionReceiver = implicitReceiverValue,
|
||||
scopeSession = components.scopeSession
|
||||
),
|
||||
group++
|
||||
)
|
||||
|
||||
// Local scope extensions via implicit receiver
|
||||
// class Foo {
|
||||
// fun test() {
|
||||
// fun Foo.bar() {}
|
||||
// bar()
|
||||
// }
|
||||
// }
|
||||
for (scope in nonEmptyLocalScopes) {
|
||||
// Local scope extensions via implicit receiver
|
||||
// class Foo {
|
||||
// fun test() {
|
||||
// fun Foo.bar() {}
|
||||
// bar()
|
||||
// }
|
||||
// }
|
||||
towerDataConsumer.consume(
|
||||
TOWER_LEVEL,
|
||||
ScopeTowerLevel(session, components, scope, implicitExtensionReceiver = implicitReceiverValue),
|
||||
|
||||
@@ -8,7 +8,9 @@ package org.jetbrains.kotlin.fir.resolve.calls
|
||||
import org.jetbrains.kotlin.descriptors.Visibilities
|
||||
import org.jetbrains.kotlin.fir.FirSession
|
||||
import org.jetbrains.kotlin.fir.declarations.*
|
||||
import org.jetbrains.kotlin.fir.expressions.FirQualifiedAccess
|
||||
import org.jetbrains.kotlin.fir.expressions.FirResolvedQualifier
|
||||
import org.jetbrains.kotlin.fir.expressions.impl.FirNoReceiverExpression
|
||||
import org.jetbrains.kotlin.fir.render
|
||||
import org.jetbrains.kotlin.fir.resolve.*
|
||||
import org.jetbrains.kotlin.fir.symbols.AbstractFirBasedSymbol
|
||||
@@ -17,10 +19,7 @@ import org.jetbrains.kotlin.fir.symbols.impl.FirCallableSymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirClassLikeSymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirFunctionSymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.FirRegularClassSymbol
|
||||
import org.jetbrains.kotlin.fir.types.ConeKotlinErrorType
|
||||
import org.jetbrains.kotlin.fir.types.ConeKotlinType
|
||||
import org.jetbrains.kotlin.fir.types.FirResolvedTypeRef
|
||||
import org.jetbrains.kotlin.fir.types.coneTypeSafe
|
||||
import org.jetbrains.kotlin.fir.types.*
|
||||
import org.jetbrains.kotlin.load.java.JavaVisibilities
|
||||
import org.jetbrains.kotlin.name.ClassId
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
@@ -84,7 +83,11 @@ internal sealed class CheckReceivers : ResolutionStage() {
|
||||
override fun Candidate.getReceiverType(): ConeKotlinType? {
|
||||
val callableSymbol = symbol as? FirCallableSymbol<*> ?: return null
|
||||
val callable = callableSymbol.fir
|
||||
return (callable.receiverTypeRef as FirResolvedTypeRef?)?.type
|
||||
val receiverType = (callable.receiverTypeRef as FirResolvedTypeRef?)?.type
|
||||
if (receiverType != null) return receiverType
|
||||
val returnTypeRef = callable.returnTypeRef as? FirResolvedTypeRef ?: return null
|
||||
if (!returnTypeRef.isExtensionFunctionType()) return null
|
||||
return (returnTypeRef.type.typeArguments.firstOrNull() as? ConeTypedProjection)?.type
|
||||
}
|
||||
}
|
||||
|
||||
@@ -136,6 +139,23 @@ internal object MapArguments : ResolutionStage() {
|
||||
override suspend fun check(candidate: Candidate, sink: CheckerSink, callInfo: CallInfo) {
|
||||
val symbol = candidate.symbol as? FirFunctionSymbol<*> ?: return sink.reportApplicability(CandidateApplicability.HIDDEN)
|
||||
val function = symbol.fir
|
||||
if (candidate.dispatchReceiverValue?.type?.isBuiltinFunctionalType == true) {
|
||||
// We don't know is it extension function or not due to lack of annotations
|
||||
// So we have to check both variants, with receiver and without it
|
||||
// TODO: remove this double-check after KT-30066
|
||||
val lambdaExtensionReceiver =
|
||||
(callInfo.explicitReceiver as? FirQualifiedAccess)?.extensionReceiver?.takeIf { it !is FirNoReceiverExpression }
|
||||
?: (candidate.implicitExtensionReceiverValue as? ImplicitReceiverValue)?.receiverExpression
|
||||
val processorWithReceiver = FirCallArgumentsProcessor(
|
||||
function,
|
||||
listOfNotNull(lambdaExtensionReceiver) + callInfo.arguments
|
||||
)
|
||||
val mappingResult = processorWithReceiver.process()
|
||||
candidate.argumentMapping = mappingResult.argumentMapping
|
||||
if (mappingResult.isSuccess) {
|
||||
return
|
||||
}
|
||||
}
|
||||
val processor = FirCallArgumentsProcessor(function, callInfo.arguments)
|
||||
val mappingResult = processor.process()
|
||||
candidate.argumentMapping = mappingResult.argumentMapping
|
||||
|
||||
+4
-1
@@ -173,9 +173,11 @@ class ExplicitReceiverTowerDataConsumer<T : AbstractFirBasedSymbol<*>>(
|
||||
): ProcessorAction {
|
||||
if (skipGroup(group)) return ProcessorAction.NEXT
|
||||
return when (kind) {
|
||||
TowerDataKind.EMPTY ->
|
||||
TowerDataKind.EMPTY -> {
|
||||
MemberScopeTowerLevel(
|
||||
session, resultCollector.components, explicitReceiver,
|
||||
implicitExtensionReceiver = (towerScopeLevel as? TowerScopeLevel.OnlyImplicitReceiver)?.implicitReceiverValue,
|
||||
invokeOnly = towerScopeLevel is TowerScopeLevel.OnlyImplicitReceiver,
|
||||
scopeSession = candidateFactory.bodyResolveComponents.scopeSession
|
||||
).processElementsByName(
|
||||
token,
|
||||
@@ -183,6 +185,7 @@ class ExplicitReceiverTowerDataConsumer<T : AbstractFirBasedSymbol<*>>(
|
||||
explicitReceiver = null,
|
||||
processor = EmptyKindTowerProcessor(group)
|
||||
)
|
||||
}
|
||||
TowerDataKind.TOWER_LEVEL -> {
|
||||
if (token == TowerScopeLevel.Token.Objects) return ProcessorAction.NEXT
|
||||
towerScopeLevel.processElementsByName(
|
||||
|
||||
@@ -20,8 +20,10 @@ import org.jetbrains.kotlin.fir.scopes.impl.FirAbstractImportingScope
|
||||
import org.jetbrains.kotlin.fir.scopes.impl.FirExplicitSimpleImportingScope
|
||||
import org.jetbrains.kotlin.fir.symbols.AbstractFirBasedSymbol
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.*
|
||||
import org.jetbrains.kotlin.fir.types.isExtensionFunctionType
|
||||
import org.jetbrains.kotlin.name.FqName
|
||||
import org.jetbrains.kotlin.name.Name
|
||||
import org.jetbrains.kotlin.util.OperatorNameConventions
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.cast
|
||||
|
||||
interface TowerScopeLevel {
|
||||
@@ -48,7 +50,7 @@ interface TowerScopeLevel {
|
||||
): ProcessorAction
|
||||
}
|
||||
|
||||
object Empty : TowerScopeLevel {
|
||||
abstract class StubTowerScopeLevel : TowerScopeLevel {
|
||||
override fun <T : AbstractFirBasedSymbol<*>> processElementsByName(
|
||||
token: Token<T>,
|
||||
name: Name,
|
||||
@@ -56,6 +58,10 @@ interface TowerScopeLevel {
|
||||
processor: TowerScopeLevelProcessor<T>
|
||||
): ProcessorAction = ProcessorAction.NEXT
|
||||
}
|
||||
|
||||
object Empty : StubTowerScopeLevel()
|
||||
|
||||
class OnlyImplicitReceiver(val implicitReceiverValue: ImplicitReceiverValue<*>) : StubTowerScopeLevel()
|
||||
}
|
||||
|
||||
abstract class SessionBasedTowerLevel(val session: FirSession) : TowerScopeLevel {
|
||||
@@ -70,8 +76,10 @@ abstract class SessionBasedTowerLevel(val session: FirSession) : TowerScopeLevel
|
||||
}
|
||||
|
||||
protected fun FirCallableSymbol<*>.hasConsistentExtensionReceiver(extensionReceiver: ReceiverValue?): Boolean {
|
||||
val hasExtensionReceiver = hasExtensionReceiver()
|
||||
return hasExtensionReceiver == (extensionReceiver != null)
|
||||
return when {
|
||||
extensionReceiver != null -> hasExtensionReceiver()
|
||||
else -> fir.receiverTypeRef == null
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -86,6 +94,7 @@ class MemberScopeTowerLevel(
|
||||
val bodyResolveComponents: BodyResolveComponents,
|
||||
val dispatchReceiver: ReceiverValue,
|
||||
val implicitExtensionReceiver: ImplicitReceiverValue<*>? = null,
|
||||
val invokeOnly: Boolean = false,
|
||||
val scopeSession: ScopeSession
|
||||
) : SessionBasedTowerLevel(session) {
|
||||
private fun <T : AbstractFirBasedSymbol<*>> processMembers(
|
||||
@@ -97,7 +106,7 @@ class MemberScopeTowerLevel(
|
||||
val extensionReceiver = implicitExtensionReceiver ?: explicitExtensionReceiver
|
||||
val scope = dispatchReceiver.scope(session, scopeSession) ?: return ProcessorAction.NEXT
|
||||
if (scope.processScopeMembers { candidate ->
|
||||
if (candidate is FirCallableSymbol<*> && candidate.hasConsistentExtensionReceiver(extensionReceiver)) {
|
||||
if (candidate is FirCallableSymbol<*> && (invokeOnly || candidate.hasConsistentExtensionReceiver(extensionReceiver))) {
|
||||
// NB: we do not check dispatchReceiverValue != null here,
|
||||
// because of objects & constructors (see comments in dispatchReceiverValue() implementation)
|
||||
output.consumeCandidate(candidate, candidate.dispatchReceiverValue(), implicitExtensionReceiver)
|
||||
@@ -120,6 +129,9 @@ class MemberScopeTowerLevel(
|
||||
explicitReceiver: ExpressionReceiverValue?,
|
||||
processor: TowerScopeLevel.TowerScopeLevelProcessor<T>
|
||||
): ProcessorAction {
|
||||
if (invokeOnly && (token != TowerScopeLevel.Token.Functions || name != OperatorNameConventions.INVOKE)) {
|
||||
return ProcessorAction.NEXT
|
||||
}
|
||||
val explicitExtensionReceiver = if (dispatchReceiver == explicitReceiver) null else explicitReceiver
|
||||
return when (token) {
|
||||
TowerScopeLevel.Token.Properties -> processMembers(processor, explicitExtensionReceiver) { symbol ->
|
||||
@@ -277,4 +289,7 @@ fun FirCallableDeclaration<*>.dispatchReceiverValue(session: FirSession): ClassD
|
||||
return ClassDispatchReceiverValue(symbol)
|
||||
}
|
||||
|
||||
private fun FirCallableSymbol<*>.hasExtensionReceiver(): Boolean = this.fir.receiverTypeRef != null
|
||||
private fun FirCallableSymbol<*>.hasExtensionReceiver(): Boolean {
|
||||
if (fir.receiverTypeRef != null) return true
|
||||
return fir.returnTypeRef.isExtensionFunctionType()
|
||||
}
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
fun String.k(): () -> String = { -> this }
|
||||
|
||||
fun test() = "hello".k()()
|
||||
@@ -0,0 +1,10 @@
|
||||
FILE: doubleBrackets.kt
|
||||
public final fun R|kotlin/String|.k(): R|() -> kotlin/String| {
|
||||
^k fun <anonymous>(): R|kotlin/String| {
|
||||
this@R|/k|
|
||||
}
|
||||
|
||||
}
|
||||
public final fun test(): R|kotlin/String| {
|
||||
^test String(hello).R|/k|().R|FakeOverride<kotlin/Function0.invoke: R|kotlin/String|>|()
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
fun test(e: Int.() -> String) {
|
||||
val s = 3.<!UNRESOLVED_REFERENCE!>e<!>()
|
||||
val ss = 3.(<!UNRESOLVED_REFERENCE!>e<!>)()
|
||||
val s = 3.e()
|
||||
val ss = 3.(e)()
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
FILE: inBrackets.kt
|
||||
public final fun test(e: R|kotlin/Int.() -> kotlin/String|): R|kotlin/Unit| {
|
||||
lval s: <ERROR TYPE REF: Unresolved name: e> = Int(3).<Unresolved name: e>#()
|
||||
lval ss: <ERROR TYPE REF: Unresolved name: e> = Int(3).<Unresolved name: e>#()
|
||||
lval s: R|kotlin/String| = Int(3).R|<local>/e|.R|FakeOverride<kotlin/Function1.invoke: R|kotlin/String|>|()
|
||||
lval ss: R|kotlin/String| = Int(3).R|<local>/e|.R|FakeOverride<kotlin/Function1.invoke: R|kotlin/String|>|()
|
||||
}
|
||||
|
||||
+10
@@ -0,0 +1,10 @@
|
||||
class A(val x: (String.() -> Unit)?, val y: (String.() -> Int))
|
||||
|
||||
fun test(a: A) {
|
||||
if (a.x != null) {
|
||||
val b = a.x
|
||||
"".b()
|
||||
}
|
||||
val c = a.y
|
||||
val d = "".c()
|
||||
}
|
||||
+24
@@ -0,0 +1,24 @@
|
||||
FILE: propertyWithExtensionType.kt
|
||||
public final class A : R|kotlin/Any| {
|
||||
public constructor(x: R|kotlin/String.() -> kotlin/Unit|, y: R|kotlin/String.() -> kotlin/Int|): R|A| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
public final val x: R|kotlin/String.() -> kotlin/Unit| = R|<local>/x|
|
||||
public get(): R|kotlin/String.() -> kotlin/Unit|
|
||||
|
||||
public final val y: R|kotlin/String.() -> kotlin/Int| = R|<local>/y|
|
||||
public get(): R|kotlin/String.() -> kotlin/Int|
|
||||
|
||||
}
|
||||
public final fun test(a: R|A|): R|kotlin/Unit| {
|
||||
when () {
|
||||
!=(R|<local>/a|.R|/A.x|, Null(null)) -> {
|
||||
lval b: R|kotlin/String.() -> kotlin/Unit| = R|<local>/a|.R|/A.x|
|
||||
String().R|<local>/b|.R|FakeOverride<kotlin/Function1.invoke: R|kotlin/Unit|>|()
|
||||
}
|
||||
}
|
||||
|
||||
lval c: R|kotlin/String.() -> kotlin/Int| = R|<local>/a|.R|/A.y|
|
||||
lval d: R|kotlin/Int| = String().R|<local>/c|.R|FakeOverride<kotlin/Function1.invoke: R|kotlin/Int|>|()
|
||||
}
|
||||
+1
-1
@@ -12,6 +12,6 @@ class Foo {
|
||||
val Buz.foobar: Bar get() = Bar()
|
||||
|
||||
fun FooBar.chk(buz: Buz) {
|
||||
buz.<!UNRESOLVED_REFERENCE!>foobar<!>()
|
||||
buz.foobar()
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -32,7 +32,7 @@ FILE: threeReceivers.kt
|
||||
}
|
||||
|
||||
public final fun R|FooBar|.chk(buz: R|Buz|): R|kotlin/Unit| {
|
||||
R|<local>/buz|.<Unresolved name: foobar>#()
|
||||
((this@R|/Foo|, R|<local>/buz|).R|/Foo.foobar|, this@R|/Foo.chk|).R|/Bar.invoke|()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -3,11 +3,11 @@ interface A {
|
||||
}
|
||||
|
||||
fun <T> myWith(receiver: T, block: T.() -> Unit) {
|
||||
receiver.<!UNRESOLVED_REFERENCE!>block<!>()
|
||||
receiver.block()
|
||||
}
|
||||
|
||||
fun <T> T.myApply(block: T.() -> Unit) {
|
||||
this.<!UNRESOLVED_REFERENCE!>block<!>()
|
||||
this.block()
|
||||
}
|
||||
|
||||
fun withA(block: A.() -> Unit) {}
|
||||
|
||||
@@ -4,10 +4,10 @@ FILE: lambdaWithReceiver.kt
|
||||
|
||||
}
|
||||
public final fun <T> myWith(receiver: R|T|, block: R|T.() -> kotlin/Unit|): R|kotlin/Unit| {
|
||||
R|<local>/receiver|.<Unresolved name: block>#()
|
||||
R|<local>/receiver|.R|<local>/block|.R|FakeOverride<kotlin/Function1.invoke: R|kotlin/Unit|>|()
|
||||
}
|
||||
public final fun <T> R|T|.myApply(block: R|T.() -> kotlin/Unit|): R|kotlin/Unit| {
|
||||
this@R|/myApply|.<Unresolved name: block>#()
|
||||
this@R|/myApply|.R|<local>/block|.R|FakeOverride<kotlin/Function1.invoke: R|kotlin/Unit|>|()
|
||||
}
|
||||
public final fun withA(block: R|A.() -> kotlin/Unit|): R|kotlin/Unit| {
|
||||
}
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@ fun <T, R> List<T>.simpleMap(f: (T) -> R): R {
|
||||
|
||||
}
|
||||
|
||||
fun <T> simpleWith(t: T, f: T.() -> Unit): Unit = t.<!UNRESOLVED_REFERENCE!>f<!>()
|
||||
fun <T> simpleWith(t: T, f: T.() -> Unit): Unit = t.f()
|
||||
|
||||
interface KMutableProperty1<T, R> : KProperty1<T, R>, KMutableProperty<R>
|
||||
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@ FILE: functionTypes.kt
|
||||
public final fun <T, R> R|kotlin/collections/List<T>|.simpleMap(f: R|(T) -> R|): R|R| {
|
||||
}
|
||||
public final fun <T> simpleWith(t: R|T|, f: R|T.() -> kotlin/Unit|): R|kotlin/Unit| {
|
||||
^simpleWith R|<local>/t|.<Unresolved name: f>#()
|
||||
^simpleWith R|<local>/t|.R|<local>/f|.R|FakeOverride<kotlin/Function1.invoke: R|kotlin/Unit|>|()
|
||||
}
|
||||
public abstract interface KMutableProperty1<T, R> : R|KProperty1<T, R>|, R|KMutableProperty<R>| {
|
||||
}
|
||||
|
||||
+11
-1
@@ -1,5 +1,15 @@
|
||||
interface A
|
||||
|
||||
fun test(a: A, block: A.() -> Int) {
|
||||
a.<!UNRESOLVED_REFERENCE!>block<!>()
|
||||
a.block()
|
||||
}
|
||||
|
||||
fun A.otherTest(block: A.() -> Int) {
|
||||
block()
|
||||
}
|
||||
|
||||
class B {
|
||||
fun anotherTest(block: B.() -> Int) {
|
||||
block()
|
||||
}
|
||||
}
|
||||
+14
-1
@@ -2,5 +2,18 @@ FILE: invokeOfLambdaWithReceiver.kt
|
||||
public abstract interface A : R|kotlin/Any| {
|
||||
}
|
||||
public final fun test(a: R|A|, block: R|A.() -> kotlin/Int|): R|kotlin/Unit| {
|
||||
R|<local>/a|.<Unresolved name: block>#()
|
||||
R|<local>/a|.R|<local>/block|.R|FakeOverride<kotlin/Function1.invoke: R|kotlin/Int|>|()
|
||||
}
|
||||
public final fun R|A|.otherTest(block: R|A.() -> kotlin/Int|): R|kotlin/Unit| {
|
||||
(R|<local>/block|, this@R|/otherTest|).R|FakeOverride<kotlin/Function1.invoke: R|kotlin/Int|>|()
|
||||
}
|
||||
public final class B : R|kotlin/Any| {
|
||||
public constructor(): R|B| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
public final fun anotherTest(block: R|B.() -> kotlin/Int|): R|kotlin/Unit| {
|
||||
(R|<local>/block|, this@R|/B|).R|FakeOverride<kotlin/Function1.invoke: R|kotlin/Int|>|()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+10
@@ -654,6 +654,11 @@ public class FirDiagnosticsTestGenerated extends AbstractFirDiagnosticsTest {
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/resolve/testData/resolve/expresssions/invoke"), Pattern.compile("^([^.]+)\\.kt$"), null, true);
|
||||
}
|
||||
|
||||
@TestMetadata("doubleBrackets.kt")
|
||||
public void testDoubleBrackets() throws Exception {
|
||||
runTest("compiler/fir/resolve/testData/resolve/expresssions/invoke/doubleBrackets.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("explicitReceiver.kt")
|
||||
public void testExplicitReceiver() throws Exception {
|
||||
runTest("compiler/fir/resolve/testData/resolve/expresssions/invoke/explicitReceiver.kt");
|
||||
@@ -694,6 +699,11 @@ public class FirDiagnosticsTestGenerated extends AbstractFirDiagnosticsTest {
|
||||
runTest("compiler/fir/resolve/testData/resolve/expresssions/invoke/propertyFromParameter.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("propertyWithExtensionType.kt")
|
||||
public void testPropertyWithExtensionType() throws Exception {
|
||||
runTest("compiler/fir/resolve/testData/resolve/expresssions/invoke/propertyWithExtensionType.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("simple.kt")
|
||||
public void testSimple() throws Exception {
|
||||
runTest("compiler/fir/resolve/testData/resolve/expresssions/invoke/simple.kt");
|
||||
|
||||
Generated
+10
@@ -654,6 +654,11 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos
|
||||
KotlinTestUtils.assertAllTestsPresentByMetadataWithExcluded(this.getClass(), new File("compiler/fir/resolve/testData/resolve/expresssions/invoke"), Pattern.compile("^([^.]+)\\.kt$"), null, true);
|
||||
}
|
||||
|
||||
@TestMetadata("doubleBrackets.kt")
|
||||
public void testDoubleBrackets() throws Exception {
|
||||
runTest("compiler/fir/resolve/testData/resolve/expresssions/invoke/doubleBrackets.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("explicitReceiver.kt")
|
||||
public void testExplicitReceiver() throws Exception {
|
||||
runTest("compiler/fir/resolve/testData/resolve/expresssions/invoke/explicitReceiver.kt");
|
||||
@@ -694,6 +699,11 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos
|
||||
runTest("compiler/fir/resolve/testData/resolve/expresssions/invoke/propertyFromParameter.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("propertyWithExtensionType.kt")
|
||||
public void testPropertyWithExtensionType() throws Exception {
|
||||
runTest("compiler/fir/resolve/testData/resolve/expresssions/invoke/propertyWithExtensionType.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("simple.kt")
|
||||
public void testSimple() throws Exception {
|
||||
runTest("compiler/fir/resolve/testData/resolve/expresssions/invoke/simple.kt");
|
||||
|
||||
+2
-2
@@ -70,7 +70,7 @@ abstract class Tag(val name : String) : Element() {
|
||||
val attributes = HashMap<String, String>()
|
||||
|
||||
protected fun <T : Element> initTag(tag : T, init : T.() -> Unit) : T {
|
||||
tag.<!UNRESOLVED_REFERENCE!>init<!>()
|
||||
tag.init()
|
||||
children.add(tag)
|
||||
return tag
|
||||
}
|
||||
@@ -143,7 +143,7 @@ class A() : BodyTag("a") {
|
||||
|
||||
fun html(init : HTML.() -> Unit) : HTML {
|
||||
val html = HTML()
|
||||
html.<!UNRESOLVED_REFERENCE!>init<!>()
|
||||
html.init()
|
||||
return html
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
fun bar(doIt: Int.() -> Int) {
|
||||
1.<!UNRESOLVED_REFERENCE!>doIt<!>()
|
||||
1?.<!UNRESOLVED_REFERENCE!>doIt<!>()
|
||||
1.doIt()
|
||||
1?.doIt()
|
||||
val i: Int? = 1
|
||||
i.<!UNRESOLVED_REFERENCE!>doIt<!>()
|
||||
i?.<!UNRESOLVED_REFERENCE!>doIt<!>()
|
||||
i?.doIt()
|
||||
}
|
||||
|
||||
@@ -9,5 +9,5 @@ interface A : (String) -> Unit {}
|
||||
fun foo(a: @ExtensionFunctionType A) {
|
||||
// @Extension annotation on an unrelated type shouldn't have any effect on this diagnostic.
|
||||
// Only kotlin.Function{n} type annotated with @Extension should
|
||||
"".<!UNRESOLVED_REFERENCE!>a<!>()
|
||||
"".a()
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ fun <T> fooT2() : (t : T) -> T {
|
||||
fun main(args : Array<String>) {
|
||||
args.foo()()
|
||||
<!INAPPLICABLE_CANDIDATE!>args.foo1()()<!>
|
||||
<!INAPPLICABLE_CANDIDATE!><!UNRESOLVED_REFERENCE!>a<!>.foo1()()<!>
|
||||
<!UNRESOLVED_REFERENCE!>a<!>.foo1()()
|
||||
<!UNRESOLVED_REFERENCE!>a<!>.foo1()(<!UNRESOLVED_REFERENCE!>a<!>)
|
||||
|
||||
args.foo1()(1)
|
||||
|
||||
+1
-1
@@ -9,7 +9,7 @@ class OverloadTest {
|
||||
object Literal
|
||||
|
||||
inline fun <T : Any> OverloadTest.overload(value: T?, function: OverloadTest.(T) -> Unit) {
|
||||
if (value == null) foo(Literal) else <!INAPPLICABLE_CANDIDATE!>function<!>(value)
|
||||
if (value == null) foo(Literal) else function(value)
|
||||
}
|
||||
|
||||
// Overload resolution ambiguity
|
||||
|
||||
@@ -29,7 +29,7 @@ class Properties {
|
||||
|
||||
fun param(param: Obsolete) { param.use() }
|
||||
|
||||
fun funcParamReceiver(param: Obsolete.()->Unit) { Obsolete().<!UNRESOLVED_REFERENCE!>param<!>() }
|
||||
fun funcParamReceiver(param: Obsolete.()->Unit) { Obsolete().param() }
|
||||
fun funcParamParam(param: (Obsolete)->Unit) { param(Obsolete()) }
|
||||
fun funcParamRetVal(param: ()->Obsolete) { param() }
|
||||
|
||||
|
||||
+4
-4
@@ -9,8 +9,8 @@ enum class E {
|
||||
|
||||
val foo: Any.() -> Unit = {}
|
||||
|
||||
fun f1() = E.FIRST.<!UNRESOLVED_REFERENCE!>foo<!>()
|
||||
fun f2() = E.FIRST.(<!UNRESOLVED_REFERENCE!>foo<!>)()
|
||||
fun f3() = E.SECOND.<!UNRESOLVED_REFERENCE!>foo<!>()
|
||||
fun f4() = E.SECOND.(<!UNRESOLVED_REFERENCE!>foo<!>)()
|
||||
fun f1() = E.FIRST.foo()
|
||||
fun f2() = E.FIRST.(foo)()
|
||||
fun f3() = E.SECOND.foo()
|
||||
fun f4() = E.SECOND.(foo)()
|
||||
fun f5() = E.SECOND.A()
|
||||
|
||||
+4
-4
@@ -9,8 +9,8 @@ enum class E {
|
||||
|
||||
val foo: Any.() -> Unit = {}
|
||||
|
||||
fun f1() = E.FIRST.<!UNRESOLVED_REFERENCE!>foo<!>()
|
||||
fun f2() = E.FIRST.(<!UNRESOLVED_REFERENCE!>foo<!>)()
|
||||
fun f3() = E.SECOND.<!UNRESOLVED_REFERENCE!>foo<!>()
|
||||
fun f4() = E.SECOND.(<!UNRESOLVED_REFERENCE!>foo<!>)()
|
||||
fun f1() = E.FIRST.foo()
|
||||
fun f2() = E.FIRST.(foo)()
|
||||
fun f3() = E.SECOND.foo()
|
||||
fun f4() = E.SECOND.(foo)()
|
||||
fun f5() = E.SECOND.A()
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
package kt1875
|
||||
|
||||
fun foo(a : Int?, b : Int.(Int)->Int) = a?.<!UNRESOLVED_REFERENCE!>b<!>(1) //unnecessary safe call warning
|
||||
fun foo(a : Int?, b : Int.(Int)->Int) = a?.b(1) //unnecessary safe call warning
|
||||
|
||||
interface T {
|
||||
val f : ((i: Int) -> Unit)?
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
class A(foo: Int.() -> Unit) {
|
||||
init {
|
||||
4.<!UNRESOLVED_REFERENCE!>foo<!>()
|
||||
4.foo()
|
||||
}
|
||||
}
|
||||
|
||||
fun test(foo: Int.(String) -> Unit) {
|
||||
4.<!UNRESOLVED_REFERENCE!>foo<!>("")
|
||||
4.<!UNRESOLVED_REFERENCE!>foo<!>(p1 = "")
|
||||
4.<!UNRESOLVED_REFERENCE!>foo<!>(p2 = "")
|
||||
4.foo("")
|
||||
4.<!INAPPLICABLE_CANDIDATE!>foo<!>(p1 = "")
|
||||
4.foo(p2 = "")
|
||||
}
|
||||
@@ -4,7 +4,7 @@ package a
|
||||
import java.util.HashMap
|
||||
|
||||
private fun <T> test(value: T, extf: String.(value: T)->Unit) {
|
||||
"".<!UNRESOLVED_REFERENCE!>extf<!>(value)
|
||||
"".extf(value)
|
||||
}
|
||||
|
||||
fun main() {
|
||||
|
||||
@@ -4,7 +4,7 @@ package kt2514
|
||||
//+JDK
|
||||
import java.io.Closeable
|
||||
|
||||
fun <T> Thread.use(block: Thread.() -> T): T = <!INAPPLICABLE_CANDIDATE!>block<!>()
|
||||
fun <T> Thread.use(block: Thread.() -> T): T = block()
|
||||
|
||||
fun <T: Closeable, R> T.use(block: (T)-> R) : R = block(this)
|
||||
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@ interface Closeable {
|
||||
class C : Closeable
|
||||
|
||||
public inline fun <T: Closeable, R> use(t: T, block: T.(T)-> R) : R {
|
||||
return t.<!UNRESOLVED_REFERENCE!>block<!>(t)
|
||||
return t.block(t)
|
||||
}
|
||||
|
||||
fun test() {
|
||||
|
||||
+1
-1
@@ -7,7 +7,7 @@ interface Closeable {
|
||||
class C : Closeable
|
||||
|
||||
public inline fun <T: Closeable, R> T.use(block: T.()-> R) : R {
|
||||
return this.<!UNRESOLVED_REFERENCE!>block<!>()
|
||||
return this.block()
|
||||
}
|
||||
|
||||
fun test() {
|
||||
|
||||
+1
-1
@@ -15,7 +15,7 @@ fun Int.test(f: String.(Int) -> Unit) {
|
||||
f("", 0)
|
||||
<!INAPPLICABLE_CANDIDATE!>f<!>("")
|
||||
with("") {
|
||||
<!INAPPLICABLE_CANDIDATE!>f<!>(0)
|
||||
f(0)
|
||||
<!INAPPLICABLE_CANDIDATE!>f<!>(0.0)
|
||||
}
|
||||
}
|
||||
@@ -5,8 +5,8 @@ inline fun inlineFunWithInvoke(s: (p: Int) -> Unit, ext: Int.(p: Int) -> Unit) {
|
||||
s.invoke(11)
|
||||
s invoke 11
|
||||
|
||||
11.<!UNRESOLVED_REFERENCE!>ext<!>(11)
|
||||
11 <!UNRESOLVED_REFERENCE!>ext<!> 11
|
||||
11.ext(11)
|
||||
11 ext 11
|
||||
}
|
||||
|
||||
inline fun inlineFunWithInvokeNonInline(noinline s: (p: Int) -> Unit, ext: Int.(p: Int) -> Unit) {
|
||||
@@ -14,8 +14,8 @@ inline fun inlineFunWithInvokeNonInline(noinline s: (p: Int) -> Unit, ext: Int.(
|
||||
s.invoke(11)
|
||||
s invoke 11
|
||||
|
||||
11.<!UNRESOLVED_REFERENCE!>ext<!>(11)
|
||||
11 <!UNRESOLVED_REFERENCE!>ext<!> 11
|
||||
11.ext(11)
|
||||
11 ext 11
|
||||
}
|
||||
|
||||
inline fun Function1<Int, Unit>.inlineExt() {
|
||||
|
||||
@@ -6,8 +6,8 @@ inline fun inlineFunWithInvoke(s: (p: Int) -> Unit, ext: Int.(p: Int) -> Unit) {
|
||||
}
|
||||
|
||||
inline fun inlineFunWithInvokeClosure(s: (p: Int) -> Unit, ext: Int.(p: Int) -> Unit) {
|
||||
subInline({p: Int -> s(p)}, { p -> this.<!UNRESOLVED_REFERENCE!>ext<!>(p)})
|
||||
subNoInline({p: Int -> s(p)}, { p -> this.<!UNRESOLVED_REFERENCE!>ext<!>(p)})
|
||||
subInline({p: Int -> s(p)}, { p -> this.ext(p)})
|
||||
subNoInline({p: Int -> s(p)}, { p -> this.ext(p)})
|
||||
}
|
||||
|
||||
//No inline
|
||||
@@ -17,8 +17,8 @@ inline fun inlineFunWithInvokeNonInline(noinline s: (p: Int) -> Unit, noinline e
|
||||
}
|
||||
|
||||
inline fun inlineFunWithInvokeClosureNoinline(noinline s: (p: Int) -> Unit, noinline ext: Int.(p: Int) -> Unit) {
|
||||
subInline({p: Int -> s(p)}, { p -> this.<!UNRESOLVED_REFERENCE!>ext<!>(p)})
|
||||
subNoInline({p: Int -> s(p)}, { p -> this.<!UNRESOLVED_REFERENCE!>ext<!>(p)})
|
||||
subInline({p: Int -> s(p)}, { p -> this.ext(p)})
|
||||
subNoInline({p: Int -> s(p)}, { p -> this.ext(p)})
|
||||
}
|
||||
|
||||
//ext function
|
||||
@@ -28,8 +28,8 @@ inline fun Function1<Int, Unit>.inlineExt(ext: Int.(p: Int) -> Unit) {
|
||||
}
|
||||
|
||||
inline fun Function1<Int, Unit>.inlineExtWithClosure(ext: Int.(p: Int) -> Unit) {
|
||||
subInline({p: Int -> this(p)}, { p -> this.<!UNRESOLVED_REFERENCE!>ext<!>(p)})
|
||||
subNoInline({p: Int -> this(p)}, { p -> this.<!UNRESOLVED_REFERENCE!>ext<!>(p)})
|
||||
subInline({p: Int -> this(p)}, { p -> this.ext(p)})
|
||||
subNoInline({p: Int -> this(p)}, { p -> this.ext(p)})
|
||||
}
|
||||
|
||||
inline fun subInline(s: (p: Int) -> Unit, ext: Int.(p: Int) -> Unit) {}
|
||||
|
||||
@@ -13,8 +13,8 @@ inline var value: (p: Int) -> String
|
||||
inline var value2: Int.(p: Int) -> String
|
||||
get() = {"123" }
|
||||
set(ext: Int.(p: Int) -> String) {
|
||||
11.<!UNRESOLVED_REFERENCE!>ext<!>(11)
|
||||
11.<!UNRESOLVED_REFERENCE!>ext<!>(11)
|
||||
11.ext(11)
|
||||
11.ext(11)
|
||||
|
||||
val p = ext
|
||||
}
|
||||
+4
-4
@@ -19,8 +19,8 @@ inline fun inlineFunWithInvoke(s: (p: Int) -> Unit, ext: Int.(p: Int) -> Unit) {
|
||||
s.invoke(11)
|
||||
s invoke 11
|
||||
|
||||
11.<!UNRESOLVED_REFERENCE!>ext<!>(11)
|
||||
11 <!UNRESOLVED_REFERENCE!>ext<!> 11
|
||||
11.ext(11)
|
||||
11 ext 11
|
||||
|
||||
s
|
||||
ext
|
||||
@@ -34,8 +34,8 @@ inline fun inlineFunWithInvokeNonInline(noinline s: (p: Int) -> Unit, ext: Int.(
|
||||
s.invoke(11)
|
||||
s invoke 11
|
||||
|
||||
11.<!UNRESOLVED_REFERENCE!>ext<!>(11)
|
||||
11 <!UNRESOLVED_REFERENCE!>ext<!> 11
|
||||
11.ext(11)
|
||||
11 ext 11
|
||||
|
||||
s
|
||||
ext
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
|
||||
fun string(init: StringBuilder.() -> Unit): String{
|
||||
val answer = StringBuilder()
|
||||
answer.<!UNRESOLVED_REFERENCE!>init<!>()
|
||||
answer.init()
|
||||
return answer.toString()
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -16,7 +16,7 @@ fun B.b() {
|
||||
|
||||
|
||||
fun test() {
|
||||
fun <T> without(f: T.() -> Unit): Unit = (null!!).<!UNRESOLVED_REFERENCE!>f<!>()
|
||||
fun <T> without(f: T.() -> Unit): Unit = (null!!).f()
|
||||
without<B>() b@ {
|
||||
object : A {
|
||||
override fun foo() {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
// !WITH_NEW_INFERENCE
|
||||
//KT-13330 AssertionError: Illegal resolved call to variable with invoke
|
||||
|
||||
fun foo(exec: (String.() -> Unit)?) = "".<!UNRESOLVED_REFERENCE!>exec<!><caret>() // <caret> is test data tag here
|
||||
fun foo(exec: (String.() -> Unit)?) = "".<!INAPPLICABLE_CANDIDATE!>exec<!><caret>() // <caret> is test data tag here
|
||||
+3
-3
@@ -21,7 +21,7 @@ fun test2(f: (String) -> Unit) {
|
||||
}
|
||||
|
||||
fun test3(f: String.(String) -> Unit) {
|
||||
"".<!UNRESOLVED_REFERENCE!>f<!>("")
|
||||
"".<!UNRESOLVED_REFERENCE!>f<!>(p0 = "")
|
||||
"".<!UNRESOLVED_REFERENCE!>f<!>(zzz = "")
|
||||
"".f("")
|
||||
"".<!INAPPLICABLE_CANDIDATE!>f<!>(p0 = "")
|
||||
"".<!INAPPLICABLE_CANDIDATE!>f<!>(zzz = "")
|
||||
}
|
||||
|
||||
@@ -10,5 +10,5 @@ return if (answer == 2) "OK" else "FAIL"
|
||||
}
|
||||
|
||||
fun apply(arg:String, f : String.() -> Int) : Int {
|
||||
return arg.<!UNRESOLVED_REFERENCE!>f<!>()
|
||||
return arg.f()
|
||||
}
|
||||
|
||||
@@ -2,15 +2,15 @@
|
||||
|
||||
class A {
|
||||
fun foo() {}
|
||||
fun bar(f: A.() -> Unit = {}) = <!INAPPLICABLE_CANDIDATE!>f<!>()
|
||||
fun bar(f: A.() -> Unit = {}) = f()
|
||||
}
|
||||
|
||||
class B {
|
||||
class D {
|
||||
init {
|
||||
A().bar {
|
||||
this.<!UNRESOLVED_REFERENCE!>foo<!>()
|
||||
<!UNRESOLVED_REFERENCE!>foo<!>()
|
||||
this.foo()
|
||||
foo()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ fun <T> generic_invoker(gen : (String) -> T) : T {
|
||||
}
|
||||
|
||||
infix fun <T> T.with(f : T.() -> Unit) {
|
||||
<!INAPPLICABLE_CANDIDATE!>f<!>()
|
||||
f()
|
||||
}
|
||||
|
||||
fun main() {
|
||||
|
||||
@@ -14,7 +14,7 @@ interface ChannelPipelineFactory{
|
||||
class StandardPipelineFactory(val config: ChannelPipeline.()->Unit) : ChannelPipelineFactory {
|
||||
override fun getPipeline() : ChannelPipeline {
|
||||
val pipeline = DefaultChannelPipeline()
|
||||
pipeline.<!UNRESOLVED_REFERENCE!>config<!> ()
|
||||
pipeline.config ()
|
||||
return pipeline
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,5 +4,5 @@ object O
|
||||
val foo: O.() -> Unit = null!!
|
||||
|
||||
fun test() {
|
||||
O.<!UNRESOLVED_REFERENCE!>foo<!>()
|
||||
O.foo()
|
||||
}
|
||||
+1
-1
@@ -2,6 +2,6 @@ object X
|
||||
|
||||
class Y {
|
||||
fun f(op: X.() -> Unit) {
|
||||
X.<!UNRESOLVED_REFERENCE!>op<!>()
|
||||
X.op()
|
||||
}
|
||||
}
|
||||
Vendored
+1
-1
@@ -2,7 +2,7 @@
|
||||
|
||||
fun foo(a: Any, f: ()->Int) = f()
|
||||
fun foo(a: Any, f: (Any)->Int) = f(a)
|
||||
fun foo(i: Int, f: Int.()->Int) = i.<!UNRESOLVED_REFERENCE!>f<!>()
|
||||
fun foo(i: Int, f: Int.()->Int) = i.f()
|
||||
|
||||
fun test1() {
|
||||
<!AMBIGUITY!>foo<!>(1) { ->
|
||||
|
||||
+7
-7
@@ -12,17 +12,17 @@ typealias XBar = Bar
|
||||
|
||||
typealias XXBar = XBar
|
||||
|
||||
fun Foo.foo(body: Foo.() -> Unit) = <!INAPPLICABLE_CANDIDATE!>body<!>()
|
||||
fun Foo.xbar(body: XBar.() -> Unit) = Bar().<!UNRESOLVED_REFERENCE!>body<!>()
|
||||
fun Foo.xxbar(body: XXBar.() -> Unit) = Bar().<!UNRESOLVED_REFERENCE!>body<!>()
|
||||
fun Foo.foo(body: Foo.() -> Unit) = body()
|
||||
fun Foo.xbar(body: XBar.() -> Unit) = Bar().body()
|
||||
fun Foo.xxbar(body: XXBar.() -> Unit) = Bar().body()
|
||||
|
||||
fun test() {
|
||||
Foo().foo {
|
||||
<!UNRESOLVED_REFERENCE!>xbar<!> {
|
||||
<!UNRESOLVED_REFERENCE!>foo<!> {}
|
||||
xbar {
|
||||
foo {}
|
||||
}
|
||||
<!UNRESOLVED_REFERENCE!>xxbar<!> {
|
||||
<!UNRESOLVED_REFERENCE!>foo<!> {}
|
||||
xxbar {
|
||||
foo {}
|
||||
}
|
||||
}
|
||||
}
|
||||
Vendored
+4
-4
@@ -12,13 +12,13 @@ class Bar
|
||||
typealias YBar = ZBar
|
||||
typealias ZBar = <!OTHER_ERROR!>YBar<!>
|
||||
|
||||
fun Foo.foo(body: Foo.() -> Unit) = <!INAPPLICABLE_CANDIDATE!>body<!>()
|
||||
fun Foo.zbar(body: ZBar.() -> Unit) = Bar().<!UNRESOLVED_REFERENCE!>body<!>()
|
||||
fun Foo.foo(body: Foo.() -> Unit) = body()
|
||||
fun Foo.zbar(body: ZBar.() -> Unit) = Bar().body()
|
||||
|
||||
fun test() {
|
||||
Foo().foo {
|
||||
<!UNRESOLVED_REFERENCE!>zbar<!> {
|
||||
<!UNRESOLVED_REFERENCE!>foo<!> {}
|
||||
zbar {
|
||||
foo {}
|
||||
}
|
||||
}
|
||||
}
|
||||
+3
-3
@@ -20,14 +20,14 @@ package test
|
||||
|
||||
import a.A
|
||||
|
||||
fun <T, R> T.with(f: T.() -> R) = <!INAPPLICABLE_CANDIDATE!>f<!>()
|
||||
fun <T, R> T.with(f: T.() -> R) = f()
|
||||
|
||||
fun A.extFun1() = b.length
|
||||
|
||||
// fun A.extFun2() = c.length // TODO fix KT-9953
|
||||
|
||||
val x1 = A("").with { b.<!UNRESOLVED_REFERENCE!>length<!> }
|
||||
val x1 = A("").with { b.length }
|
||||
|
||||
// val x2 = A("").with { c.length } // TODO fix KT-9953
|
||||
|
||||
val x3 = A.with { c.<!UNRESOLVED_REFERENCE!>length<!> }
|
||||
val x3 = A.with { c.length }
|
||||
@@ -24,10 +24,10 @@ fun test(c: () -> String, e: Int.() -> String) {
|
||||
c()
|
||||
(c)()
|
||||
|
||||
3.<!UNRESOLVED_REFERENCE!>e<!>()
|
||||
3.(<!UNRESOLVED_REFERENCE!>e<!>)()
|
||||
3.e()
|
||||
3.(e)()
|
||||
with(3) {
|
||||
<!INAPPLICABLE_CANDIDATE!>e<!>()
|
||||
(<!INAPPLICABLE_CANDIDATE!>e<!>)()
|
||||
e()
|
||||
(e)()
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -15,8 +15,8 @@ fun test(a: A) {
|
||||
a.<!INAPPLICABLE_CANDIDATE!>x<!>()
|
||||
<!INAPPLICABLE_CANDIDATE!>(a.x)()<!>
|
||||
if (a.x != null) {
|
||||
a.<!INAPPLICABLE_CANDIDATE!>x<!>() // todo
|
||||
<!INAPPLICABLE_CANDIDATE!>(a.x)()<!>
|
||||
a.x() // todo
|
||||
(a.x)()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+1
-1
@@ -8,5 +8,5 @@ fun test(a: A, foo: Foo) {
|
||||
}
|
||||
|
||||
fun test(a: Int, foo: Int.()->Unit) {
|
||||
a.<!UNRESOLVED_REFERENCE!>foo<!>()
|
||||
a.foo()
|
||||
}
|
||||
Vendored
+8
-8
@@ -55,21 +55,21 @@ fun test(a: A, b: B) {
|
||||
a.foo(b)
|
||||
|
||||
with(a) {
|
||||
b.<!UNRESOLVED_REFERENCE!>foo<!>()
|
||||
b.foo()
|
||||
|
||||
b.(<!UNRESOLVED_REFERENCE!>foo<!>)()
|
||||
b.(foo)()
|
||||
|
||||
<!UNRESOLVED_REFERENCE!>(b.<!UNRESOLVED_REFERENCE!>foo<!>)()<!>
|
||||
(b.foo)()
|
||||
|
||||
foo(b)
|
||||
(foo)(b)
|
||||
}
|
||||
|
||||
with(b) {
|
||||
a.<!INAPPLICABLE_CANDIDATE!>foo<!>()
|
||||
a.(<!INAPPLICABLE_CANDIDATE!>foo<!>)()
|
||||
a.foo()
|
||||
a.(foo)()
|
||||
|
||||
<!INAPPLICABLE_CANDIDATE!>(a.foo)()<!>
|
||||
(a.foo)()
|
||||
|
||||
(a.foo)(this)
|
||||
a.foo(this)
|
||||
@@ -77,8 +77,8 @@ fun test(a: A, b: B) {
|
||||
|
||||
with(a) {
|
||||
with(b) {
|
||||
<!INAPPLICABLE_CANDIDATE!>foo<!>()
|
||||
(<!INAPPLICABLE_CANDIDATE!>foo<!>)()
|
||||
foo()
|
||||
(foo)()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,11 +6,11 @@ class B
|
||||
|
||||
fun test(a: A, b: B) {
|
||||
with(b) {
|
||||
a.<!INAPPLICABLE_CANDIDATE!>foo<!>() // here must be error, because a is not extension receiver
|
||||
a.foo() // here must be error, because a is not extension receiver
|
||||
|
||||
a.foo(this)
|
||||
|
||||
<!INAPPLICABLE_CANDIDATE!>(a.foo)()<!>
|
||||
(a.foo)()
|
||||
|
||||
(a.foo)(this)
|
||||
}
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
interface A
|
||||
|
||||
fun foo(invoke: A.()->Unit, a: A) {
|
||||
a.<!UNRESOLVED_REFERENCE!>invoke<!>()
|
||||
a.invoke()
|
||||
}
|
||||
|
||||
fun bar(invoke: Any.()->Any, a: Any) {
|
||||
a.<!UNRESOLVED_REFERENCE!>invoke<!>()
|
||||
a.invoke()
|
||||
}
|
||||
|
||||
+2
-2
@@ -12,7 +12,7 @@ fun test(a: A, b: B) {
|
||||
b.(a)()
|
||||
|
||||
with(b) {
|
||||
val y: Int = <!UNRESOLVED_REFERENCE!>a<!>()
|
||||
(<!UNRESOLVED_REFERENCE!>a<!>)()
|
||||
val y: Int = a()
|
||||
(a)()
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -9,7 +9,7 @@ class B {
|
||||
|
||||
fun test(foo: A.() -> Int) {
|
||||
with(A()) {
|
||||
<!INAPPLICABLE_CANDIDATE!>foo<!>() <!INAPPLICABLE_CANDIDATE!>checkType<!> { <!INAPPLICABLE_CANDIDATE!>_<!><Int>() }
|
||||
foo() checkType { _<Int>() }
|
||||
with(B()) {
|
||||
foo() checkType { _<B>() }
|
||||
this.foo() checkType { _<B>() }
|
||||
|
||||
+1
-1
@@ -1,7 +1,7 @@
|
||||
// !WITH_NEW_INFERENCE
|
||||
|
||||
fun f(s: String, action: (String.() -> Unit)?) {
|
||||
s.foo().bar().<!UNRESOLVED_REFERENCE!>action<!>()
|
||||
s.foo().bar().<!INAPPLICABLE_CANDIDATE!>action<!>()
|
||||
}
|
||||
|
||||
fun String.foo() = ""
|
||||
|
||||
@@ -7,9 +7,10 @@ FILE fqName:<root> fileName:/extFunInvokeAsFun.kt
|
||||
CALL 'public abstract fun invoke (p1: kotlin.Any?): kotlin.Unit [operator] declared in kotlin.Function1' type=kotlin.Unit origin=null
|
||||
$this: GET_VAR 'block: kotlin.Function1<kotlin.Any?, kotlin.Unit> declared in <root>.with1' type=kotlin.Function1<kotlin.Any?, kotlin.Unit> origin=null
|
||||
p1: GET_VAR 'receiver: kotlin.Any? declared in <root>.with1' type=kotlin.Any? origin=null
|
||||
FUN name:with2 visibility:public modality:FINAL <> (receiver:kotlin.Any?, block:kotlin.Function1<kotlin.Any?, kotlin.Unit>) returnType:IrErrorType
|
||||
FUN name:with2 visibility:public modality:FINAL <> (receiver:kotlin.Any?, block:kotlin.Function1<kotlin.Any?, kotlin.Unit>) returnType:kotlin.Unit
|
||||
VALUE_PARAMETER name:receiver index:0 type:kotlin.Any?
|
||||
VALUE_PARAMETER name:block index:1 type:kotlin.Function1<kotlin.Any?, kotlin.Unit>
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun with2 (receiver: kotlin.Any?, block: kotlin.Function1<kotlin.Any?, kotlin.Unit>): IrErrorType declared in <root>'
|
||||
ERROR_CALL 'Unresolved reference: <Unresolved name: block>#' type=IrErrorType
|
||||
RETURN type=kotlin.Nothing from='public final fun with2 (receiver: kotlin.Any?, block: kotlin.Function1<kotlin.Any?, kotlin.Unit>): kotlin.Unit declared in <root>'
|
||||
CALL 'public abstract fun invoke (p1: kotlin.Any?): kotlin.Unit [operator] declared in kotlin.Function1' type=kotlin.Unit origin=null
|
||||
$this: GET_VAR 'block: kotlin.Function1<kotlin.Any?, kotlin.Unit> declared in <root>.with2' type=kotlin.Function1<kotlin.Any?, kotlin.Unit> origin=null
|
||||
|
||||
@@ -1,9 +1,10 @@
|
||||
FILE fqName:<root> fileName:/extFunSafeInvoke.kt
|
||||
FUN name:test visibility:public modality:FINAL <> (receiver:kotlin.Any?, fn:kotlin.Function3<kotlin.Any, kotlin.Int, kotlin.String, kotlin.Unit>) returnType:IrErrorType
|
||||
FUN name:test visibility:public modality:FINAL <> (receiver:kotlin.Any?, fn:kotlin.Function3<kotlin.Any, kotlin.Int, kotlin.String, kotlin.Unit>) returnType:kotlin.Unit?
|
||||
VALUE_PARAMETER name:receiver index:0 type:kotlin.Any?
|
||||
VALUE_PARAMETER name:fn index:1 type:kotlin.Function3<kotlin.Any, kotlin.Int, kotlin.String, kotlin.Unit>
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun test (receiver: kotlin.Any?, fn: kotlin.Function3<kotlin.Any, kotlin.Int, kotlin.String, kotlin.Unit>): IrErrorType declared in <root>'
|
||||
ERROR_CALL 'Unresolved reference: <Unresolved name: fn>#' type=IrErrorType
|
||||
CONST Int type=kotlin.Int value=42
|
||||
CONST String type=kotlin.String value="Hello"
|
||||
RETURN type=kotlin.Nothing from='public final fun test (receiver: kotlin.Any?, fn: kotlin.Function3<kotlin.Any, kotlin.Int, kotlin.String, kotlin.Unit>): kotlin.Unit? declared in <root>'
|
||||
CALL 'public abstract fun invoke (p1: kotlin.Any, p2: kotlin.Int, p3: kotlin.String): kotlin.Unit [operator] declared in kotlin.Function3' type=kotlin.Unit? origin=null
|
||||
$this: GET_VAR 'fn: kotlin.Function3<kotlin.Any, kotlin.Int, kotlin.String, kotlin.Unit> declared in <root>.test' type=kotlin.Function3<kotlin.Any, kotlin.Int, kotlin.String, kotlin.Unit> origin=null
|
||||
p1: CONST Int type=kotlin.Int value=42
|
||||
p2: CONST String type=kotlin.String value="Hello"
|
||||
|
||||
@@ -13,11 +13,12 @@ FILE fqName:<root> fileName:/variableAsFunctionCall.kt
|
||||
RETURN type=kotlin.Nothing from='public final fun test1 (f: kotlin.Function0<kotlin.Unit>): kotlin.Unit declared in <root>'
|
||||
CALL 'public abstract fun invoke (): kotlin.Unit [operator] declared in kotlin.Function0' type=kotlin.Unit origin=null
|
||||
$this: GET_VAR 'f: kotlin.Function0<kotlin.Unit> declared in <root>.test1' type=kotlin.Function0<kotlin.Unit> origin=null
|
||||
FUN name:test2 visibility:public modality:FINAL <> (f:kotlin.Function1<kotlin.String, kotlin.Unit>) returnType:IrErrorType
|
||||
FUN name:test2 visibility:public modality:FINAL <> (f:kotlin.Function1<kotlin.String, kotlin.Unit>) returnType:kotlin.Unit
|
||||
VALUE_PARAMETER name:f index:0 type:kotlin.Function1<kotlin.String, kotlin.Unit>
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun test2 (f: kotlin.Function1<kotlin.String, kotlin.Unit>): IrErrorType declared in <root>'
|
||||
ERROR_CALL 'Unresolved reference: <Unresolved name: f>#' type=IrErrorType
|
||||
RETURN type=kotlin.Nothing from='public final fun test2 (f: kotlin.Function1<kotlin.String, kotlin.Unit>): kotlin.Unit declared in <root>'
|
||||
CALL 'public abstract fun invoke (p1: kotlin.String): kotlin.Unit [operator] declared in kotlin.Function1' type=kotlin.Unit origin=null
|
||||
$this: GET_VAR 'f: kotlin.Function1<kotlin.String, kotlin.Unit> declared in <root>.test2' type=kotlin.Function1<kotlin.String, kotlin.Unit> origin=null
|
||||
FUN name:test3 visibility:public modality:FINAL <> () returnType:kotlin.String
|
||||
BLOCK_BODY
|
||||
RETURN type=kotlin.Nothing from='public final fun test3 (): kotlin.String declared in <root>'
|
||||
|
||||
Reference in New Issue
Block a user