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

Side by Side Diff: pkg/analyzer/test/src/summary/linker_test.dart

Issue 1956473004: Fix ast-based serialization of out-of-scope type parameters. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Remove temporary debugging code. Created 4 years, 7 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
OLDNEW
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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 import 'package:analyzer/dart/element/type.dart'; 5 import 'package:analyzer/dart/element/type.dart';
6 import 'package:analyzer/src/summary/format.dart'; 6 import 'package:analyzer/src/summary/format.dart';
7 import 'package:analyzer/src/summary/link.dart'; 7 import 'package:analyzer/src/summary/link.dart';
8 import 'package:unittest/unittest.dart'; 8 import 'package:unittest/unittest.dart';
9 9
10 import '../../reflective_tests.dart'; 10 import '../../reflective_tests.dart';
(...skipping 579 matching lines...) Expand 10 before | Expand all | Expand 10 after
590 expect(f.typeParameterContext, same(f)); 590 expect(f.typeParameterContext, same(f));
591 ParameterElementForLink g = f.parameters[0]; 591 ParameterElementForLink g = f.parameters[0];
592 FunctionType gType = g.type; 592 FunctionType gType = g.type;
593 FunctionElementForLink_FunctionTypedParam gTypeElement = gType.element; 593 FunctionElementForLink_FunctionTypedParam gTypeElement = gType.element;
594 expect(gTypeElement.typeParameterContext, same(f)); 594 expect(gTypeElement.typeParameterContext, same(f));
595 ParameterElementForLink h = gTypeElement.parameters[0]; 595 ParameterElementForLink h = gTypeElement.parameters[0];
596 FunctionType hType = h.type; 596 FunctionType hType = h.type;
597 FunctionElementForLink_FunctionTypedParam hTypeElement = hType.element; 597 FunctionElementForLink_FunctionTypedParam hTypeElement = hType.element;
598 expect(hTypeElement.typeParameterContext, same(f)); 598 expect(hTypeElement.typeParameterContext, same(f));
599 } 599 }
600
601 void test_typeParameter_isTypeParameterInScope_direct() {
602 createLinker('class C<T, U> {}');
603 ClassElementForLink_Class c = testLibrary.getContainedName('C');
604 TypeParameterElementForLink t = c.typeParameters[0];
605 TypeParameterElementForLink u = c.typeParameters[1];
606 expect(c.isTypeParameterInScope(t), true);
607 expect(c.isTypeParameterInScope(u), true);
608 }
609
610 void test_typeParameter_isTypeParameterInScope_indirect() {
611 createLinker('class C<T, U> { f<V, W>() {} }');
612 ClassElementForLink_Class c = testLibrary.getContainedName('C');
613 MethodElementForLink f = c.methods[0];
614 TypeParameterElementForLink t = c.typeParameters[0];
615 TypeParameterElementForLink u = c.typeParameters[1];
616 expect(f.isTypeParameterInScope(t), true);
617 expect(f.isTypeParameterInScope(u), true);
618 }
619
620 void test_typeParameter_isTypeParameterInScope_reversed() {
621 createLinker('class C<T, U> { f<V, W>() {} }');
622 ClassElementForLink_Class c = testLibrary.getContainedName('C');
623 MethodElementForLink f = c.methods[0];
624 TypeParameterElementForLink v = f.typeParameters[0];
625 TypeParameterElementForLink w = f.typeParameters[1];
626 expect(c.isTypeParameterInScope(v), false);
627 expect(c.isTypeParameterInScope(w), false);
628 }
629
630 void test_typeParameter_isTypeParameterInScope_unrelated() {
631 createLinker('class C<T, U> {} class D<V, W> {}');
632 ClassElementForLink_Class c = testLibrary.getContainedName('C');
633 ClassElementForLink_Class d = testLibrary.getContainedName('D');
634 TypeParameterElementForLink t = c.typeParameters[0];
635 TypeParameterElementForLink u = c.typeParameters[1];
636 TypeParameterElementForLink v = d.typeParameters[0];
637 TypeParameterElementForLink w = d.typeParameters[1];
638 expect(c.isTypeParameterInScope(v), false);
639 expect(c.isTypeParameterInScope(w), false);
640 expect(d.isTypeParameterInScope(t), false);
641 expect(d.isTypeParameterInScope(u), false);
642 }
600 } 643 }
OLDNEW
« no previous file with comments | « pkg/analyzer/lib/src/summary/link.dart ('k') | pkg/analyzer/test/src/summary/summary_common.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698