Skip to content

Commit 4ddd9f0

Browse files
committed
[NI] Consider explicitly specified type argument as an input type
#KT-31860 Fixed
1 parent 787a8bb commit 4ddd9f0

File tree

5 files changed

+48
-1
lines changed

5 files changed

+48
-1
lines changed

compiler/resolution/src/org/jetbrains/kotlin/resolve/calls/inference/model/MutableConstraintStorage.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ class MutableVariableWithConstraints(
3737
get() =
3838
mutableConstraints.filter {
3939
val position = it.position.from
40-
position is ArgumentConstraintPosition || position is ReceiverConstraintPosition || position is ExpectedTypeConstraintPosition
40+
position is ArgumentConstraintPosition || position is ReceiverConstraintPosition ||
41+
position is ExpectedTypeConstraintPosition || position is ExplicitTypeParameterConstraintPosition
4142
}.map {
4243
(it.type as KotlinType).unCapture().unwrap()
4344
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
// !DIAGNOSTICS: -INVISIBLE_MEMBER -INVISIBLE_REFERENCE -UNUSED_PARAMETER
2+
3+
interface Parent
4+
object ChildA : Parent
5+
object ChildB : Parent
6+
7+
fun <@kotlin.internal.OnlyInputTypes T> select(a: T, b: T) {}
8+
9+
fun test() {
10+
<!TYPE_INFERENCE_ONLY_INPUT_TYPES!>select<!>(ChildA, ChildB) // should be error
11+
select<Any>(ChildA, ChildB) // should be ok
12+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
package
2+
3+
public fun </*0*/ @kotlin.internal.OnlyInputTypes T> select(/*0*/ a: T, /*1*/ b: T): kotlin.Unit
4+
public fun test(): kotlin.Unit
5+
6+
public object ChildA : Parent {
7+
private constructor ChildA()
8+
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
9+
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
10+
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
11+
}
12+
13+
public object ChildB : Parent {
14+
private constructor ChildB()
15+
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
16+
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
17+
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
18+
}
19+
20+
public interface Parent {
21+
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
22+
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
23+
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
24+
}

compiler/tests/org/jetbrains/kotlin/checkers/DiagnosticsTestWithStdLibGenerated.java

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

compiler/tests/org/jetbrains/kotlin/checkers/javac/DiagnosticsTestWithStdLibUsingJavacGenerated.java

Lines changed: 5 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)