Warning "value of type parameter is predetermined" is no more generated for sealed bound #KT-9244 Fixed

This commit is contained in:
Mikhail Glukhikh
2015-09-30 15:30:04 +03:00
parent b24623810e
commit 92f031cc46
4 changed files with 44 additions and 0 deletions
@@ -574,6 +574,10 @@ public class DescriptorResolver {
BindingTrace trace
) {
if (!TypeUtils.canHaveSubtypes(JetTypeChecker.DEFAULT, upperBoundType)) {
ClassifierDescriptor descriptor = upperBoundType.getConstructor().getDeclarationDescriptor();
if (descriptor instanceof ClassDescriptor) {
if (((ClassDescriptor) descriptor).getModality() == Modality.SEALED) return;
}
trace.report(FINAL_UPPER_BOUND.on(upperBound, upperBoundType));
}
if (TypesPackage.isDynamic(upperBoundType)) {
+10
View File
@@ -0,0 +1,10 @@
// See KT-9244
sealed class Foo {
class Bar : Foo()
class Baz : Foo()
}
// The following warning seems incorrect here
// "Foo is a final type, and thus a value of the type parameter is predetermined"
fun <T : Foo> doit(arg: T): T = arg
+24
View File
@@ -0,0 +1,24 @@
package
public fun </*0*/ T : Foo> doit(/*0*/ arg: T): T
public sealed class Foo {
private constructor Foo()
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 Bar : Foo {
public constructor Bar()
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 Baz : Foo {
public constructor Baz()
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
}
}
@@ -13263,6 +13263,12 @@ public class JetDiagnosticsTestGenerated extends AbstractJetDiagnosticsTest {
doTest(fileName);
}
@TestMetadata("NotFinal.kt")
public void testNotFinal() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/sealed/NotFinal.kt");
doTest(fileName);
}
@TestMetadata("OperationWhen.kt")
public void testOperationWhen() throws Exception {
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/sealed/OperationWhen.kt");