4e8a4a3b44
Change-Id: I059d96ef2db91ea43cc1a6d2fffd0d6e7718659b Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/426288 Reviewed-by: Lasse Nielsen <lrn@google.com> Commit-Queue: Lasse Nielsen <lrn@google.com> Auto-Submit: Bob Nystrom <rnystrom@google.com>
58 lines
1.1 KiB
Dart
58 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;
|
|
}
|
|
}
|