KT-6751 References to type arguments of a type argument not resolved when wrong number of them
#KT-6751 Fixed
This commit is contained in:
@@ -165,6 +165,7 @@ public class TypeResolver(
|
|||||||
else {
|
else {
|
||||||
c.trace.report(WRONG_NUMBER_OF_TYPE_ARGUMENTS.on(type.getTypeArgumentList(), expectedArgumentCount))
|
c.trace.report(WRONG_NUMBER_OF_TYPE_ARGUMENTS.on(type.getTypeArgumentList(), expectedArgumentCount))
|
||||||
}
|
}
|
||||||
|
result = type(ErrorUtils.createErrorTypeWithArguments("" + typeConstructor, arguments))
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (Flexibility.FLEXIBLE_TYPE_CLASSIFIER.asSingleFqName() == DescriptorUtils.getFqName(classifierDescriptor)
|
if (Flexibility.FLEXIBLE_TYPE_CLASSIFIER.asSingleFqName() == DescriptorUtils.getFqName(classifierDescriptor)
|
||||||
|
|||||||
+3
-3
@@ -12,7 +12,7 @@ package p {
|
|||||||
|
|
||||||
public final class M1 {
|
public final class M1 {
|
||||||
public constructor M1()
|
public constructor M1()
|
||||||
public final val a: [ERROR : A<Int>]
|
public final val a: [ERROR : A]<kotlin.Int>
|
||||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||||
@@ -24,7 +24,7 @@ package p {
|
|||||||
package
|
package
|
||||||
|
|
||||||
package p {
|
package p {
|
||||||
public fun foo(/*0*/ a: [ERROR : A<Int>]): kotlin.Unit
|
public fun foo(/*0*/ a: [ERROR : A]<kotlin.Int>): kotlin.Unit
|
||||||
|
|
||||||
public final class A</*0*/ X, /*1*/ Y> {
|
public final class A</*0*/ X, /*1*/ Y> {
|
||||||
public constructor A</*0*/ X, /*1*/ Y>()
|
public constructor A</*0*/ X, /*1*/ Y>()
|
||||||
@@ -41,7 +41,7 @@ package
|
|||||||
internal fun test(): kotlin.Unit
|
internal fun test(): kotlin.Unit
|
||||||
|
|
||||||
package p {
|
package p {
|
||||||
public fun foo(/*0*/ a: [ERROR : A<Int>]): kotlin.Unit
|
public fun foo(/*0*/ a: [ERROR : A]<kotlin.Int>): kotlin.Unit
|
||||||
|
|
||||||
public final class A</*0*/ X, /*1*/ Y> {
|
public final class A</*0*/ X, /*1*/ Y> {
|
||||||
// -- Module: <m1> --
|
// -- Module: <m1> --
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
package
|
package
|
||||||
|
|
||||||
internal val b: [ERROR : B<*>]
|
internal val b: [ERROR : B]<out [ERROR : *]>
|
||||||
|
|
||||||
internal final class B {
|
internal final class B {
|
||||||
public constructor B()
|
public constructor B()
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ internal trait Test</*0*/ in I, /*1*/ out O, /*2*/ P> {
|
|||||||
internal abstract fun neOk32(/*0*/ i: [ERROR : Inv]): kotlin.Unit
|
internal abstract fun neOk32(/*0*/ i: [ERROR : Inv]): kotlin.Unit
|
||||||
internal abstract fun neOk33(/*0*/ i: Inv<[ERROR : No type element]>): kotlin.Unit
|
internal abstract fun neOk33(/*0*/ i: Inv<[ERROR : No type element]>): kotlin.Unit
|
||||||
internal abstract fun neOk34(/*0*/ i: Inv<[ERROR : C]>): kotlin.Unit
|
internal abstract fun neOk34(/*0*/ i: Inv<[ERROR : C]>): kotlin.Unit
|
||||||
internal abstract fun neOk35(/*0*/ i: [ERROR : Inv<P, P>]): kotlin.Unit
|
internal abstract fun neOk35(/*0*/ i: [ERROR : Inv]<P, P>): kotlin.Unit
|
||||||
internal abstract fun neOk4(/*0*/ i: Inv<I>): kotlin.Unit
|
internal abstract fun neOk4(/*0*/ i: Inv<I>): kotlin.Unit
|
||||||
internal abstract fun neOk5(/*0*/ i: Inv<O>): kotlin.Unit
|
internal abstract fun neOk5(/*0*/ i: Inv<O>): kotlin.Unit
|
||||||
internal abstract fun neOk6(/*0*/ i: In<In<O>>): kotlin.Unit
|
internal abstract fun neOk6(/*0*/ i: In<In<O>>): kotlin.Unit
|
||||||
|
|||||||
@@ -45,7 +45,7 @@ internal trait Test</*0*/ in I, /*1*/ out O, /*2*/ P> {
|
|||||||
internal abstract var neOk32: [ERROR : Inv]
|
internal abstract var neOk32: [ERROR : Inv]
|
||||||
internal abstract var neOk33: Inv<[ERROR : No type element]>
|
internal abstract var neOk33: Inv<[ERROR : No type element]>
|
||||||
internal abstract var neOk34: Inv<[ERROR : C]>
|
internal abstract var neOk34: Inv<[ERROR : C]>
|
||||||
internal abstract var neOk35: [ERROR : Inv<P, P>]
|
internal abstract var neOk35: [ERROR : Inv]<P, P>
|
||||||
internal abstract var neOk4: Inv<I>
|
internal abstract var neOk4: Inv<I>
|
||||||
internal abstract var neOk5: Inv<O>
|
internal abstract var neOk5: Inv<O>
|
||||||
internal abstract var neOk6: In<In<O>>
|
internal abstract var neOk6: In<In<O>>
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ internal trait Test</*0*/ in I, /*1*/ out O, /*2*/ P> {
|
|||||||
internal abstract fun neOk32(): [ERROR : Inv]
|
internal abstract fun neOk32(): [ERROR : Inv]
|
||||||
internal abstract fun neOk33(): Inv<[ERROR : No type element]>
|
internal abstract fun neOk33(): Inv<[ERROR : No type element]>
|
||||||
internal abstract fun neOk34(): Inv<[ERROR : C]>
|
internal abstract fun neOk34(): Inv<[ERROR : C]>
|
||||||
internal abstract fun neOk35(): [ERROR : Inv<P, P>]
|
internal abstract fun neOk35(): [ERROR : Inv]<P, P>
|
||||||
internal abstract fun neOk4(): Inv<I>
|
internal abstract fun neOk4(): Inv<I>
|
||||||
internal abstract fun neOk5(): Inv<O>
|
internal abstract fun neOk5(): Inv<O>
|
||||||
internal abstract fun neOk6(): Pair<In<O>, I>
|
internal abstract fun neOk6(): Pair<In<O>, I>
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
val foo: Pair<Pair<List<Int>>, String> = null!!
|
val foo: Pair<Pair<List<Int>>, String> = null!!
|
||||||
/*
|
/*
|
||||||
psi: Pair<Pair<List<Int>>, String>
|
psi: Pair<Pair<List<Int>>, String>
|
||||||
type: Pair<[ERROR : Pair<List<Int>>], String>
|
type: Pair<[ERROR : Pair]<List<Int>>, String>
|
||||||
typeParameter: <out A> defined in kotlin.Pair
|
typeParameter: <out A> defined in kotlin.Pair
|
||||||
typeProjection: [ERROR : Pair<List<Int>>]
|
typeProjection: [ERROR : Pair]<List<Int>>
|
||||||
psi: Pair<List<Int>>
|
psi: Pair<List<Int>>
|
||||||
type: [ERROR : Pair<List<Int>>]
|
type: [ERROR : Pair]<List<Int>>
|
||||||
typeParameter: null
|
typeParameter: null
|
||||||
typeProjection: List<Int>
|
typeProjection: List<Int>
|
||||||
psi: List<Int>
|
psi: List<Int>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
val foo: List<in Int, out Int> = null!!
|
val foo: List<in Int, out Int> = null!!
|
||||||
/*
|
/*
|
||||||
psi: List<in Int, out Int>
|
psi: List<in Int, out Int>
|
||||||
type: [ERROR : List<in Int, out Int>]
|
type: [ERROR : List]<in Int, out Int>
|
||||||
typeParameter: null
|
typeParameter: null
|
||||||
typeProjection: Int
|
typeProjection: Int
|
||||||
psi: Int
|
psi: Int
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
val foo: List<String, List<Int>> = null!!
|
val foo: List<String, List<Int>> = null!!
|
||||||
/*
|
/*
|
||||||
psi: List<String, List<Int>>
|
psi: List<String, List<Int>>
|
||||||
type: [ERROR : List<String, List<Int>>]
|
type: [ERROR : List]<String, List<Int>>
|
||||||
typeParameter: null
|
typeParameter: null
|
||||||
typeProjection: String
|
typeProjection: String
|
||||||
psi: String
|
psi: String
|
||||||
|
|||||||
@@ -3,11 +3,19 @@ fun <T> getT(): T = null!!
|
|||||||
val foo = getT<Pair<Pair<List<Int>>, String>>()
|
val foo = getT<Pair<Pair<List<Int>>, String>>()
|
||||||
/*
|
/*
|
||||||
psi: val foo = getT<Pair<Pair<List<Int>>, String>>()
|
psi: val foo = getT<Pair<Pair<List<Int>>, String>>()
|
||||||
type: Pair<[ERROR : Pair<List<Int>>], String>
|
type: Pair<[ERROR : Pair]<List<Int>>, String>
|
||||||
typeParameter: <out A> defined in kotlin.Pair
|
typeParameter: <out A> defined in kotlin.Pair
|
||||||
typeProjection: [ERROR : Pair<List<Int>>]
|
typeProjection: [ERROR : Pair]<List<Int>>
|
||||||
psi: val foo = getT<Pair<Pair<List<Int>>, String>>()
|
psi: val foo = getT<Pair<Pair<List<Int>>, String>>()
|
||||||
type: [ERROR : Pair<List<Int>>]
|
type: [ERROR : Pair]<List<Int>>
|
||||||
|
typeParameter: null
|
||||||
|
typeProjection: List<Int>
|
||||||
|
psi: val foo = getT<Pair<Pair<List<Int>>, String>>()
|
||||||
|
type: List<Int>
|
||||||
|
typeParameter: <out E> defined in kotlin.List
|
||||||
|
typeProjection: Int
|
||||||
|
psi: val foo = getT<Pair<Pair<List<Int>>, String>>()
|
||||||
|
type: Int
|
||||||
|
|
||||||
typeParameter: <out B> defined in kotlin.Pair
|
typeParameter: <out B> defined in kotlin.Pair
|
||||||
typeProjection: String
|
typeProjection: String
|
||||||
|
|||||||
@@ -3,5 +3,14 @@ fun <T> getT(): T = null!!
|
|||||||
val foo = getT<List<in Int, out Int>>()
|
val foo = getT<List<in Int, out Int>>()
|
||||||
/*
|
/*
|
||||||
psi: val foo = getT<List<in Int, out Int>>()
|
psi: val foo = getT<List<in Int, out Int>>()
|
||||||
type: [ERROR : List<in Int, out Int>]
|
type: [ERROR : List]<in Int, out Int>
|
||||||
|
typeParameter: null
|
||||||
|
typeProjection: in Int
|
||||||
|
psi: val foo = getT<List<in Int, out Int>>()
|
||||||
|
type: Int
|
||||||
|
|
||||||
|
typeParameter: null
|
||||||
|
typeProjection: out Int
|
||||||
|
psi: val foo = getT<List<in Int, out Int>>()
|
||||||
|
type: Int
|
||||||
*/
|
*/
|
||||||
@@ -3,5 +3,18 @@ fun <T> getT(): T = null!!
|
|||||||
val foo = getT<List<String, List<Int>>>()
|
val foo = getT<List<String, List<Int>>>()
|
||||||
/*
|
/*
|
||||||
psi: val foo = getT<List<String, List<Int>>>()
|
psi: val foo = getT<List<String, List<Int>>>()
|
||||||
type: [ERROR : List<String, List<Int>>]
|
type: [ERROR : List]<String, List<Int>>
|
||||||
|
typeParameter: null
|
||||||
|
typeProjection: String
|
||||||
|
psi: val foo = getT<List<String, List<Int>>>()
|
||||||
|
type: String
|
||||||
|
|
||||||
|
typeParameter: null
|
||||||
|
typeProjection: List<Int>
|
||||||
|
psi: val foo = getT<List<String, List<Int>>>()
|
||||||
|
type: List<Int>
|
||||||
|
typeParameter: <out E> defined in kotlin.List
|
||||||
|
typeProjection: Int
|
||||||
|
psi: val foo = getT<List<String, List<Int>>>()
|
||||||
|
type: Int
|
||||||
*/
|
*/
|
||||||
@@ -36,6 +36,8 @@ import java.util.Collections;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
|
import static kotlin.KotlinPackage.joinToString;
|
||||||
|
|
||||||
public class ErrorUtils {
|
public class ErrorUtils {
|
||||||
|
|
||||||
private static final ModuleDescriptor ERROR_MODULE;
|
private static final ModuleDescriptor ERROR_MODULE;
|
||||||
@@ -346,7 +348,7 @@ public class ErrorUtils {
|
|||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public static JetType createErrorType(@NotNull String debugMessage) {
|
public static JetType createErrorType(@NotNull String debugMessage) {
|
||||||
return new ErrorTypeImpl(createErrorTypeConstructor(debugMessage), createErrorScope(debugMessage));
|
return createErrorTypeWithArguments(debugMessage, Collections.<TypeProjection>emptyList());
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@@ -354,6 +356,11 @@ public class ErrorUtils {
|
|||||||
return new ErrorTypeImpl(createErrorTypeConstructorWithCustomDebugName(debugName), createErrorScope(debugName));
|
return new ErrorTypeImpl(createErrorTypeConstructorWithCustomDebugName(debugName), createErrorScope(debugName));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
public static JetType createErrorTypeWithArguments(@NotNull String debugMessage, @NotNull List<TypeProjection> arguments) {
|
||||||
|
return new ErrorTypeImpl(createErrorTypeConstructor(debugMessage), createErrorScope(debugMessage), arguments);
|
||||||
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public static TypeConstructor createErrorTypeConstructor(@NotNull String debugMessage) {
|
public static TypeConstructor createErrorTypeConstructor(@NotNull String debugMessage) {
|
||||||
return createErrorTypeConstructorWithCustomDebugName("[ERROR : " + debugMessage + "]");
|
return createErrorTypeConstructorWithCustomDebugName("[ERROR : " + debugMessage + "]");
|
||||||
@@ -398,10 +405,20 @@ public class ErrorUtils {
|
|||||||
private static class ErrorTypeImpl implements JetType {
|
private static class ErrorTypeImpl implements JetType {
|
||||||
private final TypeConstructor constructor;
|
private final TypeConstructor constructor;
|
||||||
private final JetScope memberScope;
|
private final JetScope memberScope;
|
||||||
|
private final List<TypeProjection> arguments;
|
||||||
|
|
||||||
private ErrorTypeImpl(@NotNull TypeConstructor constructor, @NotNull JetScope memberScope) {
|
private ErrorTypeImpl(
|
||||||
|
@NotNull TypeConstructor constructor,
|
||||||
|
@NotNull JetScope memberScope,
|
||||||
|
@NotNull List<TypeProjection> arguments
|
||||||
|
) {
|
||||||
this.constructor = constructor;
|
this.constructor = constructor;
|
||||||
this.memberScope = memberScope;
|
this.memberScope = memberScope;
|
||||||
|
this.arguments = arguments;
|
||||||
|
}
|
||||||
|
|
||||||
|
private ErrorTypeImpl(@NotNull TypeConstructor constructor, @NotNull JetScope memberScope) {
|
||||||
|
this(constructor, memberScope, Collections.<TypeProjection>emptyList());
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
@@ -413,7 +430,7 @@ public class ErrorUtils {
|
|||||||
@NotNull
|
@NotNull
|
||||||
@Override
|
@Override
|
||||||
public List<TypeProjection> getArguments() {
|
public List<TypeProjection> getArguments() {
|
||||||
return Collections.emptyList();
|
return arguments;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -446,7 +463,7 @@ public class ErrorUtils {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return constructor.toString();
|
return constructor.toString() + (arguments.isEmpty() ? "" : joinToString(arguments, ", ", "<", ">", -1, "..."));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
package foo
|
||||||
|
|
||||||
|
class A
|
||||||
|
|
||||||
|
class C<T>
|
||||||
|
class C1<T>
|
||||||
|
|
||||||
|
val v1 = C<C1<A, <caret>A>>()
|
||||||
|
|
||||||
|
// REF: (foo).A
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
package foo
|
||||||
|
|
||||||
|
class A
|
||||||
|
|
||||||
|
class C<T>
|
||||||
|
class C2<T1, T2>
|
||||||
|
|
||||||
|
val v1 = C<C2<<caret>A>>()
|
||||||
|
|
||||||
|
// REF: (foo).A
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
package foo
|
||||||
|
|
||||||
|
class A
|
||||||
|
|
||||||
|
class C<T>
|
||||||
|
class C1<T>
|
||||||
|
|
||||||
|
class D: C<C1<A, <caret>A>>()
|
||||||
|
|
||||||
|
// REF: (foo).A
|
||||||
@@ -301,6 +301,24 @@ public class ReferenceResolveTestGenerated extends AbstractReferenceResolveTest
|
|||||||
doTest(fileName);
|
doTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("WrongNumberOfTypeArguments.kt")
|
||||||
|
public void testWrongNumberOfTypeArguments() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("idea/testData/resolve/references/WrongNumberOfTypeArguments.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("WrongNumberOfTypeArguments2.kt")
|
||||||
|
public void testWrongNumberOfTypeArguments2() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("idea/testData/resolve/references/WrongNumberOfTypeArguments2.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("WrongNumberOfTypeArgumentsInSupertype.kt")
|
||||||
|
public void testWrongNumberOfTypeArgumentsInSupertype() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("idea/testData/resolve/references/WrongNumberOfTypeArgumentsInSupertype.kt");
|
||||||
|
doTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("idea/testData/resolve/references/delegatedPropertyAccessors")
|
@TestMetadata("idea/testData/resolve/references/delegatedPropertyAccessors")
|
||||||
@TestDataPath("$PROJECT_ROOT")
|
@TestDataPath("$PROJECT_ROOT")
|
||||||
@InnerTestClasses({DelegatedPropertyAccessors.InSource.class, DelegatedPropertyAccessors.InStandardLibrary.class})
|
@InnerTestClasses({DelegatedPropertyAccessors.InSource.class, DelegatedPropertyAccessors.InStandardLibrary.class})
|
||||||
|
|||||||
Reference in New Issue
Block a user