JVM_IR KT-49203 generate stubs for not found classes

This commit is contained in:
Dmitry Petrov
2021-10-14 08:17:07 +03:00
committed by TeamCityServer
parent 4cca78f8d8
commit af18b10da9
7 changed files with 37 additions and 51 deletions
@@ -13,7 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jetbrains.kotlin.ir.util
import org.jetbrains.kotlin.analyzer.CompilationErrorException
@@ -26,21 +25,19 @@ class ExternalDependenciesGenerator(
val symbolTable: SymbolTable,
private val irProviders: List<IrProvider>
) {
fun generateUnboundSymbolsAsDependencies() {
// There should be at most one DeclarationStubGenerator (none in closed world?)
irProviders.singleOrNull { it is DeclarationStubGenerator }?.let {
(it as DeclarationStubGenerator).unboundSymbolGeneration = true
}
/*
Deserializing a reference may lead to new unbound references, so we loop until none are left.
*/
var unbound = setOf<IrSymbol>()
lateinit var prevUnbound: Set<IrSymbol>
try {
do {
prevUnbound = unbound
unbound = symbolTable.allUnbound
// Deserializing a reference may lead to new unbound references, so we loop until none are left.
try {
var unbound = setOf<IrSymbol>()
do {
val prevUnbound = unbound
unbound = symbolTable.allUnbound
for (symbol in unbound) {
// Symbol could get bound as a side effect of deserializing other symbols.
if (!symbol.isBound) {
@@ -145,9 +145,6 @@ abstract class TypeTranslator(
lowerType.constructor.declarationDescriptor as? ClassDescriptor
?: throw AssertionError("No class descriptor for lower type $lowerType of $approximatedType")
annotations = translateTypeAnnotations(upperType, approximatedType)
if (lowerTypeDescriptor is NotFoundClasses.MockClassDescriptor) {
return IrErrorTypeImpl(approximatedType, annotations, variance)
}
classifier = symbolTable.referenceClass(lowerTypeDescriptor)
arguments = when {
approximatedType is RawType ->