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

Side by Side Diff: pkg/front_end/lib/src/fasta/kernel/kernel_shadow_ast.dart

Issue 2954133002: Resolve type parameter bounds when looking up interface members. (Closed)
Patch Set: Created 3 years, 5 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
« no previous file with comments | « no previous file | pkg/front_end/lib/src/fasta/type_inference/type_inferrer.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2017, 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 /// This file declares a "shadow hierarchy" of concrete classes which extend 5 /// This file declares a "shadow hierarchy" of concrete classes which extend
6 /// the kernel class hierarchy, adding methods and fields needed by the 6 /// the kernel class hierarchy, adding methods and fields needed by the
7 /// BodyBuilder. 7 /// BodyBuilder.
8 /// 8 ///
9 /// Instances of these classes may be created using the factory methods in 9 /// Instances of these classes may be created using the factory methods in
10 /// `ast_factory.dart`. 10 /// `ast_factory.dart`.
(...skipping 1934 matching lines...) Expand 10 before | Expand all | Expand 10 after
1945 // so that the type hierarchy will be simpler (which may speed up "is" 1945 // so that the type hierarchy will be simpler (which may speed up "is"
1946 // checks). 1946 // checks).
1947 return statement._inferStatement(this); 1947 return statement._inferStatement(this);
1948 } else { 1948 } else {
1949 // Encountered a statement type for which type inference is not yet 1949 // Encountered a statement type for which type inference is not yet
1950 // implemented, so just skip it for now. 1950 // implemented, so just skip it for now.
1951 // TODO(paulberry): once the BodyBuilder uses shadow classes for 1951 // TODO(paulberry): once the BodyBuilder uses shadow classes for
1952 // everything, this case should no longer be needed. 1952 // everything, this case should no longer be needed.
1953 } 1953 }
1954 } 1954 }
1955
1956 /// If the given [type] is a [TypeParameterType], resolve it to its bound.
1957 DartType resolveTypeParameter(DartType type) {
1958 DartType resolveOneStep(DartType type) {
1959 if (type is TypeParameterType) {
1960 return type.bound;
1961 } else {
1962 return null;
1963 }
1964 }
1965
1966 var resolved = resolveOneStep(type);
1967 if (resolved == null) return type;
1968
1969 // Detect circularities using the tortoise-and-hare algorithm.
1970 type = resolved;
1971 DartType hare = resolveOneStep(type);
1972 if (hare == null) return type;
1973 while (true) {
1974 if (identical(type, hare)) {
1975 // We found a circularity. Give up and return `dynamic`.
1976 return const DynamicType();
1977 }
1978
1979 // Hare takes two steps
1980 var step1 = resolveOneStep(hare);
1981 if (step1 == null) return hare;
1982 var step2 = resolveOneStep(step1);
1983 if (step2 == null) return hare;
1984 hare = step2;
1985
1986 // Tortoise takes one step
1987 type = resolveOneStep(type);
1988 }
1989 }
1990 } 1955 }
1991 1956
1992 /// Shadow object for [TypeLiteral]. 1957 /// Shadow object for [TypeLiteral].
1993 class KernelTypeLiteral extends TypeLiteral implements KernelExpression { 1958 class KernelTypeLiteral extends TypeLiteral implements KernelExpression {
1994 KernelTypeLiteral(DartType type) : super(type); 1959 KernelTypeLiteral(DartType type) : super(type);
1995 1960
1996 @override 1961 @override
1997 void _collectDependencies(KernelDependencyCollector collector) { 1962 void _collectDependencies(KernelDependencyCollector collector) {
1998 // No inference dependencies. 1963 // No inference dependencies.
1999 } 1964 }
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
2236 } 2201 }
2237 2202
2238 transformChildren(v) { 2203 transformChildren(v) {
2239 return internalError("Internal error: Unsupported operation."); 2204 return internalError("Internal error: Unsupported operation.");
2240 } 2205 }
2241 2206
2242 visitChildren(v) { 2207 visitChildren(v) {
2243 return internalError("Internal error: Unsupported operation."); 2208 return internalError("Internal error: Unsupported operation.");
2244 } 2209 }
2245 } 2210 }
OLDNEW
« no previous file with comments | « no previous file | pkg/front_end/lib/src/fasta/type_inference/type_inferrer.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698