biboudis / dotty Goto Github PK
View Code? Open in Web Editor NEWThis project forked from scala/scala3
Research platform for new language concepts and compiler technologies for Scala.
Home Page: http://dotty.epfl.ch
License: Apache License 2.0
This project forked from scala/scala3
Research platform for new language concepts and compiler technologies for Scala.
Home Page: http://dotty.epfl.ch
License: Apache License 2.0
I tried to write some integration test for @mirror annotation, available on the branch shape-checking
.:
import scala.annotation.mirror
object mirrors {
@mirror def +(A: Int, B: Int): Int & Singleton = A + B
}
There is an error when pickling:
Exception in thread "main" class dotty.tools.dotc.reporting.diagnostic.messages$Error at ?: pickling difference for module class mirrors$ in /home/metaheavens/IdeaProjects/dotty/tests/pos/mirror5.scala, for details:
diff before-pickling.txt after-pickling.txt
Here is the result of diff before-pickling.txt after-pickling.txt
:
17,18c17,18
< >@<51..58> type +[type +A >: scala.Nothing <: scala.Int@<68..71>@<68..71>@<68..71>@@(A=<68..68>),
< type +B >: scala.Nothing <: scala.Int@<76..79>@<76..79>@<76..79>@@(B=<76..76>)
---
> >@<51..58> type +[+A >: scala.Nothing <: scala.Int@<68..71>@<68..71>@<68..71>@@(A=<68..68>),
> +B >: scala.Nothing <: scala.Int@<76..79>@<76..79>@<76..79>@@(B=<76..76>)
I tried to find why is there this diff, but I didn't succeed yet, I will continue to looking for a solution.
I'm working with the new annotation @mirror
, available on the branch shape-checking
. I'm trying to develop a first draft of a Vector class as described here.
Here is the code to reproduce the issue:
import scala.annotation.mirror
object mirrors {
@mirror def +(A: Int, B: Int): Int = A + B
type Singleton[T] = T
def singlify[T](implicit x: T): T = x
}
import mirrors._
class Vector[+N <: Int : Singleton](val innerArray: List[Int]) {
def size: N = singlify[N]
def concat[M <: Int](vec: Vector[M]): Vector[N + M] =
new Vector[N + M](innerArray ++ vec.innerArray)(mirrors.+(size, vec.size))
}
object Test {
def main(args: Array[String]): Unit = {
implicit def length1: 1 = 1
implicit def length2: 2 = 2
val vec1: Vector[1] = new Vector[1](List(1))
val vec2: Vector[2] = new Vector[2](List(2, 3))
val vec3: Vector[3] = vec1.concat(vec2)
}
}
Compiling this code will lead to the following error:
37 | val vec3: Vector[3] = vec1.concat(vec2)
| ^^^^^^^^^^^^^^^^^
| found: Vector[Int(1) + Int]
| required: Vector[Int(3)]
|
Whereas if I change the line:
val vec3: Vector[3] = vec1.concat(vec2)
To:
val vec3: Vector[1 + 2] = vec1.concat(vec2)
val vec4: Vector[3] = vec3
There is no errors.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.