From 8b4af71d27ebd56f318e31ffc69225f3fdd6232d Mon Sep 17 00:00:00 2001 From: Adriaan Moors Date: Fri, 8 Feb 2013 15:06:15 -0800 Subject: [nomaster] Revert "SI-4664 Make scala.util.Random Serializable" Also revert "SI-4664 [Make scala.util.Random Serializable] Add test case" This reverts commit 0b92073a38f9d1823f051ac18173078bfcfafc8a. This reverts commit 2aa66bec86fd464712b0d15251cc400ff9d52821. This is necessary to maintain binary compatibility with 2.10.0. --- test/files/jvm/serialization.scala | 15 --------------- 1 file changed, 15 deletions(-) (limited to 'test') diff --git a/test/files/jvm/serialization.scala b/test/files/jvm/serialization.scala index f2c47aad77..34b64938b4 100644 --- a/test/files/jvm/serialization.scala +++ b/test/files/jvm/serialization.scala @@ -604,7 +604,6 @@ object Test { Test7 Test8 Test9_parallel - Test10_util } } @@ -670,17 +669,3 @@ object Test9_parallel { throw e } } - -//############################################################################ -// Test classes in package scala.util - -object Test10_util { - import scala.util.Random - def rep[A](n: Int)(f: => A) { if (n > 0) { f; rep(n-1)(f) } } - - try { - val random = new Random(345) - val random2: Random = read(write(random)) - rep(5) { assert(random.nextInt == random2.nextInt) } - } -} -- cgit v1.2.3 From 85b63b81d5951a78547641e3feab0886f6013ea1 Mon Sep 17 00:00:00 2001 From: Adriaan Moors Date: Fri, 8 Feb 2013 17:45:46 -0800 Subject: [nomaster] Revert "SI-6548 reflection now correctly enters jinners" This reverts commit 54a84a36d5b435a787d93ca48d45399136c7e162. This is necessary to maintain binary compatibility with 2.10.0. run/t6989.check had to be updated as it also (indirectly) tested SI-6548 Conflicts: test/files/lib/javac-artifacts.jar.desired.sha1 test/files/run/t6548.check test/files/run/t6548/Test_2.scala --- bincompat-backward.whitelist.conf | 16 ++--- bincompat-forward.whitelist.conf | 16 ++--- .../scala/reflect/runtime/JavaMirrors.scala | 16 ++--- test/files/run/t6548.check | 2 - .../run/t6548/JavaAnnotationWithNestedEnum_1.java | 17 ----- test/files/run/t6548/Test_2.scala | 12 ---- test/files/run/t6989.check | 84 +++++++++++++++++++--- 7 files changed, 99 insertions(+), 64 deletions(-) delete mode 100644 test/files/run/t6548.check delete mode 100644 test/files/run/t6548/JavaAnnotationWithNestedEnum_1.java delete mode 100644 test/files/run/t6548/Test_2.scala (limited to 'test') diff --git a/bincompat-backward.whitelist.conf b/bincompat-backward.whitelist.conf index 3b29f7388b..f559d673f0 100644 --- a/bincompat-backward.whitelist.conf +++ b/bincompat-backward.whitelist.conf @@ -52,14 +52,14 @@ filter { # matchName="scala.reflect.runtime.SymbolLoaders.initAndEnterClassAndModule" # problemName=MissingMethodProblem # }, - { - matchName="scala.reflect.runtime.JavaMirrors#JavaMirror.scala$reflect$runtime$JavaMirrors$JavaMirror$$jclassAsScala" - problemName=MissingMethodProblem - }, - { - matchName="scala.reflect.runtime.JavaMirrors#JavaMirror.scala$reflect$runtime$JavaMirrors$JavaMirror$$jclassAsScala" - problemName=IncompatibleResultTypeProblem - }, + # { + # matchName="scala.reflect.runtime.JavaMirrors#JavaMirror.scala$reflect$runtime$JavaMirrors$JavaMirror$$jclassAsScala" + # problemName=MissingMethodProblem + # }, + # { + # matchName="scala.reflect.runtime.JavaMirrors#JavaMirror.scala$reflect$runtime$JavaMirrors$JavaMirror$$jclassAsScala" + # problemName=IncompatibleResultTypeProblem + # }, # scala.reflect.internal diff --git a/bincompat-forward.whitelist.conf b/bincompat-forward.whitelist.conf index 66d2ba7154..529fab1e14 100644 --- a/bincompat-forward.whitelist.conf +++ b/bincompat-forward.whitelist.conf @@ -61,14 +61,14 @@ filter { }, # scala.reflect.runtime - { - matchName="scala.reflect.runtime.JavaMirrors#JavaMirror.scala$reflect$runtime$JavaMirrors$JavaMirror$$jclassAsScala" - problemName=IncompatibleResultTypeProblem - }, - { - matchName="scala.reflect.runtime.JavaMirrors#JavaMirror.scala$reflect$runtime$JavaMirrors$JavaMirror$$jclassAsScala1" - problemName=MissingMethodProblem - }, + # { + # matchName="scala.reflect.runtime.JavaMirrors#JavaMirror.scala$reflect$runtime$JavaMirrors$JavaMirror$$jclassAsScala" + # problemName=IncompatibleResultTypeProblem + # }, + # { + # matchName="scala.reflect.runtime.JavaMirrors#JavaMirror.scala$reflect$runtime$JavaMirrors$JavaMirror$$jclassAsScala1" + # problemName=MissingMethodProblem + # }, # { # matchName="scala.reflect.runtime.SymbolLoaders.initClassAndModule" # problemName=MissingMethodProblem diff --git a/src/reflect/scala/reflect/runtime/JavaMirrors.scala b/src/reflect/scala/reflect/runtime/JavaMirrors.scala index eb73ac75fb..3442e3d22e 100644 --- a/src/reflect/scala/reflect/runtime/JavaMirrors.scala +++ b/src/reflect/scala/reflect/runtime/JavaMirrors.scala @@ -686,9 +686,9 @@ private[reflect] trait JavaMirrors extends internal.SymbolTable with api.JavaUni def enter(sym: Symbol, mods: Int) = (if (jModifier.isStatic(mods)) module.moduleClass else clazz).info.decls enter sym - for (jinner <- jclazz.getDeclaredClasses) - jclassAsScala(jinner) // inner class is entered as a side-effect - // no need to call enter explicitly + for (jinner <- jclazz.getDeclaredClasses) { + enter(jclassAsScala(jinner, clazz), jinner.getModifiers) + } pendingLoadActions = { () => @@ -1046,14 +1046,14 @@ private[reflect] trait JavaMirrors extends internal.SymbolTable with api.JavaUni * @param jclazz The Java class * @return A Scala class symbol that wraps all reflection info of `jclazz` */ - private def jclassAsScala(jclazz: jClass[_]): ClassSymbol = - toScala(classCache, jclazz)(_ jclassAsScala1 _) + private def jclassAsScala(jclazz: jClass[_]): Symbol = jclassAsScala(jclazz, sOwner(jclazz)) - private def jclassAsScala1(jclazz: jClass[_]): ClassSymbol = { - val owner = sOwner(jclazz) + private def jclassAsScala(jclazz: jClass[_], owner: Symbol): ClassSymbol = { val name = scalaSimpleName(jclazz) val completer = (clazz: Symbol, module: Symbol) => new FromJavaClassCompleter(clazz, module, jclazz) - createClassModule(owner, name, completer) match { case (clazz, module) => clazz } + val (clazz, module) = createClassModule(owner, name, completer) + classCache enter (jclazz, clazz) + clazz } /** diff --git a/test/files/run/t6548.check b/test/files/run/t6548.check deleted file mode 100644 index 5dfcb12e02..0000000000 --- a/test/files/run/t6548.check +++ /dev/null @@ -1,2 +0,0 @@ -false -List(JavaAnnotationWithNestedEnum_1(value = VALUE)) diff --git a/test/files/run/t6548/JavaAnnotationWithNestedEnum_1.java b/test/files/run/t6548/JavaAnnotationWithNestedEnum_1.java deleted file mode 100644 index 32004de537..0000000000 --- a/test/files/run/t6548/JavaAnnotationWithNestedEnum_1.java +++ /dev/null @@ -1,17 +0,0 @@ -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -@Target({ElementType.ANNOTATION_TYPE, ElementType.METHOD, ElementType.FIELD, - ElementType.TYPE, ElementType.PARAMETER}) -@Retention(RetentionPolicy.RUNTIME) -public @interface JavaAnnotationWithNestedEnum_1 -{ - public Value value() default Value.VALUE; - - public enum Value - { - VALUE; - } -} \ No newline at end of file diff --git a/test/files/run/t6548/Test_2.scala b/test/files/run/t6548/Test_2.scala deleted file mode 100644 index 6e4f6ba92a..0000000000 --- a/test/files/run/t6548/Test_2.scala +++ /dev/null @@ -1,12 +0,0 @@ -import scala.reflect.runtime.universe._ -import scala.reflect.runtime.{currentMirror => cm} - -class Bean { - @JavaAnnotationWithNestedEnum_1(JavaAnnotationWithNestedEnum_1.Value.VALUE) - def value = 1 -} - -object Test extends App { - println(cm.staticClass("Bean").isCaseClass) - println(typeOf[Bean].declaration(newTermName("value")).annotations) -} diff --git a/test/files/run/t6989.check b/test/files/run/t6989.check index 8943792115..3a94f6e8df 100644 --- a/test/files/run/t6989.check +++ b/test/files/run/t6989.check @@ -113,6 +113,18 @@ isProtected = false isPublic = false privateWithin = ============ +sym = class $PrivateJavaClass, signature = ClassInfoType(...), owner = class JavaClass_1 +isPrivate = true +isProtected = false +isPublic = false +privateWithin = +============ +sym = value this$0, signature = foo.JavaClass_1, owner = class $PrivateJavaClass +isPrivate = false +isProtected = false +isPublic = false +privateWithin = package foo +============ sym = class $ProtectedJavaClass, signature = ClassInfoType(...), owner = class JavaClass_1 isPrivate = false isProtected = true @@ -131,6 +143,18 @@ isProtected = false isPublic = false privateWithin = package foo ============ +sym = class $ProtectedJavaClass, signature = ClassInfoType(...), owner = class JavaClass_1 +isPrivate = false +isProtected = true +isPublic = false +privateWithin = package foo +============ +sym = value this$0, signature = foo.JavaClass_1, owner = class $ProtectedJavaClass +isPrivate = false +isProtected = false +isPublic = false +privateWithin = package foo +============ sym = class $PublicJavaClass, signature = ClassInfoType(...), owner = class JavaClass_1 isPrivate = false isProtected = false @@ -155,55 +179,97 @@ isProtected = false isPublic = true privateWithin = ============ -sym = constructor JavaClass_1, signature = ()foo.JavaClass_1, owner = class JavaClass_1 +sym = class $PublicJavaClass, signature = ClassInfoType(...), owner = class JavaClass_1 isPrivate = false isProtected = false isPublic = true privateWithin = ============ -sym = object JavaClass_1, signature = foo.JavaClass_1.type, owner = package foo +sym = constructor $PublicJavaClass, signature = (x$1: foo.JavaClass_1)JavaClass_1.this.$PublicJavaClass, owner = class $PublicJavaClass +isPrivate = false +isProtected = false +isPublic = true +privateWithin = +============ +sym = value this$0, signature = foo.JavaClass_1, owner = class $PublicJavaClass +isPrivate = false +isProtected = false +isPublic = false +privateWithin = package foo +============ +sym = constructor JavaClass_1, signature = ()foo.JavaClass_1, owner = class JavaClass_1 isPrivate = false isProtected = false isPublic = true privateWithin = ============ -sym = class PrivateStaticJavaClass, signature = ClassInfoType(...), owner = object JavaClass_1 +sym = class PrivateStaticJavaClass, signature = ClassInfoType(...), owner = class JavaClass_1 isPrivate = true isProtected = false isPublic = false privateWithin = ============ -sym = object PrivateStaticJavaClass, signature = foo.JavaClass_1.PrivateStaticJavaClass.type, owner = object JavaClass_1 +sym = object PrivateStaticJavaClass, signature = JavaClass_1.this.PrivateStaticJavaClass.type, owner = class JavaClass_1 isPrivate = true isProtected = false isPublic = false privateWithin = ============ -sym = class ProtectedStaticJavaClass, signature = ClassInfoType(...), owner = object JavaClass_1 +sym = class ProtectedStaticJavaClass, signature = ClassInfoType(...), owner = class JavaClass_1 isPrivate = true isProtected = false isPublic = false privateWithin = ============ -sym = object ProtectedStaticJavaClass, signature = foo.JavaClass_1.ProtectedStaticJavaClass.type, owner = object JavaClass_1 +sym = object ProtectedStaticJavaClass, signature = JavaClass_1.this.ProtectedStaticJavaClass.type, owner = class JavaClass_1 isPrivate = true isProtected = false isPublic = false privateWithin = ============ -sym = class PublicStaticJavaClass, signature = ClassInfoType(...), owner = object JavaClass_1 +sym = class PublicStaticJavaClass, signature = ClassInfoType(...), owner = class JavaClass_1 +isPrivate = false +isProtected = false +isPublic = true +privateWithin = +============ +sym = constructor PublicStaticJavaClass, signature = ()JavaClass_1.this.PublicStaticJavaClass, owner = class PublicStaticJavaClass +isPrivate = false +isProtected = false +isPublic = true +privateWithin = +============ +sym = object PublicStaticJavaClass, signature = JavaClass_1.this.PublicStaticJavaClass.type, owner = class JavaClass_1 isPrivate = false isProtected = false isPublic = true privateWithin = ============ -sym = constructor PublicStaticJavaClass, signature = ()foo.JavaClass_1.PublicStaticJavaClass, owner = class PublicStaticJavaClass +sym = object JavaClass_1, signature = foo.JavaClass_1.type, owner = package foo +isPrivate = false +isProtected = false +isPublic = true +privateWithin = +============ +sym = class PrivateStaticJavaClass, signature = ClassInfoType(...), owner = class JavaClass_1 +isPrivate = true +isProtected = false +isPublic = false +privateWithin = +============ +sym = class ProtectedStaticJavaClass, signature = ClassInfoType(...), owner = class JavaClass_1 +isPrivate = true +isProtected = false +isPublic = false +privateWithin = +============ +sym = class PublicStaticJavaClass, signature = ClassInfoType(...), owner = class JavaClass_1 isPrivate = false isProtected = false isPublic = true privateWithin = ============ -sym = object PublicStaticJavaClass, signature = foo.JavaClass_1.PublicStaticJavaClass.type, owner = object JavaClass_1 +sym = constructor PublicStaticJavaClass, signature = ()JavaClass_1.this.PublicStaticJavaClass, owner = class PublicStaticJavaClass isPrivate = false isProtected = false isPublic = true -- cgit v1.2.3 From 348ff4b6176a379dba943a6b6e0dbc71410f454f Mon Sep 17 00:00:00 2001 From: Jason Zaugg Date: Thu, 14 Feb 2013 15:10:58 +0100 Subject: SI-7128 Fix regression in copyToArray for empty arrays --- src/library/scala/collection/Iterator.scala | 2 +- test/files/run/t6827.scala | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) (limited to 'test') diff --git a/src/library/scala/collection/Iterator.scala b/src/library/scala/collection/Iterator.scala index 696bc4ab5c..2bb5bd1df9 100644 --- a/src/library/scala/collection/Iterator.scala +++ b/src/library/scala/collection/Iterator.scala @@ -1111,7 +1111,7 @@ trait Iterator[+A] extends TraversableOnce[A] { * $willNotTerminateInf */ def copyToArray[B >: A](xs: Array[B], start: Int, len: Int): Unit = { - require(start >= 0 && start < xs.length, s"start $start out of range ${xs.length}") + require(start >= 0 && (start < xs.length || xs.length == 0), s"start $start out of range ${xs.length}") var i = start val end = start + math.min(len, xs.length - start) while (i < end && hasNext) { diff --git a/test/files/run/t6827.scala b/test/files/run/t6827.scala index 7e8918e3dc..8e17af09e2 100644 --- a/test/files/run/t6827.scala +++ b/test/files/run/t6827.scala @@ -28,4 +28,7 @@ object Test extends App { tryit("read -1", 0, -1) tryit("invalid read 0", 30, 0) tryit("invalid read -1", 30, -1) + + // okay, see SI-7128 + "...".toIterator.copyToArray(new Array[Char](0), 0, 0) } -- cgit v1.2.3 From bb067d31e4f02cc605146c676031bbfccac639c2 Mon Sep 17 00:00:00 2001 From: Viktor Klang Date: Tue, 19 Feb 2013 18:51:24 +0100 Subject: SI-7146 - Fixing checkinit bug in ExecutionContextImpl and adding test --- .../concurrent/impl/ExecutionContextImpl.scala | 8 ++++---- test/files/jvm/t7146.check | 5 +++++ test/files/jvm/t7146.scala | 23 ++++++++++++++++++++++ 3 files changed, 32 insertions(+), 4 deletions(-) create mode 100644 test/files/jvm/t7146.check create mode 100644 test/files/jvm/t7146.scala (limited to 'test') diff --git a/src/library/scala/concurrent/impl/ExecutionContextImpl.scala b/src/library/scala/concurrent/impl/ExecutionContextImpl.scala index 43b437dbc6..0aa6b37ffc 100644 --- a/src/library/scala/concurrent/impl/ExecutionContextImpl.scala +++ b/src/library/scala/concurrent/impl/ExecutionContextImpl.scala @@ -19,16 +19,16 @@ import scala.util.control.NonFatal private[scala] class ExecutionContextImpl private[impl] (es: Executor, reporter: Throwable => Unit) extends ExecutionContextExecutor { + // Placed here since the creation of the executor needs to read this val + private[this] val uncaughtExceptionHandler: Thread.UncaughtExceptionHandler = new Thread.UncaughtExceptionHandler { + def uncaughtException(thread: Thread, cause: Throwable): Unit = reporter(cause) + } val executor: Executor = es match { case null => createExecutorService case some => some } - private[this] val uncaughtExceptionHandler: Thread.UncaughtExceptionHandler = new Thread.UncaughtExceptionHandler { - def uncaughtException(thread: Thread, cause: Throwable): Unit = reporter(cause) - } - // Implement BlockContext on FJP threads class DefaultThreadFactory(daemonic: Boolean) extends ThreadFactory with ForkJoinPool.ForkJoinWorkerThreadFactory { def wire[T <: Thread](thread: T): T = { diff --git a/test/files/jvm/t7146.check b/test/files/jvm/t7146.check new file mode 100644 index 0000000000..7c76040205 --- /dev/null +++ b/test/files/jvm/t7146.check @@ -0,0 +1,5 @@ +should be scala.concurrent.impl.ExecutionContextImpl == true +should be scala.concurrent.forkjoin.ForkJoinPool == true +should have non-null UncaughtExceptionHandler == true +should be a scala.concurrent.impl.ExecutionContextImpl UncaughtExceptionHandler == true +should just print out on uncaught == true diff --git a/test/files/jvm/t7146.scala b/test/files/jvm/t7146.scala new file mode 100644 index 0000000000..2bd03d6d02 --- /dev/null +++ b/test/files/jvm/t7146.scala @@ -0,0 +1,23 @@ +import java.util.concurrent.Executor +import scala.concurrent._ +import scala.util.control.NoStackTrace + +object Test { + def main(args: Array[String]) { + println("should be scala.concurrent.impl.ExecutionContextImpl == " + + ExecutionContext.global.toString.startsWith("scala.concurrent.impl.ExecutionContextImpl")) + val i = ExecutionContext.global.asInstanceOf[{ def executor: Executor }] + println("should be scala.concurrent.forkjoin.ForkJoinPool == " + + i.executor.toString.startsWith("scala.concurrent.forkjoin.ForkJoinPool")) + val u = i.executor. + asInstanceOf[{ def getUncaughtExceptionHandler: Thread.UncaughtExceptionHandler }]. + getUncaughtExceptionHandler + println("should have non-null UncaughtExceptionHandler == " + (u ne null)) + println("should be a scala.concurrent.impl.ExecutionContextImpl UncaughtExceptionHandler == " + + u.toString.startsWith("scala.concurrent.impl.ExecutionContextImpl")) + print("should just print out on uncaught == ") + u.uncaughtException(Thread.currentThread, new Throwable { + override def printStackTrace() { println("true") } + }) + } +} -- cgit v1.2.3 From dafebd040e938208e26a27dbd1e14c0307021cf0 Mon Sep 17 00:00:00 2001 From: Lukas Rytz Date: Tue, 12 Feb 2013 12:32:20 +0100 Subject: Fix typing idempotency bug with Annotated trees typedAnnotated transforms an Annotated tree into a Typed tree. The original field of the result is set to the Annotated tree. The bug was that typedAnnotated was using the untyped Annotated tree as original, but also set its type. When re-typing later on the same Annotated tree, the typer would consider it as alreadyTyped. This is incorrect, the typer needs to convert Annotated trees to Typed. Also, the Annotated tree only had its type field set, but its children were still untyped. This crashed the compiler lateron, non-typed trees would get out of the typing phase. --- .../scala/tools/nsc/typechecker/Typers.scala | 14 ++--- test/files/run/annotatedRetyping.check | 6 +++ test/files/run/annotatedRetyping.scala | 62 ++++++++++++++++++++++ 3 files changed, 73 insertions(+), 9 deletions(-) create mode 100644 test/files/run/annotatedRetyping.check create mode 100644 test/files/run/annotatedRetyping.scala (limited to 'test') diff --git a/src/compiler/scala/tools/nsc/typechecker/Typers.scala b/src/compiler/scala/tools/nsc/typechecker/Typers.scala index 478312116a..cff3f4f0fa 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Typers.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Typers.scala @@ -4153,15 +4153,11 @@ trait Typers extends Modes with Adaptations with Tags { def resultingTypeTree(tpe: Type) = { // we need symbol-ful originals for reification // hence we go the extra mile to hand-craft tis guy - val original = - if (arg1.isType) - arg1 match { - case tt @ TypeTree() => Annotated(ann, tt.original) - // this clause is needed to correctly compile stuff like "new C @D" or "@(inline @getter)" - case _ => Annotated(ann, arg1) - } - else - tree + val original = arg1 match { + case tt @ TypeTree() => Annotated(ann, tt.original) + // this clause is needed to correctly compile stuff like "new C @D" or "@(inline @getter)" + case _ => Annotated(ann, arg1) + } original setType ann.tpe TypeTree(tpe) setOriginal original setPos tree.pos.focus } diff --git a/test/files/run/annotatedRetyping.check b/test/files/run/annotatedRetyping.check new file mode 100644 index 0000000000..b296a80526 --- /dev/null +++ b/test/files/run/annotatedRetyping.check @@ -0,0 +1,6 @@ +typing List(1, 2).map(((x) => { + val another = scala.Tuple2(t.nt, t.tr): @testAnn match { + case scala.Tuple2(_, _) => 1 + }; + x +})) diff --git a/test/files/run/annotatedRetyping.scala b/test/files/run/annotatedRetyping.scala new file mode 100644 index 0000000000..cf1b0f27b5 --- /dev/null +++ b/test/files/run/annotatedRetyping.scala @@ -0,0 +1,62 @@ +import scala.tools.partest._ +import scala.tools.nsc._ + +object Test extends DirectTest { + + override def extraSettings: String = "-usejavacp" + + def code = """ + class testAnn extends annotation.Annotation + + object t { + def nt = 1 + def tr = "a" + } + + class Test { + List(1,2).map(x => { + val another = ((t.nt, t.tr): @testAnn) match { case (_, _) => 1 } + x + }) + } + """.trim + + + // point of this test: type-check the "Annotated" tree twice. first time the analyzer plugin types it, + // second time the typer. + + // bug was that typedAnnotated assigned a type to the Annotated tree. The second type check would consider + // the tree as alreadyTyped, which is not cool, the Annotated needs to be transformed into a Typed tree. + + def show() { + val global = newCompiler() + import global._ + import analyzer._ + import collection.{mutable => m} + + object analyzerPlugin extends AnalyzerPlugin { + val templates: m.Map[Symbol, (Template, Typer)] = m.Map() + override def pluginsTypeSig(tpe: Type, typer: Typer, defTree: Tree, pt: Type): Type = { + defTree match { + case impl: Template => + templates += typer.context.owner -> (impl, typer) + + case dd: DefDef if dd.symbol.isPrimaryConstructor && templates.contains(dd.symbol.owner) => + val (impl, templTyper) = templates(dd.symbol.owner) + for (stat <- impl.body.filterNot(_.isDef)) { + println("typing "+ stat) + val statsOwner = impl.symbol orElse templTyper.context.owner.newLocalDummy(impl.pos) + val tpr = analyzer.newTyper(templTyper.context.make(stat, statsOwner)) + tpr.typed(stat) + } + + case _ => + } + tpe + } + } + + addAnalyzerPlugin(analyzerPlugin) + compileString(global)(code) + } +} -- cgit v1.2.3 From 26be2067a9dcc0aa44063aa94581d970427c8ad6 Mon Sep 17 00:00:00 2001 From: Jason Zaugg Date: Mon, 18 Feb 2013 12:06:19 +0100 Subject: Additional test case for Lukas' fix to annotated originals. This was inspired by the regression that Mark encountered when upgrading SBT from 2.10.0 to 2.10.1-RC1. --- test/files/pos/annotated-original/C_2.scala | 7 +++++++ test/files/pos/annotated-original/M_1.scala | 7 +++++++ 2 files changed, 14 insertions(+) create mode 100644 test/files/pos/annotated-original/C_2.scala create mode 100644 test/files/pos/annotated-original/M_1.scala (limited to 'test') diff --git a/test/files/pos/annotated-original/C_2.scala b/test/files/pos/annotated-original/C_2.scala new file mode 100644 index 0000000000..36a09ffe0c --- /dev/null +++ b/test/files/pos/annotated-original/C_2.scala @@ -0,0 +1,7 @@ +object Bug { + M.m { + def s = "" + M.m(s): @unchecked // error: macro has not been expanded. + ??? + } +} diff --git a/test/files/pos/annotated-original/M_1.scala b/test/files/pos/annotated-original/M_1.scala new file mode 100644 index 0000000000..01654e02cf --- /dev/null +++ b/test/files/pos/annotated-original/M_1.scala @@ -0,0 +1,7 @@ +import language.experimental.macros +import reflect.macros.Context + +object M { + def impl(c: Context)(a: c.Expr[Any]) = c.Expr[Any](c.resetLocalAttrs(a.tree)) + def m(a: Any) = macro impl +} -- cgit v1.2.3 From 1976d9fd780c2220178113503841504b39b419a7 Mon Sep 17 00:00:00 2001 From: Eugene Burmako Date: Sat, 23 Feb 2013 02:33:23 +0100 Subject: fixes the test for SI-7112 Freshly released Java 1.6.0_41 for OSX fails with "IllegalAccessError: tried to access class JavaSimpleEnumeration_1 from class sun.proxy.$Proxy6", and rightfully so, because that class isn't public. I think I will avoid the usual "how could this even work before" in this commit message. --- test/files/run/reflection-java-annotations/JavaSimpleEnumeration_1.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'test') diff --git a/test/files/run/reflection-java-annotations/JavaSimpleEnumeration_1.java b/test/files/run/reflection-java-annotations/JavaSimpleEnumeration_1.java index 39246141cc..5f4dcce8a7 100644 --- a/test/files/run/reflection-java-annotations/JavaSimpleEnumeration_1.java +++ b/test/files/run/reflection-java-annotations/JavaSimpleEnumeration_1.java @@ -1,4 +1,4 @@ -enum JavaSimpleEnumeration_1 { +public enum JavaSimpleEnumeration_1 { FOO, BAR } \ No newline at end of file -- cgit v1.2.3 From de1f74990aa5321a47dd1366a1e283f2ca8a4e6f Mon Sep 17 00:00:00 2001 From: Jason Zaugg Date: Mon, 25 Feb 2013 11:37:14 +0100 Subject: SI-7180 Fix regression in implicit scope of HK type alias. We actually need to call normalize here, otherwise we don't progress through #1 below. [infer implicit] scala.this.Predef.implicitly[Higher[Foo.Bar]] with pt=Higher[Foo.Bar] in object Foo 1. tp=Foo.Bar tp.normalize=[A <: ]Foo.Bar[A] tp.dealias=Foo.Bar 2. tp=Foo.Bar[A] tp.normalize=Box[A] tp.dealias=Box[A] --- src/compiler/scala/tools/nsc/typechecker/Implicits.scala | 2 +- test/files/pos/t7180.scala | 13 +++++++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) create mode 100644 test/files/pos/t7180.scala (limited to 'test') diff --git a/src/compiler/scala/tools/nsc/typechecker/Implicits.scala b/src/compiler/scala/tools/nsc/typechecker/Implicits.scala index d1cf9b1904..3bea049c59 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Implicits.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Implicits.scala @@ -1015,7 +1015,7 @@ trait Implicits { args foreach (getParts(_)) } } else if (sym.isAliasType) { - getParts(tp.dealias) + getParts(tp.normalize) // SI-7180 Normalize needed to expand HK type refs } else if (sym.isAbstractType) { getParts(tp.bounds.hi) } diff --git a/test/files/pos/t7180.scala b/test/files/pos/t7180.scala new file mode 100644 index 0000000000..15582f6df3 --- /dev/null +++ b/test/files/pos/t7180.scala @@ -0,0 +1,13 @@ +trait Higher[F[_]] + +trait Box[A] +object Box { + implicit def HigherBox = new Higher[Box] {} +} + +object Foo { + val box = implicitly[Higher[Box]] // compiles fine !!! + + type Bar[A] = Box[A] + val bar = implicitly[Higher[Bar]] // <-- this doesn't compile in 2.10.1-RC1, but does in 2.10.0 !!! +} -- cgit v1.2.3