b03d472e4c
Closes #38541 Change-Id: I078800cc98b5444c2c7f6f87b2d89bcf764bfc23 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/118582 Commit-Queue: Johnni Winther <johnniwinther@google.com> Reviewed-by: Jens Johansen <jensj@google.com>
57 lines
1.1 KiB
Dart
57 lines
1.1 KiB
Dart
// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
|
|
// for details. All rights reserved. Use of this source code is governed by a
|
|
// BSD-style license that can be found in the LICENSE file.
|
|
|
|
class Class {
|
|
int field;
|
|
|
|
Class(this.field);
|
|
}
|
|
|
|
extension Extension on Class {
|
|
int method() => this.field;
|
|
|
|
int methodWithOptionals([int a = 42]) => a;
|
|
|
|
int get property => this.field;
|
|
|
|
void set property(int value) {
|
|
this.field = value;
|
|
}
|
|
|
|
int _privateMethod() => this.field;
|
|
|
|
static int staticField = 87;
|
|
|
|
static int staticMethod() => staticField;
|
|
|
|
static int get staticProperty => staticField;
|
|
|
|
static void set staticProperty(int value) {
|
|
staticField = value;
|
|
}
|
|
}
|
|
|
|
extension /*UnnamedExtension*/ on Class {
|
|
int method() => this.field + 1;
|
|
}
|
|
|
|
extension _PrivateExtension on Class {
|
|
int method() => this.field + 2;
|
|
}
|
|
|
|
class GenericClass<T> {
|
|
T field;
|
|
|
|
GenericClass(this.field);
|
|
}
|
|
|
|
extension GenericExtension<T> on GenericClass<T> {
|
|
T method() => this.field;
|
|
|
|
T get property => this.field;
|
|
|
|
void set property(T value) {
|
|
this.field = value;
|
|
}
|
|
} |