diff options
Diffstat (limited to 'test')
-rw-r--r-- | test/files/neg/t7519.check | 7 | ||||
-rw-r--r-- | test/files/neg/t7519.scala | 18 | ||||
-rw-r--r-- | test/files/run/t2464/Annotated.java | 5 | ||||
-rw-r--r-- | test/files/run/t2464/Connect.java | 20 | ||||
-rw-r--r-- | test/files/run/t2464/Test.scala | 35 | ||||
-rw-r--r-- | test/files/run/t3425b/Base_1.scala | 2 | ||||
-rw-r--r-- | test/files/run/t6308.check | 16 | ||||
-rw-r--r-- | test/files/run/t6308.scala | 41 |
8 files changed, 143 insertions, 1 deletions
diff --git a/test/files/neg/t7519.check b/test/files/neg/t7519.check new file mode 100644 index 0000000000..164d67f595 --- /dev/null +++ b/test/files/neg/t7519.check @@ -0,0 +1,7 @@ +t7519.scala:5: error: could not find implicit value for parameter nada: Nothing + locally(0 : String) // was: "value conversion is not a member of C.this.C" + ^ +t7519.scala:15: error: could not find implicit value for parameter nada: Nothing + locally(0 : String) // was: "value conversion is not a member of U" + ^ +two errors found diff --git a/test/files/neg/t7519.scala b/test/files/neg/t7519.scala new file mode 100644 index 0000000000..aea0f35d8e --- /dev/null +++ b/test/files/neg/t7519.scala @@ -0,0 +1,18 @@ +class C { + implicit def conversion(m: Int)(implicit nada: Nothing): String = ??? + + class C { // rename class to get correct error, can't find implicit: Nothing. + locally(0 : String) // was: "value conversion is not a member of C.this.C" + } +} + +object Test2 { + trait T; trait U + new T { + implicit def conversion(m: Int)(implicit nada: Nothing): String = ??? + + new U { // nested anonymous classes also share a name. + locally(0 : String) // was: "value conversion is not a member of U" + } + } +} diff --git a/test/files/run/t2464/Annotated.java b/test/files/run/t2464/Annotated.java new file mode 100644 index 0000000000..d022f9852c --- /dev/null +++ b/test/files/run/t2464/Annotated.java @@ -0,0 +1,5 @@ +package test; + +@Connect(loadStyle = Connect.LoadStyle.EAGER) +public class Annotated { +} diff --git a/test/files/run/t2464/Connect.java b/test/files/run/t2464/Connect.java new file mode 100644 index 0000000000..59349f94c8 --- /dev/null +++ b/test/files/run/t2464/Connect.java @@ -0,0 +1,20 @@ +package test; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + + +@Retention(RetentionPolicy.RUNTIME) +@Target(ElementType.TYPE) +public @interface Connect { + + LoadStyle loadStyle() default LoadStyle.EAGER; + + public enum LoadStyle { + EAGER, + DEFERRED, + LAZY + } +} diff --git a/test/files/run/t2464/Test.scala b/test/files/run/t2464/Test.scala new file mode 100644 index 0000000000..90e1a03c17 --- /dev/null +++ b/test/files/run/t2464/Test.scala @@ -0,0 +1,35 @@ +import scala.reflect.io.Streamable +import scala.tools.asm.{ClassWriter, ClassReader} +import scala.tools.asm.tree.ClassNode +import scala.tools.partest._ +import scala.tools.partest.BytecodeTest.modifyClassFile +import java.io.{FileOutputStream, FileInputStream, File} + +object Test extends DirectTest { + def code = ??? + + def compileCode(code: String) = { + val classpath = List(sys.props("partest.lib"), testOutput.path) mkString sys.props("path.separator") + compileString(newCompiler("-cp", classpath, "-d", testOutput.path))(code) + } + + def app = """ + object O { + new test.Annotated + } + """ + + def show(): Unit = { + compileCode(app) + modifyClassFile(new File(testOutput.toFile, "test/Annotated.class")) { + (cn: ClassNode) => + // As investigated https://issues.scala-lang.org/browse/SI-2464?focusedCommentId=64521&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-64521 + // classfiles in the wild sometimes lack the required InnerClass attribute for nested enums that + // are referenced in an annotation. I don't know what compiler or bytecode processor leaves things + // that way, but this test makes sure we don't crash. + cn.innerClasses.clear() + cn + } + compileCode(app) + } +} diff --git a/test/files/run/t3425b/Base_1.scala b/test/files/run/t3425b/Base_1.scala index 02e108b320..5a660a89b2 100644 --- a/test/files/run/t3425b/Base_1.scala +++ b/test/files/run/t3425b/Base_1.scala @@ -9,7 +9,7 @@ class ABC extends A with B with C { private def reflected = ( Thread.currentThread.getStackTrace takeWhile (_.getMethodName != "main") - exists (_.toString contains "java.lang.reflect.") + exists (_.toString contains "sun.reflect.") ) lazy val y: PQ = new PQ(reflected) } diff --git a/test/files/run/t6308.check b/test/files/run/t6308.check new file mode 100644 index 0000000000..e2577db72a --- /dev/null +++ b/test/files/run/t6308.check @@ -0,0 +1,16 @@ +- Unspecialized type args +// Specialized +f1 f1$mIc$sp +f2 f2$mIc$sp +f3 f3$mIc$sp +f4 f4$mIc$sp +f5 f5$mIc$sp + +// Unspecialized type args +f4(Boolean) f4 +f4(String) f4 + +// Ideally these would be specialized +todo1 todo1 +todo2 todo2 +todo3 todo3 diff --git a/test/files/run/t6308.scala b/test/files/run/t6308.scala new file mode 100644 index 0000000000..bcd89359b0 --- /dev/null +++ b/test/files/run/t6308.scala @@ -0,0 +1,41 @@ +import scala.{specialized => sp} + +object Test { + def caller = new Exception().getStackTrace()(1).getMethodName + def f1[@sp(Int) A](a: A, b: Any) = caller + def f2[@sp(Int) A, B](a: A, b: String) = caller + def f3[B, @sp(Int) A](a: A, b: List[B]) = caller + def f4[B, @sp(Int) A](a: A, b: List[(A, B)]) = caller + + def f5[@sp(Int) A, B <: Object](a: A, b: B) = caller + + // `uncurryTreeType` calls a TypeMap on the call to this method and we end up with new + // type parameter symbols, which are not found in `TypeEnv.includes(typeEnv(member), env)` + // in `specSym`. (One of `uncurry`'s tasks is to expand type aliases in signatures.) + type T = Object + def todo1[@sp(Int) A, B <: T](a: A, b: String) = caller + def todo2[@sp(Int) A, B <: AnyRef](a: A, b: String) = caller + def todo3[B <: List[A], @specialized(Int) A](a: A, b: B) = caller + + def main(args: Array[String]) { + val s = "" + val result = + s"""|- Unspecialized type args + |// Specialized + |f1 ${f1(1,"some ref")} + |f2 ${f2(1,"some ref")} + |f3 ${f3(1,List("some ref"))} + |f4 ${f4(1,Nil)} + |f5 ${f5(1,s)} + | + |// Unspecialized type args + |f4(Boolean) ${f4(Boolean,Nil)} + |f4(String) ${f4("",Nil)} + | + |// Ideally these would be specialized + |todo1 ${todo1(1,s)} + |todo2 ${todo2(1,s)} + |todo3 ${todo3(1,List(0))}""".stripMargin + println(result) + } +} |