Created slice key LEXICAL_SCOPE
This commit is contained in:
+2
-1
@@ -219,7 +219,8 @@ public class CliLightClassGenerationSupport extends LightClassGenerationSupport
|
|||||||
public static class NoScopeRecordCliBindingTrace extends CliBindingTrace {
|
public static class NoScopeRecordCliBindingTrace extends CliBindingTrace {
|
||||||
@Override
|
@Override
|
||||||
public <K, V> void record(WritableSlice<K, V> slice, K key, V value) {
|
public <K, V> void record(WritableSlice<K, V> slice, K key, V value) {
|
||||||
if (slice == BindingContext.RESOLUTION_SCOPE || slice == BindingContext.TYPE_RESOLUTION_SCOPE) {
|
if (slice == BindingContext.RESOLUTION_SCOPE || slice == BindingContext.TYPE_RESOLUTION_SCOPE
|
||||||
|
|| slice == BindingContext.LEXICAL_SCOPE) {
|
||||||
// In the compiler there's no need to keep scopes
|
// In the compiler there's no need to keep scopes
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfo;
|
|||||||
import org.jetbrains.kotlin.resolve.constants.CompileTimeConstant;
|
import org.jetbrains.kotlin.resolve.constants.CompileTimeConstant;
|
||||||
import org.jetbrains.kotlin.resolve.diagnostics.Diagnostics;
|
import org.jetbrains.kotlin.resolve.diagnostics.Diagnostics;
|
||||||
import org.jetbrains.kotlin.resolve.scopes.JetScope;
|
import org.jetbrains.kotlin.resolve.scopes.JetScope;
|
||||||
|
import org.jetbrains.kotlin.resolve.scopes.LexicalScope;
|
||||||
import org.jetbrains.kotlin.resolve.scopes.receivers.Qualifier;
|
import org.jetbrains.kotlin.resolve.scopes.receivers.Qualifier;
|
||||||
import org.jetbrains.kotlin.types.DeferredType;
|
import org.jetbrains.kotlin.types.DeferredType;
|
||||||
import org.jetbrains.kotlin.types.JetType;
|
import org.jetbrains.kotlin.types.JetType;
|
||||||
@@ -140,7 +141,8 @@ public interface BindingContext {
|
|||||||
* A scope where type of expression has been resolved
|
* A scope where type of expression has been resolved
|
||||||
*/
|
*/
|
||||||
WritableSlice<JetTypeReference, JetScope> TYPE_RESOLUTION_SCOPE = Slices.createSimpleSlice();
|
WritableSlice<JetTypeReference, JetScope> TYPE_RESOLUTION_SCOPE = Slices.createSimpleSlice();
|
||||||
WritableSlice<JetExpression, JetScope> RESOLUTION_SCOPE = Slices.createSimpleSlice();
|
@Deprecated WritableSlice<JetExpression, JetScope> RESOLUTION_SCOPE = Slices.createSimpleSlice();
|
||||||
|
WritableSlice<JetExpression, LexicalScope> LEXICAL_SCOPE = Slices.createSimpleSlice();
|
||||||
|
|
||||||
WritableSlice<ScriptDescriptor, JetScope> SCRIPT_SCOPE = Slices.createSimpleSlice();
|
WritableSlice<ScriptDescriptor, JetScope> SCRIPT_SCOPE = Slices.createSimpleSlice();
|
||||||
|
|
||||||
|
|||||||
@@ -29,7 +29,8 @@ import org.jetbrains.kotlin.resolve.DescriptorToSourceUtils
|
|||||||
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
import org.jetbrains.kotlin.resolve.DescriptorUtils
|
||||||
import org.jetbrains.kotlin.resolve.calls.context.ResolutionContext
|
import org.jetbrains.kotlin.resolve.calls.context.ResolutionContext
|
||||||
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfo
|
import org.jetbrains.kotlin.resolve.calls.smartcasts.DataFlowInfo
|
||||||
import org.jetbrains.kotlin.resolve.scopes.WritableScope
|
import org.jetbrains.kotlin.resolve.scopes.LexicalWritableScope
|
||||||
|
import org.jetbrains.kotlin.resolve.scopes.utils.asJetScope
|
||||||
import org.jetbrains.kotlin.types.expressions.typeInfoFactory.noTypeInfo
|
import org.jetbrains.kotlin.types.expressions.typeInfoFactory.noTypeInfo
|
||||||
|
|
||||||
public fun JetReturnExpression.getTargetFunctionDescriptor(context: BindingContext): FunctionDescriptor? {
|
public fun JetReturnExpression.getTargetFunctionDescriptor(context: BindingContext): FunctionDescriptor? {
|
||||||
@@ -56,8 +57,9 @@ public fun JetExpression.isUsedAsStatement(context: BindingContext): Boolean = !
|
|||||||
public fun <C : ResolutionContext<C>> ResolutionContext<C>.recordScopeAndDataFlowInfo(expression: JetExpression?) {
|
public fun <C : ResolutionContext<C>> ResolutionContext<C>.recordScopeAndDataFlowInfo(expression: JetExpression?) {
|
||||||
if (expression == null) return
|
if (expression == null) return
|
||||||
|
|
||||||
val scopeToRecord = if (scope is WritableScope) scope.takeSnapshot() else scope
|
val scopeToRecord = if (scope is LexicalWritableScope) scope.takeSnapshot() else scope
|
||||||
trace.record(BindingContext.RESOLUTION_SCOPE, expression, scopeToRecord)
|
trace.record(BindingContext.RESOLUTION_SCOPE, expression, scopeToRecord.asJetScope())
|
||||||
|
trace.record(BindingContext.LEXICAL_SCOPE, expression, scopeToRecord)
|
||||||
|
|
||||||
val typeInfo = trace.get(BindingContext.EXPRESSION_TYPE_INFO, expression)
|
val typeInfo = trace.get(BindingContext.EXPRESSION_TYPE_INFO, expression)
|
||||||
if (typeInfo != null) {
|
if (typeInfo != null) {
|
||||||
|
|||||||
Reference in New Issue
Block a user