| 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 package com.google.dart.compiler.resolver; | 5 package com.google.dart.compiler.resolver; |
| 6 | 6 |
| 7 import com.google.common.base.Joiner; | 7 import com.google.common.base.Joiner; |
| 8 import com.google.dart.compiler.DartCompilationError; | 8 import com.google.dart.compiler.DartCompilationError; |
| 9 import com.google.dart.compiler.ErrorCode; | 9 import com.google.dart.compiler.ErrorCode; |
| 10 import com.google.dart.compiler.ast.DartClass; | 10 import com.google.dart.compiler.ast.DartClass; |
| 11 import com.google.dart.compiler.common.ErrorExpectation; | 11 import com.google.dart.compiler.common.ErrorExpectation; |
| 12 import com.google.dart.compiler.type.DynamicType; | 12 import com.google.dart.compiler.type.DynamicType; |
| 13 import com.google.dart.compiler.type.InterfaceType; | 13 import com.google.dart.compiler.type.InterfaceType; |
| 14 import com.google.dart.compiler.type.Type; | 14 import com.google.dart.compiler.type.Type; |
| 15 import com.google.dart.compiler.type.Types; | 15 import com.google.dart.compiler.type.Types; |
| 16 | 16 |
| 17 import static com.google.dart.compiler.common.ErrorExpectation.errEx; | 17 import static com.google.dart.compiler.common.ErrorExpectation.errEx; |
| 18 | 18 |
| 19 import junit.framework.Assert; | 19 import junit.framework.Assert; |
| 20 | 20 |
| 21 import java.util.List; | 21 import java.util.List; |
| 22 import java.util.Map; |
| 22 | 23 |
| 23 /** | 24 /** |
| 24 * Basic tests of the resolver. | 25 * Basic tests of the resolver. |
| 25 */ | 26 */ |
| 26 public class ResolverTest extends ResolverTestCase { | 27 public class ResolverTest extends ResolverTestCase { |
| 27 private final DartClass object = makeClass("Object", null); | 28 private final DartClass object = makeClass("Object", null); |
| 28 private final DartClass array = makeClass("Array", makeType("Object"), "E"); | 29 private final DartClass array = makeClass("Array", makeType("Object"), "E"); |
| 29 private final DartClass growableArray = makeClass("GrowableArray", makeType("A
rray", "S"), "S"); | 30 private final DartClass growableArray = makeClass("GrowableArray", makeType("A
rray", "S"), "S"); |
| 30 private final Types types = Types.getInstance(null); | 31 private final Types types = Types.getInstance(null); |
| 31 | 32 |
| (...skipping 1072 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1104 public void test_classExtendsUnknown_fieldUnknownType() throws Exception { | 1105 public void test_classExtendsUnknown_fieldUnknownType() throws Exception { |
| 1105 resolveAndTest(Joiner.on("\n").join( | 1106 resolveAndTest(Joiner.on("\n").join( |
| 1106 "class Object {}", | 1107 "class Object {}", |
| 1107 "class MyClass extends UnknownA {", | 1108 "class MyClass extends UnknownA {", |
| 1108 " UnknownB field;", | 1109 " UnknownB field;", |
| 1109 "}"), | 1110 "}"), |
| 1110 ResolverErrorCode.NO_SUCH_TYPE, | 1111 ResolverErrorCode.NO_SUCH_TYPE, |
| 1111 TypeErrorCode.NO_SUCH_TYPE); | 1112 TypeErrorCode.NO_SUCH_TYPE); |
| 1112 } | 1113 } |
| 1113 | 1114 |
| 1115 public void test_cascadeWithTypeVariable() { |
| 1116 resolveAndTest(Joiner.on("\n").join( |
| 1117 "class Object {}", |
| 1118 "class C<T> {", |
| 1119 " test() {", |
| 1120 " this..T;", |
| 1121 " }", |
| 1122 "}"), |
| 1123 ResolverErrorCode.TYPE_VARIABLE_NOT_ALLOWED_IN_IDENTIFIER); |
| 1124 } |
| 1125 |
| 1114 /** | 1126 /** |
| 1115 * When {@link SupertypeResolver} can not find "UnknownA", it uses {@link Dyna
micType}, which | 1127 * When {@link SupertypeResolver} can not find "UnknownA", it uses {@link Dyna
micType}, which |
| 1116 * returns {@link DynamicElement}. By itself, this is OK. However when we late
r try to resolve | 1128 * returns {@link DynamicElement}. By itself, this is OK. However when we late
r try to resolve |
| 1117 * super() constructor invocation, this should not cause exception. | 1129 * super() constructor invocation, this should not cause exception. |
| 1118 */ | 1130 */ |
| 1119 public void test_classExtendsUnknown_callSuperConstructor() throws Exception { | 1131 public void test_classExtendsUnknown_callSuperConstructor() throws Exception { |
| 1120 resolveAndTest(Joiner.on("\n").join( | 1132 resolveAndTest(Joiner.on("\n").join( |
| 1121 "class Object {}", | 1133 "class Object {}", |
| 1122 "class MyClass extends UnknownA {", | 1134 "class MyClass extends UnknownA {", |
| 1123 " MyClass() : super() {", | 1135 " MyClass() : super() {", |
| (...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1506 "class C {", | 1518 "class C {", |
| 1507 " C(arg){}", | 1519 " C(arg){}", |
| 1508 " C.named1() : this(topLevel());", // ok | 1520 " C.named1() : this(topLevel());", // ok |
| 1509 " C.named2() : this(method());", // error, not a static method | 1521 " C.named2() : this(method());", // error, not a static method |
| 1510 " C.named3() : this(new A().method());", // ok | 1522 " C.named3() : this(new A().method());", // ok |
| 1511 " method() {}", | 1523 " method() {}", |
| 1512 "}"), | 1524 "}"), |
| 1513 errEx(ResolverErrorCode.INSTANCE_METHOD_FROM_REDIRECT, 10, 21, 8)); | 1525 errEx(ResolverErrorCode.INSTANCE_METHOD_FROM_REDIRECT, 10, 21, 8)); |
| 1514 } | 1526 } |
| 1515 } | 1527 } |
| OLD | NEW |