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

Side by Side Diff: sdk/lib/_internal/compiler/implementation/resolution/members.dart

Issue 11418113: Substitution added to DartType (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Updated cf. comments Created 8 years 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 part of resolution; 5 part of resolution;
6 6
7 abstract class TreeElements { 7 abstract class TreeElements {
8 Element operator[](Node node); 8 Element operator[](Node node);
9 Selector getSelector(Send send); 9 Selector getSelector(Send send);
10 DartType getType(Node node); 10 DartType getType(Node node);
(...skipping 1912 matching lines...) Expand 10 before | Expand all | Expand 10 after
1923 if (node.isRedirectingFactoryBody) { 1923 if (node.isRedirectingFactoryBody) {
1924 handleRedirectingFactoryBody(node); 1924 handleRedirectingFactoryBody(node);
1925 } else { 1925 } else {
1926 visit(node.expression); 1926 visit(node.expression);
1927 } 1927 }
1928 } 1928 }
1929 1929
1930 void handleRedirectingFactoryBody(Return node) { 1930 void handleRedirectingFactoryBody(Return node) {
1931 Element redirectionTarget = resolveRedirectingFactory(node); 1931 Element redirectionTarget = resolveRedirectingFactory(node);
1932 var type = mapping.getType(node.expression); 1932 var type = mapping.getType(node.expression);
1933 if (type is InterfaceType && !type.arguments.isEmpty) { 1933 if (type is InterfaceType && !type.typeArguments.isEmpty) {
1934 unimplemented(node.expression, 'type arguments on redirecting factory'); 1934 unimplemented(node.expression, 'type arguments on redirecting factory');
1935 } 1935 }
1936 useElement(node.expression, redirectionTarget); 1936 useElement(node.expression, redirectionTarget);
1937 assert(invariant(node, enclosingElement.isFactoryConstructor())); 1937 assert(invariant(node, enclosingElement.isFactoryConstructor()));
1938 FunctionElement constructor = enclosingElement; 1938 FunctionElement constructor = enclosingElement;
1939 if (constructor.modifiers.isConst() && 1939 if (constructor.modifiers.isConst() &&
1940 !redirectionTarget.modifiers.isConst()) { 1940 !redirectionTarget.modifiers.isConst()) {
1941 error(node, MessageKind.CONSTRUCTOR_IS_NOT_CONST); 1941 error(node, MessageKind.CONSTRUCTOR_IS_NOT_CONST);
1942 } 1942 }
1943 // TODO(ahe): Check that this doesn't lead to a cycle. For now, 1943 // TODO(ahe): Check that this doesn't lead to a cycle. For now,
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
2043 if (argument.element.isTypeVariable()) { 2043 if (argument.element.isTypeVariable()) {
2044 // Register a dependency between the class where the type 2044 // Register a dependency between the class where the type
2045 // variable is, and the annotation. If the annotation requires 2045 // variable is, and the annotation. If the annotation requires
2046 // runtime type information, then the class of the type variable 2046 // runtime type information, then the class of the type variable
2047 // does too. 2047 // does too.
2048 compiler.world.registerRtiDependency( 2048 compiler.world.registerRtiDependency(
2049 annotation.element, 2049 annotation.element,
2050 argument.element.enclosingElement); 2050 argument.element.enclosingElement);
2051 } else if (argument is InterfaceType) { 2051 } else if (argument is InterfaceType) {
2052 InterfaceType type = argument; 2052 InterfaceType type = argument;
2053 type.arguments.forEach((DartType argument) { 2053 type.typeArguments.forEach((DartType argument) {
2054 analyzeTypeArgument(type, argument); 2054 analyzeTypeArgument(type, argument);
2055 }); 2055 });
2056 } 2056 }
2057 } 2057 }
2058 2058
2059 DartType resolveTypeAnnotation(TypeAnnotation node) { 2059 DartType resolveTypeAnnotation(TypeAnnotation node) {
2060 // TODO(johnniwinther): Remove this together with the named arguments 2060 // TODO(johnniwinther): Remove this together with the named arguments
2061 // on [TypeResolver.resolveTypeAnnotation]. 2061 // on [TypeResolver.resolveTypeAnnotation].
2062 void checkAndUseType(TypeAnnotation annotation, DartType type) { 2062 void checkAndUseType(TypeAnnotation annotation, DartType type) {
2063 useType(annotation, type); 2063 useType(annotation, type);
2064 if (type != null && 2064 if (type != null &&
2065 identical(type.kind, TypeKind.TYPE_VARIABLE) && 2065 identical(type.kind, TypeKind.TYPE_VARIABLE) &&
2066 enclosingElement.isInStaticMember()) { 2066 enclosingElement.isInStaticMember()) {
2067 warning(annotation, MessageKind.TYPE_VARIABLE_WITHIN_STATIC_MEMBER, 2067 warning(annotation, MessageKind.TYPE_VARIABLE_WITHIN_STATIC_MEMBER,
2068 [type]); 2068 [type]);
2069 } 2069 }
2070 } 2070 }
2071 2071
2072 Function report = typeRequired ? error : warning; 2072 Function report = typeRequired ? error : warning;
2073 DartType type = typeResolver.resolveTypeAnnotation( 2073 DartType type = typeResolver.resolveTypeAnnotation(
2074 node, scope, onFailure: report, whenResolved: checkAndUseType); 2074 node, scope, onFailure: report, whenResolved: checkAndUseType);
2075 if (type == null) return null; 2075 if (type == null) return null;
2076 if (inCheckContext) { 2076 if (inCheckContext) {
2077 compiler.enqueuer.resolution.registerIsCheck(type); 2077 compiler.enqueuer.resolution.registerIsCheck(type);
2078 } 2078 }
2079 if (typeRequired || inCheckContext) { 2079 if (typeRequired || inCheckContext) {
2080 if (type is InterfaceType) { 2080 if (type is InterfaceType) {
2081 InterfaceType itf = type; 2081 InterfaceType itf = type;
2082 itf.arguments.forEach((DartType argument) { 2082 itf.typeArguments.forEach((DartType argument) {
2083 analyzeTypeArgument(type, argument); 2083 analyzeTypeArgument(type, argument);
2084 }); 2084 });
2085 } 2085 }
2086 // TODO(ngeoffray): Also handle cases like: 2086 // TODO(ngeoffray): Also handle cases like:
2087 // 1) a is T 2087 // 1) a is T
2088 // 2) T a (in checked mode). 2088 // 2) T a (in checked mode).
2089 } 2089 }
2090 return type; 2090 return type;
2091 } 2091 }
2092 2092
(...skipping 1026 matching lines...) Expand 10 before | Expand all | Expand 10 after
3119 return e; 3119 return e;
3120 } 3120 }
3121 3121
3122 /// Assumed to be called by [resolveRedirectingFactory]. 3122 /// Assumed to be called by [resolveRedirectingFactory].
3123 Element visitReturn(Return node) { 3123 Element visitReturn(Return node) {
3124 Node expression = node.expression; 3124 Node expression = node.expression;
3125 return finishConstructorReference(visit(expression), 3125 return finishConstructorReference(visit(expression),
3126 expression, expression); 3126 expression, expression);
3127 } 3127 }
3128 } 3128 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698