Files
sdk/tests/lib/mirrors/generic_class_declaration_test.dart
T
Regis Crelier 1f55b7ca10 Reland "[VM/runtime] Refactor the representation of type parameters in the VM."
This is a reland of 8a21ab195a

Original change's description:
> [VM/runtime] Refactor the representation of type parameters in the VM.
>
> This introduces a new VM internal class 'TypeParameters' representing the declaration of a list of type parameters, either in a class or function.
> The reference to (or use of) a type parameter is still represented by the existing 'TypeParameter' class.
>
> Fixes https://github.com/dart-lang/sdk/issues/43901
> Fixes https://github.com/dart-lang/sdk/issues/45763
>
> TEST=existing ones and a regression test
>
> Change-Id: I1fde808bf753cc1cb829f2c4383c1836651cee80
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/189942
> Commit-Queue: Régis Crelier <regis@google.com>
> Reviewed-by: Alexander Markov <alexmarkov@google.com>

This fixes https://github.com/dart-lang/sdk/issues/45911

TEST=existing ones and a regression test

Change-Id: I709d38b1df3d73fe3c9796d5aca3cbbdcf77fd38
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/198380
Commit-Queue: Régis Crelier <regis@google.com>
Reviewed-by: Alexander Markov <alexmarkov@google.com>
2021-05-05 23:43:14 +00:00

85 lines
2.6 KiB
Dart

// Copyright (c) 2013, 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.
import 'dart:mirrors';
import 'package:expect/expect.dart';
import 'stringify.dart';
class A<T> {
var instanceVariable;
get instanceGetter => null;
set instanceSetter(x) => x;
instanceMethod() => null;
var _instanceVariable;
get _instanceGetter => null;
set _instanceSetter(x) => x;
_instanceMethod() => null;
static var staticVariable;
static get staticGetter => null;
static set staticSetter(x) => x;
static staticMethod() => null;
static var _staticVariable;
static get _staticGetter => null;
static set _staticSetter(x) => x;
static _staticMethod() => null;
}
main() {
ClassMirror cm = reflect(new A<String>()).type;
Expect.setEquals([
'Variable(s(_instanceVariable) in s(A), private)',
'Variable(s(_staticVariable) in s(A), private, static)',
'Variable(s(instanceVariable) in s(A))',
'Variable(s(staticVariable) in s(A), static)'
], cm.declarations.values.where((dm) => dm is VariableMirror).map(stringify),
'variables');
Expect.setEquals(
[
'Method(s(_instanceGetter) in s(A), private, getter)',
'Method(s(_staticGetter) in s(A), private, static, getter)',
'Method(s(instanceGetter) in s(A), getter)',
'Method(s(staticGetter) in s(A), static, getter)'
],
cm.declarations.values
.where((dm) => dm is MethodMirror && dm.isGetter)
.map(stringify),
'getters');
Expect.setEquals(
[
'Method(s(_instanceSetter=) in s(A), private, setter)',
'Method(s(_staticSetter=) in s(A), private, static, setter)',
'Method(s(instanceSetter=) in s(A), setter)',
'Method(s(staticSetter=) in s(A), static, setter)'
],
cm.declarations.values
.where((dm) => dm is MethodMirror && dm.isSetter)
.map(stringify),
'setters');
Expect.setEquals(
[
'Method(s(_instanceMethod) in s(A), private)',
'Method(s(_staticMethod) in s(A), private, static)',
'Method(s(instanceMethod) in s(A))',
'Method(s(staticMethod) in s(A), static)'
],
cm.declarations.values
.where((dm) => dm is MethodMirror && dm.isRegularMethod)
.map(stringify),
'methods');
Expect.setEquals(
['Method(s(A) in s(A), constructor)'],
cm.declarations.values
.where((dm) => dm is MethodMirror && dm.isConstructor)
.map(stringify),
'constructors');
}