KT-3395 mapOf function can't be used as literal
#KT-3395 Fixed
This commit is contained in:
@@ -337,6 +337,7 @@ public class CallResolver {
|
||||
CallCandidateResolutionContext<D> callCandidateResolutionContext =
|
||||
CallCandidateResolutionContext.createForCallBeingAnalyzed(resolvedCall, context, tracing);
|
||||
candidateResolver.completeNestedCallsInference(callCandidateResolutionContext);
|
||||
candidateResolver.checkValueArgumentTypes(callCandidateResolutionContext);
|
||||
return results;
|
||||
}
|
||||
ResolvedCallImpl<D> copy = CallResolverUtil.copy(resolvedCall, context);
|
||||
|
||||
@@ -301,6 +301,7 @@ public class CandidateResolver {
|
||||
}
|
||||
else {
|
||||
completeNestedCallsInference(contextForArgument);
|
||||
checkValueArgumentTypes(contextForArgument);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -507,6 +508,12 @@ public class CandidateResolver {
|
||||
return new ValueArgumentsCheckingResult(resultStatus, checkingResult.argumentTypes);
|
||||
}
|
||||
|
||||
public <D extends CallableDescriptor> ValueArgumentsCheckingResult checkValueArgumentTypes(
|
||||
@NotNull CallCandidateResolutionContext<D> context
|
||||
) {
|
||||
return checkValueArgumentTypes(context, context.candidateCall, context.trace, RESOLVE_FUNCTION_ARGUMENTS);
|
||||
}
|
||||
|
||||
private <D extends CallableDescriptor, C extends CallResolutionContext<C>> ValueArgumentsCheckingResult checkValueArgumentTypes(
|
||||
@NotNull CallResolutionContext<C> context,
|
||||
@NotNull ResolvedCallImpl<D> candidateCall,
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
//KT-3395 mapOf function can't be used as literal
|
||||
package b
|
||||
|
||||
import java.util.ArrayList
|
||||
|
||||
public fun query<T>(<!UNUSED_PARAMETER!>t<!>: T, <!UNUSED_PARAMETER!>args<!>: Map<String, Any>): List<T> {
|
||||
return ArrayList<T>()
|
||||
}
|
||||
|
||||
fun test(pair: Pair<String, Int>) {
|
||||
val id = "Hello" // variable is marked as unused
|
||||
|
||||
println("Some" + query(0, mapOf(id to 1)))
|
||||
|
||||
println("Some" + query(0, mapOf(pair)))
|
||||
}
|
||||
|
||||
|
||||
//from standard library
|
||||
fun mapOf<K, V>(vararg <!UNUSED_PARAMETER!>values<!>: Pair<K, V>): Map<K, V> { throw Exception() }
|
||||
|
||||
fun <A,B> A.to(<!UNUSED_PARAMETER!>that<!>: B): Pair<A, B> { throw Exception() }
|
||||
|
||||
fun println(<!UNUSED_PARAMETER!>message<!> : Any?) { throw Exception() }
|
||||
|
||||
class Pair<out A, out B> () {}
|
||||
|
||||
//short example
|
||||
fun foo<T>(t: T) = t
|
||||
|
||||
fun test(t: String) {
|
||||
|
||||
println("Some" + foo(t)) // t was marked with black square
|
||||
}
|
||||
|
||||
@@ -2170,6 +2170,11 @@ public class JetDiagnosticsTestGenerated extends AbstractDiagnosticsTestWithEage
|
||||
doTest("compiler/testData/diagnostics/tests/inference/nestedCalls/completeNestedForVariableAsFunctionCall.kt");
|
||||
}
|
||||
|
||||
@TestMetadata("kt3395.kt")
|
||||
public void testKt3395() throws Exception {
|
||||
doTest("compiler/testData/diagnostics/tests/inference/nestedCalls/kt3395.kt");
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@TestMetadata("compiler/testData/diagnostics/tests/inference/regressions")
|
||||
|
||||
Reference in New Issue
Block a user