Description
Code completion on the following code causes an exception. The completion point is line 29 immediately after the 't' of 'const' (no space) in class C1. The exception refers to class Bar, which is defined on line 46, so presumably a large amount of text was incorrectly parsed. Prior to the addition of 'const ' the file compiled with no errors. The stack trace follows the code. Note that a significantly different AST is created if the space following 'const' is deleted. Changing 'const' to 'const Map();' compiles without error. Changing to 'const M' and attempting completion following the 'M' causes a similar exception.
class test {
factory test<X extends List>() {}
}
interface I<T extends Map> factory Ci<T> {
}
class Ci<S> implements I<Map> {
factory I<R>() {} // <R> is not optional and must be compatible with S.
}
//
typedef Map Fox<T1 extends Map>(List input);
class HashMapImplementation<K extends Hashable, V> implements HashMap<K, V> {}
//
class Fooa {
final Bara<Fooa> bar = const Bara/* <Fooa> Workaround bug #322 */();
}
class Bara<T extends Fooa> {
const Bara();
}
main1() {
print(new Fooa());
}
/*********/
class C1<Q> {
Q x;
C1(Q x) { this.x = x; const }
}
class C2<Q> {
Q x;
C2(this.x) {}
}
main2() {
C1<int> c1 = new C1<int>(0);
C2<int> c2 = new C2<int>(1);
}
/*********/
class Foo {
final Bar<Foo> bar = const Bar<Foo>();
}
class Bar<T extends Foo> {
const Bar(T k);
T m(T a, T b){}
T f = null;
}
main3() {
print(new Foo());
}
/*********/
class X {
static final num MAX = 0;
num yc,xc;
mth() {
xc = yc = MAX;
xc.abs();
num f = MAX;
}
}
class Y {
String x="hi";
mth() {
x.length;
int n = 0;
x.charCodeAt(n);
}
}
class Z {
Map m = const Map();
mth() {
var x = new List.from(['a']);
}
}
class A {
int x;
mth() {
int y = this.x;
}
}
class B1 {
B1();
x(){}
}
class B2 extends B1 {
B2() { super.x();}
}
class C {
mth(Map x, q) {}
mtf(q, Map x) {}
m() { for (int i = 0; i < 5; i++); A x;}
}
class D {
f(){} g(){f(/f/);}
}
class E {
int x; mth() {var y = x;}
}
class F {
var x = false;
}
com.google.dart.compiler.InternalCompilerException: Unexpected element Bar kind: CLASSevaluating type for compile-time constant expression.
at com.google.dart.compiler.resolver.CompileTimeConstVisitor.getMostSpecificType(CompileTimeConstVisitor.java:396)
at com.google.dart.compiler.resolver.CompileTimeConstVisitor.visitBinaryExpression(CompileTimeConstVisitor.java:109)
at com.google.dart.compiler.resolver.CompileTimeConstVisitor.visitBinaryExpression(CompileTimeConstVisitor.java:1)
at com.google.dart.compiler.ast.DartBinaryExpression.accept(DartBinaryExpression.java:72)
at com.google.dart.compiler.resolver.Resolver$ResolveElementsVisitor.checkConstantExpression(Resolver.java:349)
at com.google.dart.compiler.resolver.Resolver$ResolveElementsVisitor.visitNewExpression(Resolver.java:883)
at com.google.dart.compiler.resolver.Resolver$ResolveElementsVisitor.visitNewExpression(Resolver.java:1)
at com.google.dart.compiler.ast.DartNewExpression.accept(DartNewExpression.java:67)
at com.google.dart.compiler.ast.DartExprStmt.visitChildren(DartExprStmt.java:31)
at com.google.dart.compiler.ast.DartNodeTraverser.visitNode(DartNodeTraverser.java:54)
at com.google.dart.compiler.ast.DartNodeTraverser.visitStatement(DartNodeTraverser.java:71)
at com.google.dart.compiler.ast.DartNodeTraverser.visitExprStmt(DartNodeTraverser.java:191)
at com.google.dart.compiler.ast.DartExprStmt.accept(DartExprStmt.java:36)
at com.google.dart.compiler.ast.DartNodeTraverser.visit(DartNodeTraverser.java:413)
at com.google.dart.compiler.ast.DartBlock.visitChildren(DartBlock.java:44)
at com.google.dart.compiler.resolver.Resolver$ResolveElementsVisitor.visitBlock(Resolver.java:477)
at com.google.dart.compiler.resolver.Resolver$ResolveElementsVisitor.visitBlock(Resolver.java:1)
at com.google.dart.compiler.ast.DartBlock.accept(DartBlock.java:49)
at com.google.dart.compiler.resolver.Resolver$ResolveElementsVisitor.resolve(Resolver.java:289)
at com.google.dart.compiler.resolver.Resolver$ResolveElementsVisitor.visitMethodDefinition(Resolver.java:330)
at com.google.dart.compiler.resolver.Resolver$ResolveElementsVisitor.visitMethodDefinition(Resolver.java:1)
at com.google.dart.compiler.ast.DartMethodDefinition.accept(DartMethodDefinition.java:90)
at com.google.dart.compiler.resolver.Resolver$ResolveElementsVisitor.visitClass(Resolver.java:236)
at com.google.dart.compiler.resolver.Resolver$ResolveElementsVisitor.visitClass(Resolver.java:1)
at com.google.dart.compiler.ast.DartClass.accept(DartClass.java:175)
at com.google.dart.compiler.resolver.Resolver$ResolveElementsVisitor.visitUnit(Resolver.java:200)
at com.google.dart.compiler.resolver.Resolver$ResolveElementsVisitor.visitUnit(Resolver.java:1)
at com.google.dart.compiler.ast.DartUnit.accept(DartUnit.java:107)
at com.google.dart.compiler.resolver.Resolver.exec(Resolver.java:112)
at com.google.dart.compiler.DeltaAnalyzer.analyze(DeltaAnalyzer.java:72)
at com.google.dart.compiler.DartCompiler.analyzeDelta(DartCompiler.java:1209)
at com.google.dart.tools.core.utilities.compiler.DartCompilerUtilities$DeltaAnalysisRunnable.run(DartCompilerUtilities.java:266)
at com.google.dart.tools.core.utilities.compiler.DartCompilerUtilities$CompilerRunner.runSafe(DartCompilerUtilities.java:92)
at com.google.dart.tools.core.utilities.compiler.DartCompilerUtilities.analyzeDelta(DartCompilerUtilities.java:465)
at com.google.dart.tools.core.internal.completion.CompletionEngine.complete(CompletionEngine.java:1066)
at com.google.dart.tools.core.internal.completion.CompletionEngine.complete(CompletionEngine.java:996)
at com.google.dart.tools.core.internal.model.OpenableElementImpl.codeComplete(OpenableElementImpl.java:374)
at com.google.dart.tools.core.internal.model.CompilationUnitImpl.codeComplete(CompilationUnitImpl.java:899)
at com.google.dart.tools.core.internal.model.CompilationUnitImpl.codeComplete(CompilationUnitImpl.java:892)
at com.google.dart.tools.core.internal.model.CompilationUnitImpl.codeComplete(CompilationUnitImpl.java:880)
at com.google.dart.tools.ui.internal.text.dart.DartCompletionProposalComputer.internalComputeCompletionProposals(DartCompletionProposalComputer.java:251)
at com.google.dart.tools.ui.internal.text.dart.DartCompletionProposalComputer.computeCompletionProposals(DartCompletionProposalComputer.java:122)
at com.google.dart.tools.ui.internal.text.dart.CompletionProposalComputerDescriptor.computeCompletionProposals(CompletionProposalComputerDescriptor.java:224)
at com.google.dart.tools.ui.internal.text.dart.CompletionProposalCategory.computeCompletionProposals(CompletionProposalCategory.java:119)
at com.google.dart.tools.ui.internal.text.dart.ContentAssistProcessor.collectProposals(ContentAssistProcessor.java:407)
at com.google.dart.tools.ui.internal.text.dart.ContentAssistProcessor.computeCompletionProposals(ContentAssistProcessor.java:227)
at org.eclipse.jface.text.contentassist.ContentAssistant.computeCompletionProposals(ContentAssistant.java:1830)
at org.eclipse.jface.text.contentassist.CompletionProposalPopup.computeProposals(CompletionProposalPopup.java:556)
at org.eclipse.jface.text.contentassist.CompletionProposalPopup.access$16(CompletionProposalPopup.java:553)
at org.eclipse.jface.text.contentassist.CompletionProposalPopup$2.run(CompletionProposalPopup.java:488)
at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70)
at org.eclipse.jface.text.contentassist.CompletionProposalPopup.showProposals(CompletionProposalPopup.java:482)
at org.eclipse.jface.text.contentassist.ContentAssistant.showPossibleCompletions(ContentAssistant.java:1656)
at com.google.dart.tools.ui.internal.text.editor.CompilationUnitEditor$AdaptedSourceViewer.doOperation(CompilationUnitEditor.java:172)
at org.eclipse.ui.texteditor.ContentAssistAction$1.run(ContentAssistAction.java:82)
at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:70)
at org.eclipse.ui.texteditor.ContentAssistAction.run(ContentAssistAction.java:80)
at org.eclipse.jface.action.Action.runWithEvent(Action.java:498)
at org.eclipse.ui.commands.ActionHandler.execute(ActionHandler.java:185)
at org.eclipse.ui.internal.handlers.LegacyHandlerWrapper.execute(LegacyHandlerWrapper.java:109)
at org.eclipse.core.commands.Command.executeWithChecks(Command.java:476)
at org.eclipse.core.commands.ParameterizedCommand.executeWithChecks(ParameterizedCommand.java:508)
at org.eclipse.ui.internal.handlers.HandlerService.executeCommand(HandlerService.java:169)
at org.eclipse.ui.internal.keys.WorkbenchKeyboard.executeCommand(WorkbenchKeyboard.java:468)
at org.eclipse.ui.internal.keys.WorkbenchKeyboard.press(WorkbenchKeyboard.java:786)
at org.eclipse.ui.internal.keys.WorkbenchKeyboard.processKeyEvent(WorkbenchKeyboard.java:885)
at org.eclipse.ui.internal.keys.WorkbenchKeyboard.filterKeySequenceBindings(WorkbenchKeyboard.java:567)
at org.eclipse.ui.internal.keys.WorkbenchKeyboard.access$3(WorkbenchKeyboard.java:508)
at org.eclipse.ui.internal.keys.WorkbenchKeyboard$KeyDownFilter.handleEvent(WorkbenchKeyboard.java:123)
at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
at org.eclipse.swt.widgets.Display.filterEvent(Display.java:1069)
at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4124)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1457)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1480)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1465)
at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:1494)
at org.eclipse.swt.widgets.Widget.sendKeyEvent(Widget.java:1490)
at org.eclipse.swt.widgets.Canvas.sendKeyEvent(Canvas.java:463)
at org.eclipse.swt.widgets.Control.doCommandBySelector(Control.java:1051)
at org.eclipse.swt.widgets.Display.windowProc(Display.java:5560)
at org.eclipse.swt.internal.cocoa.OS.objc_msgSend(Native Method)
at org.eclipse.swt.internal.cocoa.NSResponder.interpretKeyEvents(NSResponder.java:68)
at org.eclipse.swt.widgets.Composite.keyDown(Composite.java:587)
at org.eclipse.swt.widgets.Display.windowProc(Display.java:5470)
at org.eclipse.swt.internal.cocoa.OS.objc_msgSendSuper(Native Method)
at org.eclipse.swt.widgets.Widget.callSuper(Widget.java:220)
at org.eclipse.swt.widgets.Widget.windowSendEvent(Widget.java:2092)
at org.eclipse.swt.widgets.Shell.windowSendEvent(Shell.java:2255)
at org.eclipse.swt.widgets.Display.windowProc(Display.java:5532)
at org.eclipse.swt.internal.cocoa.OS.objc_msgSendSuper(Native Method)
at org.eclipse.swt.widgets.Display.applicationSendEvent(Display.java:4986)
at org.eclipse.swt.widgets.Display.applicationProc(Display.java:5135)
at org.eclipse.swt.internal.cocoa.OS.objc_msgSend(Native Method)
at org.eclipse.swt.internal.cocoa.NSApplication.sendEvent(NSApplication.java:128)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3607)
at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2696)
at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2660)
at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2494)
at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:674)
at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:667)
at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)