Chromium Code Reviews| Index: compiler/javatests/com/google/dart/compiler/resolver/ResolverTest.java |
| diff --git a/compiler/javatests/com/google/dart/compiler/resolver/ResolverTest.java b/compiler/javatests/com/google/dart/compiler/resolver/ResolverTest.java |
| index 5ce4d3691657b0bc64b0cee307bb1852e9d23007..8d90941ea6e5e9cabbd91520a30ab4990e876af9 100644 |
| --- a/compiler/javatests/com/google/dart/compiler/resolver/ResolverTest.java |
| +++ b/compiler/javatests/com/google/dart/compiler/resolver/ResolverTest.java |
| @@ -117,7 +117,7 @@ public class ResolverTest extends ResolverTestCase { |
| * class B {} |
| */ |
| public void testGetSubtypesWithInterfaceCycles() { |
| - DartClass ia = makeInterface("IA", makeTypes("ID"), makeType("B")); |
| + DartClass ia = makeInterface("IA", makeTypes("ID"), null); |
|
ahe
2011/12/15 09:02:13
I don't understand why you made this change.
zundel
2011/12/16 21:36:29
I added it back and made it actually test somethin
|
| DartClass ib = makeInterface("IB", makeTypes("IA"), null); |
| DartClass ic = makeInterface("IC", makeTypes("IA", "IB"), null); |
| DartClass id = makeInterface("ID", makeTypes("IB"), null); |
| @@ -309,116 +309,126 @@ public class ResolverTest extends ResolverTestCase { |
| ResolverErrorCode.NO_SUCH_TYPE_CONSTRUCTOR); |
| } |
| - public void testFactoryTypeArgs1() { |
| + |
| + public void testDefaultTypeArgs1() { |
| // Type arguments match |
| resolveAndTest(Joiner.on("\n").join( |
| "class Object {}", |
| "interface int {}", |
| - "interface A<T> factory B {", |
| + "interface A<T> default B<T> {", |
| " A();", |
| "}", |
| - "class B implements A {", |
| - " A<T>() {}", |
| + "class B<T> implements A<T> {", |
| + " B() {}", |
| "}")); |
| } |
| - public void testFactoryTypeArgs2() { |
| + public void testDefaultTypeArgs2() { |
| // Type arguments match |
| resolveAndTest(Joiner.on("\n").join( |
| "class Object {}", |
| - "interface A<T> factory B {", |
| + "interface A<T> default B<T> {", |
| "}", |
| - "class B {", |
| - " factory A<T>.construct () {}", |
| + "class B<T> {", |
| + " factory A.construct () {}", |
| "}")); |
| } |
| - public void testFactoryTypeArgs3() { |
| + public void testDefaultTypeArgs3() { |
| // Type arguments match |
| resolveAndTest(Joiner.on("\n").join( |
| "class Object {}", |
| - "interface A<T> factory B {", |
| + "interface A<T> default B<T> {", |
| "}", |
| - "class B {", |
| - " B<T>() {}", |
| + "class B<T> {", |
| + " B() {}", |
| "}")); |
| } |
| - public void testFactoryTypeArgsNew() { |
| + public void testDefaultTypeArgs4() { |
| + // Type arguments match |
| + resolveAndTest(Joiner.on("\n").join( |
| + "class Object {}", |
| + "interface A<T> default B<T> {", |
| + "}", |
| + "class B<T> implements A<T> {", |
| + " B() {}", |
| + "}")); |
| + } |
| + |
| + public void testDefaultTypeArgsNew() { |
| // Invoke constructor in factory method with type args |
| resolveAndTest(Joiner.on("\n").join( |
| "class Object {}", |
| "interface int {}", |
| - "interface A<T> factory B {", |
| - " A<T>();", |
| + "interface A<T> default B<T> {", |
| + " B();", |
| "}", |
| "class C<T> implements A<T> {}", |
| - "class B {", |
| - " factory A<T>() { return new C<T>();}", |
| + "class B<T> {", |
| + " factory B() { return new C<T>();}", |
| "}")); |
| } |
| - public void testFactoryBadTypeArgsNew() { |
| + public void testFactoryBadTypeArgsNew1() { |
| // Invoke constructor in factory method with (wrong) type args |
| resolveAndTest(Joiner.on("\n").join( |
| "class Object {}", |
| "interface int {}", |
| - "interface A<T> factory B {", |
| - " A<T>();", |
| + "interface A<T> default B<T> {", |
| + " A();", |
| "}", |
| "class C<T> implements A<T> {}", |
| - "class B {", |
| - " factory A<T>() { return new C<K>();}", |
| + "class B<T> {", |
| + " factory A() { return new C<K>();}", |
| "}"), |
| ResolverErrorCode.NO_SUCH_TYPE); |
| } |
| - public void disabledBadFactoryTypeArgs1() { |
| - // Type arguments don't match |
| + public void testFactoryBadTypeArgsNew2() { |
| + // Invoke constructor in factory method with (wrong) type args |
| resolveAndTest(Joiner.on("\n").join( |
| "class Object {}", |
| - "interface A<T> factory B {", |
| - " A<T>();", |
| + "interface int {}", |
| + "interface A<T> default B {", |
| + " A();", |
| "}", |
| + "class C<T> implements A<T> {}", |
| "class B {", |
| - " A<T>() {}", |
| + " factory A() { return new C<int>();}", |
| "}"), |
| - ResolverErrorCode.FACTORY_CONSTRUCTOR_TYPE_ARGS_DO_NOT_MATCH); |
| + ResolverErrorCode.DEFAULT_CLASS_MUST_HAVE_SAME_TYPE_PARAMS); |
|
ahe
2011/12/15 09:02:13
This test seems good, but you may also want to tes
zundel
2011/12/15 14:12:50
The spec is not very clear on when you need to spe
ahe
2011/12/15 14:20:53
You'd specify them for the interface "Map<K,V>" be
zundel
2011/12/16 21:36:29
Added those two (as cases that should pass w/o err
zundel
2011/12/16 21:36:29
Sure, but if you left them out, nothing would go w
|
| } |
| - public void disabledBadFactoryTypeArgs2() { |
| - // Type arguments match |
| + public void testFactoryBadTypeArgsNew3() { |
| + // Invoke constructor in factory method with (wrong) type args |
|
ahe
2011/12/15 09:02:13
This test has multiple problems. I'm not sure what
|
| resolveAndTest(Joiner.on("\n").join( |
| "class Object {}", |
| - "interface A<T> factory B {", |
| + "interface int {}", |
| + "interface A<T> default B<K> {", |
| + " A();", |
| "}", |
| - "class B {", |
| - " factory A<T>.construct () {}", |
| + "class C<T> implements A<T> {}", |
| + "class B<K> {", |
|
ahe
2011/12/15 09:02:13
This is an error because:
"If I has n type parame
zundel
2011/12/16 21:36:29
I split this up into a couple of tests.
|
| + " factory A() { return new C<int>();}", |
|
ahe
2011/12/15 09:02:13
This is a warning because C<int> is not assignable
zundel
2011/12/16 21:36:29
Done.
|
| "}"), |
| - ResolverErrorCode.FACTORY_CONSTRUCTOR_TYPE_ARGS_DO_NOT_MATCH); |
| + ResolverErrorCode.TYPE_PARAMETER_DOES_NOT_MATCH); |
| } |
| - public void disabledBadFactoryTypeArgs3() { |
| - // Type arguments match |
| + public void testFactoryBadTypeArgsNew4() { |
|
ahe
2011/12/15 09:02:13
Same problems as the above test.
|
| + // Invoke constructor in factory method with (wrong) type args |
| resolveAndTest(Joiner.on("\n").join( |
| "class Object {}", |
| - "interface A<T> factory B {", |
| - " A<T>();", |
| + "interface int {}", |
| + "interface A<T,K> default B<K,T> {", |
| + " A();", |
| "}", |
| - "class B implements A {", |
| - " B() {}", |
| + "class C<T,K> implements A<T,K> {}", |
| + "class B<K,T> {", |
| + " factory A() { return new C<int, Object>();}", |
| "}"), |
| - ResolverErrorCode.FACTORY_CONSTRUCTOR_TYPE_ARGS_DO_NOT_MATCH); |
| - } |
| - |
| - public void disabledNonConstructorMethodTypeArgs() { |
| - // Type arguments match |
| - resolveAndTest(Joiner.on("\n").join( |
| - "class Object {}", |
| - "class A {", |
| - " foo<T>() {}", |
| - "}"), |
| - ResolverErrorCode.TYPE_ARGS_ONLY_ON_CONSTRUCTORS); |
| + ResolverErrorCode.TYPE_PARAMETER_DOES_NOT_MATCH, |
| + ResolverErrorCode.TYPE_PARAMETER_DOES_NOT_MATCH); |
| } |
| public void testBadGenerativeConstructor1() { |
| @@ -550,12 +560,25 @@ public class ResolverTest extends ResolverTestCase { |
| public void testNewExpression5() { |
| // More cowbell. (Foo<T> isn't a type yet) |
| resolveAndTest(Joiner.on("\n").join( |
| - "class Object {}", |
| - "class Foo<T> { }", |
| - "class B {", |
| - " foo() { return new Foo<T>(); }", |
| - "}"), |
| - ResolverErrorCode.NO_SUCH_TYPE); |
| + "class Object {}", |
| + "class Foo<T> { }", |
| + "class B {", |
| + " foo() { return new Foo<T>(); }", |
|
ahe
2011/12/15 09:02:13
I agree this is an error because T is not in scope
|
| + "}"), |
| + ResolverErrorCode.NO_SUCH_TYPE); |
| + } |
| + |
| + public void testNewExpression6() { |
| + resolveAndTest(Joiner.on("\n").join( |
| + "class Object {}", |
| + "interface int {}", |
| + "interface A<T> default B<T> {", |
| + " A.construct(); ", |
| + "}", |
| + "class B<T> implements A<T> {", |
| + " B() { }", |
| + " factory B.construct() { return new B<T>(); }", |
| + "}")); |
| } |
| public void test_noSuchType_field() throws Exception { |