Do not throw assertion on recursion in typealias declaration,

return empty list of descriptors instead, allowing for proper error
reporting later.
#KT-18344 fixed
This commit is contained in:
Ilya Chernikov
2020-12-16 19:42:35 +01:00
parent 02c617468f
commit 9ee17cd610
6 changed files with 22 additions and 1 deletions
@@ -50,7 +50,7 @@ protected constructor(
private val propertyDescriptors: MemoizedFunctionToNotNull<Name, Collection<PropertyDescriptor>> =
storageManager.createMemoizedFunction { doGetProperties(it) }
private val typeAliasDescriptors: MemoizedFunctionToNotNull<Name, Collection<TypeAliasDescriptor>> =
storageManager.createMemoizedFunction { doGetTypeAliases(it) }
storageManager.createMemoizedFunction( { doGetTypeAliases(it) }, onRecursiveCall = { _,_ -> emptyList() })
private val declaredFunctionDescriptors: MemoizedFunctionToNotNull<Name, Collection<SimpleFunctionDescriptor>> =
storageManager.createMemoizedFunction { getDeclaredFunctions(it) }
@@ -0,0 +1,3 @@
// !DIAGNOSTICS: -UNUSED_VARIABLE -UNUSED_PARAMETER
typealias R<T: List<R>> = List<T>
@@ -0,0 +1,3 @@
// !DIAGNOSTICS: -UNUSED_VARIABLE -UNUSED_PARAMETER
typealias R<T: <!BOUND_ON_TYPE_ALIAS_PARAMETER_NOT_ALLOWED!>List<<!UNRESOLVED_REFERENCE!>R<!>><!>> = List<T>
@@ -0,0 +1,3 @@
package
public typealias R</*0*/ T : kotlin.collections.List<[ERROR : R]>> = kotlin.collections.List<T>
@@ -28653,6 +28653,12 @@ public class DiagnosticTestGenerated extends AbstractDiagnosticTest {
runTest("compiler/testData/diagnostics/tests/typealias/boundsViolationInTypeAliasRHS.kt");
}
@Test
@TestMetadata("boundsViolationRecursive.kt")
public void testBoundsViolationRecursive() throws Exception {
runTest("compiler/testData/diagnostics/tests/typealias/boundsViolationRecursive.kt");
}
@Test
@TestMetadata("capturingTypeParametersFromOuterClass.kt")
public void testCapturingTypeParametersFromOuterClass() throws Exception {
@@ -28557,6 +28557,12 @@ public class FirOldFrontendDiagnosticsTestGenerated extends AbstractFirDiagnosti
runTest("compiler/testData/diagnostics/tests/typealias/boundsViolationInTypeAliasRHS.kt");
}
@Test
@TestMetadata("boundsViolationRecursive.kt")
public void testBoundsViolationRecursive() throws Exception {
runTest("compiler/testData/diagnostics/tests/typealias/boundsViolationRecursive.kt");
}
@Test
@TestMetadata("capturingTypeParametersFromOuterClass.kt")
public void testCapturingTypeParametersFromOuterClass() throws Exception {