Skip to content

Commit

Permalink
encoding: simplify by considering abstract classes as classes, and ma…
Browse files Browse the repository at this point in the history
…rk with a comment.

this is very rarely used, and would need significant work to avoid some bugs which break conversion
  • Loading branch information
oyvindberg committed Oct 17, 2022
1 parent 8cbefd6 commit baf58e8
Show file tree
Hide file tree
Showing 7 changed files with 15 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,24 +8,20 @@ sealed trait ClassType {

final def combine(that: ClassType): ClassType =
(this, that) match {
case (Class, _) => Class
case (_, Class) => Class
case (AbstractClass, _) => AbstractClass
case (_, AbstractClass) => AbstractClass
case (_, _) => Trait
case (Class, _) => Class
case (_, Class) => Class
case (_, _) => Trait
}

final def asString: String =
this match {
case Trait => "trait"
case AbstractClass => "abstract class"
case Class => "class"
case Trait => "trait"
case Class => "class"
}
}

object ClassType {
case object Class extends ClassType
case object AbstractClass extends ClassType
case object Trait extends ClassType

implicit val encodes: Encoder[ClassType] = io.circe013.generic.semiauto.deriveEncoder
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -283,10 +283,7 @@ object ImportScalaDefinitions extends App {
IArray.fromTraversable(parentTypes).map(toTypeRefForce).filter(_.typeName =/= codePath).filterNot(Anies)
val name = Name(processName(c.name))

val classType =
if (c.isTrait) ClassType.Trait
else if (c.isAbstract) ClassType.AbstractClass
else ClassType.Class
val classType = if (c.isTrait) ClassType.Trait else ClassType.Class

val (ctors, _, members) =
IArray
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,8 @@ class ImportTree(
val anns = ImportJsLocation(location)
val parents = (IArray.fromOption(parent) ++ implements).map(importType(scope, importName))

val classType = if (isAbstract) ClassType.AbstractClass else ClassType.Class
val abstractComment = if (isAbstract) Comments("/* note: abstract class */") else NoComments

val cls = ClassTree(
isImplicit = false,
annotations = anns,
Expand All @@ -197,9 +198,9 @@ class ImportTree(
parents = parents ++ extraInheritance.sorted,
ctors = ctors,
members = ms,
classType = classType,
classType = ClassType.Class,
isSealed = false,
comments = cs ++ cs2,
comments = cs ++ cs2 ++ abstractComment,
codePath = newCodePath,
)

Expand Down
2 changes: 1 addition & 1 deletion scalajs/src/main/resources/scalajs-definitions.json

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ object ParentsResolver {
def pruneClasses: Parents = {
def go(it: Parent): Option[Parent] =
it.classTree match {
case ClassTree(_, _, _, _, _, _, _, _, ClassType.Class | ClassType.AbstractClass, _, _, _) =>
case ClassTree(_, _, _, _, _, _, _, _, ClassType.Class, _, _, _) =>
None
case _ =>
Some(Parent(it.refs)(it.classTree, it.foundIn, it.parents.mapNotNone(go), it.unresolved))
Expand Down
2 changes: 1 addition & 1 deletion tests/aws-sdk/check-3/a/aws-sdk/build.sbt
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
organization := "org.scalablytyped"
name := "aws-sdk"
version := "2.247.1-bd92aa"
version := "2.247.1-7c2a96"
scalaVersion := "3.1.2"
enablePlugins(ScalaJSPlugin)
libraryDependencies ++= Seq(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import scala.scalajs.js.annotation.{JSGlobalScope, JSGlobal, JSImport, JSName, J

object configServicePlaceholdersMod {

@JSImport("aws-sdk/lib/config_service_placeholders", "ConfigurationServicePlaceholders")
/* note: abstract class */ @JSImport("aws-sdk/lib/config_service_placeholders", "ConfigurationServicePlaceholders")
@js.native
abstract class ConfigurationServicePlaceholders () extends StObject {
open class ConfigurationServicePlaceholders () extends StObject {

var dynamodb: js.UndefOr[ClientConfiguration] = js.native
}
Expand Down

0 comments on commit baf58e8

Please sign in to comment.