Do not add error types as upper bounds in type parameter

#KT-10237 Fixed
 #KT-11821 Fixed
 #KT-8200 Fixed
This commit is contained in:
Denis Zharkov
2016-07-01 17:35:53 +03:00
parent 7723a3a105
commit 60a0cd8cfd
10 changed files with 132 additions and 10 deletions
@@ -76,7 +76,10 @@ public class LazyTypeParameterDescriptor extends AbstractLazyTypeParameterDescri
List<KotlinType> upperBounds = new ArrayList<KotlinType>(1);
for (KtTypeReference typeReference : getAllUpperBounds()) {
upperBounds.add(resolveBoundType(typeReference));
KotlinType resolvedType = resolveBoundType(typeReference);
if (!resolvedType.isError()) {
upperBounds.add(resolvedType);
}
}
if (upperBounds.isEmpty()) {
+2 -2
View File
@@ -30,8 +30,8 @@ package Jet87 {
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
}
public final class Buzz</*0*/ T : Jet87.Bar<kotlin.Int>> where T : [ERROR : nioho] {
public constructor Buzz</*0*/ T : Jet87.Bar<kotlin.Int>>() where T : [ERROR : nioho]
public final class Buzz</*0*/ T : Jet87.Bar<kotlin.Int>> {
public constructor Buzz</*0*/ T : Jet87.Bar<kotlin.Int>>()
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 toString(): kotlin.String
@@ -1,6 +1,6 @@
package
public interface A</*0*/ T : [ERROR : List]<T, T, T>> {
public interface A</*0*/ T> {
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 toString(): kotlin.String
@@ -0,0 +1,19 @@
class A
interface I0<T : A<!WRONG_NUMBER_OF_TYPE_ARGUMENTS!><Int><!>>
interface I1<T> where T : A<!WRONG_NUMBER_OF_TYPE_ARGUMENTS!><Int><!>
interface I2<<!MISPLACED_TYPE_PARAMETER_CONSTRAINTS!>T : A<!WRONG_NUMBER_OF_TYPE_ARGUMENTS!><Int><!><!>> where T : A<!WRONG_NUMBER_OF_TYPE_ARGUMENTS!><Int><!>
fun <E : A<!WRONG_NUMBER_OF_TYPE_ARGUMENTS!><Int><!>> foo0() {}
fun <E> foo1() where E : A<!WRONG_NUMBER_OF_TYPE_ARGUMENTS!><Int><!> {}
fun <<!MISPLACED_TYPE_PARAMETER_CONSTRAINTS!>E : A<!WRONG_NUMBER_OF_TYPE_ARGUMENTS!><Int><!><!>> foo2() where E : A<!WRONG_NUMBER_OF_TYPE_ARGUMENTS!><Int><!> {}
val <E : A<!WRONG_NUMBER_OF_TYPE_ARGUMENTS!><Int><!>> E.p1: Int
get() = 1
val <E> E.p2: Int where E : A<!WRONG_NUMBER_OF_TYPE_ARGUMENTS!><Int><!>
get() = 1
val <<!MISPLACED_TYPE_PARAMETER_CONSTRAINTS!>E : A<!WRONG_NUMBER_OF_TYPE_ARGUMENTS!><Int><!><!>> E.p3: Int where E : A<!WRONG_NUMBER_OF_TYPE_ARGUMENTS!><Int><!>
get() = 1
// See KT-8200
interface X
public class EnumAttribute<<!MISPLACED_TYPE_PARAMETER_CONSTRAINTS!>T : X<!WRONG_NUMBER_OF_TYPE_ARGUMENTS!><T><!><!>>(val klass: Class<T>) where T : Enum<T>
@@ -0,0 +1,47 @@
package
public val </*0*/ E> E.p1: kotlin.Int
public val </*0*/ E> E.p2: kotlin.Int
public val </*0*/ E> E.p3: kotlin.Int
public fun </*0*/ E> foo0(): kotlin.Unit
public fun </*0*/ E> foo1(): kotlin.Unit
public fun </*0*/ E> foo2(): kotlin.Unit
public final class A {
public constructor A()
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 toString(): kotlin.String
}
public final class EnumAttribute</*0*/ T : kotlin.Enum<T>> {
public constructor EnumAttribute</*0*/ T : kotlin.Enum<T>>(/*0*/ klass: java.lang.Class<T>)
public final val klass: java.lang.Class<T>
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 toString(): kotlin.String
}
public interface I0</*0*/ T> {
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 toString(): kotlin.String
}
public interface I1</*0*/ T> {
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 toString(): kotlin.String
}
public interface I2</*0*/ T> {
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 toString(): kotlin.String
}
public interface X {
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 toString(): kotlin.String
}
@@ -0,0 +1,14 @@
interface I0<T : <!UNRESOLVED_REFERENCE!>Unresolved0<!><String>>
interface I1<T> where T : <!UNRESOLVED_REFERENCE!>Unresolved1<!><String>
interface I2<<!MISPLACED_TYPE_PARAMETER_CONSTRAINTS!>T : <!UNRESOLVED_REFERENCE!>Unresolved2<!><String><!>> where T : <!UNRESOLVED_REFERENCE!>Unresolved3<!><String>
fun <E : <!UNRESOLVED_REFERENCE!>Unresolved4<!><String>> foo0() {}
fun <E> foo1() where E : <!UNRESOLVED_REFERENCE!>Unresolved5<!><String> {}
fun <<!MISPLACED_TYPE_PARAMETER_CONSTRAINTS!>E : <!UNRESOLVED_REFERENCE!>Unresolved6<!><String><!>> foo2() where E : <!UNRESOLVED_REFERENCE!>Unresolved7<!><String> {}
val <E : <!UNRESOLVED_REFERENCE!>Unresolved7<!>> E.p1: Int
get() = 1
val <E> E.p2: Int where E : <!UNRESOLVED_REFERENCE!>Unresolved8<!>
get() = 1
val <<!MISPLACED_TYPE_PARAMETER_CONSTRAINTS!>E : <!UNRESOLVED_REFERENCE!>Unresolved9<!><!>> E.p3: Int where E : <!UNRESOLVED_REFERENCE!>Unresolved10<!>
get() = 1
@@ -0,0 +1,26 @@
package
public val </*0*/ E> E.p1: kotlin.Int
public val </*0*/ E> E.p2: kotlin.Int
public val </*0*/ E> E.p3: kotlin.Int
public fun </*0*/ E> foo0(): kotlin.Unit
public fun </*0*/ E> foo1(): kotlin.Unit
public fun </*0*/ E> foo2(): kotlin.Unit
public interface I0</*0*/ T> {
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 toString(): kotlin.String
}
public interface I1</*0*/ T> {
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 toString(): kotlin.String
}
public interface I2</*0*/ T> {
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 toString(): kotlin.String
}
@@ -1,12 +1,12 @@
package
public final class A</*0*/ T : [ERROR : Nested], /*1*/ F : [ERROR : Inner], /*2*/ G : [ERROR : Interace]> {
public constructor A</*0*/ T : [ERROR : Nested], /*1*/ F : [ERROR : Inner], /*2*/ G : [ERROR : Interace]>()
public final class A</*0*/ T, /*1*/ F, /*2*/ G> {
public constructor A</*0*/ T, /*1*/ F, /*2*/ G>()
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 toString(): kotlin.String
public final inner class Inner /*captured type parameters: /*0*/ T : [ERROR : Nested], /*1*/ F : [ERROR : Inner], /*2*/ G : [ERROR : Interace]*/ {
public final inner class Inner /*captured type parameters: /*0*/ T, /*1*/ F, /*2*/ G*/ {
public constructor Inner()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
@@ -27,13 +27,13 @@ public final class A</*0*/ T : [ERROR : Nested], /*1*/ F : [ERROR : Inner], /*2*
}
}
public final class B</*0*/ T : [ERROR : Nested], /*1*/ F : [ERROR : Inner], /*2*/ G : [ERROR : Interace]> {
public constructor B</*0*/ T : [ERROR : Nested], /*1*/ F : [ERROR : Inner], /*2*/ G : [ERROR : Interace]>()
public final class B</*0*/ T, /*1*/ F, /*2*/ G> {
public constructor B</*0*/ T, /*1*/ F, /*2*/ G>()
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 toString(): kotlin.String
public final inner class Inner /*captured type parameters: /*0*/ T : [ERROR : Nested], /*1*/ F : [ERROR : Inner], /*2*/ G : [ERROR : Interace]*/ {
public final inner class Inner /*captured type parameters: /*0*/ T, /*1*/ F, /*2*/ G*/ {
public constructor Inner()
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
@@ -7500,6 +7500,12 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest {
doTest(fileName);
}
@TestMetadata("invalidArgumentsNumberInWhere.kt")
public void testInvalidArgumentsNumberInWhere() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/generics/invalidArgumentsNumberInWhere.kt");
doTest(fileName);
}
@TestMetadata("kt1575-Class.kt")
public void testKt1575_Class() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/generics/kt1575-Class.kt");
@@ -7596,6 +7602,12 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest {
doTest(fileName);
}
@TestMetadata("unresolvedClassifierInWhere.kt")
public void testUnresolvedClassifierInWhere() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/generics/unresolvedClassifierInWhere.kt");
doTest(fileName);
}
@TestMetadata("wildcardInValueParameter.kt")
public void testWildcardInValueParameter() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/generics/wildcardInValueParameter.kt");
@@ -126,6 +126,7 @@ public class TypeParameterDescriptorImpl extends AbstractTypeParameterDescriptor
}
private void doAddUpperBound(KotlinType bound) {
if (bound.isError()) return;
upperBounds.add(bound); // TODO : Duplicates?
}