Skip to content

Commit

Permalink
Issue 34896. Verify the superconstraint signature invoked by a mixin,…
Browse files Browse the repository at this point in the history
… not the mixin's one.

R=brianwilkerson@google.com, paulberry@google.com

Fixes: dart-lang/sdk#34896
Change-Id: I778d572e2e2d0affb15c28d7bf2c1fbb58a8cd8a
Reviewed-on: https://dart-review.googlesource.com/c/81204
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Paul Berry <paulberry@google.com>
  • Loading branch information
scheglov authored and commit-bot@chromium.org committed Oct 23, 2018
1 parent b82c1f9 commit 2f90f8d
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 1 deletion.
2 changes: 1 addition & 1 deletion pkg/analyzer/lib/src/generated/error_verifier.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4166,7 +4166,7 @@ class ErrorVerifier extends RecursiveAstVisitor<Object> {
}

FunctionType mixinMemberType =
_inheritanceManager.getMember(mixinType, nameObject);
_inheritanceManager.getMember(mixinType, nameObject, forSuper: true);

if (mixinMemberType != null &&
!_typeSystem.isOverrideSubtypeOf(superMemberType, mixinMemberType)) {
Expand Down
18 changes: 18 additions & 0 deletions pkg/analyzer/test/src/dart/resolution/mixin_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -902,6 +902,24 @@ abstract class X extends B with M {}
]);
}

test_error_mixinApplicationConcreteSuperInvokedMemberType_OK_method_overriddenInMixin() async {
addTestFile(r'''
class A<T> {
void remove(T x) {}
}
mixin M<U> on A<U> {
void remove(Object x) {
super.remove(x as U);
}
}
class X<T> = A<T> with M<T>;
''');
await resolveTestFile();
assertNoTestErrors();
}

test_error_mixinApplicationNoConcreteSuperInvokedMember_getter() async {
addTestFile(r'''
abstract class A {
Expand Down
20 changes: 20 additions & 0 deletions tests/language_2/issue34896_test.dart
Original file line number Diff line number Diff line change
@@ -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<T> {
void remove(T x) {}
}

mixin M<U> on A<U> {
void remove(Object x) {
super.remove(x as U);
}
}

class X<T> = A<T> with M<T>;

main() {}

0 comments on commit 2f90f8d

Please sign in to comment.