A test to ensure @abc.abstractproperty return value is analyzed correctly#131
Conversation
fixed namespace in InheritanceTests
|
Speaking of the later: what is the reasoning behind module's members being analyzed before overall module is? I'd expect |
| <PropertyGroup> | ||
| <TargetFramework>netcoreapp2.1</TargetFramework> | ||
| <RootNamespace>Microsoft.PythonTools.Analysis</RootNamespace> | ||
| <RootNamespace>AnalysisTests</RootNamespace> |
There was a problem hiding this comment.
Let's not change namespaces for now.
There was a problem hiding this comment.
This only affects what namespace VS uses when you create a new file. It was set to AnalysisTests in PTVS but, I guess, was overlooked when porting, which in turn accidentally caused my new file InheritanceTests to get wrong namespace.
There was a problem hiding this comment.
Basically, I think this change should be kept until you guys decide to straighten this up.
| } | ||
|
|
||
| public override string Name { | ||
| get { |
There was a problem hiding this comment.
This can be written with expression:
public override string Name => _original != null ? _original.Name : base.Name;There was a problem hiding this comment.
Probable even
public override string Name => _original?.Name ?? base.Name;There was a problem hiding this comment.
No, that's a bit different semantics. In original code, if _original != null and _original.Name == null, it will return null. In case of _original?.Name ?? base.Name, it will return base.Name. Can't say what is the right behavior though.
There was a problem hiding this comment.
Wasn't sure if the project wants to maintain compatibility with older C# versions, so just followed the patterns around (you never know what reviewers would prefer). Will change to C# 7.
A test to ensure @abc.abstractproperty return value is analyzed correctly
This adds a test for the analysis of return values of abstract properties (properties, marked with
@abc.abstractproperty).This also adds a partial fix for it not being analyzed properly. (related to #115)
Unfortunately, due to some regression (?) between PTVS/master and python-language-server/master, this does not seem to be enough: test variable
banalysis results in two possible return values,int(correct) andA.virt(which is incorrect, and eventually resolves to beUnknown). The later seems to be happening because on the first passddg._eval.Evaluate(@abc.abstractproperty)results in empty set.