@@ -161,8 +161,11 @@ class InterfaceResolverTest {
161
161
isAbstract: isAbstract);
162
162
}
163
163
164
- Field makeField ({String name: 'foo' , DartType type: const DynamicType ()}) {
165
- return new Field (new Name (name), type: type);
164
+ Field makeField (
165
+ {String name: 'foo' ,
166
+ DartType type: const DynamicType (),
167
+ bool isFinal: false }) {
168
+ return new Field (new Name (name), type: type, isFinal: isFinal);
166
169
}
167
170
168
171
Procedure makeForwardingStub (Procedure method, bool setter,
@@ -718,6 +721,7 @@ class InterfaceResolverTest {
718
721
expect (y.isGenericCovariantImpl, isFalse);
719
722
expect (y.isGenericCovariantInterface, isFalse);
720
723
expect (y.isCovariant, isTrue);
724
+ expect (ForwardingStub .getInterfaceTarget (stub), same (methodA));
721
725
expect (getStubTarget (stub), same (methodA));
722
726
}
723
727
@@ -765,9 +769,68 @@ class InterfaceResolverTest {
765
769
expect (y.isGenericCovariantImpl, isTrue);
766
770
expect (y.isGenericCovariantInterface, isFalse);
767
771
expect (y.isCovariant, isFalse);
772
+ expect (ForwardingStub .getInterfaceTarget (stub), same (methodA));
768
773
expect (getStubTarget (stub), same (methodA));
769
774
}
770
775
776
+ void test_interfaceTarget_cascaded () {
777
+ var methodC = makeEmptyMethod (positionalParameters: [
778
+ new VariableDeclaration ('x' , type: intType),
779
+ new VariableDeclaration ('y' , type: intType)
780
+ ]);
781
+ var c = makeClass (name: 'C' , procedures: [methodC]);
782
+ var t = new TypeParameter ('T' , objectType);
783
+ var methodI1 = makeEmptyMethod (positionalParameters: [
784
+ new VariableDeclaration ('x' , type: new TypeParameterType (t))
785
+ ..isGenericCovariantImpl = true ,
786
+ new VariableDeclaration ('y' , type: intType)
787
+ ]);
788
+ var i1 = makeClass (name: 'I1' , typeParameters: [t], procedures: [methodI1]);
789
+ // Let's say D was previously compiled, so it already has a forwarding stub
790
+ var methodD = new ForwardingStub (
791
+ methodC,
792
+ methodC.name,
793
+ methodC.kind,
794
+ new FunctionNode (null , positionalParameters: [
795
+ new VariableDeclaration ('x' , type: intType),
796
+ new VariableDeclaration ('y' , type: intType)
797
+ ]));
798
+ var d =
799
+ makeClass (name: 'D' , supertype: c.asThisSupertype, implementedTypes: [
800
+ new Supertype (i1, [intType])
801
+ ], procedures: [
802
+ methodD
803
+ ]);
804
+ var u = new TypeParameter ('U' , objectType);
805
+ var methodI2 = makeEmptyMethod (positionalParameters: [
806
+ new VariableDeclaration ('x' , type: intType),
807
+ new VariableDeclaration ('y' , type: new TypeParameterType (u))
808
+ ..isGenericCovariantImpl = true
809
+ ]);
810
+ var i2 = makeClass (name: 'I2' , typeParameters: [u], procedures: [methodI2]);
811
+ var e =
812
+ makeClass (name: 'E' , supertype: d.asThisSupertype, implementedTypes: [
813
+ new Supertype (i2, [intType])
814
+ ]);
815
+ var node = getForwardingNode (e, false );
816
+ var stub = node.finalize ();
817
+ expect (ForwardingStub .getInterfaceTarget (stub), same (methodC));
818
+ }
819
+
820
+ void test_interfaceTarget_field () {
821
+ var fieldA = makeField (type: numType, isFinal: true );
822
+ var fieldB = makeField (type: intType, isFinal: true );
823
+ var a = makeClass (name: 'A' , fields: [fieldA]);
824
+ var b = makeClass (name: 'B' , fields: [fieldB]);
825
+ var c = makeClass (
826
+ name: 'C' ,
827
+ supertype: a.asThisSupertype,
828
+ implementedTypes: [b.asThisSupertype]);
829
+ var node = getForwardingNode (c, false );
830
+ var stub = node.finalize ();
831
+ expect (ForwardingStub .getInterfaceTarget (stub), same (fieldB));
832
+ }
833
+
771
834
void test_merge_candidates_including_mixin () {
772
835
var methodA = makeEmptyMethod ();
773
836
var methodB = makeEmptyMethod ();
@@ -860,6 +923,7 @@ class InterfaceResolverTest {
860
923
name: 'C' , implementedTypes: [a.asThisSupertype, b.asThisSupertype]);
861
924
var node = getForwardingNode (c, false );
862
925
var stub = node.finalize ();
926
+ expect (ForwardingStub .getInterfaceTarget (stub), same (methodB));
863
927
expect (getStubTarget (stub), isNull);
864
928
expect (stub.function.returnType, intType);
865
929
}
@@ -878,6 +942,7 @@ class InterfaceResolverTest {
878
942
]);
879
943
var node = getForwardingNode (d, true );
880
944
var stub = node.finalize ();
945
+ expect (ForwardingStub .getInterfaceTarget (stub), same (setterB));
881
946
expect (getStubTarget (stub), isNull);
882
947
expect (stub.function.positionalParameters[0 ].type, objectType);
883
948
}
@@ -910,6 +975,7 @@ class InterfaceResolverTest {
910
975
var resolvedMethod = node.finalize ();
911
976
expect (resolvedMethod, same (methodC));
912
977
expect (methodC.function.body, isNotNull);
978
+ expect (methodC, isNot (new isInstanceOf <ForwardingStub >()));
913
979
expect (getStubTarget (methodC), same (methodA));
914
980
}
915
981
@@ -938,6 +1004,7 @@ class InterfaceResolverTest {
938
1004
]);
939
1005
var node = getForwardingNode (d, false );
940
1006
var stub = node.finalize ();
1007
+ expect (ForwardingStub .getInterfaceTarget (stub), same (methodB));
941
1008
expect (getStubTarget (stub), isNull);
942
1009
expect (stub.function.returnType, intType);
943
1010
}
0 commit comments