From 2f90f8d0ef3b9a7ca8692f0ca3514940750d6e40 Mon Sep 17 00:00:00 2001 From: Konstantin Shcheglov Date: Tue, 23 Oct 2018 06:20:59 +0000 Subject: [PATCH] Issue 34896. Verify the superconstraint signature invoked by a mixin, not the mixin's one. R=brianwilkerson@google.com, paulberry@google.com Fixes: https://github.com/dart-lang/sdk/issues/34896 Change-Id: I778d572e2e2d0affb15c28d7bf2c1fbb58a8cd8a Reviewed-on: https://dart-review.googlesource.com/c/81204 Commit-Queue: Konstantin Shcheglov Reviewed-by: Paul Berry --- .../lib/src/generated/error_verifier.dart | 2 +- .../test/src/dart/resolution/mixin_test.dart | 18 +++++++++++++++++ tests/language_2/issue34896_test.dart | 20 +++++++++++++++++++ 3 files changed, 39 insertions(+), 1 deletion(-) create mode 100644 tests/language_2/issue34896_test.dart diff --git a/pkg/analyzer/lib/src/generated/error_verifier.dart b/pkg/analyzer/lib/src/generated/error_verifier.dart index ed7fe2bc9fd25..9f5eef91e6c08 100644 --- a/pkg/analyzer/lib/src/generated/error_verifier.dart +++ b/pkg/analyzer/lib/src/generated/error_verifier.dart @@ -4166,7 +4166,7 @@ class ErrorVerifier extends RecursiveAstVisitor { } FunctionType mixinMemberType = - _inheritanceManager.getMember(mixinType, nameObject); + _inheritanceManager.getMember(mixinType, nameObject, forSuper: true); if (mixinMemberType != null && !_typeSystem.isOverrideSubtypeOf(superMemberType, mixinMemberType)) { diff --git a/pkg/analyzer/test/src/dart/resolution/mixin_test.dart b/pkg/analyzer/test/src/dart/resolution/mixin_test.dart index df7494a476bb6..ca8630a8f66cb 100644 --- a/pkg/analyzer/test/src/dart/resolution/mixin_test.dart +++ b/pkg/analyzer/test/src/dart/resolution/mixin_test.dart @@ -902,6 +902,24 @@ abstract class X extends B with M {} ]); } + test_error_mixinApplicationConcreteSuperInvokedMemberType_OK_method_overriddenInMixin() async { + addTestFile(r''' +class A { + void remove(T x) {} +} + +mixin M on A { + void remove(Object x) { + super.remove(x as U); + } +} + +class X = A with M; +'''); + await resolveTestFile(); + assertNoTestErrors(); + } + test_error_mixinApplicationNoConcreteSuperInvokedMember_getter() async { addTestFile(r''' abstract class A { diff --git a/tests/language_2/issue34896_test.dart b/tests/language_2/issue34896_test.dart new file mode 100644 index 0000000000000..d7a0ea3f18b7e --- /dev/null +++ b/tests/language_2/issue34896_test.dart @@ -0,0 +1,20 @@ +// Copyright (c) 2018, 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. + +// Regression test: verify super-signatures of super-invoked methods of a +// mixin against the superclass, not signatures in the mixin. + +class A { + void remove(T x) {} +} + +mixin M on A { + void remove(Object x) { + super.remove(x as U); + } +} + +class X = A with M; + +main() {}