Evaluate Expression: support anonymous objects evaluation
This commit is contained in:
@@ -17,8 +17,10 @@
|
||||
package org.jetbrains.kotlin.psi.codeFragmentUtil
|
||||
|
||||
import com.intellij.openapi.util.Key
|
||||
import org.jetbrains.kotlin.psi.JetFile
|
||||
import org.jetbrains.kotlin.psi.JetCodeFragment
|
||||
import org.jetbrains.kotlin.psi.JetFile
|
||||
import org.jetbrains.kotlin.psi.JetTypeReference
|
||||
import org.jetbrains.kotlin.types.JetType
|
||||
|
||||
public val SUPPRESS_DIAGNOSTICS_IN_DEBUG_MODE: Key<Boolean> = Key.create<Boolean>("SUPPRESS_DIAGNOSTICS_IN_DEBUG_MODE")
|
||||
|
||||
@@ -30,4 +32,15 @@ public var JetFile.suppressDiagnosticsInDebugMode: Boolean
|
||||
}
|
||||
set(skip: Boolean) {
|
||||
putUserData(SUPPRESS_DIAGNOSTICS_IN_DEBUG_MODE, skip)
|
||||
}
|
||||
}
|
||||
|
||||
public val DEBUG_TYPE_REFERENCE_STRING: String = "DebugTypeKotlinRulezzzz"
|
||||
|
||||
public val DEBUG_TYPE_INFO: Key<JetType> = Key.create<JetType>("DEBUG_TYPE_INFO")
|
||||
public var JetTypeReference.debugTypeInfo: JetType?
|
||||
get() = getUserData(DEBUG_TYPE_INFO)
|
||||
set(type: JetType?) {
|
||||
if (type != null && this.getText() == DEBUG_TYPE_REFERENCE_STRING) {
|
||||
putUserData(DEBUG_TYPE_INFO, type)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -36,6 +36,7 @@ import org.jetbrains.kotlin.resolve.lazy.LazyEntity
|
||||
import org.jetbrains.kotlin.resolve.lazy.ForceResolveUtil
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.firstIsInstanceOrNull
|
||||
import org.jetbrains.kotlin.psi.debugText.getDebugText
|
||||
import org.jetbrains.kotlin.psi.codeFragmentUtil.debugTypeInfo
|
||||
|
||||
public class TypeResolver(
|
||||
private val annotationResolver: AnnotationResolver,
|
||||
@@ -67,6 +68,12 @@ public class TypeResolver(
|
||||
val cachedType = c.trace.getBindingContext().get(BindingContext.TYPE, typeReference)
|
||||
if (cachedType != null) return type(cachedType)
|
||||
|
||||
if (typeReference.debugTypeInfo != null) {
|
||||
val debugType = typeReference.debugTypeInfo
|
||||
c.trace.record(BindingContext.TYPE, typeReference, debugType)
|
||||
return type(debugType)
|
||||
}
|
||||
|
||||
if (!c.allowBareTypes && lazinessToken.isLazy()) {
|
||||
// Bare types can be allowed only inside expressions; lazy type resolution is only relevant for declarations
|
||||
class LazyKotlinType : DelegatingType(), LazyEntity {
|
||||
|
||||
Reference in New Issue
Block a user