From f47dc171db4246ecaf83bf48116182979debca71 Mon Sep 17 00:00:00 2001 From: Henry Story Date: Mon, 30 Aug 2021 10:51:20 +0200 Subject: [PATCH] upgrade to use opaque inline https://github.com/lampepfl/dotty/pull/12815 --- build.sbt | 2 +- src/test/scala/ideas/MatchTypes.scala | 32 +++++++++++++++++++-------- 2 files changed, 24 insertions(+), 10 deletions(-) diff --git a/build.sbt b/build.sbt index 1f306fe..c9e71be 100644 --- a/build.sbt +++ b/build.sbt @@ -32,5 +32,5 @@ lazy val root = project // "-Yexplicit-nulls", // For explicit nulls behavior. ) ) -val Scala3Version = "3.0.1" +val Scala3Version = "3.0.2-RC1" val munit = "org.scalameta" %% "munit" % "0.7.28" % Test diff --git a/src/test/scala/ideas/MatchTypes.scala b/src/test/scala/ideas/MatchTypes.scala index 8518c9b..ce613ec 100644 --- a/src/test/scala/ideas/MatchTypes.scala +++ b/src/test/scala/ideas/MatchTypes.scala @@ -4,6 +4,10 @@ package ideas /** * following an idea by Neko-kai https://twitter.com/kai_nyasha * https://discord.com/channels/632277896739946517/632277897448652844/880944909660606525 + * + * Differences with banana-rdf: + * - + * */ object MatchTypes { @@ -32,13 +36,20 @@ object MatchTypes { override opaque type BNode <: Node = jena.Node_Blank override opaque type Literal <: Node = jena.Node_Literal - override def mkUri(iriStr: String): URI = + override inline + def mkUri(iriStr: String): URI = NodeFactory.createURI(iriStr).asInstanceOf[URI] - override def mkStringLit(str: String): Literal = + + override inline + def mkStringLit(str: String): Literal = NodeFactory.createLiteral(str).asInstanceOf[Literal] - override def mkTriple(subj: Node, rel: URI, obj: Node): Triple = + + override inline + def mkTriple(subj: Node, rel: URI, obj: Node): Triple = jena.Triple.create(subj, rel, obj) - override def mkGraph(triples: Iterable[Triple]): Graph = + + override inline + def mkGraph(triples: Iterable[Triple]): Graph = val g = Factory.createDefaultGraph() triples.foreach(t => g.add(t)) g @@ -52,12 +63,15 @@ object MatchTypes { override opaque type Literal <: Node = String override opaque type Graph = Set[Triple] - override def mkUri(iriStr: String): URI = new java.net.URI(iriStr) - override def mkStringLit(str: String): Literal = str - override def mkTriple(subj: Node, rel: URI, obj: Node): Triple = + override inline + def mkUri(iriStr: String): URI = new java.net.URI(iriStr) + override inline + def mkStringLit(str: String): Literal = str + override inline + def mkTriple(subj: Node, rel: URI, obj: Node): Triple = (subj,rel,obj) - override def mkGraph(triples: Iterable[Triple]): Graph = - triples.toSet + override inline + def mkGraph(triples: Iterable[Triple]): Graph = triples.toSet } object RDF {