Initializers prohibited on val-properties with no backing field
This commit is contained in:
@@ -392,6 +392,10 @@ public class TopDownAnalyzer {
|
||||
if (setter != null && setterDescriptor != null) {
|
||||
resolveFunctionBody(fieldAccessTrackingTrace, setter, setterDescriptor, accessorScope);
|
||||
}
|
||||
|
||||
if (!declaration.isVar() && initializer != null && !trace.hasBackingField(propertyDescriptor)) {
|
||||
semanticServices.getErrorHandler().genericError(initializer.getNode(), "Initializer is not allowed here because this property has no setter and no backing field either");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -5,10 +5,13 @@
|
||||
$x = <error>1.lng</error>
|
||||
}
|
||||
|
||||
val xx : Int = 1 + x
|
||||
val xx : Int = <error>1 + x</error>
|
||||
get() : Int = 1
|
||||
<error>set(ref value : Long) {$x = value}</error>
|
||||
|
||||
val p : Int = <error>1</error>
|
||||
get() = 1
|
||||
|
||||
class Test {
|
||||
var a : Int
|
||||
var b : Int get() = <error>$a</error>; set(x) {a = x; <error>$a</error> = x}
|
||||
|
||||
Reference in New Issue
Block a user