| // Copyright (c) 2026, the Dart project authors. Please see the AUTHORS file |
| // for details. All rights reserved. Use of this source code is governed by a |
| // BSD-style license that can be found in the LICENSE file. |
| |
| /// @assertion Note that override inference does not provide other properties of |
| /// a parameter than the type. E.g., it does not make a parameter `required` |
| /// based on overridden declarations. This property must then be specified |
| /// explicitly if needed. |
| /// |
| /// @description Check that missing components of a method signature are |
| /// inferred as a combined member signature from a direct superinterface. |
| /// @author sgrekhov22@gmail.com |
| |
| import '../../Utils/static_type_helper.dart'; |
| |
| mixin class A { |
| void m2(num v) {} |
| void m3([num v = 0]) {} |
| void m4({num v = 0}) {} |
| void m5({required num v}) {} |
| } |
| |
| mixin class B { |
| void m2(covariant int v) {} |
| void m3([covariant int v = 0]) {} |
| void m4({covariant int v = 0}) {} |
| void m5({required covariant int v}) {} |
| } |
| |
| |
| class C1 extends A implements B { |
| void m2(covariant v) {} |
| void m3([covariant v = 1]) {} |
| void m4({covariant v = 1}) {} |
| void m5({required covariant v}) {} |
| } |
| |
| class C2 implements A, B { |
| void m2(covariant v) {} |
| void m3([covariant v = 1]) {} |
| void m4({covariant v = 1}) {} |
| void m5({required covariant v}) {} |
| } |
| |
| class C3 with A implements B { |
| void m2(covariant v) {} |
| void m3([covariant v = 1]) {} |
| void m4({covariant v = 1}) {} |
| void m5({required covariant v}) {} |
| } |
| |
| class C4 with B implements A { |
| void m2(covariant v) {} |
| void m3([covariant v = 1]) {} |
| void m4({covariant v = 1}) {} |
| void m5({required covariant v}) {} |
| } |
| |
| mixin M implements A, B { |
| void m2(covariant v) {} |
| void m3([covariant v = 1]) {} |
| void m4({covariant v = 1}) {} |
| void m5({required covariant v}) {} |
| } |
| |
| mixin class MC implements A, B { |
| void m2(covariant v) {} |
| void m3([covariant v = 1]) {} |
| void m4({covariant v = 1}) {} |
| void m5({required covariant v}) {} |
| } |
| |
| enum E1 implements A, B { |
| e0; |
| |
| void m2(covariant v) {} |
| void m3([covariant v = 1]) {} |
| void m4({covariant v = 1}) {} |
| void m5({required covariant v}) {} |
| } |
| |
| class MA = Object with M; |
| |
| main() { |
| C1().m2.expectStaticType<Exactly<void Function(num)>>(); |
| C1().m3.expectStaticType<Exactly<void Function([num])>>(); |
| C1().m4.expectStaticType<Exactly<void Function({num v})>>(); |
| C1().m5.expectStaticType<Exactly<void Function({required num v})>>(); |
| |
| C2().m2.expectStaticType<Exactly<void Function(num)>>(); |
| C2().m3.expectStaticType<Exactly<void Function([num])>>(); |
| C2().m4.expectStaticType<Exactly<void Function({num v})>>(); |
| C2().m5.expectStaticType<Exactly<void Function({required num v})>>(); |
| |
| C3().m2.expectStaticType<Exactly<void Function(num)>>(); |
| C3().m3.expectStaticType<Exactly<void Function([num])>>(); |
| C3().m4.expectStaticType<Exactly<void Function({num v})>>(); |
| C3().m5.expectStaticType<Exactly<void Function({required num v})>>(); |
| |
| C4().m2.expectStaticType<Exactly<void Function(num)>>(); |
| C4().m3.expectStaticType<Exactly<void Function([num])>>(); |
| C4().m4.expectStaticType<Exactly<void Function({num v})>>(); |
| C4().m5.expectStaticType<Exactly<void Function({required num v})>>(); |
| |
| MA().m2.expectStaticType<Exactly<void Function(num)>>(); |
| MA().m3.expectStaticType<Exactly<void Function([num])>>(); |
| MA().m4.expectStaticType<Exactly<void Function({num v})>>(); |
| MA().m5.expectStaticType<Exactly<void Function({required num v})>>(); |
| |
| MC().m2.expectStaticType<Exactly<void Function(num)>>(); |
| MC().m3.expectStaticType<Exactly<void Function([num])>>(); |
| MC().m4.expectStaticType<Exactly<void Function({num v})>>(); |
| MC().m5.expectStaticType<Exactly<void Function({required num v})>>(); |
| |
| E1.e0.m2.expectStaticType<Exactly<void Function(num)>>(); |
| E1.e0.m3.expectStaticType<Exactly<void Function([num])>>(); |
| E1.e0.m4.expectStaticType<Exactly<void Function({num v})>>(); |
| E1.e0.m5.expectStaticType<Exactly<void Function({required num v})>>(); |
| } |