diff --git a/pkg/dart2js_incremental/lib/library_updater.dart b/pkg/dart2js_incremental/lib/library_updater.dart index 25eb60b0c84..3582f726d21 100644 --- a/pkg/dart2js_incremental/lib/library_updater.dart +++ b/pkg/dart2js_incremental/lib/library_updater.dart @@ -233,9 +233,6 @@ class LibraryUpdater extends JsFeatures { logVerbose("Removed method $element."); PartialClassElement cls = element.enclosingClass; - if (cls != null && !element.isInstanceMember) { - return cannotReuse(element, "Removed static method"); - } for (ScopeContainerElement scope in scopesAffectedBy(element, cls)) { scanSites(scope, (Element member, DeclarationSite site) { // TODO(ahe): Cache qualifiedNamesIn to avoid quadratic behavior. diff --git a/tests/try/web/incremental_compilation_update_test.dart b/tests/try/web/incremental_compilation_update_test.dart index babde70e5d2..41917114693 100644 --- a/tests/try/web/incremental_compilation_update_test.dart +++ b/tests/try/web/incremental_compilation_update_test.dart @@ -12,6 +12,9 @@ import 'dart:async' show import 'package:async_helper/async_helper.dart' show asyncTest; +import 'package:try/src/interaction_manager.dart' show + splitLines; + import 'sandbox.dart' show appendIFrame, listener; @@ -340,13 +343,77 @@ main() { const ['v2']), ], - - + // Test that deleting a static method works. + const [ + const ProgramResult( + """ +class B { + static staticMethod() { + print('v1'); + } +} +class C { + m() { + try { + B.staticMethod(); + } catch (e) { + print('v2'); + } + try { + // Ensure that noSuchMethod support is compiled. This test is not about + // adding new classes. + B.missingMethod(); + print('bad'); + } catch (e) { + } + } +} +var instance; +main() { + if (instance == null) { + instance = new C(); + } + instance.m(); +} +""", + const ['v1']), + const ProgramResult( + """ +class B { +} +class C { + m() { + try { + B.staticMethod(); + } catch (e) { + print('v2'); + } + try { + // Ensure that noSuchMethod support is compiled. This test is not about + // adding new classes. + B.missingMethod(); + print('bad'); + } catch (e) { + } + } +} +var instance; +main() { + if (instance == null) { + instance = new C(); + } + instance.m(); +} +""", + const ['v2']), + ], ]; void main() { listener.start(); + document.head.append(lineNumberStyle()); + return asyncTest(() => Future.forEach(tests, compileAndRun)); } @@ -363,7 +430,11 @@ Future compileAndRun(List programs) { return listener.expect('iframe-ready').then((_) { ProgramResult program = programs.first; - status.append(new PreElement()..appendText(program.code)); + + + status.append(new HeadingElement.h2()..appendText("Full program:")); + status.append(numberedLines(program.code)); + status.style.color = 'orange'; WebCompilerTestCase test = new WebCompilerTestCase(program.code); return test.run().then((String jsCode) { @@ -378,7 +449,8 @@ Future compileAndRun(List programs) { int version = 2; return Future.forEach(programs.skip(1), (ProgramResult program) { - status.append(new PreElement()..appendText(program.code)); + status.append(new HeadingElement.h2()..appendText("Update:")); + status.append(numberedLines(program.code)); WebInputProvider inputProvider = test.incrementalCompiler.inputProvider; @@ -413,3 +485,51 @@ void logger(x) { throw 'Test timed out.'; } } + +Element numberedLines(String code) { + DivElement result = new DivElement(); + result.classes.add("output"); + + for (String text in splitLines(code)) { + Element line = new PreElement() + ..appendText(text.trimRight()) + ..classes.add("line"); + result.append(line); + } + + return result; +} + + +StyleElement lineNumberStyle() { + StyleElement style = new StyleElement()..appendText(''' +h2 { + color: black; +} + +.output { + padding: 0px; + counter-reset: line-number; + padding-bottom: 1em; +} + +.line { + white-space: pre-wrap; + padding-left: 3.5em; + margin-top: 0; + margin-bottom: 0; +} + +.line::before { + counter-increment: line-number; + content: counter(line-number) " "; + position: absolute; + left: 0px; + width: 3em; + text-align: right; + background-color: lightgoldenrodyellow; +} +'''); + style.type = 'text/css'; + return style; +}