Warning "value of type parameter is predetermined" is no more generated for sealed bound #KT-9244 Fixed
This commit is contained in:
@@ -574,6 +574,10 @@ public class DescriptorResolver {
|
|||||||
BindingTrace trace
|
BindingTrace trace
|
||||||
) {
|
) {
|
||||||
if (!TypeUtils.canHaveSubtypes(JetTypeChecker.DEFAULT, upperBoundType)) {
|
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));
|
trace.report(FINAL_UPPER_BOUND.on(upperBound, upperBoundType));
|
||||||
}
|
}
|
||||||
if (TypesPackage.isDynamic(upperBoundType)) {
|
if (TypesPackage.isDynamic(upperBoundType)) {
|
||||||
|
|||||||
@@ -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
|
||||||
@@ -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);
|
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")
|
@TestMetadata("OperationWhen.kt")
|
||||||
public void testOperationWhen() throws Exception {
|
public void testOperationWhen() throws Exception {
|
||||||
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/sealed/OperationWhen.kt");
|
String fileName = JetTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/sealed/OperationWhen.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user