Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(300)

Side by Side Diff: compiler/javatests/com/google/dart/compiler/resolver/ResolverTest.java

Issue 10544040: Issue 3309. Report only single error when attempt to use function in place of type (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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;
(...skipping 694 matching lines...) Expand 10 before | Expand all | Expand 10 after
705 } 705 }
706 706
707 public void testNewExpression3() { 707 public void testNewExpression3() {
708 // Trying new on a variable name shouldn't work. 708 // Trying new on a variable name shouldn't work.
709 resolveAndTest(Joiner.on("\n").join( 709 resolveAndTest(Joiner.on("\n").join(
710 "class Object {}", 710 "class Object {}",
711 "class Foo {", 711 "class Foo {",
712 " var Bar;", 712 " var Bar;",
713 " create() { return new Bar();}", 713 " create() { return new Bar();}",
714 "}"), 714 "}"),
715 ResolverErrorCode.NOT_A_TYPE, 715 ResolverErrorCode.NOT_A_TYPE);
716 ResolverErrorCode.NEW_EXPRESSION_NOT_CONSTRUCTOR);
717 } 716 }
718 717
719 public void testNewExpression4() { 718 public void testNewExpression4() {
720 // New expression tied to an unbound type variable is not allowed. 719 // New expression tied to an unbound type variable is not allowed.
721 resolveAndTest(Joiner.on("\n").join( 720 resolveAndTest(Joiner.on("\n").join(
722 "class Object {}", 721 "class Object {}",
723 "class Foo<T> {", 722 "class Foo<T> {",
724 " T create() {", 723 " T create() {",
725 " return new T();", 724 " return new T();",
726 " }", 725 " }",
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
920 } 919 }
921 920
922 public void test_new_noSuchType() throws Exception { 921 public void test_new_noSuchType() throws Exception {
923 resolveAndTest(Joiner.on("\n").join( 922 resolveAndTest(Joiner.on("\n").join(
924 "class Object {}", 923 "class Object {}",
925 "class MyClass {", 924 "class MyClass {",
926 " foo() {", 925 " foo() {",
927 " new Unknown();", 926 " new Unknown();",
928 " }", 927 " }",
929 "}"), 928 "}"),
930 ResolverErrorCode.NO_SUCH_TYPE, 929 ResolverErrorCode.NO_SUCH_TYPE);
931 ResolverErrorCode.NEW_EXPRESSION_NOT_CONSTRUCTOR);
932 } 930 }
933 931
934 public void test_new_noSuchType_typeArgument() throws Exception { 932 public void test_new_noSuchType_typeArgument() throws Exception {
935 resolveAndTest(Joiner.on("\n").join( 933 resolveAndTest(Joiner.on("\n").join(
936 "class Object {}", 934 "class Object {}",
937 "class Foo<T> {}", 935 "class Foo<T> {}",
938 "class MyClass {", 936 "class MyClass {",
939 " foo() {", 937 " foo() {",
940 " new Foo<T>();", 938 " new Foo<T>();",
941 " }", 939 " }",
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
1056 } 1054 }
1057 1055
1058 public void testTypeVariableInStatic() { 1056 public void testTypeVariableInStatic() {
1059 resolveAndTest(Joiner.on("\n").join( 1057 resolveAndTest(Joiner.on("\n").join(
1060 "class Object {}", 1058 "class Object {}",
1061 "class A<T> {", 1059 "class A<T> {",
1062 " static foo() { new T(); }", // can't ref type variable in method 1060 " static foo() { new T(); }", // can't ref type variable in method
1063 " static bar() { T variable = 1; }", 1061 " static bar() { T variable = 1; }",
1064 "}"), 1062 "}"),
1065 ResolverErrorCode.TYPE_VARIABLE_IN_STATIC_CONTEXT, 1063 ResolverErrorCode.TYPE_VARIABLE_IN_STATIC_CONTEXT,
1066 ResolverErrorCode.NEW_EXPRESSION_NOT_CONSTRUCTOR,
1067 TypeErrorCode.TYPE_VARIABLE_IN_STATIC_CONTEXT); 1064 TypeErrorCode.TYPE_VARIABLE_IN_STATIC_CONTEXT);
1068 } 1065 }
1069 1066
1070 public void testTypeVariableShadowsClass() { 1067 public void testTypeVariableShadowsClass() {
1071 resolveAndTest(Joiner.on("\n").join( 1068 resolveAndTest(Joiner.on("\n").join(
1072 "class Object {}", 1069 "class Object {}",
1073 "class T {}", 1070 "class T {}",
1074 "class A<T> {", // type var T shadows class T 1071 "class A<T> {", // type var T shadows class T
1075 " static foo() { new T(); }", // should resolve to class T 1072 " static foo() { new T(); }", // should resolve to class T
1076 "}"), 1073 "}"),
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
1220 "class Object {}", 1217 "class Object {}",
1221 "interface int {}", 1218 "interface int {}",
1222 "method() {", 1219 "method() {",
1223 " outer: for(int i = 0; i < 1; i++) {", 1220 " outer: for(int i = 0; i < 1; i++) {",
1224 " outer();", 1221 " outer();",
1225 " }", 1222 " }",
1226 "}"), 1223 "}"),
1227 errEx(ResolverErrorCode.CANNOT_RESOLVE_METHOD, 5, 5, 7)); 1224 errEx(ResolverErrorCode.CANNOT_RESOLVE_METHOD, 5, 5, 7));
1228 } 1225 }
1229 } 1226 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698