[FIR] Properly handle callable references which were resolved with error
This commit is contained in:
+10
@@ -2827,11 +2827,21 @@ public class LazyBodyIsNotTouchedTilContractsPhaseTestGenerated extends Abstract
|
||||
runTest("compiler/fir/analysis-tests/testData/resolve/references/integerLiteralInLhs.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("leakedImplicitType.kt")
|
||||
public void testLeakedImplicitType() throws Exception {
|
||||
runTest("compiler/fir/analysis-tests/testData/resolve/references/leakedImplicitType.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("referenceToExtension.kt")
|
||||
public void testReferenceToExtension() throws Exception {
|
||||
runTest("compiler/fir/analysis-tests/testData/resolve/references/referenceToExtension.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("referenceToField.kt")
|
||||
public void testReferenceToField() throws Exception {
|
||||
runTest("compiler/fir/analysis-tests/testData/resolve/references/referenceToField.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("simple.kt")
|
||||
public void testSimple() throws Exception {
|
||||
runTest("compiler/fir/analysis-tests/testData/resolve/references/simple.kt");
|
||||
|
||||
+2
-2
@@ -18,10 +18,10 @@ FILE: errCallable.kt
|
||||
}
|
||||
|
||||
public final fun foo(): R|kotlin/Unit| {
|
||||
lval x: <ERROR TYPE REF: No result type for initializer> = ::<Unresolved name: Nested>#
|
||||
lval x: R|ERROR CLASS: Unresolved reference: Nested| = ::<Unresolved reference: Nested>#
|
||||
}
|
||||
|
||||
}
|
||||
public final fun R|Your|.foo(): R|kotlin/Unit| {
|
||||
lval x: <ERROR TYPE REF: No result type for initializer> = ::<Unresolved name: Nested>#
|
||||
lval x: R|ERROR CLASS: Unresolved reference: Nested| = ::<Unresolved reference: Nested>#
|
||||
}
|
||||
|
||||
+25
@@ -0,0 +1,25 @@
|
||||
FILE: leakedImplicitType.kt
|
||||
public final class Foo : R|kotlin/Any| {
|
||||
public constructor(): R|Foo| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
public final fun bar(): R|kotlin/Unit| {
|
||||
}
|
||||
|
||||
public final fun f(): R|ERROR CLASS: Unresolved reference: bar| {
|
||||
^f <Unresolved name: Unresolved>#()::<Unresolved reference: bar>#
|
||||
}
|
||||
|
||||
}
|
||||
public abstract interface IA : R|kotlin/Any| {
|
||||
}
|
||||
public abstract interface IB : R|IA| {
|
||||
}
|
||||
public final fun R|IA|.extFun(x: R|IB|): R|kotlin/Unit| {
|
||||
}
|
||||
public final fun R|IB|.extFun(x: R|IA|): R|kotlin/Unit| {
|
||||
}
|
||||
public final fun testWithExpectedType(): R|kotlin/Unit| {
|
||||
lval extFun_AA_B: R|IA.(IA) -> kotlin/Unit| = Q|IB|::<Unresolved reference: extFun>#
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
// ISSUE: KT-46072
|
||||
|
||||
// Case 1
|
||||
class Foo {
|
||||
fun bar() {}
|
||||
fun f() = <!UNRESOLVED_REFERENCE!>Unresolved<!>()::bar // Type of Unresolved()::bar is implicit
|
||||
}
|
||||
|
||||
// Case 2
|
||||
interface IA
|
||||
interface IB : IA
|
||||
|
||||
fun IA.extFun(x: IB) {}
|
||||
fun IB.extFun(x: IA) {}
|
||||
|
||||
fun testWithExpectedType() {
|
||||
val extFun_AA_B: IA.(IA) -> Unit = IB::<!UNRESOLVED_REFERENCE!>extFun<!> // extFun is unresolved, type of IB::extFun is implicit
|
||||
}
|
||||
+2
-2
@@ -40,8 +40,8 @@ FILE: referenceToExtension.kt
|
||||
}
|
||||
|
||||
public final fun test_2(): R|kotlin/Unit| {
|
||||
lval extensionValRef: <ERROR TYPE REF: No result type for initializer> = Q|GenericTest.B|::<Unresolved name: extensionVal>#
|
||||
lval extensionFunRef: <ERROR TYPE REF: No result type for initializer> = Q|GenericTest.B|::<Unresolved name: extensionFun>#
|
||||
lval extensionValRef: R|ERROR CLASS: Unresolved reference: extensionVal| = Q|GenericTest.B|::<Unresolved reference: extensionVal>#
|
||||
lval extensionFunRef: R|ERROR CLASS: Unresolved reference: extensionFun| = Q|GenericTest.B|::<Unresolved reference: extensionFun>#
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
FILE: referenceToField.kt
|
||||
public final class A : R|kotlin/Any| {
|
||||
public constructor(): R|A| {
|
||||
super<R|kotlin/Any|>()
|
||||
}
|
||||
|
||||
public final val x: R|kotlin/Int| = Int(1)
|
||||
public get(): R|kotlin/Int| {
|
||||
::F|/A.x|
|
||||
^ this@R|/A|.F|/A.x|
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
class A {
|
||||
val x: Int = 1
|
||||
get() {
|
||||
::<!UNSUPPORTED!>field<!>
|
||||
return field
|
||||
}
|
||||
}
|
||||
Vendored
+1
-1
@@ -13,7 +13,7 @@ FILE: beyoundCalls.kt
|
||||
}
|
||||
public final fun foo(): R|kotlin/Unit| {
|
||||
lval x: R|(kotlin/String) -> kotlin/Int| = ::R|/bar|
|
||||
lval y: <ERROR TYPE REF: No result type for initializer> = ::<Unresolved reference: bar>#
|
||||
lval y: R|ERROR CLASS: Ambiguity: bar, [/bar, /bar]| = ::<Ambiguity: bar, [/bar, /bar]>#
|
||||
lval z: R|kotlin/reflect/KFunction1<kotlin/String, kotlin/Int>| = ::R|/baz|
|
||||
lval w: R|(kotlin/String) -> kotlin/Int| = ::R|/foobaz<kotlin/String, kotlin/Int>|
|
||||
::R|/baz|
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@ fun <T, R> foobaz(x: T): R = TODO()
|
||||
|
||||
fun foo() {
|
||||
val x: (String) -> Int = ::bar
|
||||
val y = ::<!UNRESOLVED_REFERENCE!>bar<!>
|
||||
val y = ::<!OVERLOAD_RESOLUTION_AMBIGUITY!>bar<!>
|
||||
val z = ::baz
|
||||
val w: (String) -> Int = ::foobaz
|
||||
|
||||
|
||||
+1
-1
@@ -6,5 +6,5 @@ FILE: ambiguityWhenNoApplicableCallableReferenceCandidate.kt
|
||||
public final fun <T> bar(f: R|(T) -> kotlin/Unit|): R|kotlin/Unit| {
|
||||
}
|
||||
public final fun test(): R|kotlin/Unit| {
|
||||
R|/bar|<R|kotlin/Any?|>(::<Unresolved reference: foo>#)
|
||||
R|/bar|<R|kotlin/Any?|>(::<Ambiguity: foo, [/foo, /foo]>#)
|
||||
}
|
||||
|
||||
+1
-1
@@ -4,5 +4,5 @@ fun foo(y: String) {}
|
||||
fun <T> bar(f: (T) -> Unit) {}
|
||||
|
||||
fun test() {
|
||||
bar(::<!UNRESOLVED_REFERENCE!>foo<!>)
|
||||
bar(::<!OVERLOAD_RESOLUTION_AMBIGUITY!>foo<!>)
|
||||
}
|
||||
|
||||
+1
-1
@@ -37,7 +37,7 @@ FILE: chooseCallableReferenceDependingOnInferredReceiver.kt
|
||||
lval a: R|A| = R|/bar|<R|A|>(::R|/A.foo|)
|
||||
lval b: R|B| = R|/bar|<R|B|>(::R|/B.foo|)
|
||||
lval t3: R|B| = R|/bar|<R|B|>(::R|/B.baz|)
|
||||
^ R|/bar|<R|kotlin/Nothing|>(::<Unresolved reference: foo>#)
|
||||
^ R|/bar|<R|kotlin/Nothing|>(::<Ambiguity: foo, [/B.foo, /B.foo]>#)
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
+1
-1
@@ -25,7 +25,7 @@ fun test() {
|
||||
|
||||
val t3 = bar(::baz)
|
||||
|
||||
bar(::<!UNRESOLVED_REFERENCE!>foo<!>)
|
||||
bar(::<!OVERLOAD_RESOLUTION_AMBIGUITY!>foo<!>)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -21,5 +21,5 @@ FILE: eagerAndPostponedCallableReferences.kt
|
||||
lval a4: R|B| = R|/foo|<R|B|>(::R|/multiple|, ::R|/singleB|)
|
||||
lval a5: R|A| = R|/foo|<R|A|>(::R|/singleA|, ::R|/singleA|)
|
||||
lval a6: R|it(A & B)| = R|/foo|<R|it(A & B)|>(::R|/singleA|, ::R|/singleB|)
|
||||
R|/foo|<R|kotlin/Nothing|>(::<Unresolved reference: multiple>#, ::<Unresolved reference: multiple>#)
|
||||
R|/foo|<R|kotlin/Nothing|>(::<Ambiguity: multiple, [/multiple, /multiple]>#, ::<Ambiguity: multiple, [/multiple, /multiple]>#)
|
||||
}
|
||||
|
||||
+1
-1
@@ -22,5 +22,5 @@ fun test() {
|
||||
|
||||
val a6 = foo(::singleA, ::singleB)
|
||||
|
||||
foo(::<!UNRESOLVED_REFERENCE!>multiple<!>, ::<!UNRESOLVED_REFERENCE!>multiple<!>)
|
||||
foo(::<!OVERLOAD_RESOLUTION_AMBIGUITY!>multiple<!>, ::<!OVERLOAD_RESOLUTION_AMBIGUITY!>multiple<!>)
|
||||
}
|
||||
|
||||
+2
-2
@@ -9,12 +9,12 @@ FILE: moreSpecificAmbiguousExtensions.kt
|
||||
}
|
||||
public final fun test(): R|kotlin/Unit| {
|
||||
lval extFun1: R|@ExtensionFunctionType kotlin/reflect/KFunction2<IA, IB, kotlin/Unit>| = Q|IA|::R|/extFun|
|
||||
lval extFun2: <ERROR TYPE REF: No result type for initializer> = Q|IB|::<Unresolved reference: extFun>#
|
||||
lval extFun2: R|ERROR CLASS: Ambiguity: extFun, [/extFun, /extFun]| = Q|IB|::<Ambiguity: extFun, [/extFun, /extFun]>#
|
||||
}
|
||||
public final fun testWithExpectedType(): R|kotlin/Unit| {
|
||||
lval extFun_AB_A: R|IA.(IB) -> kotlin/Unit| = Q|IA|::R|/extFun|
|
||||
lval extFun_AA_B: R|IA.(IA) -> kotlin/Unit| = Q|IB|::<Unresolved reference: extFun>#
|
||||
lval extFun_BB_A: R|IB.(IB) -> kotlin/Unit| = Q|IA|::R|/extFun|
|
||||
lval extFun_BA_B: R|IB.(IA) -> kotlin/Unit| = Q|IB|::R|/extFun|
|
||||
lval extFun_BB_B: R|IB.(IB) -> kotlin/Unit| = Q|IB|::<Unresolved reference: extFun>#
|
||||
lval extFun_BB_B: R|IB.(IB) -> kotlin/Unit| = Q|IB|::<Ambiguity: extFun, [/extFun, /extFun]>#
|
||||
}
|
||||
|
||||
+2
-2
@@ -6,7 +6,7 @@ fun IB.extFun(x: IA) {}
|
||||
|
||||
fun test() {
|
||||
val extFun1 = IA::extFun
|
||||
val extFun2 = IB::<!UNRESOLVED_REFERENCE!>extFun<!>
|
||||
val extFun2 = IB::<!OVERLOAD_RESOLUTION_AMBIGUITY!>extFun<!>
|
||||
}
|
||||
|
||||
fun testWithExpectedType() {
|
||||
@@ -15,5 +15,5 @@ fun testWithExpectedType() {
|
||||
val extFun_AA_B: IA.(IA) -> Unit = IB::<!UNRESOLVED_REFERENCE!>extFun<!>
|
||||
val extFun_BB_A: IB.(IB) -> Unit = IA::extFun
|
||||
val extFun_BA_B: IB.(IA) -> Unit = IB::extFun
|
||||
val extFun_BB_B: IB.(IB) -> Unit = IB::<!UNRESOLVED_REFERENCE!>extFun<!>
|
||||
val extFun_BB_B: IB.(IB) -> Unit = IB::<!OVERLOAD_RESOLUTION_AMBIGUITY!>extFun<!>
|
||||
}
|
||||
|
||||
+1
-1
@@ -10,5 +10,5 @@ FILE: manyInnermanyOuterCandidatesAmbiguity.kt
|
||||
^bar Int(1)
|
||||
}
|
||||
public final fun main(): R|kotlin/Unit| {
|
||||
<Ambiguity: foo, [/foo, /foo]>#(::<Unresolved reference: bar>#)
|
||||
<Ambiguity: foo, [/foo, /foo]>#(::<Ambiguity: bar, [/bar, /bar]>#)
|
||||
}
|
||||
|
||||
+1
-1
@@ -6,5 +6,5 @@ fun bar(): Int = 1
|
||||
fun bar(x: String): Int = 1
|
||||
|
||||
fun main() {
|
||||
<!OVERLOAD_RESOLUTION_AMBIGUITY!>foo<!>(::<!UNRESOLVED_REFERENCE!>bar<!>)
|
||||
<!OVERLOAD_RESOLUTION_AMBIGUITY!>foo<!>(::<!OVERLOAD_RESOLUTION_AMBIGUITY!>bar<!>)
|
||||
}
|
||||
|
||||
+12
@@ -3199,12 +3199,24 @@ public class FirDiagnosticTestGenerated extends AbstractFirDiagnosticTest {
|
||||
runTest("compiler/fir/analysis-tests/testData/resolve/references/integerLiteralInLhs.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("leakedImplicitType.kt")
|
||||
public void testLeakedImplicitType() throws Exception {
|
||||
runTest("compiler/fir/analysis-tests/testData/resolve/references/leakedImplicitType.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("referenceToExtension.kt")
|
||||
public void testReferenceToExtension() throws Exception {
|
||||
runTest("compiler/fir/analysis-tests/testData/resolve/references/referenceToExtension.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("referenceToField.kt")
|
||||
public void testReferenceToField() throws Exception {
|
||||
runTest("compiler/fir/analysis-tests/testData/resolve/references/referenceToField.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("simple.kt")
|
||||
public void testSimple() throws Exception {
|
||||
|
||||
+12
@@ -3235,12 +3235,24 @@ public class FirDiagnosticsWithLightTreeTestGenerated extends AbstractFirDiagnos
|
||||
runTest("compiler/fir/analysis-tests/testData/resolve/references/integerLiteralInLhs.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("leakedImplicitType.kt")
|
||||
public void testLeakedImplicitType() throws Exception {
|
||||
runTest("compiler/fir/analysis-tests/testData/resolve/references/leakedImplicitType.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("referenceToExtension.kt")
|
||||
public void testReferenceToExtension() throws Exception {
|
||||
runTest("compiler/fir/analysis-tests/testData/resolve/references/referenceToExtension.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("referenceToField.kt")
|
||||
public void testReferenceToField() throws Exception {
|
||||
runTest("compiler/fir/analysis-tests/testData/resolve/references/referenceToField.kt");
|
||||
}
|
||||
|
||||
@Test
|
||||
@TestMetadata("simple.kt")
|
||||
public void testSimple() throws Exception {
|
||||
|
||||
@@ -214,7 +214,12 @@ class FirCallResolver(
|
||||
|
||||
when {
|
||||
referencedSymbol is FirClassLikeSymbol<*> -> {
|
||||
return components.buildResolvedQualifierForClass(referencedSymbol, nameReference.source, qualifiedAccess.typeArguments, diagnostic)
|
||||
return components.buildResolvedQualifierForClass(
|
||||
referencedSymbol,
|
||||
nameReference.source,
|
||||
qualifiedAccess.typeArguments,
|
||||
diagnostic
|
||||
)
|
||||
}
|
||||
referencedSymbol is FirTypeParameterSymbol && referencedSymbol.fir.isReified -> {
|
||||
return buildResolvedReifiedParameterReference {
|
||||
@@ -260,7 +265,8 @@ class FirCallResolver(
|
||||
)
|
||||
}
|
||||
val bestCandidates = result.bestCandidates()
|
||||
val noSuccessfulCandidates = !result.currentApplicability.isSuccess
|
||||
val applicability = result.currentApplicability
|
||||
val noSuccessfulCandidates = !applicability.isSuccess
|
||||
val reducedCandidates = if (noSuccessfulCandidates) {
|
||||
bestCandidates.toSet()
|
||||
} else {
|
||||
@@ -271,10 +277,24 @@ class FirCallResolver(
|
||||
|
||||
when {
|
||||
noSuccessfulCandidates -> {
|
||||
val errorReference = buildErrorReference(
|
||||
info,
|
||||
ConeUnresolvedReferenceError(info.name),
|
||||
callableReferenceAccess.source
|
||||
)
|
||||
resolvedCallableReferenceAtom.resultingReference = errorReference
|
||||
return false
|
||||
}
|
||||
reducedCandidates.size > 1 -> {
|
||||
if (resolvedCallableReferenceAtom.hasBeenPostponed) return false
|
||||
if (resolvedCallableReferenceAtom.hasBeenPostponed) {
|
||||
val errorReference = buildErrorReference(
|
||||
info,
|
||||
ConeAmbiguityError(info.name, applicability, reducedCandidates.map { it.symbol }),
|
||||
callableReferenceAccess.source
|
||||
)
|
||||
resolvedCallableReferenceAtom.resultingReference = errorReference
|
||||
return false
|
||||
}
|
||||
resolvedCallableReferenceAtom.hasBeenPostponed = true
|
||||
return true
|
||||
}
|
||||
@@ -283,11 +303,19 @@ class FirCallResolver(
|
||||
val chosenCandidate = reducedCandidates.single()
|
||||
constraintSystemBuilder.runTransaction {
|
||||
chosenCandidate.outerConstraintBuilderEffect!!(this)
|
||||
|
||||
true
|
||||
}
|
||||
|
||||
resolvedCallableReferenceAtom.resultingCandidate = Pair(chosenCandidate, result.currentApplicability)
|
||||
val reference = createResolvedNamedReference(
|
||||
callableReferenceAccess.calleeReference,
|
||||
info.name,
|
||||
info,
|
||||
reducedCandidates,
|
||||
applicability,
|
||||
createResolvedReferenceWithoutCandidateForLocalVariables = false
|
||||
)
|
||||
resolvedCallableReferenceAtom.resultingReference = reference
|
||||
resolvedCallableReferenceAtom.resultingTypeForCallableReference = chosenCandidate.resultingTypeForCallableReference
|
||||
|
||||
return true
|
||||
}
|
||||
@@ -384,8 +412,7 @@ class FirCallResolver(
|
||||
callInfo,
|
||||
if (annotationClassSymbol != null) ConeIllegalAnnotationError(reference.name)
|
||||
else ConeUnresolvedNameError(reference.name),
|
||||
reference.source,
|
||||
reference.name
|
||||
reference.source
|
||||
)
|
||||
}
|
||||
|
||||
@@ -491,21 +518,20 @@ class FirCallResolver(
|
||||
candidates: Collection<Candidate>,
|
||||
applicability: CandidateApplicability,
|
||||
explicitReceiver: FirExpression? = null,
|
||||
createResolvedReferenceWithoutCandidateForLocalVariables: Boolean = true
|
||||
): FirNamedReference {
|
||||
val source = reference.source
|
||||
return when {
|
||||
candidates.isEmpty() -> buildErrorReference(
|
||||
callInfo,
|
||||
ConeUnresolvedNameError(name),
|
||||
source,
|
||||
name
|
||||
source
|
||||
)
|
||||
|
||||
candidates.size > 1 -> buildErrorReference(
|
||||
callInfo,
|
||||
ConeAmbiguityError(name, applicability, candidates.map { it.symbol }),
|
||||
source,
|
||||
name
|
||||
source
|
||||
)
|
||||
|
||||
!applicability.isSuccess -> {
|
||||
@@ -514,7 +540,13 @@ class FirCallResolver(
|
||||
CandidateApplicability.HIDDEN -> ConeHiddenCandidateError(candidate.symbol)
|
||||
else -> ConeInapplicableCandidateError(applicability, candidate)
|
||||
}
|
||||
buildErrorReference(source, candidate, diagnostic)
|
||||
createErrorReferenceWithExistingCandidate(
|
||||
candidate,
|
||||
diagnostic,
|
||||
source,
|
||||
transformer.resolutionContext,
|
||||
components.resolutionStageRunner
|
||||
)
|
||||
}
|
||||
|
||||
else -> {
|
||||
@@ -527,17 +559,25 @@ class FirCallResolver(
|
||||
resolvedSymbol = coneSymbol
|
||||
}
|
||||
}
|
||||
if (explicitReceiver?.typeRef?.coneTypeSafe<ConeIntegerLiteralType>() == null) {
|
||||
if (coneSymbol is FirVariableSymbol) {
|
||||
if (coneSymbol !is FirPropertySymbol ||
|
||||
(coneSymbol.fir as FirMemberDeclaration).typeParameters.isEmpty()
|
||||
) {
|
||||
return buildResolvedNamedReference {
|
||||
this.source = source
|
||||
this.name = name
|
||||
resolvedSymbol = coneSymbol
|
||||
}
|
||||
}
|
||||
/*
|
||||
* This `if` is an optimization for local variables and properties without type parameters
|
||||
* Since they have no type variables, so we can don't run completion on them at all and create
|
||||
* resolved reference immediately
|
||||
*
|
||||
* But for callable reference resolution we should keep candidate, because it was resolved
|
||||
* with special resolution stages, which saved in candidate additional reference info,
|
||||
* like `resultingTypeForCallableReference`
|
||||
*/
|
||||
if (
|
||||
createResolvedReferenceWithoutCandidateForLocalVariables &&
|
||||
explicitReceiver?.typeRef?.coneTypeSafe<ConeIntegerLiteralType>() == null &&
|
||||
coneSymbol is FirVariableSymbol &&
|
||||
(coneSymbol !is FirPropertySymbol || (coneSymbol.fir as FirMemberDeclaration).typeParameters.isEmpty())
|
||||
) {
|
||||
return buildResolvedNamedReference {
|
||||
this.source = source
|
||||
this.name = name
|
||||
resolvedSymbol = coneSymbol
|
||||
}
|
||||
}
|
||||
FirNamedReferenceWithCandidate(source, name, candidate)
|
||||
@@ -548,22 +588,14 @@ class FirCallResolver(
|
||||
private fun buildErrorReference(
|
||||
callInfo: CallInfo,
|
||||
diagnostic: ConeDiagnostic,
|
||||
source: FirSourceElement?,
|
||||
name: Name
|
||||
source: FirSourceElement?
|
||||
): FirErrorReferenceWithCandidate {
|
||||
val candidate = CandidateFactory(transformer.resolutionContext, callInfo).createErrorCandidate(callInfo, diagnostic)
|
||||
components.resolutionStageRunner.processCandidate(candidate, transformer.resolutionContext, stopOnFirstError = false)
|
||||
return FirErrorReferenceWithCandidate(source, name, candidate, diagnostic)
|
||||
}
|
||||
|
||||
private fun buildErrorReference(
|
||||
source: FirSourceElement?,
|
||||
candidate: Candidate,
|
||||
diagnostic: ConeDiagnostic
|
||||
): FirErrorReferenceWithCandidate {
|
||||
if (!candidate.fullyAnalyzed) {
|
||||
components.resolutionStageRunner.processCandidate(candidate, transformer.resolutionContext, stopOnFirstError = false)
|
||||
}
|
||||
return FirErrorReferenceWithCandidate(source, candidate.callInfo.name, candidate, diagnostic)
|
||||
return createErrorReferenceWithErrorCandidate(
|
||||
callInfo,
|
||||
diagnostic,
|
||||
source,
|
||||
transformer.resolutionContext,
|
||||
components.resolutionStageRunner
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
/*
|
||||
* Copyright 2010-2021 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||
*/
|
||||
|
||||
package org.jetbrains.kotlin.fir.resolve
|
||||
|
||||
import org.jetbrains.kotlin.fir.FirSourceElement
|
||||
import org.jetbrains.kotlin.fir.diagnostics.ConeDiagnostic
|
||||
import org.jetbrains.kotlin.fir.resolve.calls.*
|
||||
|
||||
|
||||
fun createErrorReferenceWithErrorCandidate(
|
||||
callInfo: CallInfo,
|
||||
diagnostic: ConeDiagnostic,
|
||||
source: FirSourceElement?,
|
||||
resolutionContext: ResolutionContext,
|
||||
resolutionStageRunner: ResolutionStageRunner
|
||||
): FirErrorReferenceWithCandidate {
|
||||
return FirErrorReferenceWithCandidate(
|
||||
source,
|
||||
callInfo.name,
|
||||
resolutionStageRunner.createErrorCandidate(callInfo, resolutionContext, diagnostic),
|
||||
diagnostic
|
||||
)
|
||||
}
|
||||
|
||||
fun createErrorReferenceWithExistingCandidate(
|
||||
candidate: Candidate,
|
||||
diagnostic: ConeDiagnostic,
|
||||
source: FirSourceElement?,
|
||||
resolutionContext: ResolutionContext,
|
||||
resolutionStageRunner: ResolutionStageRunner,
|
||||
): FirErrorReferenceWithCandidate {
|
||||
resolutionStageRunner.fullyProcessCandidate(candidate, resolutionContext)
|
||||
return FirErrorReferenceWithCandidate(source, candidate.callInfo.name, candidate, diagnostic)
|
||||
}
|
||||
|
||||
fun ResolutionStageRunner.createErrorCandidate(
|
||||
callInfo: CallInfo,
|
||||
resolutionContext: ResolutionContext,
|
||||
diagnostic: ConeDiagnostic
|
||||
): Candidate {
|
||||
val candidate = CandidateFactory(resolutionContext, callInfo).createErrorCandidate(callInfo, diagnostic)
|
||||
processCandidate(candidate, resolutionContext, stopOnFirstError = false)
|
||||
return candidate
|
||||
}
|
||||
|
||||
fun ResolutionStageRunner.fullyProcessCandidate(candidate: Candidate, resolutionContext: ResolutionContext) {
|
||||
if (!candidate.fullyAnalyzed) {
|
||||
processCandidate(candidate, resolutionContext, stopOnFirstError = false)
|
||||
}
|
||||
}
|
||||
+17
-16
@@ -16,13 +16,12 @@ import org.jetbrains.kotlin.fir.resolve.diagnostics.ConeUnresolvedReferenceError
|
||||
import org.jetbrains.kotlin.fir.resolve.substitution.ConeSubstitutor
|
||||
import org.jetbrains.kotlin.fir.resolve.transformers.StoreNameReference
|
||||
import org.jetbrains.kotlin.fir.types.*
|
||||
import org.jetbrains.kotlin.fir.types.builder.buildErrorTypeRef
|
||||
import org.jetbrains.kotlin.fir.types.builder.buildResolvedTypeRef
|
||||
import org.jetbrains.kotlin.resolve.calls.components.PostponedArgumentsAnalyzerContext
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.ConstraintSystemBuilder
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.model.CoroutinePosition
|
||||
import org.jetbrains.kotlin.resolve.calls.inference.model.SimpleConstraintSystemConstraintPosition
|
||||
import org.jetbrains.kotlin.resolve.calls.tower.CandidateApplicability
|
||||
import org.jetbrains.kotlin.resolve.calls.tower.isSuccess
|
||||
import org.jetbrains.kotlin.types.model.StubTypeMarker
|
||||
import org.jetbrains.kotlin.types.model.TypeVariableMarker
|
||||
import org.jetbrains.kotlin.types.model.freshTypeConstructor
|
||||
@@ -78,27 +77,29 @@ class PostponedArgumentsAnalyzer(
|
||||
|
||||
resolutionContext.bodyResolveContext.dropCallableReferenceContext(callableReferenceAccess)
|
||||
|
||||
val (resultingCandidate, applicability) = atom.resultingCandidate
|
||||
?: Pair(null, CandidateApplicability.INAPPLICABLE)
|
||||
|
||||
val namedReference = when {
|
||||
resultingCandidate == null || !applicability.isSuccess ->
|
||||
buildErrorNamedReference {
|
||||
source = callableReferenceAccess.source
|
||||
diagnostic = ConeUnresolvedReferenceError(callableReferenceAccess.calleeReference.name)
|
||||
}
|
||||
else -> FirNamedReferenceWithCandidate(callableReferenceAccess.source, callableReferenceAccess.calleeReference.name, resultingCandidate)
|
||||
val namedReference = atom.resultingReference ?: buildErrorNamedReference {
|
||||
source = callableReferenceAccess.source
|
||||
diagnostic = ConeUnresolvedReferenceError(callableReferenceAccess.calleeReference.name)
|
||||
}
|
||||
|
||||
callableReferenceAccess.transformCalleeReference(
|
||||
StoreNameReference,
|
||||
namedReference
|
||||
).apply {
|
||||
if (resultingCandidate != null) {
|
||||
val resolvedTypeRef = buildResolvedTypeRef { type = resultingCandidate.resultingTypeForCallableReference!! }
|
||||
replaceTypeRef(resolvedTypeRef)
|
||||
resolutionContext.session.lookupTracker?.recordTypeResolveAsLookup(resolvedTypeRef, source, null)
|
||||
val typeForCallableReference = atom.resultingTypeForCallableReference
|
||||
val resolvedTypeRef = when {
|
||||
typeForCallableReference != null -> buildResolvedTypeRef {
|
||||
type = typeForCallableReference
|
||||
}
|
||||
namedReference is FirErrorReferenceWithCandidate -> buildErrorTypeRef {
|
||||
diagnostic = namedReference.diagnostic
|
||||
}
|
||||
else -> buildErrorTypeRef {
|
||||
diagnostic = ConeUnresolvedReferenceError(callableReferenceAccess.calleeReference.name)
|
||||
}
|
||||
}
|
||||
replaceTypeRef(resolvedTypeRef)
|
||||
resolutionContext.session.lookupTracker?.recordTypeResolveAsLookup(resolvedTypeRef, source, null)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+4
-3
@@ -9,16 +9,16 @@ import org.jetbrains.kotlin.fir.FirSession
|
||||
import org.jetbrains.kotlin.fir.declarations.FirAnonymousFunction
|
||||
import org.jetbrains.kotlin.fir.expressions.FirCallableReferenceAccess
|
||||
import org.jetbrains.kotlin.fir.expressions.FirStatement
|
||||
import org.jetbrains.kotlin.fir.references.FirNamedReference
|
||||
import org.jetbrains.kotlin.fir.resolve.DoubleColonLHS
|
||||
import org.jetbrains.kotlin.fir.resolve.calls.Candidate
|
||||
import org.jetbrains.kotlin.name.StandardClassIds
|
||||
import org.jetbrains.kotlin.fir.symbols.impl.ConeClassLikeLookupTagImpl
|
||||
import org.jetbrains.kotlin.fir.types.*
|
||||
import org.jetbrains.kotlin.fir.types.impl.ConeClassLikeTypeImpl
|
||||
import org.jetbrains.kotlin.name.StandardClassIds
|
||||
import org.jetbrains.kotlin.resolve.calls.model.LambdaWithTypeVariableAsExpectedTypeMarker
|
||||
import org.jetbrains.kotlin.resolve.calls.model.PostponedCallableReferenceMarker
|
||||
import org.jetbrains.kotlin.resolve.calls.model.PostponedResolvedAtomMarker
|
||||
import org.jetbrains.kotlin.resolve.calls.tower.CandidateApplicability
|
||||
import org.jetbrains.kotlin.types.model.KotlinTypeMarker
|
||||
|
||||
// --------------------------- Variables ---------------------------
|
||||
@@ -121,7 +121,8 @@ class ResolvedCallableReferenceAtom(
|
||||
|
||||
val mightNeedAdditionalResolution get() = !hasBeenResolvedOnce || hasBeenPostponed
|
||||
|
||||
var resultingCandidate: Pair<Candidate, CandidateApplicability>? = null
|
||||
var resultingReference: FirNamedReference? = null
|
||||
var resultingTypeForCallableReference: ConeKotlinType? = null
|
||||
|
||||
override val inputTypes: Collection<ConeKotlinType>
|
||||
get() {
|
||||
|
||||
+13
-4
@@ -327,15 +327,24 @@ class FirCallCompletionResultsWriterTransformer(
|
||||
callableReferenceAccess.replaceTypeArguments(typeArguments)
|
||||
session.lookupTracker?.recordTypeResolveAsLookup(resultType, typeRef.source ?: callableReferenceAccess.source, null)
|
||||
|
||||
return callableReferenceAccess.transformCalleeReference(
|
||||
StoreCalleeReference,
|
||||
buildResolvedCallableReference {
|
||||
val resolvedReference = when (calleeReference) {
|
||||
is FirErrorReferenceWithCandidate -> buildErrorNamedReference {
|
||||
source = calleeReference.source
|
||||
diagnostic = calleeReference.diagnostic
|
||||
candidateSymbol = calleeReference.candidateSymbol
|
||||
}
|
||||
else -> buildResolvedCallableReference {
|
||||
source = calleeReference.source
|
||||
name = calleeReference.name
|
||||
resolvedSymbol = calleeReference.candidateSymbol
|
||||
inferredTypeArguments.addAll(computeTypeArgumentTypes(calleeReference.candidate))
|
||||
mappedArguments = subCandidate.callableReferenceAdaptation?.mappedArguments ?: emptyMap()
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
return callableReferenceAccess.transformCalleeReference(
|
||||
StoreCalleeReference,
|
||||
resolvedReference,
|
||||
).transformDispatchReceiver(StoreReceiver, subCandidate.dispatchReceiverExpression())
|
||||
.transformExtensionReceiver(StoreReceiver, subCandidate.extensionReceiverExpression())
|
||||
}
|
||||
|
||||
+14
-14
@@ -8,6 +8,7 @@ package org.jetbrains.kotlin.fir.resolve.transformers
|
||||
import org.jetbrains.kotlin.descriptors.Modality
|
||||
import org.jetbrains.kotlin.descriptors.Visibilities
|
||||
import org.jetbrains.kotlin.fir.FirElement
|
||||
import org.jetbrains.kotlin.fir.resolve.createErrorReferenceWithExistingCandidate
|
||||
import org.jetbrains.kotlin.fir.declarations.*
|
||||
import org.jetbrains.kotlin.fir.declarations.builder.FirSimpleFunctionBuilder
|
||||
import org.jetbrains.kotlin.fir.declarations.builder.buildTypeParameter
|
||||
@@ -17,11 +18,10 @@ import org.jetbrains.kotlin.fir.expressions.*
|
||||
import org.jetbrains.kotlin.fir.expressions.builder.buildArgumentList
|
||||
import org.jetbrains.kotlin.fir.expressions.builder.buildFunctionCall
|
||||
import org.jetbrains.kotlin.fir.references.FirReference
|
||||
import org.jetbrains.kotlin.fir.references.builder.buildErrorNamedReference
|
||||
import org.jetbrains.kotlin.fir.references.impl.FirStubReference
|
||||
import org.jetbrains.kotlin.fir.resolve.BodyResolveComponents
|
||||
import org.jetbrains.kotlin.fir.resolve.calls.*
|
||||
import org.jetbrains.kotlin.fir.resolve.diagnostics.ConeUnresolvedNameError
|
||||
import org.jetbrains.kotlin.fir.resolve.diagnostics.ConeInapplicableCandidateError
|
||||
import org.jetbrains.kotlin.fir.resolvedTypeFromPrototype
|
||||
import org.jetbrains.kotlin.name.CallableId
|
||||
import org.jetbrains.kotlin.fir.symbols.SyntheticCallableId
|
||||
@@ -65,7 +65,7 @@ class FirSyntheticCallGenerator(
|
||||
argumentList,
|
||||
SyntheticCallableId.WHEN.callableName,
|
||||
context = context
|
||||
) ?: return null // TODO
|
||||
)
|
||||
|
||||
return whenExpression.transformCalleeReference(UpdateReference, reference)
|
||||
}
|
||||
@@ -89,7 +89,7 @@ class FirSyntheticCallGenerator(
|
||||
argumentList,
|
||||
SyntheticCallableId.TRY.callableName,
|
||||
context = context
|
||||
) ?: return null // TODO
|
||||
)
|
||||
|
||||
return tryExpression.transformCalleeReference(UpdateReference, reference)
|
||||
}
|
||||
@@ -104,7 +104,7 @@ class FirSyntheticCallGenerator(
|
||||
checkNotNullCall.argumentList,
|
||||
SyntheticCallableId.CHECK_NOT_NULL.callableName,
|
||||
context = context
|
||||
) ?: return null // TODO
|
||||
)
|
||||
|
||||
return checkNotNullCall.transformCalleeReference(UpdateReference, reference)
|
||||
}
|
||||
@@ -122,7 +122,7 @@ class FirSyntheticCallGenerator(
|
||||
argumentList,
|
||||
SyntheticCallableId.ELVIS_NOT_NULL.callableName,
|
||||
context = context
|
||||
) ?: return null
|
||||
)
|
||||
|
||||
return elvisExpression.transformCalleeReference(UpdateReference, reference)
|
||||
}
|
||||
@@ -142,12 +142,6 @@ class FirSyntheticCallGenerator(
|
||||
SyntheticCallableId.ID.callableName,
|
||||
CallKind.SyntheticIdForCallableReferencesResolution,
|
||||
context
|
||||
) ?: return callableReferenceAccess.transformCalleeReference(
|
||||
StoreCalleeReference,
|
||||
buildErrorNamedReference {
|
||||
source = callableReferenceAccess.source
|
||||
diagnostic = ConeUnresolvedNameError(callableReferenceAccess.calleeReference.name)
|
||||
}
|
||||
)
|
||||
val fakeCallElement = buildFunctionCall {
|
||||
calleeReference = reference
|
||||
@@ -165,12 +159,18 @@ class FirSyntheticCallGenerator(
|
||||
name: Name,
|
||||
callKind: CallKind = CallKind.SyntheticSelect,
|
||||
context: ResolutionContext
|
||||
): FirNamedReferenceWithCandidate? {
|
||||
): FirNamedReferenceWithCandidate {
|
||||
val callInfo = generateCallInfo(callSite, name, argumentList, callKind)
|
||||
val candidate = generateCandidate(callInfo, function, context)
|
||||
val applicability = components.resolutionStageRunner.processCandidate(candidate, context)
|
||||
if (applicability <= CandidateApplicability.INAPPLICABLE) {
|
||||
return null
|
||||
return createErrorReferenceWithExistingCandidate(
|
||||
candidate,
|
||||
ConeInapplicableCandidateError(applicability, candidate),
|
||||
source = null,
|
||||
context,
|
||||
components.resolutionStageRunner
|
||||
)
|
||||
}
|
||||
|
||||
return FirNamedReferenceWithCandidate(null, name, candidate)
|
||||
|
||||
+3
-8
@@ -701,26 +701,21 @@ open class FirExpressionsResolveTransformer(transformer: FirBodyResolveTransform
|
||||
}
|
||||
}
|
||||
|
||||
val callableReferenceAccessWithTransformedLHS =
|
||||
if (transformedLHS != null)
|
||||
callableReferenceAccess.transformExplicitReceiver(StoreReceiver, transformedLHS)
|
||||
else
|
||||
callableReferenceAccess
|
||||
transformedLHS?.let { callableReferenceAccess.replaceExplicitReceiver(transformedLHS) }
|
||||
|
||||
if (data !is ResolutionMode.ContextDependent /* ContextDependentDelegate is Ok here */) {
|
||||
val resolvedReference =
|
||||
components.syntheticCallGenerator.resolveCallableReferenceWithSyntheticOuterCall(
|
||||
callableReferenceAccess, data.expectedType, resolutionContext,
|
||||
) ?: callableReferenceAccess
|
||||
|
||||
dataFlowAnalyzer.exitCallableReference(resolvedReference)
|
||||
return resolvedReference
|
||||
}
|
||||
|
||||
context.storeCallableReferenceContext(callableReferenceAccess)
|
||||
|
||||
dataFlowAnalyzer.exitCallableReference(callableReferenceAccessWithTransformedLHS)
|
||||
return callableReferenceAccessWithTransformedLHS
|
||||
dataFlowAnalyzer.exitCallableReference(callableReferenceAccess)
|
||||
return callableReferenceAccess
|
||||
}
|
||||
|
||||
override fun transformGetClassCall(getClassCall: FirGetClassCall, data: ResolutionMode): FirStatement {
|
||||
|
||||
Vendored
+1
-1
@@ -3,7 +3,7 @@ fun foo(x: Int, y: Any) = x
|
||||
fun foo(x: Any, y: Int) = y
|
||||
|
||||
fun main() {
|
||||
::<!UNRESOLVED_REFERENCE!>foo<!>
|
||||
::<!OVERLOAD_RESOLUTION_AMBIGUITY!>foo<!>
|
||||
|
||||
val fooRef: (Int, Any) -> Unit = ::<!UNRESOLVED_REFERENCE!>foo<!>
|
||||
}
|
||||
|
||||
+1
-1
@@ -6,5 +6,5 @@ object TestCallableReferences {
|
||||
|
||||
fun test0(): (String) -> String = TestCallableReferences::foo
|
||||
|
||||
fun <T> test1(): (List<T>) -> List<T> = TestCallableReferences::<!UNRESOLVED_REFERENCE!>foo<!>
|
||||
fun <T> test1(): (List<T>) -> List<T> = TestCallableReferences::<!OVERLOAD_RESOLUTION_AMBIGUITY!>foo<!>
|
||||
}
|
||||
|
||||
-7
@@ -1,7 +0,0 @@
|
||||
// !DIAGNOSTICS: -UNUSED_EXPRESSION
|
||||
|
||||
val i: Int = 10
|
||||
get() {
|
||||
<!UNSUPPORTED!>::field<!>
|
||||
return field
|
||||
}
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !DIAGNOSTICS: -UNUSED_EXPRESSION
|
||||
|
||||
val i: Int = 10
|
||||
|
||||
+1
-1
@@ -22,7 +22,7 @@ fun B.foo(): Double = 0.0
|
||||
fun call(a: Any) {}
|
||||
|
||||
fun testA(a: A) {
|
||||
call(A::<!UNRESOLVED_REFERENCE!>foo<!>)
|
||||
call(A::<!OVERLOAD_RESOLUTION_AMBIGUITY!>foo<!>)
|
||||
call(A.Companion::foo)
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -7,5 +7,5 @@ fun foo(y: String) {}
|
||||
fun <T> bar(f: (T) -> Unit) {}
|
||||
|
||||
fun test() {
|
||||
bar(::<!UNRESOLVED_REFERENCE!>foo<!>)
|
||||
bar(::<!OVERLOAD_RESOLUTION_AMBIGUITY!>foo<!>)
|
||||
}
|
||||
|
||||
+1
-1
@@ -10,6 +10,6 @@ fun A.foo() = ""
|
||||
|
||||
class A {
|
||||
fun main() {
|
||||
bar(::<!UNRESOLVED_REFERENCE!>foo<!>) checkType { <!INAPPLICABLE_CANDIDATE!>_<!><String>() }
|
||||
bar(::<!OVERLOAD_RESOLUTION_AMBIGUITY!>foo<!>) checkType { <!INAPPLICABLE_CANDIDATE!>_<!><String>() }
|
||||
}
|
||||
}
|
||||
|
||||
-16
@@ -1,16 +0,0 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
fun fun1() {}
|
||||
fun fun1(x: Int) {}
|
||||
|
||||
val ref1 = ::<!UNRESOLVED_REFERENCE!>fun1<!>
|
||||
|
||||
fun fun2(vararg x: Int) {}
|
||||
fun fun2(x: Int) {}
|
||||
|
||||
val ref2 = ::<!UNRESOLVED_REFERENCE!>fun2<!>
|
||||
|
||||
fun fun3(x0: Int, vararg xs: Int) {}
|
||||
fun fun3(x0: String, vararg xs: String) {}
|
||||
|
||||
val ref3 = ::<!UNRESOLVED_REFERENCE!>fun3<!>
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
fun fun1() {}
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@
|
||||
fun foo() {}
|
||||
fun foo(s: String) {}
|
||||
|
||||
val x1 = ::<!UNRESOLVED_REFERENCE!>foo<!>
|
||||
val x1 = ::<!OVERLOAD_RESOLUTION_AMBIGUITY!>foo<!>
|
||||
val x2: () -> Unit = ::foo
|
||||
val x3: (String) -> Unit = ::foo
|
||||
val x4: (Int) -> Unit = ::<!UNRESOLVED_REFERENCE!>foo<!>
|
||||
|
||||
+1
-1
@@ -31,7 +31,7 @@ fun test() {
|
||||
val t3 = bar(::baz)
|
||||
t3
|
||||
|
||||
bar(::<!UNRESOLVED_REFERENCE!>foo<!>)
|
||||
bar(::<!OVERLOAD_RESOLUTION_AMBIGUITY!>foo<!>)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -31,5 +31,5 @@ fun test() {
|
||||
val a6 = foo(::singleA, ::singleB)
|
||||
a6
|
||||
|
||||
foo(::<!UNRESOLVED_REFERENCE!>multiple<!>, ::<!UNRESOLVED_REFERENCE!>multiple<!>)
|
||||
foo(::<!OVERLOAD_RESOLUTION_AMBIGUITY!>multiple<!>, ::<!OVERLOAD_RESOLUTION_AMBIGUITY!>multiple<!>)
|
||||
}
|
||||
|
||||
compiler/testData/diagnostics/tests/callableReference/resolve/moreSpecificAmbiguousExtensions.fir.kt
Vendored
+2
-2
@@ -9,7 +9,7 @@ fun IB.extFun(x: IA) {}
|
||||
|
||||
fun test() {
|
||||
val extFun1 = IA::extFun
|
||||
val extFun2 = IB::<!UNRESOLVED_REFERENCE!>extFun<!>
|
||||
val extFun2 = IB::<!OVERLOAD_RESOLUTION_AMBIGUITY!>extFun<!>
|
||||
}
|
||||
|
||||
fun testWithExpectedType() {
|
||||
@@ -17,5 +17,5 @@ fun testWithExpectedType() {
|
||||
val extFun_AA_B: IA.(IA) -> Unit = IB::<!UNRESOLVED_REFERENCE!>extFun<!>
|
||||
val extFun_BB_A: IB.(IB) -> Unit = IA::extFun
|
||||
val extFun_BA_B: IB.(IA) -> Unit = IB::extFun
|
||||
val extFun_BB_B: IB.(IB) -> Unit = IB::<!UNRESOLVED_REFERENCE!>extFun<!>
|
||||
val extFun_BB_B: IB.(IB) -> Unit = IB::<!OVERLOAD_RESOLUTION_AMBIGUITY!>extFun<!>
|
||||
}
|
||||
|
||||
-30
@@ -1,30 +0,0 @@
|
||||
// !CHECK_TYPE
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_EXPRESSION
|
||||
import kotlin.reflect.KFunction1
|
||||
|
||||
open class A {
|
||||
open fun bar() {}
|
||||
|
||||
fun bas() {}
|
||||
}
|
||||
class B: A() {
|
||||
override fun bar() {}
|
||||
|
||||
fun bas(i: Int) {}
|
||||
}
|
||||
|
||||
fun A.foo() {}
|
||||
fun B.foo() {}
|
||||
|
||||
fun fas() {}
|
||||
fun fas(i: Int = 1) {}
|
||||
|
||||
fun test() {
|
||||
B::foo // todo KT-9601 Chose maximally specific function in callable reference
|
||||
|
||||
B::bar checkType { _<KFunction1<B, Unit>>() }
|
||||
|
||||
B::<!UNRESOLVED_REFERENCE!>bas<!>
|
||||
|
||||
::<!UNRESOLVED_REFERENCE!>fas<!>
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !CHECK_TYPE
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_EXPRESSION
|
||||
import kotlin.reflect.KFunction1
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
fun foo() {}
|
||||
fun foo(s: String) {}
|
||||
|
||||
fun bar(f: () -> Unit) = 1
|
||||
fun bar(f: (String) -> Unit) = 2
|
||||
|
||||
val x1 = ::<!UNRESOLVED_REFERENCE!>foo<!> as () -> Unit
|
||||
val x2 = bar(::<!UNRESOLVED_REFERENCE!>foo<!> as (String) -> Unit)
|
||||
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER
|
||||
|
||||
fun foo() {}
|
||||
|
||||
-27
@@ -1,27 +0,0 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER, -EXTENSION_SHADOWED_BY_MEMBER
|
||||
|
||||
import kotlin.reflect.*
|
||||
|
||||
fun <T> ofType(x: T): T = x
|
||||
|
||||
class A {
|
||||
val foo: Int = 0
|
||||
fun foo() {}
|
||||
|
||||
fun bar() {}
|
||||
val bar: Int = 0
|
||||
}
|
||||
|
||||
fun A.foo(): String = "A"
|
||||
|
||||
val x0 = A::<!UNRESOLVED_REFERENCE!>foo<!>
|
||||
|
||||
val x1 = ofType<(A) -> Unit>(A::foo)
|
||||
val x2 = ofType<KProperty1<A, Int>>(A::foo)
|
||||
val x3: KProperty1<A, Int> = A::foo
|
||||
val x4: (A) -> String = A::foo
|
||||
|
||||
val y0 = A::<!UNRESOLVED_REFERENCE!>bar<!>
|
||||
val y1 = ofType<(A) -> Unit>(A::bar)
|
||||
val y2 = ofType<KProperty1<A, Int>>(A::bar)
|
||||
val y3: KProperty1<A, Int> = A::bar
|
||||
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER, -EXTENSION_SHADOWED_BY_MEMBER
|
||||
|
||||
import kotlin.reflect.*
|
||||
|
||||
+2
-2
@@ -22,7 +22,7 @@ val x1 = fn1(1, ::foo, ::foo)
|
||||
val x2 = fn1(1, ::foo, ::bar)
|
||||
|
||||
val x3 = fn2(::bar, ::foo)
|
||||
val x4 = <!OVERLOAD_RESOLUTION_AMBIGUITY!>fn2<!>(::<!UNRESOLVED_REFERENCE!>foo<!>, ::bar)
|
||||
val x5 = <!OVERLOAD_RESOLUTION_AMBIGUITY!>fn2<!>(::<!UNRESOLVED_REFERENCE!>foo<!>, ::<!UNRESOLVED_REFERENCE!>foo<!>)
|
||||
val x4 = <!OVERLOAD_RESOLUTION_AMBIGUITY!>fn2<!>(::<!OVERLOAD_RESOLUTION_AMBIGUITY!>foo<!>, ::bar)
|
||||
val x5 = <!OVERLOAD_RESOLUTION_AMBIGUITY!>fn2<!>(::<!OVERLOAD_RESOLUTION_AMBIGUITY!>foo<!>, ::<!OVERLOAD_RESOLUTION_AMBIGUITY!>foo<!>)
|
||||
|
||||
val x6 = fn3(1, ::qux)
|
||||
|
||||
-8
@@ -1,8 +0,0 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE
|
||||
|
||||
fun a() {
|
||||
val x = 10
|
||||
foo(<!UNSUPPORTED!>::x<!>)
|
||||
}
|
||||
|
||||
fun foo(a: Any) {}
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE
|
||||
|
||||
fun a() {
|
||||
|
||||
-15
@@ -1,15 +0,0 @@
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE
|
||||
|
||||
fun eat(value: Any) {}
|
||||
|
||||
fun test(param: String) {
|
||||
val a = <!UNSUPPORTED!>::param<!>
|
||||
|
||||
val local = "local"
|
||||
val b = <!UNSUPPORTED!>::local<!>
|
||||
|
||||
val lambda = { -> }
|
||||
val g = <!UNSUPPORTED!>::lambda<!>
|
||||
|
||||
eat(<!UNSUPPORTED!>::param<!>)
|
||||
}
|
||||
+1
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !DIAGNOSTICS: -UNUSED_PARAMETER -UNUSED_VARIABLE
|
||||
|
||||
fun eat(value: Any) {}
|
||||
|
||||
+1
-1
@@ -9,6 +9,6 @@ class Foo {
|
||||
fun main() {
|
||||
val f = Foo()
|
||||
val a: Int
|
||||
<!VARIABLE_EXPECTED!>get()<!> = f.getValue(null, <!UNSUPPORTED!>::a<!>) // no exception after fix
|
||||
<!VARIABLE_EXPECTED!>get()<!> = f.getValue(null, ::<!UNSUPPORTED!>a<!>) // no exception after fix
|
||||
<!UNRESOLVED_REFERENCE!>print<!>(<!UNINITIALIZED_VARIABLE!>a<!>)
|
||||
}
|
||||
|
||||
Vendored
+1
-1
@@ -9,6 +9,6 @@ class Foo {
|
||||
fun main(x: Int) {
|
||||
val f = Foo()
|
||||
val a: Int
|
||||
<!VARIABLE_EXPECTED!>get()<!> = f.getValue(null, <!UNSUPPORTED!>::x<!>) // no exception after fix
|
||||
<!VARIABLE_EXPECTED!>get()<!> = f.getValue(null, ::<!UNSUPPORTED!>x<!>) // no exception after fix
|
||||
<!UNRESOLVED_REFERENCE!>print<!>(<!UNINITIALIZED_VARIABLE!>a<!>)
|
||||
}
|
||||
|
||||
+3
-3
@@ -13,9 +13,9 @@ fun main() {
|
||||
val x7 = <!UNRESOLVED_REFERENCE!>logger<!>::info<!NOT_NULL_ASSERTION_ON_CALLABLE_REFERENCE!>!!<!>::<!UNRESOLVED_REFERENCE!>print<!>?::<!UNRESOLVED_REFERENCE!>print<!>
|
||||
val x8 = <!UNRESOLVED_REFERENCE!>logger<!>?::info<!NOT_NULL_ASSERTION_ON_CALLABLE_REFERENCE!>!!<!>::<!UNRESOLVED_REFERENCE!>print<!>?::<!UNRESOLVED_REFERENCE!>print<!>
|
||||
val x9 = <!UNRESOLVED_REFERENCE!>logger<!>!!::<!UNRESOLVED_REFERENCE!>info<!>?::<!UNRESOLVED_REFERENCE!>print<!>?::<!UNRESOLVED_REFERENCE!>print<!>
|
||||
val x10 = <!UNRESOLVED_REFERENCE!>logger<!>::info?::print<!NOT_NULL_ASSERTION_ON_CALLABLE_REFERENCE!>!!<!>::<!UNRESOLVED_REFERENCE!>print<!>
|
||||
val x11 = <!UNRESOLVED_REFERENCE!>logger<!>!!::info<!NOT_NULL_ASSERTION_ON_CALLABLE_REFERENCE!>!!<!>::print<!NOT_NULL_ASSERTION_ON_CALLABLE_REFERENCE!>!!<!>::<!UNRESOLVED_REFERENCE!>print<!>
|
||||
val x12 = <!UNRESOLVED_REFERENCE!>logger<!>?::info<!NOT_NULL_ASSERTION_ON_CALLABLE_REFERENCE!>!!<!>::print<!NOT_NULL_ASSERTION_ON_CALLABLE_REFERENCE!>!!<!>::<!UNRESOLVED_REFERENCE!>print<!>
|
||||
val x10 = <!UNRESOLVED_REFERENCE!>logger<!>::info?::<!UNRESOLVED_REFERENCE!>print<!><!NOT_NULL_ASSERTION_ON_CALLABLE_REFERENCE!>!!<!>::<!UNRESOLVED_REFERENCE!>print<!>
|
||||
val x11 = <!UNRESOLVED_REFERENCE!>logger<!>!!::<!UNRESOLVED_REFERENCE!>info<!><!NOT_NULL_ASSERTION_ON_CALLABLE_REFERENCE!>!!<!>::<!UNRESOLVED_REFERENCE!>print<!><!NOT_NULL_ASSERTION_ON_CALLABLE_REFERENCE!>!!<!>::<!UNRESOLVED_REFERENCE!>print<!>
|
||||
val x12 = <!UNRESOLVED_REFERENCE!>logger<!>?::info<!NOT_NULL_ASSERTION_ON_CALLABLE_REFERENCE!>!!<!>::<!UNRESOLVED_REFERENCE!>print<!><!NOT_NULL_ASSERTION_ON_CALLABLE_REFERENCE!>!!<!>::<!UNRESOLVED_REFERENCE!>print<!>
|
||||
val x13 = 42?::<!UNRESOLVED_REFERENCE!>unresolved<!>?::<!UNRESOLVED_REFERENCE!>print<!>
|
||||
|
||||
val x14 = <!UNRESOLVED_REFERENCE!>logger<!><!SYNTAX!>?!!::info?::print?::print<!>
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
// !CHECK_TYPE
|
||||
|
||||
interface Tr
|
||||
interface G<T>
|
||||
|
||||
fun test(tr: Tr) {
|
||||
val v = tr as <!NO_TYPE_ARGUMENTS_ON_RHS!>G?<!>
|
||||
// If v is not nullable, there will be a warning on this line:
|
||||
checkSubtype<G<*>>(<!ARGUMENT_TYPE_MISMATCH!>v!!<!>)
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !CHECK_TYPE
|
||||
|
||||
interface Tr
|
||||
|
||||
-9
@@ -1,9 +0,0 @@
|
||||
// !CHECK_TYPE
|
||||
|
||||
interface Tr
|
||||
interface G<T>
|
||||
|
||||
fun test(tr: Tr?) {
|
||||
val v = tr as <!NO_TYPE_ARGUMENTS_ON_RHS!>G?<!>
|
||||
checkSubtype<G<*>>(<!ARGUMENT_TYPE_MISMATCH!>v!!<!>)
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
// FIR_IDENTICAL
|
||||
// !CHECK_TYPE
|
||||
|
||||
interface Tr
|
||||
|
||||
+2
-2
@@ -24,7 +24,7 @@ fun <T> Foo2<T>.setX(y: T): T {
|
||||
fun Float.bar() {}
|
||||
|
||||
fun test1() {
|
||||
val fooSetRef = <!DEBUG_INFO_EXPRESSION_TYPE("Type is unknown")!>Foo<*>::<!UNRESOLVED_REFERENCE!>setX<!><!>
|
||||
val fooSetRef = <!DEBUG_INFO_EXPRESSION_TYPE("ERROR CLASS: Unresolved reference: setX")!>Foo<*>::<!UNRESOLVED_REFERENCE!>setX<!><!>
|
||||
val foo = Foo<Float>(1f)
|
||||
|
||||
fooSetRef.<!UNRESOLVED_REFERENCE!>invoke<!>(foo, 1)
|
||||
@@ -42,7 +42,7 @@ fun test2() {
|
||||
}
|
||||
|
||||
fun test3() {
|
||||
val fooSetRef = <!DEBUG_INFO_EXPRESSION_TYPE("Type is unknown")!>Foo2<*>::<!UNRESOLVED_REFERENCE!>setX<!><!>
|
||||
val fooSetRef = <!DEBUG_INFO_EXPRESSION_TYPE("ERROR CLASS: Unresolved reference: setX")!>Foo2<*>::<!UNRESOLVED_REFERENCE!>setX<!><!>
|
||||
val foo = Foo2<Int>(1)
|
||||
|
||||
fooSetRef.<!UNRESOLVED_REFERENCE!>invoke<!>(foo, "")
|
||||
|
||||
@@ -84,14 +84,14 @@ fun <T : Foo, R: Number, D: Int> main() {
|
||||
bar1(::resolve) // OK
|
||||
|
||||
// with LHS and conflicting projection
|
||||
bar2<T>(Foo::<!UNRESOLVED_REFERENCE!>resolve<!>)
|
||||
bar2<Foo>(Foo::<!UNRESOLVED_REFERENCE!>resolve<!>)
|
||||
bar2(Foo::<!UNRESOLVED_REFERENCE!>resolve<!>)
|
||||
bar2<T>(Foo::<!OVERLOAD_RESOLUTION_AMBIGUITY!>resolve<!>)
|
||||
bar2<Foo>(Foo::<!OVERLOAD_RESOLUTION_AMBIGUITY!>resolve<!>)
|
||||
bar2(Foo::<!OVERLOAD_RESOLUTION_AMBIGUITY!>resolve<!>)
|
||||
|
||||
// with LHS and Any? expected type
|
||||
bar3<T>(Foo::<!UNRESOLVED_REFERENCE!>resolve<!>)
|
||||
bar3<Foo>(Foo::<!UNRESOLVED_REFERENCE!>resolve<!>)
|
||||
bar3(Foo::<!UNRESOLVED_REFERENCE!>resolve<!>)
|
||||
bar3<T>(Foo::<!OVERLOAD_RESOLUTION_AMBIGUITY!>resolve<!>)
|
||||
bar3<Foo>(Foo::<!OVERLOAD_RESOLUTION_AMBIGUITY!>resolve<!>)
|
||||
bar3(Foo::<!OVERLOAD_RESOLUTION_AMBIGUITY!>resolve<!>)
|
||||
|
||||
// with LHS and `Function` expected type
|
||||
bar4<T>(Foo::resolve) // ERROR before the fix in NI
|
||||
|
||||
+1
-1
@@ -12,5 +12,5 @@ fun <V, T : V?> G<T>.foo(vararg values: V2<V?>) = build()
|
||||
fun forReference(ref: Any?) {}
|
||||
|
||||
fun test() {
|
||||
forReference(G<Int?>::<!UNRESOLVED_REFERENCE!>foo<!>)
|
||||
forReference(G<Int?>::<!OVERLOAD_RESOLUTION_AMBIGUITY!>foo<!>)
|
||||
}
|
||||
|
||||
+4
-4
@@ -6,10 +6,10 @@ fun main1() = when {
|
||||
else -> Foo::<!UNRESOLVED_REFERENCE!>plus<!>
|
||||
}
|
||||
|
||||
fun main2() = if (true) Foo::minus else Foo::times
|
||||
fun main2() = if (true) Foo::<!UNRESOLVED_REFERENCE!>minus<!> else Foo::<!UNRESOLVED_REFERENCE!>times<!>
|
||||
|
||||
fun main3() = if (true) { Foo::minus } else { Foo::times }
|
||||
fun main3() = if (true) { Foo::<!UNRESOLVED_REFERENCE!>minus<!> } else { Foo::<!UNRESOLVED_REFERENCE!>times<!> }
|
||||
|
||||
fun main4() = try { Foo::minus } finally { Foo::<!UNRESOLVED_REFERENCE!>times<!> }
|
||||
fun main4() = try { Foo::<!UNRESOLVED_REFERENCE!>minus<!> } finally { Foo::<!UNRESOLVED_REFERENCE!>times<!> }
|
||||
|
||||
fun main5() = Foo::minus ?: Foo::times
|
||||
fun main5() = Foo::<!UNRESOLVED_REFERENCE!>minus<!> ?: Foo::<!UNRESOLVED_REFERENCE!>times<!>
|
||||
|
||||
+19
-19
@@ -29,13 +29,13 @@ fun poll11(flag: Boolean) {
|
||||
}
|
||||
|
||||
fun poll12(flag: Boolean) {
|
||||
val inv = if (flag) { ::bar3 } else { ::foo3 }
|
||||
val inv = if (flag) { ::<!UNRESOLVED_REFERENCE!>bar3<!> } else { ::<!UNRESOLVED_REFERENCE!>foo3<!> }
|
||||
inv(<!NO_VALUE_FOR_PARAMETER!>)<!>
|
||||
}
|
||||
|
||||
fun poll13(flag: Boolean) {
|
||||
val inv = if (flag) { ::bar2 } else { ::foo3 }
|
||||
inv(<!NO_VALUE_FOR_PARAMETER!>)<!>
|
||||
val inv = if (flag) { ::bar2 } else { ::<!UNRESOLVED_REFERENCE!>foo3<!> }
|
||||
inv()
|
||||
}
|
||||
|
||||
fun poll14(flag: Boolean) {
|
||||
@@ -44,7 +44,7 @@ fun poll14(flag: Boolean) {
|
||||
}
|
||||
|
||||
fun poll15(flag: Boolean) {
|
||||
val inv = if (flag) { ::bar5 } else { ::foo5 }
|
||||
val inv = if (flag) { ::<!UNRESOLVED_REFERENCE!>bar5<!> } else { ::<!UNRESOLVED_REFERENCE!>foo5<!> }
|
||||
inv(<!NO_VALUE_FOR_PARAMETER!>)<!>
|
||||
}
|
||||
|
||||
@@ -59,7 +59,7 @@ fun poll17(flag: Boolean) {
|
||||
}
|
||||
|
||||
fun poll2(flag: Boolean) {
|
||||
val inv = when (flag) { true -> ::bar else -> ::foo }
|
||||
val inv = when (flag) { true -> ::<!UNRESOLVED_REFERENCE!>bar<!> else -> ::<!UNRESOLVED_REFERENCE!>foo<!> }
|
||||
inv(<!NO_VALUE_FOR_PARAMETER!>)<!>
|
||||
}
|
||||
|
||||
@@ -69,7 +69,7 @@ fun poll21(flag: Boolean) {
|
||||
}
|
||||
|
||||
fun poll22(flag: Boolean) {
|
||||
val inv = when (flag) { true -> ::bar3 else -> ::foo3 }
|
||||
val inv = when (flag) { true -> ::<!UNRESOLVED_REFERENCE!>bar3<!> else -> ::<!UNRESOLVED_REFERENCE!>foo3<!> }
|
||||
inv(<!NO_VALUE_FOR_PARAMETER!>)<!>
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ fun poll23(flag: Boolean) {
|
||||
}
|
||||
|
||||
fun poll24(flag: Boolean) {
|
||||
val inv = when (flag) { true -> ::bar5 else -> ::foo5 }
|
||||
val inv = when (flag) { true -> ::<!UNRESOLVED_REFERENCE!>bar5<!> else -> ::<!UNRESOLVED_REFERENCE!>foo5<!> }
|
||||
inv
|
||||
}
|
||||
|
||||
@@ -94,7 +94,7 @@ fun poll26(flag: Boolean) {
|
||||
}
|
||||
|
||||
fun poll3(flag: Boolean) {
|
||||
val inv = when (flag) { true -> ::bar false -> ::foo }
|
||||
val inv = when (flag) { true -> ::<!UNRESOLVED_REFERENCE!>bar<!> false -> ::<!UNRESOLVED_REFERENCE!>foo<!> }
|
||||
inv(<!NO_VALUE_FOR_PARAMETER!>)<!>
|
||||
}
|
||||
|
||||
@@ -104,7 +104,7 @@ fun poll31(flag: Boolean) {
|
||||
}
|
||||
|
||||
fun poll32(flag: Boolean) {
|
||||
val inv = when (flag) { true -> ::bar3 false -> ::foo3 }
|
||||
val inv = when (flag) { true -> ::<!UNRESOLVED_REFERENCE!>bar3<!> false -> ::<!UNRESOLVED_REFERENCE!>foo3<!> }
|
||||
inv(<!NO_VALUE_FOR_PARAMETER!>)<!>
|
||||
}
|
||||
|
||||
@@ -114,7 +114,7 @@ fun poll33(flag: Boolean) {
|
||||
}
|
||||
|
||||
fun poll34(flag: Boolean) {
|
||||
val inv = when (flag) { true -> ::bar5 false -> ::foo5 }
|
||||
val inv = when (flag) { true -> ::<!UNRESOLVED_REFERENCE!>bar5<!> false -> ::<!UNRESOLVED_REFERENCE!>foo5<!> }
|
||||
inv
|
||||
}
|
||||
|
||||
@@ -129,7 +129,7 @@ fun poll36(flag: Boolean) {
|
||||
}
|
||||
|
||||
fun poll4() {
|
||||
val inv = try { ::bar } finally { ::<!UNRESOLVED_REFERENCE!>foo<!> }
|
||||
val inv = try { ::<!UNRESOLVED_REFERENCE!>bar<!> } finally { ::<!UNRESOLVED_REFERENCE!>foo<!> }
|
||||
inv(<!NO_VALUE_FOR_PARAMETER!>)<!>
|
||||
}
|
||||
|
||||
@@ -139,7 +139,7 @@ fun poll41() {
|
||||
}
|
||||
|
||||
fun poll42() {
|
||||
val inv = try { ::bar3 } finally { ::<!UNRESOLVED_REFERENCE!>foo3<!> }
|
||||
val inv = try { ::<!UNRESOLVED_REFERENCE!>bar3<!> } finally { ::<!UNRESOLVED_REFERENCE!>foo3<!> }
|
||||
inv(<!NO_VALUE_FOR_PARAMETER!>)<!>
|
||||
}
|
||||
|
||||
@@ -149,7 +149,7 @@ fun poll43() {
|
||||
}
|
||||
|
||||
fun poll44() {
|
||||
val inv = try { ::bar5 } finally { ::<!UNRESOLVED_REFERENCE!>foo5<!> }
|
||||
val inv = try { ::<!UNRESOLVED_REFERENCE!>bar5<!> } finally { ::<!UNRESOLVED_REFERENCE!>foo5<!> }
|
||||
inv(<!NO_VALUE_FOR_PARAMETER!>)<!>
|
||||
}
|
||||
|
||||
@@ -164,7 +164,7 @@ fun poll46() {
|
||||
}
|
||||
|
||||
fun poll5() {
|
||||
val inv = try { ::bar } catch (e: Exception) { ::foo } finally { ::<!UNRESOLVED_REFERENCE!>foo<!> }
|
||||
val inv = try { ::<!UNRESOLVED_REFERENCE!>bar<!> } catch (e: Exception) { ::<!UNRESOLVED_REFERENCE!>foo<!> } finally { ::<!UNRESOLVED_REFERENCE!>foo<!> }
|
||||
inv(<!NO_VALUE_FOR_PARAMETER!>)<!>
|
||||
}
|
||||
|
||||
@@ -174,7 +174,7 @@ fun poll51() {
|
||||
}
|
||||
|
||||
fun poll52() {
|
||||
val inv = try { ::bar3 } catch (e: Exception) { ::foo3 } finally { ::<!UNRESOLVED_REFERENCE!>foo3<!> }
|
||||
val inv = try { ::<!UNRESOLVED_REFERENCE!>bar3<!> } catch (e: Exception) { ::<!UNRESOLVED_REFERENCE!>foo3<!> } finally { ::<!UNRESOLVED_REFERENCE!>foo3<!> }
|
||||
inv(<!NO_VALUE_FOR_PARAMETER!>)<!>
|
||||
}
|
||||
|
||||
@@ -184,7 +184,7 @@ fun poll53() {
|
||||
}
|
||||
|
||||
fun poll54() {
|
||||
val inv = try { ::bar5 } catch (e: Exception) { ::foo5 } finally { ::<!UNRESOLVED_REFERENCE!>foo5<!> }
|
||||
val inv = try { ::<!UNRESOLVED_REFERENCE!>bar5<!> } catch (e: Exception) { ::<!UNRESOLVED_REFERENCE!>foo5<!> } finally { ::<!UNRESOLVED_REFERENCE!>foo5<!> }
|
||||
inv(<!NO_VALUE_FOR_PARAMETER!>)<!>
|
||||
}
|
||||
|
||||
@@ -234,7 +234,7 @@ fun poll66() {
|
||||
}
|
||||
|
||||
fun poll7() {
|
||||
val inv = ::bar<!NOT_NULL_ASSERTION_ON_CALLABLE_REFERENCE!>!!<!>
|
||||
val inv = ::<!UNRESOLVED_REFERENCE!>bar<!><!NOT_NULL_ASSERTION_ON_CALLABLE_REFERENCE!>!!<!>
|
||||
inv(<!NO_VALUE_FOR_PARAMETER!>)<!>
|
||||
}
|
||||
|
||||
@@ -244,7 +244,7 @@ fun poll71() {
|
||||
}
|
||||
|
||||
fun poll72() {
|
||||
val inv = ::bar3<!NOT_NULL_ASSERTION_ON_CALLABLE_REFERENCE!>!!<!>
|
||||
val inv = ::<!UNRESOLVED_REFERENCE!>bar3<!><!NOT_NULL_ASSERTION_ON_CALLABLE_REFERENCE!>!!<!>
|
||||
inv(<!NO_VALUE_FOR_PARAMETER!>)<!>
|
||||
}
|
||||
|
||||
@@ -254,7 +254,7 @@ fun poll73() {
|
||||
}
|
||||
|
||||
fun poll74() {
|
||||
val inv = ::bar5<!NOT_NULL_ASSERTION_ON_CALLABLE_REFERENCE!>!!<!>
|
||||
val inv = ::<!UNRESOLVED_REFERENCE!>bar5<!><!NOT_NULL_ASSERTION_ON_CALLABLE_REFERENCE!>!!<!>
|
||||
inv
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -23,6 +23,6 @@ fun main(c: CollectionWithSize) {
|
||||
CompressionType.ZIP.<!OVERLOAD_RESOLUTION_AMBIGUITY!>name<!> <!INAPPLICABLE_CANDIDATE!>checkType<!> { <!INAPPLICABLE_CANDIDATE!>_<!><Double>() }
|
||||
c.<!OVERLOAD_RESOLUTION_AMBIGUITY!>size<!> <!INAPPLICABLE_CANDIDATE!>checkType<!> { <!INAPPLICABLE_CANDIDATE!>_<!><String>() }
|
||||
|
||||
CompressionType.ZIP::<!UNRESOLVED_REFERENCE!>name<!> <!INAPPLICABLE_CANDIDATE!>checkType<!> { <!INAPPLICABLE_CANDIDATE!>_<!><kotlin.reflect.KProperty0<Double>>() }
|
||||
c::<!UNRESOLVED_REFERENCE!>size<!> <!INAPPLICABLE_CANDIDATE!>checkType<!> { <!INAPPLICABLE_CANDIDATE!>_<!><kotlin.reflect.KProperty0<String>>() }
|
||||
CompressionType.ZIP::<!OVERLOAD_RESOLUTION_AMBIGUITY!>name<!> <!INAPPLICABLE_CANDIDATE!>checkType<!> { <!INAPPLICABLE_CANDIDATE!>_<!><kotlin.reflect.KProperty0<Double>>() }
|
||||
c::<!OVERLOAD_RESOLUTION_AMBIGUITY!>size<!> <!INAPPLICABLE_CANDIDATE!>checkType<!> { <!INAPPLICABLE_CANDIDATE!>_<!><kotlin.reflect.KProperty0<String>>() }
|
||||
}
|
||||
|
||||
@@ -4,33 +4,33 @@
|
||||
fun testWhen(x: Any?) {
|
||||
val y = when (x) {
|
||||
null -> ""
|
||||
else -> ::unresolved
|
||||
else -> ::<!UNRESOLVED_REFERENCE!>unresolved<!>
|
||||
}
|
||||
}
|
||||
|
||||
fun testWhenWithBraces(x: Any?) {
|
||||
val z = when(x) {
|
||||
null -> { "" }
|
||||
else -> { ::unresolved }
|
||||
else -> { ::<!UNRESOLVED_REFERENCE!>unresolved<!> }
|
||||
}
|
||||
}
|
||||
|
||||
fun testIf(x: Any?) {
|
||||
val y = if (x != null) ::unresolved else null
|
||||
val y = if (x != null) ::<!UNRESOLVED_REFERENCE!>unresolved<!> else null
|
||||
}
|
||||
|
||||
fun testIfWithBraces(x: Any?) {
|
||||
val z = if (x != null) { ::unresolved } else { null }
|
||||
val z = if (x != null) { ::<!UNRESOLVED_REFERENCE!>unresolved<!> } else { null }
|
||||
}
|
||||
|
||||
fun testElvis(x: Any?) {
|
||||
val y = x ?: ::unresolved
|
||||
val y = x ?: ::<!UNRESOLVED_REFERENCE!>unresolved<!>
|
||||
}
|
||||
|
||||
fun testExclExcl() {
|
||||
val y = :: unresolved<!NOT_NULL_ASSERTION_ON_CALLABLE_REFERENCE!>!!<!>
|
||||
val y = :: <!UNRESOLVED_REFERENCE!>unresolved<!><!NOT_NULL_ASSERTION_ON_CALLABLE_REFERENCE!>!!<!>
|
||||
}
|
||||
|
||||
fun testTry() {
|
||||
val v = try { ::unresolved } catch (e: Exception) {}
|
||||
val v = try { ::<!UNRESOLVED_REFERENCE!>unresolved<!> } catch (e: Exception) {}
|
||||
}
|
||||
|
||||
+1
-1
@@ -49,7 +49,7 @@ fun main() {
|
||||
select(id(<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.reflect.KFunction1<A, kotlin.Unit>")!>::foo4<!>), id { x: A -> }, id { <!DEBUG_INFO_EXPRESSION_TYPE("A")!>it<!> })
|
||||
select(id(<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.reflect.KFunction1<B, kotlin.Unit>")!>::foo4<!>), id { x: B -> }, id { <!DEBUG_INFO_EXPRESSION_TYPE("B")!>it<!> })
|
||||
// Expected ambiguity
|
||||
select(id(::<!UNRESOLVED_REFERENCE!>foo4<!>), id { x: A -> }, id { x: B -> }, id { <!DEBUG_INFO_EXPRESSION_TYPE("A & B")!>it<!> })
|
||||
select(id(::<!OVERLOAD_RESOLUTION_AMBIGUITY!>foo4<!>), id { x: A -> }, id { x: B -> }, id { <!DEBUG_INFO_EXPRESSION_TYPE("A & B")!>it<!> })
|
||||
|
||||
select(id(::foo5), id { x: A -> }, id { x: B -> }, id { <!DEBUG_INFO_EXPRESSION_TYPE("C")!>it<!> })
|
||||
|
||||
|
||||
@@ -6,10 +6,10 @@ fun main1() = when {
|
||||
else -> Foo::<!UNRESOLVED_REFERENCE!>plus<!>
|
||||
}
|
||||
|
||||
fun main2() = if (true) Foo::minus else Foo::times
|
||||
fun main2() = if (true) Foo::<!UNRESOLVED_REFERENCE!>minus<!> else Foo::<!UNRESOLVED_REFERENCE!>times<!>
|
||||
|
||||
fun main3() = if (true) { Foo::minus } else { Foo::times }
|
||||
fun main3() = if (true) { Foo::<!UNRESOLVED_REFERENCE!>minus<!> } else { Foo::<!UNRESOLVED_REFERENCE!>times<!> }
|
||||
|
||||
fun main4() = try { Foo::minus } finally { Foo::<!UNRESOLVED_REFERENCE!>times<!> }
|
||||
fun main4() = try { Foo::<!UNRESOLVED_REFERENCE!>minus<!> } finally { Foo::<!UNRESOLVED_REFERENCE!>times<!> }
|
||||
|
||||
fun main5() = Foo::minus ?: Foo::times
|
||||
fun main5() = Foo::<!UNRESOLVED_REFERENCE!>minus<!> ?: Foo::<!UNRESOLVED_REFERENCE!>times<!>
|
||||
|
||||
+5
-5
@@ -11,7 +11,7 @@ class Case1() {
|
||||
}
|
||||
|
||||
fun case() {
|
||||
<!NONE_APPLICABLE!>Companion<!>(::<!UNRESOLVED_REFERENCE!>x<!>)
|
||||
<!NONE_APPLICABLE!>Companion<!>(::<!OVERLOAD_RESOLUTION_AMBIGUITY!>x<!>)
|
||||
}
|
||||
|
||||
val x = ""
|
||||
@@ -27,7 +27,7 @@ class Case2() {
|
||||
}
|
||||
|
||||
fun case() {
|
||||
<!NONE_APPLICABLE!>Companion<!>(::<!UNRESOLVED_REFERENCE!>x<!>)
|
||||
<!NONE_APPLICABLE!>Companion<!>(::<!OVERLOAD_RESOLUTION_AMBIGUITY!>x<!>)
|
||||
}
|
||||
|
||||
val x = C()
|
||||
@@ -54,8 +54,8 @@ class Case3() : I {
|
||||
fun x() = "" as CharSequence
|
||||
|
||||
fun case() {
|
||||
I.<!OVERLOAD_RESOLUTION_AMBIGUITY!>invoke<!>(::<!UNRESOLVED_REFERENCE!>x<!>)
|
||||
<!OVERLOAD_RESOLUTION_AMBIGUITY!>I<!>(::<!UNRESOLVED_REFERENCE!>x<!>)
|
||||
<!OVERLOAD_RESOLUTION_AMBIGUITY!>Case3<!>(::<!UNRESOLVED_REFERENCE!>x<!>)
|
||||
I.<!OVERLOAD_RESOLUTION_AMBIGUITY!>invoke<!>(::<!OVERLOAD_RESOLUTION_AMBIGUITY!>x<!>)
|
||||
<!OVERLOAD_RESOLUTION_AMBIGUITY!>I<!>(::<!OVERLOAD_RESOLUTION_AMBIGUITY!>x<!>)
|
||||
<!OVERLOAD_RESOLUTION_AMBIGUITY!>Case3<!>(::<!OVERLOAD_RESOLUTION_AMBIGUITY!>x<!>)
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -11,7 +11,7 @@ import libCase1.*
|
||||
import kotlin.text.format
|
||||
|
||||
fun case1() {
|
||||
val y1 =(String)::<!UNRESOLVED_REFERENCE!>format<!>
|
||||
val y1 =(String)::<!OVERLOAD_RESOLUTION_AMBIGUITY!>format<!>
|
||||
}
|
||||
|
||||
// FILE: LibCase1.kt
|
||||
@@ -28,7 +28,7 @@ import libCase2.*
|
||||
import kotlin.text.*
|
||||
|
||||
fun case2() {
|
||||
val y1 =(String)::<!UNRESOLVED_REFERENCE!>format<!>
|
||||
val y1 =(String)::<!OVERLOAD_RESOLUTION_AMBIGUITY!>format<!>
|
||||
}
|
||||
|
||||
// FILE: LibCase2.kt
|
||||
|
||||
+2
-2
@@ -10,7 +10,7 @@ package testsCase1
|
||||
import libCase1.*
|
||||
|
||||
fun case1() {
|
||||
val y1 =(A)::<!UNRESOLVED_REFERENCE!>boo<!>
|
||||
val y1 =(A)::<!OVERLOAD_RESOLUTION_AMBIGUITY!>boo<!>
|
||||
}
|
||||
|
||||
// FILE: LibCase1.kt
|
||||
@@ -31,7 +31,7 @@ import libCase2.A
|
||||
import libCase2.boo
|
||||
|
||||
fun case2() {
|
||||
val y1 =(A)::<!UNRESOLVED_REFERENCE!>boo<!>
|
||||
val y1 =(A)::<!OVERLOAD_RESOLUTION_AMBIGUITY!>boo<!>
|
||||
}
|
||||
|
||||
// FILE: LibCase2.kt
|
||||
|
||||
+2
-2
@@ -11,7 +11,7 @@ package testsCase1
|
||||
import libCase1.boo
|
||||
|
||||
fun case1() {
|
||||
val y1 =1::<!UNRESOLVED_REFERENCE!>boo<!>
|
||||
val y1 =1::<!OVERLOAD_RESOLUTION_AMBIGUITY!>boo<!>
|
||||
}
|
||||
|
||||
// FILE: LibCase1.kt
|
||||
@@ -27,7 +27,7 @@ package testsCase2
|
||||
import libCase2.*
|
||||
|
||||
fun case2() {
|
||||
val y1 =1::<!UNRESOLVED_REFERENCE!>boo<!>
|
||||
val y1 =1::<!OVERLOAD_RESOLUTION_AMBIGUITY!>boo<!>
|
||||
}
|
||||
|
||||
// FILE: LibCase2.kt
|
||||
|
||||
+3
-3
@@ -11,7 +11,7 @@ package testsCase1
|
||||
import libCase1.boo
|
||||
|
||||
fun case1() {
|
||||
val y1 =::<!UNRESOLVED_REFERENCE!>boo<!>
|
||||
val y1 =::<!OVERLOAD_RESOLUTION_AMBIGUITY!>boo<!>
|
||||
}
|
||||
|
||||
// FILE: LibCase1.kt
|
||||
@@ -27,7 +27,7 @@ package testsCase2
|
||||
import libCase2.*
|
||||
|
||||
fun case2() {
|
||||
val y1 =::<!UNRESOLVED_REFERENCE!>boo<!>
|
||||
val y1 =::<!OVERLOAD_RESOLUTION_AMBIGUITY!>boo<!>
|
||||
}
|
||||
|
||||
val boo: String
|
||||
@@ -46,7 +46,7 @@ package testsCase3
|
||||
import libCase3.*
|
||||
|
||||
fun case3() {
|
||||
val y1 =::<!UNRESOLVED_REFERENCE!>boo<!>
|
||||
val y1 =::<!OVERLOAD_RESOLUTION_AMBIGUITY!>boo<!>
|
||||
}
|
||||
|
||||
val boo: String
|
||||
|
||||
@@ -180,7 +180,7 @@ fun case_12(x: TypealiasNullableStringIndirect, y: TypealiasNullableStringIndire
|
||||
|
||||
// TESTCASE NUMBER: 13
|
||||
fun case_13(x: <!UNRESOLVED_REFERENCE!>otherpackage.Case13?<!>) =
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("ERROR CLASS: Can't resolve when expression")!>if ((x == null !is Boolean) !== true) {
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("kotlin.Nothing")!>if ((x == null !is Boolean) !== true) {
|
||||
throw Exception()
|
||||
} else {
|
||||
<!DEBUG_INFO_EXPRESSION_TYPE("ERROR CLASS: Symbol not found for otherpackage.Case13?")!>x<!>
|
||||
|
||||
Reference in New Issue
Block a user