Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Analyzer thinks that private methods from other library is overridable #25538

Closed
alexander-doroshko opened this issue Jan 20, 2016 · 6 comments
Closed
Assignees
Labels
area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. P2 A bug or feature request we're likely to work on type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)

Comments

@alexander-doroshko
Copy link

Analyzer thinks that private methods from other library is overridable, but according to the spec they are not.
See section 10.9.1 Inheritance and Overriding in the Dart Language spec:
C inherits all accessible instance members of A that have not been overridden by a declaration in C.

"accessible" is defined in section 6.2 Privacy:
A declaration m is accessible to library L if m is declared in L or if m is public.

Now consider this code:
file1.dart

library someLib;

import 'file2.dart';

main() {
  var b = new B();
  var c = new C();

  b.publicMethod();
  b._privateMethod();

  c.publicMethod();
  c._privateMethod();
}

class A {
  publicMethod() {print('A.publicMethod');}
  _privateMethod() {print('A._privateMethod');}
}

class B extends A {
  publicMethod() {print('B.publicMethod');}
  _privateMethod() {print('B._privateMethod');}
}

file2.dart

library otherLib;

import 'file1.dart';

class C extends A {
  publicMethod() {print('C.publicMethod');}
  _privateMethod() {print('C._privateMethod');}
}

Output is:

B.publicMethod
B._privateMethod
C.publicMethod
A._privateMethod

Output shows that B._privateMethod() overrides A._privateMethod - DAS thinks the same, so far so good.
But also output shows that C._privateMethod() doesn't override A._privateMethod. But all DAS methods that deal with hierarchy say that it does. I mean:

  • AnalysisServer.search_getTypeHierarchy()
  • AnalysisServerListener.computedOverrides() notification
  • AnalysisServerListener.computedImplemented() notification

May be some other DAS methods use incorrect assumption as well, not sure.

@alexander-doroshko alexander-doroshko added Type-Defect area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. labels Jan 20, 2016
@scheglov
Copy link
Contributor

CL for analysis.override https://codereview.chromium.org/1610773003

scheglov added a commit that referenced this issue Jan 21, 2016
@scheglov
Copy link
Contributor

CL for analysis.implemented https://codereview.chromium.org/1615023002

scheglov added a commit that referenced this issue Jan 21, 2016
@scheglov
Copy link
Contributor

CL for type hierarchy https://codereview.chromium.org/1615093002

scheglov added a commit that referenced this issue Jan 21, 2016
@scheglov
Copy link
Contributor

Fixed.

@kevmoo kevmoo added P2 A bug or feature request we're likely to work on type-bug Incorrect behavior (everything from a crash to more subtle misbehavior) and removed Priority-Medium labels Mar 1, 2016
@miyoyo
Copy link

miyoyo commented Dec 6, 2018

It seems that this bug has resurfaced

method _callPerformLayout is shown, while working in a file inheriting from it's package

import 'package:flutter/material.dart';

class _PercentText extends MultiChildLayoutDelegate {

  performLa

  @override
  bool shouldRelayout(MultiChildLayoutDelegate oldDelegate) => false;
}
[√] Flutter (Channel stable, v1.0.0, on Microsoft Windows [Version 10.0.17134.407], locale en-BE)
    • Flutter version 1.0.0 at C:\tools\flutter
    • Framework revision 5391447fae (7 days ago), 2018-11-29 19:41:26 -0800
    • Engine revision 7375a0f414
    • Dart version 2.1.0 (build 2.1.0-dev.9.4 f9ebf21297)

@scheglov
Copy link
Contributor

scheglov commented Dec 6, 2018

https://dart-review.googlesource.com/c/sdk/+/86480

dart-bot pushed a commit that referenced this issue Dec 6, 2018
R=brianwilkerson@google.com

Bug: #25538
Change-Id: I61904881c602f373df839bc546b1e65665997bb9
Reviewed-on: https://dart-review.googlesource.com/c/86480
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-analyzer Use area-analyzer for Dart analyzer issues, including the analysis server and code completion. P2 A bug or feature request we're likely to work on type-bug Incorrect behavior (everything from a crash to more subtle misbehavior)
Projects
None yet
Development

No branches or pull requests

5 participants