Skip to content

transpiler: constructor and typed field semantics #11

@tbosch

Description

@tbosch
  1. Only allow assignments to fields in constructor and translate these assignment into constructor initializers
  2. Make field declaration explicit through @FIELD annotation
  3. Make const constructors in Dart through @CONST annotation

Example:

class Annotation {
  @FIELD('final name:String')
  @FIELD('final age:int')
  @CONST constructor(name:String, age:int) {
    this.name = 'Hello ' + name;
    this.age = age + 0;
  }
}

@Annotation('usage', 5)
class Foo {}

this needs to transpile to:

class Annotation {
  final String name;
  final int age;
  const Annotation(String name, int age): 
     name = 'Hello ' + name,
     age = age + 0;
}

@Annotation('usage', 5)
class Foo {}

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions