diff --git a/syntax/src/main/scala/chester/syntax/concrete/Expr.scala b/syntax/src/main/scala/chester/syntax/concrete/Expr.scala index f49742a5..a4ad27b7 100644 --- a/syntax/src/main/scala/chester/syntax/concrete/Expr.scala +++ b/syntax/src/main/scala/chester/syntax/concrete/Expr.scala @@ -197,9 +197,9 @@ case class ResolvedIdentifier( @deprecated("not used") case class ResolvedLocalVar( - name: Name, - varId: Uniqid, - meta: Option[ExprMeta] + name: Name, + varId: Uniqid, + meta: Option[ExprMeta] ) extends Expr { override type ThisTree = ResolvedLocalVar diff --git a/syntax/src/main/scala/chester/syntax/core/Term.scala b/syntax/src/main/scala/chester/syntax/core/Term.scala index 8864bc0e..b1a3c224 100644 --- a/syntax/src/main/scala/chester/syntax/core/Term.scala +++ b/syntax/src/main/scala/chester/syntax/core/Term.scala @@ -1053,10 +1053,10 @@ sealed trait ReferenceCall extends Term with Uneval with TermWithUniqid derives } case class LocalV( - name: Name, - ty: Term, - uniqId: UniqidOf[LocalV], - meta: OptionTermMeta + name: Name, + ty: Term, + uniqId: UniqidOf[LocalV], + meta: OptionTermMeta ) extends ReferenceCall derives ReadWriter { override type ThisTree = LocalV override def descent(f: Term => Term, g: SpecialMap): LocalV = thisOr( @@ -1070,10 +1070,10 @@ case class LocalV( } case class ToplevelV( - id: AbsoluteRef, - ty: Term, - uniqId: UniqidOf[ToplevelV], - meta: OptionTermMeta + id: AbsoluteRef, + ty: Term, + uniqId: UniqidOf[ToplevelV], + meta: OptionTermMeta ) extends ReferenceCall { override type ThisTree = ToplevelV override def descent(f: Term => Term, g: SpecialMap): ToplevelV = thisOr( @@ -1270,11 +1270,11 @@ sealed trait TypeDefinition extends StmtTerm with TermWithUniqid derives ReadWri } case class RecordStmtTerm( - name: Name, - uniqId: UniqidOf[RecordStmtTerm] = Uniqid.generate[RecordStmtTerm], - fields: Vector[FieldTerm], - body: Option[BlockTerm], - meta: OptionTermMeta + name: Name, + uniqId: UniqidOf[RecordStmtTerm] = Uniqid.generate[RecordStmtTerm], + fields: Vector[FieldTerm], + body: Option[BlockTerm], + meta: OptionTermMeta ) extends TypeDefinition { override type ThisTree = RecordStmtTerm override def switchUniqId(r: UReplacer): RecordStmtTerm = copy(uniqId = r(uniqId)) @@ -1312,11 +1312,11 @@ case class RecordConstructorCallTerm( } } case class TraitStmtTerm( - name: Name, - uniqId: UniqidOf[TraitStmtTerm] = Uniqid.generate[TraitStmtTerm], - extendsClause: Option[Term] = None, - body: Option[BlockTerm] = None, - meta: OptionTermMeta + name: Name, + uniqId: UniqidOf[TraitStmtTerm] = Uniqid.generate[TraitStmtTerm], + extendsClause: Option[Term] = None, + body: Option[BlockTerm] = None, + meta: OptionTermMeta ) extends TypeDefinition derives ReadWriter { override type ThisTree = TraitStmtTerm override def switchUniqId(r: UReplacer): TraitStmtTerm = copy(uniqId = r(uniqId)) @@ -1338,11 +1338,11 @@ case class TraitStmtTerm( } case class InterfaceStmtTerm( - name: Name, - uniqId: UniqidOf[InterfaceStmtTerm] = Uniqid.generate[InterfaceStmtTerm], - extendsClause: Option[Term] = None, - body: Option[BlockTerm] = None, - meta: OptionTermMeta + name: Name, + uniqId: UniqidOf[InterfaceStmtTerm] = Uniqid.generate[InterfaceStmtTerm], + extendsClause: Option[Term] = None, + body: Option[BlockTerm] = None, + meta: OptionTermMeta ) extends TypeDefinition derives ReadWriter { override type ThisTree = InterfaceStmtTerm override def switchUniqId(r: UReplacer): InterfaceStmtTerm = copy(uniqId = r(uniqId)) @@ -1363,11 +1363,11 @@ case class InterfaceStmtTerm( } } case class ObjectStmtTerm( - name: Name, - uniqId: UniqidOf[ObjectStmtTerm], - extendsClause: Option[Term], - body: Option[BlockTerm], - meta: OptionTermMeta + name: Name, + uniqId: UniqidOf[ObjectStmtTerm], + extendsClause: Option[Term], + body: Option[BlockTerm], + meta: OptionTermMeta ) extends TypeDefinition derives ReadWriter { override def switchUniqId(r: UReplacer): ObjectStmtTerm = copy(uniqId = r(uniqId)) override def toDoc(using options: PrettierOptions): Doc = { diff --git a/syntax/src/main/scala/chester/syntax/core/stmt/TyckedDefinition.scala b/syntax/src/main/scala/chester/syntax/core/stmt/TyckedDefinition.scala index 559f09c3..9f81d04b 100644 --- a/syntax/src/main/scala/chester/syntax/core/stmt/TyckedDefinition.scala +++ b/syntax/src/main/scala/chester/syntax/core/stmt/TyckedDefinition.scala @@ -35,16 +35,16 @@ case class RecordMember() @deprecated("deprecated") case class TyckedRecord( - name: Name, - varId: Uniqid, - members: Vector[RecordMember], - meta: Option[TermMeta] = None + name: Name, + varId: Uniqid, + members: Vector[RecordMember], + meta: Option[TermMeta] = None ) extends TyckedDefinitionNamed @deprecated("deprecated") case class TyckedDef( - name: Name, - varId: Uniqid, - body: Judge, - meta: Option[TermMeta] = None + name: Name, + varId: Uniqid, + body: Judge, + meta: Option[TermMeta] = None ) extends TyckedDefinitionNamed diff --git a/syntax/src/main/scala/chester/uniqid/Uniqid.scala b/syntax/src/main/scala/chester/uniqid/Uniqid.scala index 267c29ae..3443a933 100644 --- a/syntax/src/main/scala/chester/uniqid/Uniqid.scala +++ b/syntax/src/main/scala/chester/uniqid/Uniqid.scala @@ -12,13 +12,11 @@ private val uniqIdCounter = AtomicInteger(0) type Uniqid = UniqidOf[Any] private val rwUniqID: ReadWriter[UniqidOf[Any]] = - readwriter[java.lang.Integer].bimap(_.id, x=>UniqidOf(x.toInt.refineUnsafe)) + readwriter[java.lang.Integer].bimap(_.id, x => UniqidOf(x.toInt.refineUnsafe)) implicit inline def rwUniqIDOf[T]: ReadWriter[UniqidOf[T]] = rwUniqID.asInstanceOf[ReadWriter[UniqidOf[T]]] -case class UniqidOf[+A] private[uniqid] (id: Int :| Positive0) extends AnyVal { - -} +case class UniqidOf[+A] private[uniqid] (id: Int :| Positive0) extends AnyVal {} type UniqidOffset = Int :| Positive0 private implicit val UniqIdOffsetRW: ReadWriter[UniqidOffset] = @@ -99,7 +97,7 @@ object Uniqid { def is(x: Any): Boolean = x match { case UniqidOf(_) => true - case _ => false + case _ => false } def calculateRange[T <: ContainsUniqid](x: T): UniqIdRange = { diff --git a/tyck/src/main/scala/chester/tyck/Context.scala b/tyck/src/main/scala/chester/tyck/Context.scala index a96dfb71..043bef58 100644 --- a/tyck/src/main/scala/chester/tyck/Context.scala +++ b/tyck/src/main/scala/chester/tyck/Context.scala @@ -78,11 +78,11 @@ object TyAndVal {} /** for pure values only like let and def. record is not included */ case class ContextItem( - name: Name, - uniqId: UniqidOf[ReferenceCall], - ref: ReferenceCall, - ty: Term, - reference: Option[SymbolCollector] = None + name: Name, + uniqId: UniqidOf[ReferenceCall], + ref: ReferenceCall, + ty: Term, + reference: Option[SymbolCollector] = None ) object ContextItem {} case class Imports() @@ -92,16 +92,16 @@ object Imports { } case class Context( - map: Map[Name, UniqidOf[ReferenceCall]] = Map.empty[Name, UniqidOf[ReferenceCall]], // empty[...] are needed because compiler bugs - contextItems: Map[UniqidOf[ReferenceCall], ContextItem] = + map: Map[Name, UniqidOf[ReferenceCall]] = Map.empty[Name, UniqidOf[ReferenceCall]], // empty[...] are needed because compiler bugs + contextItems: Map[UniqidOf[ReferenceCall], ContextItem] = Map.empty[UniqidOf[ReferenceCall], ContextItem], // empty[...] are needed because compiler bugs - knownMap: Map[UniqidOf[ReferenceCall], TyAndVal] = Map.empty[UniqidOf[ReferenceCall], TyAndVal], // empty[...] are needed because compiler bugs - typeDefinitionNames: Map[Name, UniqidOf[TypeDefinition]] = Map.empty, - typeDefinitions: Map[UniqidOf[TypeDefinition], TypeDefinition] = Map.empty, - imports: Imports = Imports.Empty, - loadedModules: LoadedModules = LoadedModules.Empty, - operators: OperatorsContext = OperatorsContext.Default, - currentModule: ModuleRef = DefaultModule + knownMap: Map[UniqidOf[ReferenceCall], TyAndVal] = Map.empty[UniqidOf[ReferenceCall], TyAndVal], // empty[...] are needed because compiler bugs + typeDefinitionNames: Map[Name, UniqidOf[TypeDefinition]] = Map.empty, + typeDefinitions: Map[UniqidOf[TypeDefinition], TypeDefinition] = Map.empty, + imports: Imports = Imports.Empty, + loadedModules: LoadedModules = LoadedModules.Empty, + operators: OperatorsContext = OperatorsContext.Default, + currentModule: ModuleRef = DefaultModule ) { def updateModule(module: ModuleRef): Context = copy(currentModule = module) diff --git a/tyck/src/main/scala/chester/tyck/ElaboraterBlock.scala b/tyck/src/main/scala/chester/tyck/ElaboraterBlock.scala index 8aae2ff1..74e45b54 100644 --- a/tyck/src/main/scala/chester/tyck/ElaboraterBlock.scala +++ b/tyck/src/main/scala/chester/tyck/ElaboraterBlock.scala @@ -30,29 +30,29 @@ trait ElaboraterBlock extends Elaborater { // Case class for 'record' declarations case class RecordDeclaration( - expr: RecordStmt, - uniqId: UniqidOf[RecordStmtTerm], - name: Name + expr: RecordStmt, + uniqId: UniqidOf[RecordStmtTerm], + name: Name ) extends DeclarationInfo // New declarations for trait and interface case class TraitDeclaration( - expr: TraitStmt, - uniqId: UniqidOf[TraitStmtTerm], - name: Name + expr: TraitStmt, + uniqId: UniqidOf[TraitStmtTerm], + name: Name ) extends DeclarationInfo case class InterfaceDeclaration( - expr: InterfaceStmt, - uniqId: UniqidOf[InterfaceStmtTerm], - name: Name + expr: InterfaceStmt, + uniqId: UniqidOf[InterfaceStmtTerm], + name: Name ) extends DeclarationInfo // Add case class for 'object' declarations case class ObjectDeclaration( - expr: ObjectStmt, - uniqId: UniqidOf[ObjectStmtTerm], - name: Name + expr: ObjectStmt, + uniqId: UniqidOf[ObjectStmtTerm], + name: Name ) extends DeclarationInfo def elabBlock(expr: Block, ty0: CellIdOr[Term], effects: CIdOf[EffectsCell])(using diff --git a/tyck/src/main/scala/chester/tyck/ElaboraterCommon.scala b/tyck/src/main/scala/chester/tyck/ElaboraterCommon.scala index cc3fb370..3685974d 100644 --- a/tyck/src/main/scala/chester/tyck/ElaboraterCommon.scala +++ b/tyck/src/main/scala/chester/tyck/ElaboraterCommon.scala @@ -530,10 +530,10 @@ trait ElaboraterBase extends CommonPropagator[Tyck] { } def newLocalv( - name: Name, - ty: CellIdOr[Term], - id: UniqidOf[LocalV], - meta: Option[ExprMeta] + name: Name, + ty: CellIdOr[Term], + id: UniqidOf[LocalV], + meta: Option[ExprMeta] )(using ck: Tyck, state: StateAbility[Tyck]): LocalV = { val m = convertMeta(meta) LocalV(name, toTerm(ty), id, m) diff --git a/tyck/src/main/scala/chester/tyck/api/SemanticCollector.scala b/tyck/src/main/scala/chester/tyck/api/SemanticCollector.scala index 47f81c04..2eed9f50 100644 --- a/tyck/src/main/scala/chester/tyck/api/SemanticCollector.scala +++ b/tyck/src/main/scala/chester/tyck/api/SemanticCollector.scala @@ -21,10 +21,10 @@ trait SemanticCollector { def highlightLiteral(expr: Expr): Unit = () def newSymbol( - call: ReferenceCall, - id: UniqidOf[ReferenceCall], - definedOn: Expr, - localCtx: Context + call: ReferenceCall, + id: UniqidOf[ReferenceCall], + definedOn: Expr, + localCtx: Context ): SymbolCollector = NoopSymbolCollector def metaFinished(replace: MetaTerm => Term): Unit = () @@ -35,10 +35,10 @@ private implicit inline def rwUniqIDOfVar[T]: ReadWriter[UniqidOf[ReferenceCall] // TODO: handle when call's ty is MetaTerm case class CollectedSymbol( - call: ReferenceCall, - id: UniqidOf[ReferenceCall], - definedOn: Expr, - referencedOn: Vector[Expr] + call: ReferenceCall, + id: UniqidOf[ReferenceCall], + definedOn: Expr, + referencedOn: Vector[Expr] ) derives ReadWriter { def name: Name = call.name @@ -51,10 +51,10 @@ class VectorSemanticCollector extends SemanticCollector { private var builder: mutable.ArrayDeque[CollectedSymbol] = new mutable.ArrayDeque[CollectedSymbol]() override def newSymbol( - call: ReferenceCall, - id: UniqidOf[ReferenceCall], - definedOn: Expr, - localCtx: Context + call: ReferenceCall, + id: UniqidOf[ReferenceCall], + definedOn: Expr, + localCtx: Context ): SymbolCollector = { val index = builder.length builder.append(CollectedSymbol(call, id, definedOn, Vector())) @@ -78,10 +78,10 @@ object NoopSemanticCollector extends SemanticCollector {} class UnusedVariableWarningWrapper(x: SemanticCollector) extends SemanticCollector { private var unusedVariables: Vector[CollectedSymbol] = Vector() override def newSymbol( - call: ReferenceCall, - id: UniqidOf[ReferenceCall], - definedOn: Expr, - localCtx: Context + call: ReferenceCall, + id: UniqidOf[ReferenceCall], + definedOn: Expr, + localCtx: Context ): SymbolCollector = { val symbolCollector = x.newSymbol(call, id, definedOn, localCtx) val c = CollectedSymbol(call, id, definedOn, Vector()) diff --git a/tyck/src/main/scala/chester/utils/propagator/ProvideMultithread.scala b/tyck/src/main/scala/chester/utils/propagator/ProvideMultithread.scala index ba52b9e7..95755c6d 100644 --- a/tyck/src/main/scala/chester/utils/propagator/ProvideMultithread.scala +++ b/tyck/src/main/scala/chester/utils/propagator/ProvideMultithread.scala @@ -10,8 +10,8 @@ import scala.jdk.CollectionConverters.* trait ProvideMultithread extends ProvideImpl { class HoldCell[+T <: Cell[?]]( - val uniqId: UniqidOf[Impl[?]], - initialValue: T + val uniqId: UniqidOf[Impl[?]], + initialValue: T ) { private val storeRef = new AtomicReference[Cell[?]](initialValue) val readingPropagators = new ConcurrentLinkedQueue[PIdOf[Propagator[?]]]() @@ -42,8 +42,8 @@ trait ProvideMultithread extends ProvideImpl { x.asInstanceOf[CIdOf[Cell[?]]] class HoldPropagator[+T <: Propagator[?]]( - val uniqId: UniqidOf[Impl[?]], - initialValue: T + val uniqId: UniqidOf[Impl[?]], + initialValue: T ) { private val storeRef = new AtomicReference[Propagator[?]](initialValue) private val aliveRef = new AtomicBoolean(true) diff --git a/tyck/src/main/scala/chester/utils/propagator/ProvideMutable.scala b/tyck/src/main/scala/chester/utils/propagator/ProvideMutable.scala index 84d3758b..310e830b 100644 --- a/tyck/src/main/scala/chester/utils/propagator/ProvideMutable.scala +++ b/tyck/src/main/scala/chester/utils/propagator/ProvideMutable.scala @@ -17,8 +17,8 @@ trait ProvideMutable extends ProvideImpl { type CIdOf[+T <: Cell[?]] = HoldCell[T] class HoldPropagator[+T <: Propagator[?]]( - val uniqId: UniqidOf[Impl[?]], - value: T + val uniqId: UniqidOf[Impl[?]], + value: T ) { var store: Propagator[?] = value var alive: Boolean = true