Inner classes of generic classes can't extend Throwable
Do it in the same way as Java: prohibit inner classes (including anonymous inner classes) capturing type parameters from outer classes (but not outer methods) extending Throwable. See KT-17981: - Deprecated in 1.2 - Error in 1.3
This commit is contained in:
@@ -162,6 +162,10 @@ public interface Errors {
|
||||
DiagnosticFactory0<KtParameter> REIFIED_TYPE_IN_CATCH_CLAUSE = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<KtParameter> TYPE_PARAMETER_IN_CATCH_CLAUSE = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<KtTypeParameterList> GENERIC_THROWABLE_SUBCLASS = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory0<KtClassOrObject> INNER_CLASS_OF_GENERIC_THROWABLE_SUBCLASS =
|
||||
DiagnosticFactory0.create(ERROR, DECLARATION_NAME);
|
||||
DiagnosticFactory0<KtClassOrObject> INNER_CLASS_OF_GENERIC_THROWABLE_SUBCLASS_WARNING =
|
||||
DiagnosticFactory0.create(WARNING, DECLARATION_NAME);
|
||||
|
||||
DiagnosticFactory0<KtTypeAlias> TOPLEVEL_TYPEALIASES_ONLY = DiagnosticFactory0.create(ERROR);
|
||||
DiagnosticFactory1<KtElement, ClassifierDescriptor> RECURSIVE_TYPEALIAS_EXPANSION = DiagnosticFactory1.create(ERROR);
|
||||
|
||||
+2
@@ -661,6 +661,8 @@ public class DefaultErrorMessages {
|
||||
MAP.put(REIFIED_TYPE_IN_CATCH_CLAUSE, "Reified type is forbidden for catch parameter");
|
||||
MAP.put(TYPE_PARAMETER_IN_CATCH_CLAUSE, "Type parameter is forbidden for catch parameter");
|
||||
MAP.put(GENERIC_THROWABLE_SUBCLASS, "Subclass of 'Throwable' may not have type parameters");
|
||||
MAP.put(INNER_CLASS_OF_GENERIC_THROWABLE_SUBCLASS, "Inner class of generic class extending 'Throwable' is prohibited");
|
||||
MAP.put(INNER_CLASS_OF_GENERIC_THROWABLE_SUBCLASS_WARNING, "Inner class of generic class extending 'Throwable' is deprecated");
|
||||
|
||||
MAP.put(TYPE_MISMATCH_IN_FOR_LOOP, "The loop iterates over values of type {0} but the parameter is declared to be {1}", RENDER_TYPE,
|
||||
RENDER_TYPE);
|
||||
|
||||
@@ -542,10 +542,21 @@ public class BodyResolver {
|
||||
trace.report(DATA_CLASS_CANNOT_HAVE_CLASS_SUPERTYPES.on(typeReference));
|
||||
addSupertype = false;
|
||||
}
|
||||
else if (DescriptorUtils.isSubclass(classDescriptor, builtIns.getThrowable()) &&
|
||||
!supertypeOwner.getDeclaredTypeParameters().isEmpty()) {
|
||||
trace.report(GENERIC_THROWABLE_SUBCLASS.on(ktClassOrObject.getTypeParameterList()));
|
||||
addSupertype = false;
|
||||
else if (DescriptorUtils.isSubclass(classDescriptor, builtIns.getThrowable())) {
|
||||
if (!supertypeOwner.getDeclaredTypeParameters().isEmpty()) {
|
||||
trace.report(GENERIC_THROWABLE_SUBCLASS.on(ktClassOrObject.getTypeParameterList()));
|
||||
addSupertype = false;
|
||||
}
|
||||
else if (!supertypeOwner.getTypeConstructor().getParameters().isEmpty()) {
|
||||
if (languageVersionSettings
|
||||
.supportsFeature(LanguageFeature.ProhibitInnerClassesOfGenericClassExtendingThrowable)) {
|
||||
trace.report(INNER_CLASS_OF_GENERIC_THROWABLE_SUBCLASS.on(ktClassOrObject));
|
||||
addSupertype = false;
|
||||
}
|
||||
else {
|
||||
trace.report(INNER_CLASS_OF_GENERIC_THROWABLE_SUBCLASS_WARNING.on(ktClassOrObject));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (classAppeared) {
|
||||
|
||||
+40
@@ -0,0 +1,40 @@
|
||||
// !LANGUAGE: +ProhibitInnerClassesOfGenericClassExtendingThrowable
|
||||
// !DIAGNOSTICS: -UNUSED_VARIABLE
|
||||
|
||||
class OuterGeneric<T> {
|
||||
inner <!INNER_CLASS_OF_GENERIC_THROWABLE_SUBCLASS!>class ErrorInnerExn<!> : Exception()
|
||||
|
||||
inner class InnerA {
|
||||
inner <!INNER_CLASS_OF_GENERIC_THROWABLE_SUBCLASS!>class ErrorInnerExn2<!> : Exception()
|
||||
}
|
||||
|
||||
class OkNestedExn : Exception()
|
||||
|
||||
val errorAnonymousObjectExn = <!INNER_CLASS_OF_GENERIC_THROWABLE_SUBCLASS!>object<!> : Exception() {}
|
||||
|
||||
fun foo() {
|
||||
<!INNER_CLASS_OF_GENERIC_THROWABLE_SUBCLASS!>class OkLocalExn<!> : Exception()
|
||||
|
||||
val errorAnonymousObjectExn = <!INNER_CLASS_OF_GENERIC_THROWABLE_SUBCLASS!>object<!> : Exception() {}
|
||||
}
|
||||
|
||||
fun <X> genericFoo() {
|
||||
<!INNER_CLASS_OF_GENERIC_THROWABLE_SUBCLASS!>class OkLocalExn<!> : Exception()
|
||||
|
||||
class LocalGeneric<Y> {
|
||||
inner <!INNER_CLASS_OF_GENERIC_THROWABLE_SUBCLASS!>class ErrorInnerExnOfLocalGeneric<!> : Exception()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class Outer {
|
||||
inner class InnerGeneric<T> {
|
||||
inner <!INNER_CLASS_OF_GENERIC_THROWABLE_SUBCLASS!>class ErrorInnerExn<!> : Exception()
|
||||
}
|
||||
}
|
||||
|
||||
fun <T> genericFoo() {
|
||||
<!INNER_CLASS_OF_GENERIC_THROWABLE_SUBCLASS!>class ErrorLocalExnInGenericFun<!> : Exception()
|
||||
|
||||
val errorkAnonymousObjectExnInGenericFun = <!INNER_CLASS_OF_GENERIC_THROWABLE_SUBCLASS!>object<!> : Exception() {}
|
||||
}
|
||||
+110
@@ -0,0 +1,110 @@
|
||||
package
|
||||
|
||||
public fun </*0*/ T> genericFoo(): kotlin.Unit
|
||||
|
||||
public final class Outer {
|
||||
public constructor Outer()
|
||||
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 InnerGeneric</*0*/ T> {
|
||||
public constructor InnerGeneric</*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 final inner class ErrorInnerExn /*captured type parameters: /*0*/ T*/ : kotlin.Exception /* = java.lang.Exception */ {
|
||||
public constructor ErrorInnerExn()
|
||||
public open override /*1*/ /*fake_override*/ val cause: kotlin.Throwable?
|
||||
public open override /*1*/ /*fake_override*/ val message: kotlin.String?
|
||||
public final override /*1*/ /*fake_override*/ fun addSuppressed(/*0*/ exception: kotlin.Throwable!): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun fillInStackTrace(): kotlin.Throwable!
|
||||
public open override /*1*/ /*fake_override*/ fun getLocalizedMessage(): kotlin.String!
|
||||
public open override /*1*/ /*fake_override*/ fun getStackTrace(): kotlin.Array<(out) java.lang.StackTraceElement!>!
|
||||
public final override /*1*/ /*fake_override*/ fun getSuppressed(): kotlin.Array<(out) kotlin.Throwable!>!
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun initCause(/*0*/ cause: kotlin.Throwable!): kotlin.Throwable!
|
||||
public open override /*1*/ /*fake_override*/ fun printStackTrace(): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun printStackTrace(/*0*/ s: java.io.PrintStream!): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun printStackTrace(/*0*/ s: java.io.PrintWriter!): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun setStackTrace(/*0*/ stackTrace: kotlin.Array<(out) java.lang.StackTraceElement!>!): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public final class OuterGeneric</*0*/ T> {
|
||||
public constructor OuterGeneric</*0*/ T>()
|
||||
public final val errorAnonymousObjectExn: kotlin.Exception /* = java.lang.Exception */
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public final fun foo(): kotlin.Unit
|
||||
public final fun </*0*/ X> genericFoo(): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
|
||||
public final inner class ErrorInnerExn /*captured type parameters: /*0*/ T*/ : kotlin.Exception /* = java.lang.Exception */ {
|
||||
public constructor ErrorInnerExn()
|
||||
public open override /*1*/ /*fake_override*/ val cause: kotlin.Throwable?
|
||||
public open override /*1*/ /*fake_override*/ val message: kotlin.String?
|
||||
public final override /*1*/ /*fake_override*/ fun addSuppressed(/*0*/ exception: kotlin.Throwable!): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun fillInStackTrace(): kotlin.Throwable!
|
||||
public open override /*1*/ /*fake_override*/ fun getLocalizedMessage(): kotlin.String!
|
||||
public open override /*1*/ /*fake_override*/ fun getStackTrace(): kotlin.Array<(out) java.lang.StackTraceElement!>!
|
||||
public final override /*1*/ /*fake_override*/ fun getSuppressed(): kotlin.Array<(out) kotlin.Throwable!>!
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun initCause(/*0*/ cause: kotlin.Throwable!): kotlin.Throwable!
|
||||
public open override /*1*/ /*fake_override*/ fun printStackTrace(): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun printStackTrace(/*0*/ s: java.io.PrintStream!): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun printStackTrace(/*0*/ s: java.io.PrintWriter!): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun setStackTrace(/*0*/ stackTrace: kotlin.Array<(out) java.lang.StackTraceElement!>!): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public final inner class InnerA /*captured type parameters: /*0*/ T*/ {
|
||||
public constructor InnerA()
|
||||
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 ErrorInnerExn2 /*captured type parameters: /*0*/ T*/ : kotlin.Exception /* = java.lang.Exception */ {
|
||||
public constructor ErrorInnerExn2()
|
||||
public open override /*1*/ /*fake_override*/ val cause: kotlin.Throwable?
|
||||
public open override /*1*/ /*fake_override*/ val message: kotlin.String?
|
||||
public final override /*1*/ /*fake_override*/ fun addSuppressed(/*0*/ exception: kotlin.Throwable!): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun fillInStackTrace(): kotlin.Throwable!
|
||||
public open override /*1*/ /*fake_override*/ fun getLocalizedMessage(): kotlin.String!
|
||||
public open override /*1*/ /*fake_override*/ fun getStackTrace(): kotlin.Array<(out) java.lang.StackTraceElement!>!
|
||||
public final override /*1*/ /*fake_override*/ fun getSuppressed(): kotlin.Array<(out) kotlin.Throwable!>!
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun initCause(/*0*/ cause: kotlin.Throwable!): kotlin.Throwable!
|
||||
public open override /*1*/ /*fake_override*/ fun printStackTrace(): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun printStackTrace(/*0*/ s: java.io.PrintStream!): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun printStackTrace(/*0*/ s: java.io.PrintWriter!): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun setStackTrace(/*0*/ stackTrace: kotlin.Array<(out) java.lang.StackTraceElement!>!): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
}
|
||||
|
||||
public final class OkNestedExn : kotlin.Exception /* = java.lang.Exception */ {
|
||||
public constructor OkNestedExn()
|
||||
public open override /*1*/ /*fake_override*/ val cause: kotlin.Throwable?
|
||||
public open override /*1*/ /*fake_override*/ val message: kotlin.String?
|
||||
public final override /*1*/ /*fake_override*/ fun addSuppressed(/*0*/ exception: kotlin.Throwable!): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun fillInStackTrace(): kotlin.Throwable!
|
||||
public open override /*1*/ /*fake_override*/ fun getLocalizedMessage(): kotlin.String!
|
||||
public open override /*1*/ /*fake_override*/ fun getStackTrace(): kotlin.Array<(out) java.lang.StackTraceElement!>!
|
||||
public final override /*1*/ /*fake_override*/ fun getSuppressed(): kotlin.Array<(out) kotlin.Throwable!>!
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun initCause(/*0*/ cause: kotlin.Throwable!): kotlin.Throwable!
|
||||
public open override /*1*/ /*fake_override*/ fun printStackTrace(): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun printStackTrace(/*0*/ s: java.io.PrintStream!): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun printStackTrace(/*0*/ s: java.io.PrintWriter!): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun setStackTrace(/*0*/ stackTrace: kotlin.Array<(out) java.lang.StackTraceElement!>!): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
}
|
||||
Vendored
+40
@@ -0,0 +1,40 @@
|
||||
// !LANGUAGE: -ProhibitInnerClassesOfGenericClassExtendingThrowable
|
||||
// !DIAGNOSTICS: -UNUSED_VARIABLE
|
||||
|
||||
class OuterGeneric<T> {
|
||||
inner <!INNER_CLASS_OF_GENERIC_THROWABLE_SUBCLASS_WARNING!>class ErrorInnerExn<!> : Exception()
|
||||
|
||||
inner class InnerA {
|
||||
inner <!INNER_CLASS_OF_GENERIC_THROWABLE_SUBCLASS_WARNING!>class ErrorInnerExn2<!> : Exception()
|
||||
}
|
||||
|
||||
class OkNestedExn : Exception()
|
||||
|
||||
val errorAnonymousObjectExn = <!INNER_CLASS_OF_GENERIC_THROWABLE_SUBCLASS_WARNING!>object<!> : Exception() {}
|
||||
|
||||
fun foo() {
|
||||
<!INNER_CLASS_OF_GENERIC_THROWABLE_SUBCLASS_WARNING!>class OkLocalExn<!> : Exception()
|
||||
|
||||
val errorAnonymousObjectExn = <!INNER_CLASS_OF_GENERIC_THROWABLE_SUBCLASS_WARNING!>object<!> : Exception() {}
|
||||
}
|
||||
|
||||
fun <X> genericFoo() {
|
||||
<!INNER_CLASS_OF_GENERIC_THROWABLE_SUBCLASS_WARNING!>class OkLocalExn<!> : Exception()
|
||||
|
||||
class LocalGeneric<Y> {
|
||||
inner <!INNER_CLASS_OF_GENERIC_THROWABLE_SUBCLASS_WARNING!>class ErrorInnerExnOfLocalGeneric<!> : Exception()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class Outer {
|
||||
inner class InnerGeneric<T> {
|
||||
inner <!INNER_CLASS_OF_GENERIC_THROWABLE_SUBCLASS_WARNING!>class ErrorInnerExn<!> : Exception()
|
||||
}
|
||||
}
|
||||
|
||||
fun <T> genericFoo() {
|
||||
<!INNER_CLASS_OF_GENERIC_THROWABLE_SUBCLASS_WARNING!>class ErrorLocalExnInGenericFun<!> : Exception()
|
||||
|
||||
val errorkAnonymousObjectExnInGenericFun = <!INNER_CLASS_OF_GENERIC_THROWABLE_SUBCLASS_WARNING!>object<!> : Exception() {}
|
||||
}
|
||||
Vendored
+110
@@ -0,0 +1,110 @@
|
||||
package
|
||||
|
||||
public fun </*0*/ T> genericFoo(): kotlin.Unit
|
||||
|
||||
public final class Outer {
|
||||
public constructor Outer()
|
||||
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 InnerGeneric</*0*/ T> {
|
||||
public constructor InnerGeneric</*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 final inner class ErrorInnerExn /*captured type parameters: /*0*/ T*/ : kotlin.Exception /* = java.lang.Exception */ {
|
||||
public constructor ErrorInnerExn()
|
||||
public open override /*1*/ /*fake_override*/ val cause: kotlin.Throwable?
|
||||
public open override /*1*/ /*fake_override*/ val message: kotlin.String?
|
||||
public final override /*1*/ /*fake_override*/ fun addSuppressed(/*0*/ exception: kotlin.Throwable!): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun fillInStackTrace(): kotlin.Throwable!
|
||||
public open override /*1*/ /*fake_override*/ fun getLocalizedMessage(): kotlin.String!
|
||||
public open override /*1*/ /*fake_override*/ fun getStackTrace(): kotlin.Array<(out) java.lang.StackTraceElement!>!
|
||||
public final override /*1*/ /*fake_override*/ fun getSuppressed(): kotlin.Array<(out) kotlin.Throwable!>!
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun initCause(/*0*/ cause: kotlin.Throwable!): kotlin.Throwable!
|
||||
public open override /*1*/ /*fake_override*/ fun printStackTrace(): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun printStackTrace(/*0*/ s: java.io.PrintStream!): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun printStackTrace(/*0*/ s: java.io.PrintWriter!): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun setStackTrace(/*0*/ stackTrace: kotlin.Array<(out) java.lang.StackTraceElement!>!): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public final class OuterGeneric</*0*/ T> {
|
||||
public constructor OuterGeneric</*0*/ T>()
|
||||
public final val errorAnonymousObjectExn: kotlin.Exception /* = java.lang.Exception */
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public final fun foo(): kotlin.Unit
|
||||
public final fun </*0*/ X> genericFoo(): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
|
||||
public final inner class ErrorInnerExn /*captured type parameters: /*0*/ T*/ : kotlin.Exception /* = java.lang.Exception */ {
|
||||
public constructor ErrorInnerExn()
|
||||
public open override /*1*/ /*fake_override*/ val cause: kotlin.Throwable?
|
||||
public open override /*1*/ /*fake_override*/ val message: kotlin.String?
|
||||
public final override /*1*/ /*fake_override*/ fun addSuppressed(/*0*/ exception: kotlin.Throwable!): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun fillInStackTrace(): kotlin.Throwable!
|
||||
public open override /*1*/ /*fake_override*/ fun getLocalizedMessage(): kotlin.String!
|
||||
public open override /*1*/ /*fake_override*/ fun getStackTrace(): kotlin.Array<(out) java.lang.StackTraceElement!>!
|
||||
public final override /*1*/ /*fake_override*/ fun getSuppressed(): kotlin.Array<(out) kotlin.Throwable!>!
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun initCause(/*0*/ cause: kotlin.Throwable!): kotlin.Throwable!
|
||||
public open override /*1*/ /*fake_override*/ fun printStackTrace(): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun printStackTrace(/*0*/ s: java.io.PrintStream!): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun printStackTrace(/*0*/ s: java.io.PrintWriter!): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun setStackTrace(/*0*/ stackTrace: kotlin.Array<(out) java.lang.StackTraceElement!>!): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
|
||||
public final inner class InnerA /*captured type parameters: /*0*/ T*/ {
|
||||
public constructor InnerA()
|
||||
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 ErrorInnerExn2 /*captured type parameters: /*0*/ T*/ : kotlin.Exception /* = java.lang.Exception */ {
|
||||
public constructor ErrorInnerExn2()
|
||||
public open override /*1*/ /*fake_override*/ val cause: kotlin.Throwable?
|
||||
public open override /*1*/ /*fake_override*/ val message: kotlin.String?
|
||||
public final override /*1*/ /*fake_override*/ fun addSuppressed(/*0*/ exception: kotlin.Throwable!): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun fillInStackTrace(): kotlin.Throwable!
|
||||
public open override /*1*/ /*fake_override*/ fun getLocalizedMessage(): kotlin.String!
|
||||
public open override /*1*/ /*fake_override*/ fun getStackTrace(): kotlin.Array<(out) java.lang.StackTraceElement!>!
|
||||
public final override /*1*/ /*fake_override*/ fun getSuppressed(): kotlin.Array<(out) kotlin.Throwable!>!
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun initCause(/*0*/ cause: kotlin.Throwable!): kotlin.Throwable!
|
||||
public open override /*1*/ /*fake_override*/ fun printStackTrace(): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun printStackTrace(/*0*/ s: java.io.PrintStream!): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun printStackTrace(/*0*/ s: java.io.PrintWriter!): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun setStackTrace(/*0*/ stackTrace: kotlin.Array<(out) java.lang.StackTraceElement!>!): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
}
|
||||
|
||||
public final class OkNestedExn : kotlin.Exception /* = java.lang.Exception */ {
|
||||
public constructor OkNestedExn()
|
||||
public open override /*1*/ /*fake_override*/ val cause: kotlin.Throwable?
|
||||
public open override /*1*/ /*fake_override*/ val message: kotlin.String?
|
||||
public final override /*1*/ /*fake_override*/ fun addSuppressed(/*0*/ exception: kotlin.Throwable!): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun equals(/*0*/ other: kotlin.Any?): kotlin.Boolean
|
||||
public open override /*1*/ /*fake_override*/ fun fillInStackTrace(): kotlin.Throwable!
|
||||
public open override /*1*/ /*fake_override*/ fun getLocalizedMessage(): kotlin.String!
|
||||
public open override /*1*/ /*fake_override*/ fun getStackTrace(): kotlin.Array<(out) java.lang.StackTraceElement!>!
|
||||
public final override /*1*/ /*fake_override*/ fun getSuppressed(): kotlin.Array<(out) kotlin.Throwable!>!
|
||||
public open override /*1*/ /*fake_override*/ fun hashCode(): kotlin.Int
|
||||
public open override /*1*/ /*fake_override*/ fun initCause(/*0*/ cause: kotlin.Throwable!): kotlin.Throwable!
|
||||
public open override /*1*/ /*fake_override*/ fun printStackTrace(): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun printStackTrace(/*0*/ s: java.io.PrintStream!): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun printStackTrace(/*0*/ s: java.io.PrintWriter!): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun setStackTrace(/*0*/ stackTrace: kotlin.Array<(out) java.lang.StackTraceElement!>!): kotlin.Unit
|
||||
public open override /*1*/ /*fake_override*/ fun toString(): kotlin.String
|
||||
}
|
||||
}
|
||||
compiler/testData/diagnostics/tests/controlStructures/catchingLocalClassesCapturingTypeParameters.kt
Vendored
+27
@@ -0,0 +1,27 @@
|
||||
// !LANGUAGE: +ProhibitInnerClassesOfGenericClassExtendingThrowable
|
||||
package test
|
||||
|
||||
var global: Throwable? = null
|
||||
|
||||
fun <T> foo(x: Throwable, z: T, b: (T) -> Unit) {
|
||||
<!INNER_CLASS_OF_GENERIC_THROWABLE_SUBCLASS!>class A<!>(val y : T) : Exception()
|
||||
|
||||
try {
|
||||
throw x
|
||||
} catch (a: A) {
|
||||
b(a.y)
|
||||
} catch (e: Throwable) {
|
||||
global = A(z)
|
||||
}
|
||||
}
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
foo(RuntimeException(), 1) { throw IllegalStateException() }
|
||||
foo(global!!, "") { it.length } // (*)
|
||||
}
|
||||
|
||||
// (*):
|
||||
//Exception in thread "main" java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.String
|
||||
// at test.TestKt$main$2.invoke(test.kt)
|
||||
// at test.TestKt.foo(test.kt:12)
|
||||
// at test.TestKt.main(test.kt:21)
|
||||
+7
@@ -0,0 +1,7 @@
|
||||
package
|
||||
|
||||
package test {
|
||||
public var global: kotlin.Throwable?
|
||||
public fun </*0*/ T> foo(/*0*/ x: kotlin.Throwable, /*1*/ z: T, /*2*/ b: (T) -> kotlin.Unit): kotlin.Unit
|
||||
public fun main(/*0*/ args: kotlin.Array<kotlin.String>): kotlin.Unit
|
||||
}
|
||||
@@ -4498,12 +4498,30 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("catchInnerClassesOfGenerics.kt")
|
||||
public void testCatchInnerClassesOfGenerics() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/controlStructures/catchInnerClassesOfGenerics.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("catchInnerClassesOfGenerics_deprecation.kt")
|
||||
public void testCatchInnerClassesOfGenerics_deprecation() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/controlStructures/catchInnerClassesOfGenerics_deprecation.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("catchWithDefault.kt")
|
||||
public void testCatchWithDefault() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/controlStructures/catchWithDefault.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("catchingLocalClassesCapturingTypeParameters.kt")
|
||||
public void testCatchingLocalClassesCapturingTypeParameters() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/controlStructures/catchingLocalClassesCapturingTypeParameters.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("commonSupertypeOfT.kt")
|
||||
public void testCommonSupertypeOfT() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/controlStructures/commonSupertypeOfT.kt");
|
||||
|
||||
+18
@@ -4498,12 +4498,30 @@ public class DiagnosticsUsingJavacTestGenerated extends AbstractDiagnosticsUsing
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("catchInnerClassesOfGenerics.kt")
|
||||
public void testCatchInnerClassesOfGenerics() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/controlStructures/catchInnerClassesOfGenerics.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("catchInnerClassesOfGenerics_deprecation.kt")
|
||||
public void testCatchInnerClassesOfGenerics_deprecation() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/controlStructures/catchInnerClassesOfGenerics_deprecation.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("catchWithDefault.kt")
|
||||
public void testCatchWithDefault() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/controlStructures/catchWithDefault.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("catchingLocalClassesCapturingTypeParameters.kt")
|
||||
public void testCatchingLocalClassesCapturingTypeParameters() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/controlStructures/catchingLocalClassesCapturingTypeParameters.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("commonSupertypeOfT.kt")
|
||||
public void testCommonSupertypeOfT() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/controlStructures/commonSupertypeOfT.kt");
|
||||
|
||||
@@ -69,6 +69,7 @@ enum class LanguageFeature(
|
||||
NestedClassesInEnumEntryShouldBeInner(KOTLIN_1_3),
|
||||
ProhibitDataClassesOverridingCopy(KOTLIN_1_3),
|
||||
RestrictionOfWrongAnnotationsWithUseSiteTargetsOnTypes(KOTLIN_1_3),
|
||||
ProhibitInnerClassesOfGenericClassExtendingThrowable(KOTLIN_1_3),
|
||||
|
||||
// Experimental features
|
||||
|
||||
|
||||
Reference in New Issue
Block a user