Propagate resolution results without ambiguity to constant evaluator
This allows to get rid of useless diagnostics that some value is not a constant
This commit is contained in:
+5
-5
@@ -1804,15 +1804,15 @@ public class BasicExpressionTypingVisitor extends ExpressionTypingVisitor {
|
||||
}
|
||||
|
||||
Call call = CallMaker.makeCallForCollectionLiteral(collectionLiteralExpression);
|
||||
OverloadResolutionResults<FunctionDescriptor> functionResults = components.callResolver.resolveCallWithGivenName(
|
||||
OverloadResolutionResults<FunctionDescriptor> resolutionResults = components.callResolver.resolveCallWithGivenName(
|
||||
context, call, collectionLiteralExpression, collectionLiteralCallName);
|
||||
|
||||
if (!functionResults.isSuccess() || !functionResults.isSingleResult()) {
|
||||
// TODO: report an error
|
||||
// TODO: check that resolved function is from package `kotlin`, otherwise report an error
|
||||
if (!resolutionResults.isSingleResult()) {
|
||||
return TypeInfoFactoryKt.noTypeInfo(context);
|
||||
}
|
||||
|
||||
context.trace.record(COLLECTION_LITERAL_CALL, collectionLiteralExpression, functionResults.getResultingCall());
|
||||
return TypeInfoFactoryKt.createTypeInfo(functionResults.getResultingDescriptor().getReturnType(), context);
|
||||
context.trace.record(COLLECTION_LITERAL_CALL, collectionLiteralExpression, resolutionResults.getResultingCall());
|
||||
return TypeInfoFactoryKt.createTypeInfo(resolutionResults.getResultingDescriptor().getReturnType(), context);
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -4,7 +4,7 @@ public const val ONE: kotlin.Int = 1
|
||||
public val two: kotlin.Int = 2
|
||||
@Foo(a = {1}, b = {"/"}, c = {1.0.toFloat()}) public fun test1(): kotlin.Unit
|
||||
@Foo(a = {}, b = {}, c = {}) public fun test2(): kotlin.Unit
|
||||
@Foo public fun test3(): kotlin.Unit
|
||||
@Foo(a = {1.0.toFloat()}, b = {\u0020 (' ')}, c = {1}) public fun test3(): kotlin.Unit
|
||||
@Foo(a = {1}, b = {""}, c = {1.0.toFloat()}) public fun test4(): kotlin.Unit
|
||||
@Foo(a = {3}, b = {"Hello, Kotlin"}, c = {Infinity.toFloat()}) public fun test5(): kotlin.Unit
|
||||
@Foo(a = {1}, b = {}, c = {}) public fun test6(): kotlin.Unit
|
||||
|
||||
+2
-2
@@ -4,8 +4,8 @@ package
|
||||
@Foo(a = {kotlin.Int::class, kotlin.String::class}) public fun test2(): kotlin.Unit
|
||||
@Foo(a = {kotlin.Array<*>::class}) public fun test3(): kotlin.Unit
|
||||
@Foo(a = {Gen<kotlin.Int>::class}) public fun test4(): kotlin.Unit
|
||||
@Foo public fun test5(): kotlin.Unit
|
||||
@Foo public fun test6(): kotlin.Unit
|
||||
@Foo(a = {""}) public fun test5(): kotlin.Unit
|
||||
@Foo(a = {kotlin.Int::class, 1}) public fun test6(): kotlin.Unit
|
||||
@Bar public fun test7(): kotlin.Unit
|
||||
|
||||
public final annotation class Bar : kotlin.Annotation {
|
||||
|
||||
+5
-5
@@ -5,9 +5,9 @@ annotation class Foo(
|
||||
)
|
||||
|
||||
annotation class Bar(
|
||||
val a: Array<String> = <!TYPE_INFERENCE_EXPECTED_TYPE_MISMATCH, ANNOTATION_PARAMETER_DEFAULT_VALUE_MUST_BE_CONSTANT!>[' ']<!>,
|
||||
val b: Array<String> = <!TYPE_INFERENCE_EXPECTED_TYPE_MISMATCH, ANNOTATION_PARAMETER_DEFAULT_VALUE_MUST_BE_CONSTANT!>["", <!EMPTY_CHARACTER_LITERAL!>''<!>]<!>,
|
||||
val c: Array<String> = <!TYPE_INFERENCE_EXPECTED_TYPE_MISMATCH, ANNOTATION_PARAMETER_DEFAULT_VALUE_MUST_BE_CONSTANT!>[1]<!>
|
||||
val a: Array<String> = <!TYPE_INFERENCE_EXPECTED_TYPE_MISMATCH!>[' ']<!>,
|
||||
val b: Array<String> = <!TYPE_INFERENCE_EXPECTED_TYPE_MISMATCH!>["", <!EMPTY_CHARACTER_LITERAL!>''<!>]<!>,
|
||||
val c: Array<String> = <!TYPE_INFERENCE_EXPECTED_TYPE_MISMATCH!>[1]<!>
|
||||
)
|
||||
|
||||
annotation class Base(
|
||||
@@ -18,6 +18,6 @@ annotation class Base(
|
||||
)
|
||||
|
||||
annotation class Err(
|
||||
val a: IntArray = <!ANNOTATION_PARAMETER_DEFAULT_VALUE_MUST_BE_CONSTANT!>[<!CONSTANT_EXPECTED_TYPE_MISMATCH!>1L<!>]<!>,
|
||||
val b: Array<String> = <!TYPE_INFERENCE_EXPECTED_TYPE_MISMATCH, ANNOTATION_PARAMETER_DEFAULT_VALUE_MUST_BE_CONSTANT!>[1]<!>
|
||||
val a: IntArray = [<!CONSTANT_EXPECTED_TYPE_MISMATCH!>1L<!>],
|
||||
val b: Array<String> = <!TYPE_INFERENCE_EXPECTED_TYPE_MISMATCH!>[1]<!>
|
||||
)
|
||||
Vendored
+2
-2
@@ -17,7 +17,7 @@ annotation class Bar(
|
||||
)
|
||||
|
||||
annotation class Baz(
|
||||
val a: IntArray = <!ANNOTATION_PARAMETER_DEFAULT_VALUE_MUST_BE_CONSTANT!>[<!NULL_FOR_NONNULL_TYPE!>null<!>]<!>,
|
||||
val b: IntArray = <!ANNOTATION_PARAMETER_DEFAULT_VALUE_MUST_BE_CONSTANT!>[1, <!NULL_FOR_NONNULL_TYPE!>null<!>, 2]<!>,
|
||||
val a: IntArray = [<!NULL_FOR_NONNULL_TYPE!>null<!>],
|
||||
val b: IntArray = [1, <!NULL_FOR_NONNULL_TYPE!>null<!>, 2],
|
||||
val c: IntArray = [<!NO_THIS!>this<!>]
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user