Skip to content
This repository was archived by the owner on Apr 14, 2022. It is now read-only.

Added an option to propagate parameter types to base methods #283

Conversation

lostmsu
Copy link
Contributor

@lostmsu lostmsu commented Oct 18, 2018

It is similar #194, in that the same types parameter types might be OK for base methods. It could happen when we just don't have any examples in the current code, that would give that kind of information to analyzer.

By default set to false to keep conservative behavior.

class Base:
  def foo(x):
    ...

class Derived(Base):
  def foo(x):
    ...

Derived().foo(42)

# Base().foo(42) is actually also called, but not in this project

/// <c>True</c> to propagate parameter types to base methods.
/// Parameter types always propagate to derived methods.
/// </summary>
public bool PropagateParameterTypeToBaseMethods { get; set; }

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there case when we don't want this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In A: B, B: C case, when we see b:B = ..., b.foo(SomeType()), b can be either of A and B. So, assuming substitution principle, B.foo should propagate to A.foo. However, there's no principle, that would tell, that C.foo should also take an instance of SomeType. At best, its an lucky guess.

So I think its good to have an option.

Now for my purposes, I need it true. But you guys can decide for the default value.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean, it is not something that user sets so it it typically set by the application one way or another. #261 may be related.

@MikhailArkhipov MikhailArkhipov merged commit 198e8dd into microsoft:master Oct 25, 2018
jakebailey pushed a commit to jakebailey/python-language-server that referenced this pull request Nov 1, 2019
…eterTypePropagationToBase

Added an option to propagate parameter types to base methods
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants