Do not load error classes in ReflectionTypes
Previously ReflectionTypes.find returned an error class in case a class is not found in the module dependencies. The problem with this approach is that each call site should call ErrorUtils.isError on the result and report an error if needed, in order to stop this type from reaching the codegen, which can't handle error types. Now we create a MockClassDescriptor instance instead. It's not an error class, so it'll be handled correctly in the codegen. Also its scope is empty and errors are reported on any non-trivial usage (see MissingDependencyClassChecker), so this approach is not worse than error classes #KT-16484 Fixed
This commit is contained in:
+3
-2
@@ -55,11 +55,13 @@ class RuntimeModuleData private constructor(
|
||||
val singleModuleClassResolver = SingleModuleClassResolver()
|
||||
val runtimePackagePartProvider = RuntimePackagePartProvider(classLoader)
|
||||
val javaResolverCache = JavaResolverCache.EMPTY
|
||||
val notFoundClasses = NotFoundClasses(storageManager, module)
|
||||
val globalJavaResolverContext = JavaResolverComponents(
|
||||
storageManager, ReflectJavaClassFinder(classLoader), reflectKotlinClassFinder, deserializedDescriptorResolver,
|
||||
ExternalAnnotationResolver.EMPTY, SignaturePropagator.DO_NOTHING, RuntimeErrorReporter, javaResolverCache,
|
||||
JavaPropertyInitializerEvaluator.DoNothing, SamConversionResolver, RuntimeSourceElementFactory, singleModuleClassResolver,
|
||||
runtimePackagePartProvider, SupertypeLoopChecker.EMPTY, LookupTracker.DO_NOTHING, module, ReflectionTypes(module)
|
||||
runtimePackagePartProvider, SupertypeLoopChecker.EMPTY, LookupTracker.DO_NOTHING, module,
|
||||
ReflectionTypes(module, notFoundClasses)
|
||||
)
|
||||
|
||||
val lazyJavaPackageFragmentProvider = LazyJavaPackageFragmentProvider(globalJavaResolverContext)
|
||||
@@ -68,7 +70,6 @@ class RuntimeModuleData private constructor(
|
||||
|
||||
val javaDescriptorResolver = JavaDescriptorResolver(lazyJavaPackageFragmentProvider, javaResolverCache)
|
||||
val javaClassDataFinder = JavaClassDataFinder(reflectKotlinClassFinder, deserializedDescriptorResolver)
|
||||
val notFoundClasses = NotFoundClasses(storageManager, module)
|
||||
val binaryClassAnnotationAndConstantLoader = BinaryClassAnnotationAndConstantLoaderImpl(
|
||||
module, notFoundClasses, storageManager, reflectKotlinClassFinder
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user