KT-2142 function local classes do not work
#KT-2142 fixed except KT-2277 Check overloads for local declarations
This commit is contained in:
@@ -107,7 +107,7 @@ public class OverloadResolver {
|
|||||||
ClassDescriptor classDescriptor = (ClassDescriptor) containingDeclaration;
|
ClassDescriptor classDescriptor = (ClassDescriptor) containingDeclaration;
|
||||||
inClasses.put(classDescriptor, klass.getConstructors());
|
inClasses.put(classDescriptor, klass.getConstructors());
|
||||||
}
|
}
|
||||||
else {
|
else if (!(containingDeclaration instanceof FunctionDescriptor)) {
|
||||||
throw new IllegalStateException();
|
throw new IllegalStateException();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
import org.jetbrains.jet.di.InjectorForTopDownAnalyzerBasic;
|
import org.jetbrains.jet.di.InjectorForTopDownAnalyzerBasic;
|
||||||
import org.jetbrains.jet.lang.ModuleConfiguration;
|
import org.jetbrains.jet.lang.ModuleConfiguration;
|
||||||
import org.jetbrains.jet.lang.descriptors.*;
|
import org.jetbrains.jet.lang.descriptors.*;
|
||||||
|
import org.jetbrains.jet.lang.psi.JetClassOrObject;
|
||||||
import org.jetbrains.jet.lang.psi.JetDeclaration;
|
import org.jetbrains.jet.lang.psi.JetDeclaration;
|
||||||
import org.jetbrains.jet.lang.psi.JetFile;
|
import org.jetbrains.jet.lang.psi.JetFile;
|
||||||
import org.jetbrains.jet.lang.psi.JetObjectDeclaration;
|
import org.jetbrains.jet.lang.psi.JetObjectDeclaration;
|
||||||
@@ -191,12 +192,12 @@ public class TopDownAnalyzer {
|
|||||||
doProcess(outerScope, standardLibraryNamespace.getBuilder(), toAnalyze);
|
doProcess(outerScope, standardLibraryNamespace.getBuilder(), toAnalyze);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void processObject(
|
public static void processClassOrObject(
|
||||||
@NotNull Project project,
|
@NotNull Project project,
|
||||||
@NotNull final BindingTrace trace,
|
@NotNull final BindingTrace trace,
|
||||||
@NotNull JetScope outerScope,
|
@NotNull JetScope outerScope,
|
||||||
@NotNull final DeclarationDescriptor containingDeclaration,
|
@NotNull final DeclarationDescriptor containingDeclaration,
|
||||||
@NotNull JetObjectDeclaration object
|
@NotNull JetClassOrObject object
|
||||||
) {
|
) {
|
||||||
ModuleDescriptor moduleDescriptor = new ModuleDescriptor(Name.special("<dummy for object>"));
|
ModuleDescriptor moduleDescriptor = new ModuleDescriptor(Name.special("<dummy for object>"));
|
||||||
|
|
||||||
|
|||||||
+2
-1
@@ -80,7 +80,8 @@ public class ClosureExpressionsTypingVisitor extends ExpressionTypingVisitor {
|
|||||||
};
|
};
|
||||||
ObservableBindingTrace traceAdapter = new ObservableBindingTrace(temporaryTrace);
|
ObservableBindingTrace traceAdapter = new ObservableBindingTrace(temporaryTrace);
|
||||||
traceAdapter.addHandler(CLASS, handler);
|
traceAdapter.addHandler(CLASS, handler);
|
||||||
TopDownAnalyzer.processObject(context.expressionTypingServices.getProject(), traceAdapter, context.scope, context.scope.getContainingDeclaration(), expression.getObjectDeclaration());
|
TopDownAnalyzer.processClassOrObject(context.expressionTypingServices.getProject(), traceAdapter, context.scope,
|
||||||
|
context.scope.getContainingDeclaration(), expression.getObjectDeclaration());
|
||||||
|
|
||||||
DelegatingBindingTrace cloneDelta = new DelegatingBindingTrace(new BindingTraceContext().getBindingContext());
|
DelegatingBindingTrace cloneDelta = new DelegatingBindingTrace(new BindingTraceContext().getBindingContext());
|
||||||
temporaryTrace.addAllMyDataTo(cloneDelta);
|
temporaryTrace.addAllMyDataTo(cloneDelta);
|
||||||
|
|||||||
+9
-2
@@ -79,7 +79,8 @@ public class ExpressionTypingVisitorForStatements extends ExpressionTypingVisito
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JetType visitObjectDeclaration(JetObjectDeclaration declaration, ExpressionTypingContext context) {
|
public JetType visitObjectDeclaration(JetObjectDeclaration declaration, ExpressionTypingContext context) {
|
||||||
TopDownAnalyzer.processObject(context.expressionTypingServices.getProject(), context.trace, scope, scope.getContainingDeclaration(), declaration);
|
TopDownAnalyzer.processClassOrObject(context.expressionTypingServices.getProject(), context.trace, scope,
|
||||||
|
scope.getContainingDeclaration(), declaration);
|
||||||
ClassDescriptor classDescriptor = context.trace.getBindingContext().get(BindingContext.CLASS, declaration);
|
ClassDescriptor classDescriptor = context.trace.getBindingContext().get(BindingContext.CLASS, declaration);
|
||||||
if (classDescriptor != null) {
|
if (classDescriptor != null) {
|
||||||
VariableDescriptor variableDescriptor = context.expressionTypingServices.getDescriptorResolver()
|
VariableDescriptor variableDescriptor = context.expressionTypingServices.getDescriptorResolver()
|
||||||
@@ -136,7 +137,13 @@ public class ExpressionTypingVisitorForStatements extends ExpressionTypingVisito
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public JetType visitClass(JetClass klass, ExpressionTypingContext context) {
|
public JetType visitClass(JetClass klass, ExpressionTypingContext context) {
|
||||||
return super.visitClass(klass, context); // TODO
|
TopDownAnalyzer.processClassOrObject(context.expressionTypingServices.getProject(), context.trace, scope,
|
||||||
|
scope.getContainingDeclaration(), klass);
|
||||||
|
ClassDescriptor classDescriptor = context.trace.getBindingContext().get(BindingContext.CLASS, klass);
|
||||||
|
if (classDescriptor != null) {
|
||||||
|
scope.addClassifierDescriptor(classDescriptor);
|
||||||
|
}
|
||||||
|
return DataFlowUtils.checkStatementType(klass, context);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -18,25 +18,24 @@ fun main(args : Array<String>) {
|
|||||||
else -> <!UNRESOLVED_IDE_TEMPLATE!><#<elseValue>#><!>
|
else -> <!UNRESOLVED_IDE_TEMPLATE!><#<elseValue>#><!>
|
||||||
}
|
}
|
||||||
|
|
||||||
var <#<name>#> = <!UNRESOLVED_IDE_TEMPLATE!><#<value>#><!>
|
<!REDECLARATION!>var <#<name>#> = <!UNRESOLVED_IDE_TEMPLATE!><#<value>#><!><!>
|
||||||
|
|
||||||
class <#<name>#> {
|
<!REDECLARATION, REDECLARATION!>class <#<name>#> {
|
||||||
<#<body>#>
|
<#<body>#>
|
||||||
}
|
}<!>
|
||||||
|
|
||||||
class <#<name>#> {
|
<!REDECLARATION!>class <#<name>#> {
|
||||||
var <#<name>#> : <#<varType>#>
|
<!REDECLARATION!>var <#<name>#> : <#<varType>#>
|
||||||
get() {
|
get() <!RETURN_TYPE_MISMATCH!>{
|
||||||
<#<body>#>
|
<!UNRESOLVED_IDE_TEMPLATE!><#<body>#><!>
|
||||||
}
|
}<!>
|
||||||
set(value) {
|
set(value) {
|
||||||
<#<body>#>
|
<!UNRESOLVED_IDE_TEMPLATE!><#<body>#><!>
|
||||||
}
|
}<!>
|
||||||
|
|
||||||
val <#<name>#> : <#<valType>#>
|
|
||||||
get() {
|
|
||||||
<#<body>#>
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
<!REDECLARATION!>val <#<name>#> : <#<valType>#>
|
||||||
|
get() <!RETURN_TYPE_MISMATCH!>{
|
||||||
|
<!UNRESOLVED_IDE_TEMPLATE!><#<body>#><!>
|
||||||
|
}<!><!>
|
||||||
|
}<!>
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
//KT-2142 function local classes do not work
|
||||||
|
|
||||||
|
package a
|
||||||
|
|
||||||
|
fun foo() {
|
||||||
|
class Foo() {}
|
||||||
|
Foo() // Unresolved reference Foo
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user