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:
+1
@@ -2,6 +2,7 @@ import kotlin.reflect.*
|
||||
|
||||
fun foo() {
|
||||
String::class.primaryConstructor
|
||||
Void::class
|
||||
::foo.isExternal
|
||||
listOf(42)
|
||||
}
|
||||
|
||||
+5
-5
@@ -1,13 +1,13 @@
|
||||
compiler/testData/cli/jvm/noStdlib.kt:1:8: error: unresolved reference: kotlin
|
||||
import kotlin.reflect.*
|
||||
^
|
||||
compiler/testData/cli/jvm/noStdlib.kt:4:5: error: cannot access class 'kotlin.reflect.KClass'. Check your module classpath for missing or conflicting dependencies
|
||||
compiler/testData/cli/jvm/noStdlib.kt:4:19: error: unresolved reference: primaryConstructor
|
||||
String::class.primaryConstructor
|
||||
^
|
||||
compiler/testData/cli/jvm/noStdlib.kt:5:5: error: cannot access class 'kotlin.reflect.KCallable'. Check your module classpath for missing or conflicting dependencies
|
||||
^
|
||||
compiler/testData/cli/jvm/noStdlib.kt:6:11: error: unresolved reference: isExternal
|
||||
::foo.isExternal
|
||||
^
|
||||
compiler/testData/cli/jvm/noStdlib.kt:6:5: error: unresolved reference: listOf
|
||||
^
|
||||
compiler/testData/cli/jvm/noStdlib.kt:7:5: error: unresolved reference: listOf
|
||||
listOf(42)
|
||||
^
|
||||
COMPILATION_ERROR
|
||||
|
||||
Reference in New Issue
Block a user