FIR: don't perform argument check for callable references

This fixes failing FIR2IR test
This commit is contained in:
Mikhail Glukhikh
2019-09-25 15:35:12 +03:00
parent da7d5d5702
commit 4718ae4186
5 changed files with 58 additions and 10 deletions
@@ -48,6 +48,9 @@ fun resolveArgumentExpression(
isSafeCall,
typeProvider
)
// TODO:!
is FirCallableReferenceAccess -> Unit
// NB: FirCallableReferenceAccess should be checked earlier
is FirQualifiedAccessExpression -> resolvePlainExpressionArgument(
csBuilder,
argument,
@@ -60,8 +63,6 @@ fun resolveArgumentExpression(
// TODO:!
is FirAnonymousFunction -> preprocessLambdaArgument(csBuilder, argument, expectedType, expectedTypeRef, acceptLambdaAtoms)
// TODO:!
is FirCallableReferenceAccess -> Unit
// TODO:!
//TODO: Collection literal
is FirWrappedArgumentExpression -> resolveArgumentExpression(
csBuilder,
@@ -0,0 +1,14 @@
class C<T>(var x: T)
var <T> C<T>.y
get() = x
set(v) {
x = v
}
fun use(f: () -> String) {}
fun test1() {
use { C("abc").y }
use(C("abc")::y)
}
@@ -0,0 +1,27 @@
FILE: extensionPropertyInLambda.kt
public final class C<T> : R|kotlin/Any| {
public constructor<T>(x: R|T|): R|C<T>| {
super<R|kotlin/Any|>()
}
public final var x: R|T| = R|<local>/x|
public get(): R|T|
public set(value: R|T|): R|kotlin/Unit|
}
public final var <T> R|C<T>|.y: R|T|
public get(): R|T| {
^ this@R|/C|.R|/C.x|
}
public set(v: R|T|): R|kotlin/Unit| {
this@R|/C|.R|/C.x| = R|<local>/v|
}
public final fun use(f: R|kotlin/Function0<kotlin/String>|): R|kotlin/Unit| {
}
public final fun test1(): R|kotlin/Unit| {
R|/use|(<L> = use@fun <anonymous>(): R|kotlin/String| <kind=EXACTLY_ONCE> {
R|/C.C|<R|kotlin/String|>(String(abc)).R|/y|
}
)
R|/use|(R|/C.C|<R|kotlin/String|>(String(abc))::R|/y|)
}
@@ -292,6 +292,11 @@ public class FirResolveTestCaseGenerated extends AbstractFirResolveTestCase {
runTest("compiler/fir/resolve/testData/resolve/expresssions/dispatchReceiver.kt");
}
@TestMetadata("extensionPropertyInLambda.kt")
public void testExtensionPropertyInLambda() throws Exception {
runTest("compiler/fir/resolve/testData/resolve/expresssions/extensionPropertyInLambda.kt");
}
@TestMetadata("genericPropertyAccess.kt")
public void testGenericPropertyAccess() throws Exception {
runTest("compiler/fir/resolve/testData/resolve/expresssions/genericPropertyAccess.kt");
@@ -40,27 +40,28 @@ FILE fqName:<root> fileName:/genericPropertyReferenceType.kt
public open fun toString (): kotlin.String declared in kotlin.Any
$this: VALUE_PARAMETER name:<this> type:kotlin.Any
PROPERTY name:y visibility:public modality:FINAL [var]
FUN name:<get-y> visibility:public modality:FINAL <> () returnType:IrErrorType
FUN name:<get-y> visibility:public modality:FINAL <> () returnType:T of <uninitialized parent>
correspondingProperty: PROPERTY name:y visibility:public modality:FINAL [var]
BLOCK_BODY
RETURN type=kotlin.Nothing from='public final fun <get-y> (): IrErrorType declared in <root>'
ERROR_CALL 'Unresolved reference: <Unresolved name: x>#' type=IrErrorType
FUN name:<set-y> visibility:public modality:FINAL <> (v:IrErrorType) returnType:kotlin.Unit
RETURN type=kotlin.Nothing from='public final fun <get-y> (): T of <uninitialized parent> declared in <root>'
CALL 'public final fun <get-x> (): T of <uninitialized parent> declared in <root>.C' type=T of <uninitialized parent> origin=null
$this: GET_VAR '<this>: <root>.C declared in <root>.C' type=<root>.C<*> origin=null
FUN name:<set-y> visibility:public modality:FINAL <> (v:T of <uninitialized parent>) returnType:kotlin.Unit
correspondingProperty: PROPERTY name:y visibility:public modality:FINAL [var]
VALUE_PARAMETER name:v index:0 type:IrErrorType
VALUE_PARAMETER name:v index:0 type:T of <uninitialized parent>
BLOCK_BODY
ERROR_CALL 'Unresolved reference: <Unresolved name: x>#' type=IrErrorType
ERROR_CALL 'Unresolved reference: R|/C.x|' type=IrErrorType
FUN name:use visibility:public modality:FINAL <> (p:kotlin.reflect.KMutableProperty<kotlin.String>) returnType:kotlin.Unit
VALUE_PARAMETER name:p index:0 type:kotlin.reflect.KMutableProperty<kotlin.String>
BLOCK_BODY
FUN name:test1 visibility:public modality:FINAL <> () returnType:kotlin.Unit
BLOCK_BODY
CALL 'public final fun use (p: kotlin.reflect.KMutableProperty<kotlin.String>): kotlin.Unit declared in <root>' type=kotlin.Unit origin=null
p: PROPERTY_REFERENCE 'public final y: IrErrorType [var]' field=null getter='public final fun <get-y> (): IrErrorType declared in <root>' setter='public final fun <set-y> (v: IrErrorType): kotlin.Unit declared in <root>' type=IrErrorType origin=null
p: PROPERTY_REFERENCE 'public final y: T of <uninitialized parent> [var]' field=null getter='public final fun <get-y> (): T of <uninitialized parent> declared in <root>' setter='public final fun <set-y> (v: T of <uninitialized parent>): kotlin.Unit declared in <root>' type=T of <uninitialized parent> origin=null
FUN name:test2 visibility:public modality:FINAL <> (a:kotlin.Any) returnType:kotlin.Unit
VALUE_PARAMETER name:a index:0 type:kotlin.Any
BLOCK_BODY
TYPE_OP type=<root>.C<kotlin.String> origin=CAST typeOperand=<root>.C<kotlin.String>
GET_VAR 'a: kotlin.Any declared in <root>.test2' type=kotlin.Any origin=null
CALL 'public final fun use (p: kotlin.reflect.KMutableProperty<kotlin.String>): kotlin.Unit declared in <root>' type=kotlin.Unit origin=null
p: PROPERTY_REFERENCE 'public final y: IrErrorType [var]' field=null getter='public final fun <get-y> (): IrErrorType declared in <root>' setter='public final fun <set-y> (v: IrErrorType): kotlin.Unit declared in <root>' type=IrErrorType origin=null
p: PROPERTY_REFERENCE 'public final y: T of <uninitialized parent> [var]' field=null getter='public final fun <get-y> (): T of <uninitialized parent> declared in <root>' setter='public final fun <set-y> (v: T of <uninitialized parent>): kotlin.Unit declared in <root>' type=T of <uninitialized parent> origin=null