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

Side by Side Diff: pkg/analyzer/test/generated/resolver_test.dart

Issue 1472183002: add a failing test case to demonstrate a substitution issue (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 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
« no previous file with comments | « no previous file | no next file » | 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) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, 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 library engine.resolver_test; 5 library engine.resolver_test;
6 6
7 import 'dart:collection'; 7 import 'dart:collection';
8 8
9 import 'package:analyzer/src/context/context.dart' as newContext; 9 import 'package:analyzer/src/context/context.dart' as newContext;
10 import 'package:analyzer/src/generated/ast.dart'; 10 import 'package:analyzer/src/generated/ast.dart';
(...skipping 12201 matching lines...) Expand 10 before | Expand all | Expand 10 after
12212 expect(e.type.toString(), '(E) → List<T>'); 12212 expect(e.type.toString(), '(E) → List<T>');
12213 12213
12214 SimpleIdentifier c = _findIdentifier('cOfString'); 12214 SimpleIdentifier c = _findIdentifier('cOfString');
12215 FunctionType ft = (c.staticType as InterfaceType).getMethod('f').type; 12215 FunctionType ft = (c.staticType as InterfaceType).getMethod('f').type;
12216 expect(ft.toString(), '(String) → List<T>'); 12216 expect(ft.toString(), '(String) → List<T>');
12217 DartType t = e.typeParameters[0].type; 12217 DartType t = e.typeParameters[0].type;
12218 ft = ft.substitute2([typeProvider.intType], [t]); 12218 ft = ft.substitute2([typeProvider.intType], [t]);
12219 expect(ft.toString(), '(String) → List<int>'); 12219 expect(ft.toString(), '(String) → List<int>');
12220 } 12220 }
12221 12221
12222 void fail_genericMethod_nested() {
12223 // TODO(jmesserly): this test currently fails because we incorrectly capture
12224 // S in FunctionTypeImpl.substitute. We should probably rename free
12225 // variables during substitution to avoid it.
12226 _resolveTestUnit(r'''
12227 class C<T> {
12228 /*=T*/ f/*<S>*/(/*=S*/ x) {
12229 new C<S>().f/*<int>*/(3);
12230 return null;
12231 }
12232 }
12233 ''');
12234 SimpleIdentifier f = _findIdentifier('f/*<int>*/(3);');
12235 expect(f.staticType.toString(), '(int) → S');
12236 }
12237
12222 void test_genericMethod_functionTypedParameter() { 12238 void test_genericMethod_functionTypedParameter() {
12223 if (!AnalysisEngine.instance.useTaskModel) { 12239 if (!AnalysisEngine.instance.useTaskModel) {
12224 return; 12240 return;
12225 } 12241 }
12226 _resolveTestUnit(r''' 12242 _resolveTestUnit(r'''
12227 class C<E> { 12243 class C<E> {
12228 List/*<T>*/ f/*<T>*/(/*=T*/ f(E e)) => null; 12244 List/*<T>*/ f/*<T>*/(/*=T*/ f(E e)) => null;
12229 } 12245 }
12230 main() { 12246 main() {
12231 C<String> cOfString; 12247 C<String> cOfString;
(...skipping 2976 matching lines...) Expand 10 before | Expand all | Expand 10 after
15208 15224
15209 void _resolveTestUnit(String code) { 15225 void _resolveTestUnit(String code) {
15210 testCode = code; 15226 testCode = code;
15211 testSource = addSource(testCode); 15227 testSource = addSource(testCode);
15212 LibraryElement library = resolve2(testSource); 15228 LibraryElement library = resolve2(testSource);
15213 assertNoErrors(testSource); 15229 assertNoErrors(testSource);
15214 verify([testSource]); 15230 verify([testSource]);
15215 testUnit = resolveCompilationUnit(testSource, library); 15231 testUnit = resolveCompilationUnit(testSource, library);
15216 } 15232 }
15217 } 15233 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698