Mismatched type arguments result in an error not a type warning.

BUG=
TEST=

Review URL: http://codereview.chromium.org//8392047

git-svn-id: https://dart.googlecode.com/svn/branches/bleeding_edge/dart@821 260f80e4-7a28-3924-810f-c04153c831b5
This commit is contained in:
mmendez@google.com 2011-10-27 13:33:45 +00:00
parent d864b5e1f6
commit 959e3573d7
7 changed files with 53 additions and 14 deletions

View file

@ -200,7 +200,7 @@ public class ResolutionContext implements ResolutionErrorListener {
typeArguments[i] = typeProvider.getDynamicType();
}
if (typeArgumentNodes != null && typeArgumentNodes.size() > 0) {
typeError(node, DartCompilerErrorCode.WRONG_NUMBER_OF_TYPE_ARGUMENTS, element.getType());
resolutionError(node, DartCompilerErrorCode.WRONG_NUMBER_OF_TYPE_ARGUMENTS, element.getType());
}
int index = 0;
if (typeArgumentNodes != null) {

View file

@ -0,0 +1,9 @@
// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
class A {
main() {
List<int, int> ints = [1];
}
}

View file

@ -0,0 +1,9 @@
// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
class A {
main() {
Map<String, int, int> map = {'foo':1};
}
}

View file

@ -53,6 +53,14 @@ public class NegativeResolverTest extends CompilerTestCase {
checkNumErrors("Initializer6NegativeTest.dart", 1);
}
public void testArrayLiteralNegativeTest() {
checkNumErrors("ArrayLiteralNegativeTest.dart", 1);
}
public void testMapLiteralNegativeTest() {
checkNumErrors("MapLiteralNegativeTest.dart", 1);
}
public void testCall1() {
checkNumErrors("StaticInstanceCallNegativeTest.dart", 1);
}
@ -169,6 +177,10 @@ public class NegativeResolverTest extends CompilerTestCase {
checkNumErrors("ConstRedirectedConstructorNegativeTest.dart", 1);
}
public void testRawTypesNegativeTest() {
checkNumErrors("RawTypesNegativeTest.dart", 4);
}
private TestCompilerContext getContext() {
return new TestCompilerContext() {
@Override

View file

@ -0,0 +1,22 @@
// Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
interface Super<T> {}
interface Sub<S> extends Super<S> factory SubImplementation<S> {
Sub();
}
class SubImplementation<U> implements Sub<U> {
SubImplementation() {}
}
class A {
main() {
Sub<A, A> s = new Sub();
Sub<A, A> s2 = new Sub<A>();
Sub<A, A> s3;
A<A> s4;
}
}

View file

@ -177,14 +177,6 @@ public class TypeAnalyzerTest extends TypeTestCase {
analyze("{ var s = new Sub<String>(); }");
analyze("{ Sub s = new Sub<String>(); }");
analyze("{ Sub<String> s = new Sub<String>(); }");
// FYI, this is detected in the resolver, not TypeAnalyzer
analyzeFail("{ Sub<String, String> s = new Sub(); }",
DartCompilerErrorCode.WRONG_NUMBER_OF_TYPE_ARGUMENTS);
analyzeFail("{ Sub<String, String> s = new Sub<String>(); }",
DartCompilerErrorCode.WRONG_NUMBER_OF_TYPE_ARGUMENTS);
analyzeFail("{ Sub<String, String> s; }", DartCompilerErrorCode.WRONG_NUMBER_OF_TYPE_ARGUMENTS);
analyzeFail("{ String<String> s; }", DartCompilerErrorCode.WRONG_NUMBER_OF_TYPE_ARGUMENTS);
}
public void testMethodInvocations() {
@ -850,8 +842,6 @@ public class TypeAnalyzerTest extends TypeTestCase {
DartCompilerErrorCode.TYPE_NOT_ASSIGNMENT_COMPATIBLE);
analyzeFail("{ int i; var x = const {'key': i = 0.42}; }",
DartCompilerErrorCode.TYPE_NOT_ASSIGNMENT_COMPATIBLE);
analyzeFail("Map<String, int, int> map = {'foo':1};",
DartCompilerErrorCode.WRONG_NUMBER_OF_TYPE_ARGUMENTS);
analyzeFail("{var x = const <num, num>{}; }",
DartCompilerErrorCode.TYPE_NOT_ASSIGNMENT_COMPATIBLE);
}
@ -1234,8 +1224,6 @@ public class TypeAnalyzerTest extends TypeTestCase {
analyze("List<int> ints = ['x'];");
analyzeFail("List<int> ints = <String>['x'];",
DartCompilerErrorCode.TYPE_NOT_ASSIGNMENT_COMPATIBLE);
analyzeFail("List<int, int> ints = [1];",
DartCompilerErrorCode.WRONG_NUMBER_OF_TYPE_ARGUMENTS);
}
public void testInitializedLocals() {

View file

@ -106,7 +106,6 @@ ConstObjectsAreImmutableTest: Fail # Bug 5202940
SuperNegativeTest: Fail # Now that super calls are automatically injected this test doesn't make sense
NullToStringTest: Fail # Bug 5421978
FunctionTypeAliasTest: Crash # Bug 4519208.
WrongNumberTypeArgumentsNegativeTest: Fail # Bug 235.
# Other bugs (or unimplemented features) in dartc.
SuperOperatorTest: Fail # Bug 4995463.