This repository was archived by the owner on Apr 14, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +25
-1
lines changed Expand file tree Collapse file tree 3 files changed +25
-1
lines changed Original file line number Diff line number Diff line change @@ -150,6 +150,12 @@ private PythonFunctionOverload GetOverloadFromStub(FunctionDefinition node) {
150
150
}
151
151
152
152
private bool TryAddProperty ( FunctionDefinition node , IPythonType declaringType ) {
153
+ // We can't add a property to an unknown type. Fallback to a regular function for now.
154
+ // TOOD: Decouple declaring types from the property.
155
+ if ( declaringType . IsUnknown ( ) ) {
156
+ return false ;
157
+ }
158
+
153
159
var dec = node . Decorators ? . Decorators ;
154
160
var decorators = dec != null ? dec . ExcludeDefault ( ) . ToArray ( ) : Array . Empty < Expression > ( ) ;
155
161
Original file line number Diff line number Diff line change @@ -143,7 +143,9 @@ private void ProcessDecorators(FunctionDefinition fd) {
143
143
break ;
144
144
case @"property" :
145
145
case @"abstractproperty" :
146
- Debug . Assert ( false , "Found property attribute while processing function. Properties should be handled in the respective class." ) ;
146
+ // Ignore property decorators if the declaring type is unknown.
147
+ // TODO: Restore this to a hard failure once property can handle not having a declaring type.
148
+ Debug . Assert ( DeclaringType . IsUnknown ( ) , "Found property attribute while processing function. Properties should be handled in the respective class." ) ;
147
149
break ;
148
150
}
149
151
}
Original file line number Diff line number Diff line change @@ -634,5 +634,21 @@ def __init__(self):
634
634
// Test run time: typically ~ 20 sec.
635
635
sw . ElapsedMilliseconds . Should ( ) . BeLessThan ( 60000 ) ;
636
636
}
637
+
638
+ [ TestMethod , Priority ( 0 ) ]
639
+ public async Task NestedProperty ( ) {
640
+ const string code = @"
641
+ class x(object):
642
+ def func(self):
643
+ @property
644
+ def foo(*args, **kwargs):
645
+ pass
646
+ return 42
647
+
648
+ a = x().func()
649
+ " ;
650
+ var analysis = await GetAnalysisAsync ( code ) ;
651
+ analysis . Should ( ) . HaveVariable ( "a" ) . OfType ( BuiltinTypeId . Int ) ;
652
+ }
637
653
}
638
654
}
You can’t perform that action at this time.
0 commit comments