| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #import("../../../lib/compiler/implementation/leg.dart"); | 5 #import("../../../lib/compiler/implementation/leg.dart"); |
| 6 #import("../../../lib/compiler/implementation/elements/elements.dart"); | 6 #import("../../../lib/compiler/implementation/elements/elements.dart"); |
| 7 #import("../../../lib/compiler/implementation/tree/tree.dart"); | 7 #import("../../../lib/compiler/implementation/tree/tree.dart"); |
| 8 #import("../../../lib/compiler/implementation/util/util.dart"); | 8 #import("../../../lib/compiler/implementation/util/util.dart"); |
| 9 #import("mock_compiler.dart"); | 9 #import("mock_compiler.dart"); |
| 10 #import("parser_helper.dart"); | 10 #import("parser_helper.dart"); |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 114 Expect.equals(MessageKind.CANNOT_RESOLVE_TYPE, | 114 Expect.equals(MessageKind.CANNOT_RESOLVE_TYPE, |
| 115 compiler.errors[0].message.kind); | 115 compiler.errors[0].message.kind); |
| 116 | 116 |
| 117 compiler = new MockCompiler(); | 117 compiler = new MockCompiler(); |
| 118 compiler.parseScript('class Foo<T> {' | 118 compiler.parseScript('class Foo<T> {' |
| 119 ' Foo<T> t;' | 119 ' Foo<T> t;' |
| 120 ' foo(Foo<T> f) {}' | 120 ' foo(Foo<T> f) {}' |
| 121 ' bar() { g(Foo<T> f) {}; g(); }' | 121 ' bar() { g(Foo<T> f) {}; g(); }' |
| 122 '}'); | 122 '}'); |
| 123 foo = compiler.mainApp.find(buildSourceString('Foo')); | 123 foo = compiler.mainApp.find(buildSourceString('Foo')); |
| 124 compiler.resolveClass(foo); | 124 foo.ensureResolved(compiler); |
| 125 foo.lookupLocalMember(buildSourceString('t')).computeType(compiler);; | 125 foo.lookupLocalMember(buildSourceString('t')).computeType(compiler);; |
| 126 foo.lookupLocalMember(buildSourceString('foo')).computeType(compiler);; | 126 foo.lookupLocalMember(buildSourceString('foo')).computeType(compiler);; |
| 127 compiler.resolver.resolve(foo.lookupLocalMember(buildSourceString('bar'))); | 127 compiler.resolver.resolve(foo.lookupLocalMember(buildSourceString('bar'))); |
| 128 Expect.equals(0, compiler.warnings.length); | 128 Expect.equals(0, compiler.warnings.length); |
| 129 Expect.equals(0, compiler.errors.length); | 129 Expect.equals(0, compiler.errors.length); |
| 130 } | 130 } |
| 131 | 131 |
| 132 testSuperCalls() { | 132 testSuperCalls() { |
| 133 MockCompiler compiler = new MockCompiler(); | 133 MockCompiler compiler = new MockCompiler(); |
| 134 String script = """class A { foo() {} } | 134 String script = """class A { foo() {} } |
| (...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 402 // Test that 'var' does not create a warning. | 402 // Test that 'var' does not create a warning. |
| 403 mapping = compiler.resolveStatement("var foo;").map; | 403 mapping = compiler.resolveStatement("var foo;").map; |
| 404 Expect.equals(1, mapping.length); | 404 Expect.equals(1, mapping.length); |
| 405 Expect.equals(0, compiler.warnings.length); | 405 Expect.equals(0, compiler.warnings.length); |
| 406 } | 406 } |
| 407 | 407 |
| 408 testSuperclass() { | 408 testSuperclass() { |
| 409 MockCompiler compiler = new MockCompiler(); | 409 MockCompiler compiler = new MockCompiler(); |
| 410 compiler.parseScript("class Foo extends Bar {}"); | 410 compiler.parseScript("class Foo extends Bar {}"); |
| 411 compiler.resolveStatement("Foo bar;"); | 411 compiler.resolveStatement("Foo bar;"); |
| 412 Expect.equals(1, compiler.errors.length); | 412 // TODO(ahe): We get the same error twice: once from |
| 413 Expect.equals( | 413 // ClassResolverVisitor, and once from ClassSupertypeResolver. We |
| 414 new Message(MessageKind.CANNOT_RESOLVE_TYPE, ['Bar']), | 414 // should only the get the error once. |
| 415 compiler.errors[0].message); | 415 Expect.equals(2, compiler.errors.length); |
| 416 var cannotResolveBar = new Message(MessageKind.CANNOT_RESOLVE_TYPE, ['Bar']); |
| 417 Expect.equals(cannotResolveBar, compiler.errors[0].message); |
| 418 Expect.equals(cannotResolveBar, compiler.errors[1].message); |
| 416 compiler.clearErrors(); | 419 compiler.clearErrors(); |
| 417 | 420 |
| 418 compiler = new MockCompiler(); | 421 compiler = new MockCompiler(); |
| 419 compiler.parseScript("class Foo extends Bar {}"); | 422 compiler.parseScript("class Foo extends Bar {}"); |
| 420 compiler.parseScript("class Bar {}"); | 423 compiler.parseScript("class Bar {}"); |
| 421 Map mapping = compiler.resolveStatement("Foo bar;").map; | 424 Map mapping = compiler.resolveStatement("Foo bar;").map; |
| 422 Expect.equals(2, mapping.length); | 425 Expect.equals(2, mapping.length); |
| 423 | 426 |
| 424 ClassElement fooElement = compiler.mainApp.find(buildSourceString('Foo')); | 427 ClassElement fooElement = compiler.mainApp.find(buildSourceString('Foo')); |
| 425 ClassElement barElement = compiler.mainApp.find(buildSourceString('Bar')); | 428 ClassElement barElement = compiler.mainApp.find(buildSourceString('Bar')); |
| (...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 711 length(Link link) => link.isEmpty() ? 0 : length(link.tail) + 1; | 714 length(Link link) => link.isEmpty() ? 0 : length(link.tail) + 1; |
| 712 | 715 |
| 713 at(Link link, int index) => (index == 0) ? link.head : at(link.tail, index - 1); | 716 at(Link link, int index) => (index == 0) ? link.head : at(link.tail, index - 1); |
| 714 | 717 |
| 715 List<String> asSortedStrings(Link link) { | 718 List<String> asSortedStrings(Link link) { |
| 716 List<String> result = <String>[]; | 719 List<String> result = <String>[]; |
| 717 for (; !link.isEmpty(); link = link.tail) result.add(link.head.toString()); | 720 for (; !link.isEmpty(); link = link.tail) result.add(link.head.toString()); |
| 718 result.sort((s1, s2) => s1.compareTo(s2)); | 721 result.sort((s1, s2) => s1.compareTo(s2)); |
| 719 return result; | 722 return result; |
| 720 } | 723 } |
| OLD | NEW |