Index: pkg/analyzer/test/generated/type_system_test.dart |
diff --git a/pkg/analyzer/test/generated/type_system_test.dart b/pkg/analyzer/test/generated/type_system_test.dart |
index d7d72f87fe05264b02d0510950c1a1729b6bb0d6..2b3248de880652a391a6fba9dce16c12b0daedf1 100644 |
--- a/pkg/analyzer/test/generated/type_system_test.dart |
+++ b/pkg/analyzer/test/generated/type_system_test.dart |
@@ -881,6 +881,80 @@ class StrongGenericFunctionInferenceTest { |
]); |
} |
+ void test_boundedByOuterClass() { |
+ // Regression test for https://github.com/dart-lang/sdk/issues/25740. |
+ |
+ // class A {} |
+ var a = ElementFactory.classElement('A', objectType); |
+ |
+ // class B extends A {} |
+ var b = ElementFactory.classElement('B', a.type); |
+ |
+ // class C<T extends A> { |
+ var c = ElementFactory.classElement('C', objectType, ['T']); |
+ (c.typeParameters[0] as TypeParameterElementImpl).bound = a.type; |
+ // S m<S extends T>(S); |
+ var s = TypeBuilder.variable('S'); |
+ (s.element as TypeParameterElementImpl).bound = c.typeParameters[0].type; |
+ var m = ElementFactory.methodElement('m', s, [s]); |
+ m.typeParameters = [s.element]; |
+ c.methods = [m]; |
+ // } |
+ |
+ // C<Object> cOfObject; |
+ var cOfObject = c.type.instantiate([objectType]); |
+ // C<A> cOfA; |
+ var cOfA = c.type.instantiate([a.type]); |
+ // C<B> cOfB; |
+ var cOfB = c.type.instantiate([b.type]); |
+ // B b; |
+ // cOfB.m(b); // infer <B> |
+ expect(_inferCall(cOfB.getMethod('m').type, [b.type]), [b.type, b.type]); |
+ // cOfA.m(b); // infer <B> |
+ expect(_inferCall(cOfA.getMethod('m').type, [b.type]), [a.type, b.type]); |
+ // cOfObject.m(b); // infer <B> |
+ expect(_inferCall(cOfObject.getMethod('m').type, [b.type]), |
+ [objectType, b.type]); |
+ } |
+ |
+ void test_boundedByOuterClassSubstituted() { |
+ // Regression test for https://github.com/dart-lang/sdk/issues/25740. |
+ |
+ // class A {} |
+ var a = ElementFactory.classElement('A', objectType); |
+ |
+ // class B extends A {} |
+ var b = ElementFactory.classElement('B', a.type); |
+ |
+ // class C<T extends A> { |
+ var c = ElementFactory.classElement('C', objectType, ['T']); |
+ (c.typeParameters[0] as TypeParameterElementImpl).bound = a.type; |
+ // S m<S extends Iterable<T>>(S); |
+ var s = TypeBuilder.variable('S'); |
+ var iterableOfT = iterableType.instantiate([c.typeParameters[0].type]); |
+ (s.element as TypeParameterElementImpl).bound = iterableOfT; |
+ var m = ElementFactory.methodElement('m', s, [s]); |
+ m.typeParameters = [s.element]; |
+ c.methods = [m]; |
+ // } |
+ |
+ // C<Object> cOfObject; |
+ var cOfObject = c.type.instantiate([objectType]); |
+ // C<A> cOfA; |
+ var cOfA = c.type.instantiate([a.type]); |
+ // C<B> cOfB; |
+ var cOfB = c.type.instantiate([b.type]); |
+ // List<B> b; |
+ var listOfB = listType.instantiate([b.type]); |
+ // cOfB.m(b); // infer <B> |
+ expect(_inferCall(cOfB.getMethod('m').type, [listOfB]), [b.type, listOfB]); |
+ // cOfA.m(b); // infer <B> |
+ expect(_inferCall(cOfA.getMethod('m').type, [listOfB]), [a.type, listOfB]); |
+ // cOfObject.m(b); // infer <B> |
+ expect(_inferCall(cOfObject.getMethod('m').type, [listOfB]), |
+ [objectType, listOfB]); |
+ } |
+ |
void test_boundedRecursively() { |
// class Clonable<T extends Clonable<T>> |
ClassElementImpl clonable = |