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;
|
||||
inClasses.put(classDescriptor, klass.getConstructors());
|
||||
}
|
||||
else {
|
||||
else if (!(containingDeclaration instanceof FunctionDescriptor)) {
|
||||
throw new IllegalStateException();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.jet.di.InjectorForTopDownAnalyzerBasic;
|
||||
import org.jetbrains.jet.lang.ModuleConfiguration;
|
||||
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.JetFile;
|
||||
import org.jetbrains.jet.lang.psi.JetObjectDeclaration;
|
||||
@@ -191,12 +192,12 @@ public class TopDownAnalyzer {
|
||||
doProcess(outerScope, standardLibraryNamespace.getBuilder(), toAnalyze);
|
||||
}
|
||||
|
||||
public static void processObject(
|
||||
public static void processClassOrObject(
|
||||
@NotNull Project project,
|
||||
@NotNull final BindingTrace trace,
|
||||
@NotNull JetScope outerScope,
|
||||
@NotNull final DeclarationDescriptor containingDeclaration,
|
||||
@NotNull JetObjectDeclaration object
|
||||
@NotNull JetClassOrObject 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);
|
||||
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());
|
||||
temporaryTrace.addAllMyDataTo(cloneDelta);
|
||||
|
||||
+9
-2
@@ -79,7 +79,8 @@ public class ExpressionTypingVisitorForStatements extends ExpressionTypingVisito
|
||||
|
||||
@Override
|
||||
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);
|
||||
if (classDescriptor != null) {
|
||||
VariableDescriptor variableDescriptor = context.expressionTypingServices.getDescriptorResolver()
|
||||
@@ -136,7 +137,13 @@ public class ExpressionTypingVisitorForStatements extends ExpressionTypingVisito
|
||||
|
||||
@Override
|
||||
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
|
||||
|
||||
@@ -18,25 +18,24 @@ fun main(args : Array<String>) {
|
||||
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>#>
|
||||
}
|
||||
}<!>
|
||||
|
||||
class <#<name>#> {
|
||||
var <#<name>#> : <#<varType>#>
|
||||
get() {
|
||||
<#<body>#>
|
||||
}
|
||||
<!REDECLARATION!>class <#<name>#> {
|
||||
<!REDECLARATION!>var <#<name>#> : <#<varType>#>
|
||||
get() <!RETURN_TYPE_MISMATCH!>{
|
||||
<!UNRESOLVED_IDE_TEMPLATE!><#<body>#><!>
|
||||
}<!>
|
||||
set(value) {
|
||||
<#<body>#>
|
||||
}
|
||||
|
||||
val <#<name>#> : <#<valType>#>
|
||||
get() {
|
||||
<#<body>#>
|
||||
}
|
||||
}
|
||||
}
|
||||
<!UNRESOLVED_IDE_TEMPLATE!><#<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