[NI] Fix resolving callable references with typealias in ths

#KT-31199 Fixed
This commit is contained in:
Dmitriy Novozhilov
2019-04-25 10:41:18 +03:00
committed by Mikhail Zarechenskiy
parent 65380f4eb4
commit f2bbae6a63
7 changed files with 42 additions and 5 deletions
@@ -1709,6 +1709,11 @@ public class FirDiagnosticsSmokeTestGenerated extends AbstractFirDiagnosticsSmok
runTest("compiler/testData/diagnostics/tests/callableReference/subtypeArgumentFromRHSForReference.kt");
}
@TestMetadata("typealiases.kt")
public void testTypealiases() throws Exception {
runTest("compiler/testData/diagnostics/tests/callableReference/typealiases.kt");
}
@TestMetadata("unused.kt")
public void testUnused() throws Exception {
runTest("compiler/testData/diagnostics/tests/callableReference/unused.kt");
@@ -681,10 +681,9 @@ class PSICallResolver(
is DoubleColonLHS.Type -> {
val qualifiedExpression = ktExpression.receiverExpression!!.let { it.referenceExpression() ?: it }
val qualifier = expressionTypingContext.trace.get(BindingContext.QUALIFIER, qualifiedExpression)
if (qualifier is ClassQualifier) {
LHSResult.Type(qualifier, lhsResult.type.unwrap())
} else {
LHSResult.Error
when (qualifier) {
is ClassQualifier, is TypeAliasQualifier -> LHSResult.Type(qualifier, lhsResult.type.unwrap())
else -> LHSResult.Error
}
}
}
@@ -6,6 +6,7 @@
package org.jetbrains.kotlin.resolve.calls.model
import org.jetbrains.kotlin.descriptors.ClassDescriptor
import org.jetbrains.kotlin.descriptors.TypeAliasDescriptor
import org.jetbrains.kotlin.name.Name
import org.jetbrains.kotlin.resolve.DescriptorUtils
import org.jetbrains.kotlin.resolve.scopes.receivers.DetailedReceiver
@@ -81,7 +82,7 @@ sealed class LHSResult {
val unboundDetailedReceiver: ReceiverValueWithSmartCastInfo
init {
assert(qualifier.descriptor is ClassDescriptor) {
assert(qualifier.descriptor is ClassDescriptor || qualifier.descriptor is TypeAliasDescriptor) {
"Should be ClassDescriptor: ${qualifier.descriptor}"
}
@@ -0,0 +1,16 @@
// !DIAGNOSTICS: -UNUSED_PARAMETER
// !LANGUAGE: +NewInference
// !WITH_NEW_INFERENCE
// Issue: KT-31199
typealias Global = String
fun String.toUpperCase(): String = TODO()
inline fun <T, R> Iterable<T>.myMap(transform: (T) -> R): List<R> {
TODO()
}
fun usesGlobal(p: List<Global>) {
p.myMap(Global::toUpperCase)
}
@@ -0,0 +1,6 @@
package
public fun usesGlobal(/*0*/ p: kotlin.collections.List<Global /* = kotlin.String */>): kotlin.Unit
public inline fun </*0*/ T, /*1*/ R> kotlin.collections.Iterable<T>.myMap(/*0*/ transform: (T) -> R): kotlin.collections.List<R>
public fun kotlin.String.toUpperCase(): kotlin.String
public typealias Global = kotlin.String
@@ -1716,6 +1716,11 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest {
runTest("compiler/testData/diagnostics/tests/callableReference/subtypeArgumentFromRHSForReference.kt");
}
@TestMetadata("typealiases.kt")
public void testTypealiases() throws Exception {
runTest("compiler/testData/diagnostics/tests/callableReference/typealiases.kt");
}
@TestMetadata("unused.kt")
public void testUnused() throws Exception {
runTest("compiler/testData/diagnostics/tests/callableReference/unused.kt");
@@ -1711,6 +1711,11 @@ public class DiagnosticsUsingJavacTestGenerated extends AbstractDiagnosticsUsing
runTest("compiler/testData/diagnostics/tests/callableReference/subtypeArgumentFromRHSForReference.kt");
}
@TestMetadata("typealiases.kt")
public void testTypealiases() throws Exception {
runTest("compiler/testData/diagnostics/tests/callableReference/typealiases.kt");
}
@TestMetadata("unused.kt")
public void testUnused() throws Exception {
runTest("compiler/testData/diagnostics/tests/callableReference/unused.kt");