mirror of
https://github.com/dart-lang/sdk
synced 2024-09-16 00:19:48 +00:00
[cfe] Add synthesized this to view instance methods
+ generate getters. Change-Id: Id873e8e6c3f8d64a845b211f18616d807302f180 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/273180 Reviewed-by: Jens Johansen <jensj@google.com> Commit-Queue: Johnni Winther <johnniwinther@google.com>
This commit is contained in:
parent
55b4542dab
commit
05c0f5ca9a
|
@ -1947,8 +1947,10 @@ class OutlineBuilder extends StackListenerImpl {
|
|||
bool isStatic = (modifiers & staticMask) != 0;
|
||||
if (constructorName == null &&
|
||||
!isStatic &&
|
||||
libraryBuilder.currentTypeParameterScopeBuilder.kind ==
|
||||
TypeParameterScopeKind.extensionDeclaration) {
|
||||
(libraryBuilder.currentTypeParameterScopeBuilder.kind ==
|
||||
TypeParameterScopeKind.extensionDeclaration ||
|
||||
libraryBuilder.currentTypeParameterScopeBuilder.kind ==
|
||||
TypeParameterScopeKind.viewDeclaration)) {
|
||||
TypeParameterScopeBuilder extension =
|
||||
libraryBuilder.currentTypeParameterScopeBuilder;
|
||||
Map<TypeVariableBuilder, TypeBuilder>? substitution;
|
||||
|
@ -1975,7 +1977,27 @@ class OutlineBuilder extends StackListenerImpl {
|
|||
}
|
||||
}
|
||||
List<FormalParameterBuilder> synthesizedFormals = [];
|
||||
TypeBuilder thisType = extension.extensionThisType;
|
||||
TypeBuilder thisType;
|
||||
if (extension.kind == TypeParameterScopeKind.extensionDeclaration) {
|
||||
thisType = extension.extensionThisType;
|
||||
} else {
|
||||
thisType = libraryBuilder.addNamedType(
|
||||
extension.name,
|
||||
const NullabilityBuilder.omitted(),
|
||||
typeVariables != null
|
||||
? new List<TypeBuilder>.generate(
|
||||
typeVariables.length,
|
||||
(int index) =>
|
||||
new NamedTypeBuilder.fromTypeDeclarationBuilder(
|
||||
typeVariables![index],
|
||||
const NullabilityBuilder.omitted(),
|
||||
instanceTypeVariableAccess:
|
||||
InstanceTypeVariableAccessState.Allowed))
|
||||
: null,
|
||||
charOffset,
|
||||
instanceTypeVariableAccess:
|
||||
InstanceTypeVariableAccessState.Allowed);
|
||||
}
|
||||
if (substitution != null) {
|
||||
List<NamedTypeBuilder> unboundTypes = [];
|
||||
List<TypeVariableBuilder> unboundTypeVariables = [];
|
||||
|
|
|
@ -114,9 +114,7 @@ class SourceProcedureBuilder extends SourceFunctionBuilderImpl
|
|||
..isNonNullableByDefault = libraryBuilder.isNonNullableByDefault;
|
||||
nameScheme.getProcedureMemberName(kind, name).attachMember(_procedure);
|
||||
this.asyncModifier = asyncModifier;
|
||||
if ((isExtensionInstanceMember
|
||||
// TODO(johnniwinther): Support view tear offs.
|
||||
/* || isViewInstanceMember*/) &&
|
||||
if ((isExtensionInstanceMember || isViewInstanceMember) &&
|
||||
kind == ProcedureKind.Method) {
|
||||
_extensionTearOff = new Procedure(
|
||||
dummyName, ProcedureKind.Method, new FunctionNode(null),
|
||||
|
|
|
@ -5,6 +5,13 @@
|
|||
view class Class {
|
||||
final int it;
|
||||
|
||||
void instanceMethod() {}
|
||||
static void staticMethod() {}
|
||||
}
|
||||
|
||||
view class GenericClass<T> {
|
||||
final T it;
|
||||
|
||||
void instanceMethod() {}
|
||||
static void staticMethod() {}
|
||||
}
|
|
@ -4,7 +4,19 @@ import "dart:core" as core;
|
|||
|
||||
view Class /* representationType = core::int */ {
|
||||
method instanceMethod = self::Class|instanceMethod;
|
||||
tearoff instanceMethod = self::Class|get#instanceMethod;
|
||||
static method staticMethod = self::Class|staticMethod;
|
||||
}
|
||||
static method Class|instanceMethod() → void {}
|
||||
view GenericClass<T extends core::Object? = dynamic> /* representationType = T% */ {
|
||||
method instanceMethod = self::GenericClass|instanceMethod;
|
||||
tearoff instanceMethod = self::GenericClass|get#instanceMethod;
|
||||
static method staticMethod = self::GenericClass|staticMethod;
|
||||
}
|
||||
static method Class|instanceMethod(lowered final self::Class #this) → void {}
|
||||
static method Class|get#instanceMethod(lowered final self::Class #this) → () → void
|
||||
return () → void => self::Class|instanceMethod(#this);
|
||||
static method Class|staticMethod() → void {}
|
||||
static method GenericClass|instanceMethod<T extends core::Object? = dynamic>(lowered final self::GenericClass<self::GenericClass|instanceMethod::T%> #this) → void {}
|
||||
static method GenericClass|get#instanceMethod<T extends core::Object? = dynamic>(lowered final self::GenericClass<self::GenericClass|get#instanceMethod::T%> #this) → () → void
|
||||
return () → void => self::GenericClass|instanceMethod<self::GenericClass|get#instanceMethod::T%>(#this);
|
||||
static method GenericClass|staticMethod() → void {}
|
||||
|
|
|
@ -4,7 +4,19 @@ import "dart:core" as core;
|
|||
|
||||
view Class /* representationType = core::int */ {
|
||||
method instanceMethod = self::Class|instanceMethod;
|
||||
tearoff instanceMethod = self::Class|get#instanceMethod;
|
||||
static method staticMethod = self::Class|staticMethod;
|
||||
}
|
||||
static method Class|instanceMethod() → void {}
|
||||
view GenericClass<T extends core::Object? = dynamic> /* representationType = T% */ {
|
||||
method instanceMethod = self::GenericClass|instanceMethod;
|
||||
tearoff instanceMethod = self::GenericClass|get#instanceMethod;
|
||||
static method staticMethod = self::GenericClass|staticMethod;
|
||||
}
|
||||
static method Class|instanceMethod(lowered final self::Class #this) → void {}
|
||||
static method Class|get#instanceMethod(lowered final self::Class #this) → () → void
|
||||
return () → void => self::Class|instanceMethod(#this);
|
||||
static method Class|staticMethod() → void {}
|
||||
static method GenericClass|instanceMethod<T extends core::Object? = dynamic>(lowered final self::GenericClass<self::GenericClass|instanceMethod::T%> #this) → void {}
|
||||
static method GenericClass|get#instanceMethod<T extends core::Object? = dynamic>(lowered final self::GenericClass<self::GenericClass|get#instanceMethod::T%> #this) → () → void
|
||||
return () → void => self::GenericClass|instanceMethod<self::GenericClass|get#instanceMethod::T%>(#this);
|
||||
static method GenericClass|staticMethod() → void {}
|
||||
|
|
|
@ -4,3 +4,9 @@ class Class {
|
|||
void instanceMethod() {}
|
||||
static void staticMethod() {}
|
||||
}
|
||||
view
|
||||
class GenericClass<T> {
|
||||
final T it;
|
||||
void instanceMethod() {}
|
||||
static void staticMethod() {}
|
||||
}
|
||||
|
|
|
@ -4,7 +4,19 @@ import "dart:core" as core;
|
|||
|
||||
view Class /* representationType = core::int */ {
|
||||
method instanceMethod = self::Class|instanceMethod;
|
||||
tearoff instanceMethod = self::Class|get#instanceMethod;
|
||||
static method staticMethod = self::Class|staticMethod;
|
||||
}
|
||||
static method Class|instanceMethod() → void {}
|
||||
view GenericClass<T extends core::Object? = dynamic> /* representationType = T% */ {
|
||||
method instanceMethod = self::GenericClass|instanceMethod;
|
||||
tearoff instanceMethod = self::GenericClass|get#instanceMethod;
|
||||
static method staticMethod = self::GenericClass|staticMethod;
|
||||
}
|
||||
static method Class|instanceMethod(lowered final self::Class #this) → void {}
|
||||
static method Class|get#instanceMethod(lowered final self::Class #this) → () → void
|
||||
return () → void => self::Class|instanceMethod(#this);
|
||||
static method Class|staticMethod() → void {}
|
||||
static method GenericClass|instanceMethod<T extends core::Object? = dynamic>(lowered final self::GenericClass<self::GenericClass|instanceMethod::T%> #this) → void {}
|
||||
static method GenericClass|get#instanceMethod<T extends core::Object? = dynamic>(lowered final self::GenericClass<self::GenericClass|get#instanceMethod::T%> #this) → () → void
|
||||
return () → void => self::GenericClass|instanceMethod<self::GenericClass|get#instanceMethod::T%>(#this);
|
||||
static method GenericClass|staticMethod() → void {}
|
||||
|
|
|
@ -4,7 +4,19 @@ import "dart:core" as core;
|
|||
|
||||
view Class /* representationType = core::int */ {
|
||||
method instanceMethod = self::Class|instanceMethod;
|
||||
tearoff instanceMethod = self::Class|get#instanceMethod;
|
||||
static method staticMethod = self::Class|staticMethod;
|
||||
}
|
||||
static method Class|instanceMethod() → void {}
|
||||
view GenericClass<T extends core::Object? = dynamic> /* representationType = T% */ {
|
||||
method instanceMethod = self::GenericClass|instanceMethod;
|
||||
tearoff instanceMethod = self::GenericClass|get#instanceMethod;
|
||||
static method staticMethod = self::GenericClass|staticMethod;
|
||||
}
|
||||
static method Class|instanceMethod(lowered final self::Class #this) → void {}
|
||||
static method Class|get#instanceMethod(lowered final self::Class #this) → () → void
|
||||
return () → void => self::Class|instanceMethod(#this);
|
||||
static method Class|staticMethod() → void {}
|
||||
static method GenericClass|instanceMethod<T extends core::Object? = dynamic>(lowered final self::GenericClass<self::GenericClass|instanceMethod::T%> #this) → void {}
|
||||
static method GenericClass|get#instanceMethod<T extends core::Object? = dynamic>(lowered final self::GenericClass<self::GenericClass|get#instanceMethod::T%> #this) → () → void
|
||||
return () → void => self::GenericClass|instanceMethod<self::GenericClass|get#instanceMethod::T%>(#this);
|
||||
static method GenericClass|staticMethod() → void {}
|
||||
|
|
|
@ -4,9 +4,23 @@ import "dart:core" as core;
|
|||
|
||||
view Class /* representationType = core::int */ {
|
||||
method instanceMethod = self::Class|instanceMethod;
|
||||
tearoff instanceMethod = self::Class|get#instanceMethod;
|
||||
static method staticMethod = self::Class|staticMethod;
|
||||
}
|
||||
static method Class|instanceMethod() → void
|
||||
view GenericClass<T extends core::Object? = dynamic> /* representationType = T% */ {
|
||||
method instanceMethod = self::GenericClass|instanceMethod;
|
||||
tearoff instanceMethod = self::GenericClass|get#instanceMethod;
|
||||
static method staticMethod = self::GenericClass|staticMethod;
|
||||
}
|
||||
static method Class|instanceMethod(lowered final self::Class #this) → void
|
||||
;
|
||||
static method Class|get#instanceMethod(lowered final self::Class #this) → () → void
|
||||
return () → void => self::Class|instanceMethod(#this);
|
||||
static method Class|staticMethod() → void
|
||||
;
|
||||
static method GenericClass|instanceMethod<T extends core::Object? = dynamic>(lowered final self::GenericClass<self::GenericClass|instanceMethod::T%> #this) → void
|
||||
;
|
||||
static method GenericClass|get#instanceMethod<T extends core::Object? = dynamic>(lowered final self::GenericClass<self::GenericClass|get#instanceMethod::T%> #this) → () → void
|
||||
return () → void => self::GenericClass|instanceMethod<self::GenericClass|get#instanceMethod::T%>(#this);
|
||||
static method GenericClass|staticMethod() → void
|
||||
;
|
||||
|
|
|
@ -4,7 +4,19 @@ import "dart:core" as core;
|
|||
|
||||
view Class /* representationType = core::int */ {
|
||||
method instanceMethod = self::Class|instanceMethod;
|
||||
tearoff instanceMethod = self::Class|get#instanceMethod;
|
||||
static method staticMethod = self::Class|staticMethod;
|
||||
}
|
||||
static method Class|instanceMethod() → void {}
|
||||
view GenericClass<T extends core::Object? = dynamic> /* representationType = T% */ {
|
||||
method instanceMethod = self::GenericClass|instanceMethod;
|
||||
tearoff instanceMethod = self::GenericClass|get#instanceMethod;
|
||||
static method staticMethod = self::GenericClass|staticMethod;
|
||||
}
|
||||
static method Class|instanceMethod(lowered final self::Class #this) → void {}
|
||||
static method Class|get#instanceMethod(lowered final self::Class #this) → () → void
|
||||
return () → void => self::Class|instanceMethod(#this);
|
||||
static method Class|staticMethod() → void {}
|
||||
static method GenericClass|instanceMethod<T extends core::Object? = dynamic>(lowered final self::GenericClass<self::GenericClass|instanceMethod::T%> #this) → void {}
|
||||
static method GenericClass|get#instanceMethod<T extends core::Object? = dynamic>(lowered final self::GenericClass<self::GenericClass|get#instanceMethod::T%> #this) → () → void
|
||||
return () → void => self::GenericClass|instanceMethod<self::GenericClass|get#instanceMethod::T%>(#this);
|
||||
static method GenericClass|staticMethod() → void {}
|
||||
|
|
Loading…
Reference in a new issue