KT-13422 Type alias for Java exception class can be used as an object in 'throw' expression
Report NO_COMPANION_OBJECT for type aliases.
This commit is contained in:
@@ -47,6 +47,13 @@ fun resolveQualifierAsStandaloneExpression(
|
||||
val referenceTarget = resolveQualifierReferenceTarget(qualifier, null, context, classifierUsageCheckers)
|
||||
|
||||
when (referenceTarget) {
|
||||
is TypeAliasDescriptor -> {
|
||||
referenceTarget.classDescriptor?.let { classDescriptor ->
|
||||
if (!classDescriptor.kind.isSingleton) {
|
||||
context.trace.report(Errors.NO_COMPANION_OBJECT.on(qualifier.referenceExpression, referenceTarget))
|
||||
}
|
||||
}
|
||||
}
|
||||
is TypeParameterDescriptor -> {
|
||||
context.trace.report(Errors.TYPE_PARAMETER_IS_NOT_AN_EXPRESSION.on(qualifier.referenceExpression, referenceTarget))
|
||||
}
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
// +JDK
|
||||
|
||||
typealias Exn = java.lang.Exception
|
||||
|
||||
fun test() {
|
||||
throw <!NO_COMPANION_OBJECT!>Exn<!>
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
package
|
||||
|
||||
public typealias Exn = java.lang.Exception
|
||||
public fun test(): kotlin.Unit
|
||||
@@ -20244,6 +20244,12 @@ public class DiagnosticsTestGenerated extends AbstractDiagnosticsTest {
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("throwJLException.kt")
|
||||
public void testThrowJLException() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/typealias/throwJLException.kt");
|
||||
doTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("typeAliasArgumentsInCompanionObject.kt")
|
||||
public void testTypeAliasArgumentsInCompanionObject() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("compiler/testData/diagnostics/tests/typealias/typeAliasArgumentsInCompanionObject.kt");
|
||||
|
||||
Reference in New Issue
Block a user