Skip to content

Commit

Permalink
Bug #185: Meaningful message
Browse files Browse the repository at this point in the history
  • Loading branch information
VladUreche committed Sep 13, 2016
1 parent e83d63b commit d0ce4b1
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 7 deletions.
Expand Up @@ -16,6 +16,7 @@ package hijack

import scala.tools.nsc.transform.InfoTransform
import scala.collection.immutable.ListMap
import miniboxing.plugin.ScalacVersion

trait MiniboxCompileTimeOnlyAddTags extends InfoTransform {
this: CompileTimeOnlyAddTagsComponent =>
Expand All @@ -42,8 +43,12 @@ trait MiniboxCompileTimeOnlyAddTags extends InfoTransform {
annotate = true

// Annotate the constructor with @compileTimeOnly:
if (annotate)
sym.addAnnotation(Annotation(CompileTimeOnlyClass.tpe, List(Literal(Constant("use the miniboxing plugin!"))), ListMap.empty))
if (annotate) {
val message = "The " + sym.toString + " was compiled with the miniboxing plugin and can only be called by code also " +
"compiled with the miniboxing plugin (see scala-miniboxing.org/compatibility) [mbox=0.4, scala=" +
(new ScalacVersion{}).scalaBinaryVersion + "]"
sym.addAnnotation(Annotation(CompileTimeOnlyClass.tpe, List(Literal(Constant(message))), ListMap.empty))
}

tpe
}
Expand Down
Expand Up @@ -28,7 +28,8 @@ trait MiniboxCompileTimeOnlyRemoveTags extends InfoTransform {
case Some(List(Literal(Constant(msg)))) =>
// TODO: Check the message is actually a miniboxing-issued message
// TODO: Check the miniboxing plugin version and warn in case of mismatch
true
msg.toString.contains("was compiled with the miniboxing plugin and can only be called by code also " +
"compiled with the miniboxing plugin (see scala-miniboxing.org/compatibility)")
case _ => false
}
}
Expand Down
@@ -1,6 +1,6 @@
newSource1.scala:6: error: use the miniboxing plugin!
newSource1.scala:6: error: The constructor C was compiled with the miniboxing plugin and can only be called by code also compiled with the miniboxing plugin (see scala-miniboxing.org/compatibility) [mbox=0.4, scala=2.11]
val c = new C[Int]
^
newSource1.scala:7: error: use the miniboxing plugin!
newSource1.scala:7: error: The constructor C was compiled with the miniboxing plugin and can only be called by code also compiled with the miniboxing plugin (see scala-miniboxing.org/compatibility) [mbox=0.4, scala=2.11]
object O extends C[String]
^
@@ -1,3 +1,3 @@
newSource1.scala:2: error: use the miniboxing plugin!
newSource1.scala:2: error: The method identityFun was compiled with the miniboxing plugin and can only be called by code also compiled with the miniboxing plugin (see scala-miniboxing.org/compatibility) [mbox=0.4, scala=2.11]
Test.identityFun(3)
^
Expand Up @@ -47,7 +47,8 @@ class TestSuite extends ScalacVersion {
// line number changes for 2.11.7:
"<console>:\\d+:" -> "console:<line>:",
// don't rely on anonymous class numbers:
"anon\\$[0-9]+" -> "anon\\$X"
"anon\\$[0-9]+" -> "anon\\$X",
"scala=2.[0-9]+" -> "scala=ver"
)

implicit class JFileExt(jfile: JFile) {
Expand Down

0 comments on commit d0ce4b1

Please sign in to comment.