summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Implicits.scala10
-rw-r--r--src/reflect/scala/reflect/runtime/JavaMirrors.scala17
-rw-r--r--test/files/pos/t7486.scala8
-rw-r--r--test/files/run/t6989.check84
-rw-r--r--test/files/run/t6989/JavaClass_1.java2
-rw-r--r--test/files/run/t7359.check1
-rw-r--r--test/files/run/t7359/Cyclic_1.java3
-rw-r--r--test/files/run/t7359/Test_2.scala6
8 files changed, 47 insertions, 84 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Implicits.scala b/src/compiler/scala/tools/nsc/typechecker/Implicits.scala
index 770aef5d61..ef87a32c1d 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Implicits.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Implicits.scala
@@ -996,11 +996,15 @@ trait Implicits {
if (divergence || DivergentImplicitRecovery.sym != null) {
if (settings.Xdivergence211.value) DivergingImplicitExpansionError(tree, pt, DivergentImplicitRecovery.sym)(context)
else throw DivergentImplicit
- } else invalidImplicits take 1 foreach { sym =>
- def isSensibleAddendum = pt match {
+ }
+ else if (invalidImplicits.nonEmpty) {
+ val sym = invalidImplicits.head
+ // We don't even dare look if errors are being buffered
+ // !sym.hasFlag(LOCKED) is a hail mary between SI-2206 and SI-7486
+ def isSensibleAddendum = !sym.hasFlag(LOCKED) && (pt match {
case Function1(_, out) => out <:< sym.tpe.finalResultType
case _ => pt <:< sym.tpe.finalResultType
- }
+ })
// Don't pitch in with this theory unless it looks plausible that the
// implicit would have helped
setAddendum(pos, () =>
diff --git a/src/reflect/scala/reflect/runtime/JavaMirrors.scala b/src/reflect/scala/reflect/runtime/JavaMirrors.scala
index ed4458c455..ccc727451c 100644
--- a/src/reflect/scala/reflect/runtime/JavaMirrors.scala
+++ b/src/reflect/scala/reflect/runtime/JavaMirrors.scala
@@ -692,7 +692,8 @@ private[reflect] trait JavaMirrors extends internal.SymbolTable with api.JavaUni
(if (jModifier.isStatic(mods)) module.moduleClass else clazz).info.decls enter sym
for (jinner <- jclazz.getDeclaredClasses) {
- enter(jclassAsScala(jinner, clazz), jinner.getModifiers)
+ jclassAsScala(jinner) // inner class is entered as a side-effect
+ // no need to call enter explicitly
}
pendingLoadActions = { () =>
@@ -1051,13 +1052,17 @@ 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[_]): Symbol = jclassAsScala(jclazz, sOwner(jclazz))
+ private def jclassAsScala(jclazz: jClass[_]): Symbol = {
+ val clazz = sOwner(jclazz) // sOwner called outside of closure for binary compatibility
+ toScala(classCache, jclazz){ (mirror, jclazz) =>
+ mirror.jclassAsScala(jclazz, clazz)
+ }
+ }
private def jclassAsScala(jclazz: jClass[_], owner: Symbol): ClassSymbol = {
- val name = scalaSimpleName(jclazz)
- val completer = (clazz: Symbol, module: Symbol) => new FromJavaClassCompleter(clazz, module, jclazz)
- val (clazz, module) = createClassModule(owner, name, completer)
- classCache enter (jclazz, clazz)
+ val name = scalaSimpleName(jclazz)
+ val completer = (clazz: Symbol, module: Symbol) => new FromJavaClassCompleter(clazz, module, jclazz)
+ val (clazz, _) = createClassModule(owner, name, completer)
clazz
}
diff --git a/test/files/pos/t7486.scala b/test/files/pos/t7486.scala
new file mode 100644
index 0000000000..6dd7f4c4ac
--- /dev/null
+++ b/test/files/pos/t7486.scala
@@ -0,0 +1,8 @@
+object Test{
+ var locker = 0
+ // remove implicit, or change to `locker = locker + 1` to make it compile.
+ implicit val davyJones0 = {
+ locker += 0
+ 0
+ }
+}
diff --git a/test/files/run/t6989.check b/test/files/run/t6989.check
index 3a94f6e8df..8943792115 100644
--- a/test/files/run/t6989.check
+++ b/test/files/run/t6989.check
@@ -113,18 +113,6 @@ isProtected = false
isPublic = false
privateWithin = <none>
============
-sym = class $PrivateJavaClass, signature = ClassInfoType(...), owner = class JavaClass_1
-isPrivate = true
-isProtected = false
-isPublic = false
-privateWithin = <none>
-============
-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
@@ -143,18 +131,6 @@ 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
@@ -179,97 +155,55 @@ isProtected = false
isPublic = true
privateWithin = <none>
============
-sym = class $PublicJavaClass, signature = ClassInfoType(...), owner = class JavaClass_1
-isPrivate = false
-isProtected = false
-isPublic = true
-privateWithin = <none>
-============
-sym = constructor $PublicJavaClass, signature = (x$1: foo.JavaClass_1)JavaClass_1.this.$PublicJavaClass, owner = class $PublicJavaClass
+sym = constructor JavaClass_1, signature = ()foo.JavaClass_1, owner = class JavaClass_1
isPrivate = false
isProtected = false
isPublic = true
privateWithin = <none>
============
-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
+sym = object JavaClass_1, signature = foo.JavaClass_1.type, owner = package foo
isPrivate = false
isProtected = false
isPublic = true
privateWithin = <none>
============
-sym = class PrivateStaticJavaClass, signature = ClassInfoType(...), owner = class JavaClass_1
+sym = class PrivateStaticJavaClass, signature = ClassInfoType(...), owner = object JavaClass_1
isPrivate = true
isProtected = false
isPublic = false
privateWithin = <none>
============
-sym = object PrivateStaticJavaClass, signature = JavaClass_1.this.PrivateStaticJavaClass.type, owner = class JavaClass_1
+sym = object PrivateStaticJavaClass, signature = foo.JavaClass_1.PrivateStaticJavaClass.type, owner = object JavaClass_1
isPrivate = true
isProtected = false
isPublic = false
privateWithin = <none>
============
-sym = class ProtectedStaticJavaClass, signature = ClassInfoType(...), owner = class JavaClass_1
+sym = class ProtectedStaticJavaClass, signature = ClassInfoType(...), owner = object JavaClass_1
isPrivate = true
isProtected = false
isPublic = false
privateWithin = <none>
============
-sym = object ProtectedStaticJavaClass, signature = JavaClass_1.this.ProtectedStaticJavaClass.type, owner = class JavaClass_1
+sym = object ProtectedStaticJavaClass, signature = foo.JavaClass_1.ProtectedStaticJavaClass.type, owner = object JavaClass_1
isPrivate = true
isProtected = false
isPublic = false
privateWithin = <none>
============
-sym = class PublicStaticJavaClass, signature = ClassInfoType(...), owner = class JavaClass_1
-isPrivate = false
-isProtected = false
-isPublic = true
-privateWithin = <none>
-============
-sym = constructor PublicStaticJavaClass, signature = ()JavaClass_1.this.PublicStaticJavaClass, owner = class PublicStaticJavaClass
-isPrivate = false
-isProtected = false
-isPublic = true
-privateWithin = <none>
-============
-sym = object PublicStaticJavaClass, signature = JavaClass_1.this.PublicStaticJavaClass.type, owner = class JavaClass_1
+sym = class PublicStaticJavaClass, signature = ClassInfoType(...), owner = object JavaClass_1
isPrivate = false
isProtected = false
isPublic = true
privateWithin = <none>
============
-sym = object JavaClass_1, signature = foo.JavaClass_1.type, owner = package foo
-isPrivate = false
-isProtected = false
-isPublic = true
-privateWithin = <none>
-============
-sym = class PrivateStaticJavaClass, signature = ClassInfoType(...), owner = class JavaClass_1
-isPrivate = true
-isProtected = false
-isPublic = false
-privateWithin = <none>
-============
-sym = class ProtectedStaticJavaClass, signature = ClassInfoType(...), owner = class JavaClass_1
-isPrivate = true
-isProtected = false
-isPublic = false
-privateWithin = <none>
-============
-sym = class PublicStaticJavaClass, signature = ClassInfoType(...), owner = class JavaClass_1
+sym = constructor PublicStaticJavaClass, signature = ()foo.JavaClass_1.PublicStaticJavaClass, owner = class PublicStaticJavaClass
isPrivate = false
isProtected = false
isPublic = true
privateWithin = <none>
============
-sym = constructor PublicStaticJavaClass, signature = ()JavaClass_1.this.PublicStaticJavaClass, owner = class PublicStaticJavaClass
+sym = object PublicStaticJavaClass, signature = foo.JavaClass_1.PublicStaticJavaClass.type, owner = object JavaClass_1
isPrivate = false
isProtected = false
isPublic = true
diff --git a/test/files/run/t6989/JavaClass_1.java b/test/files/run/t6989/JavaClass_1.java
index eb26a08700..72ec4d6ab6 100644
--- a/test/files/run/t6989/JavaClass_1.java
+++ b/test/files/run/t6989/JavaClass_1.java
@@ -7,6 +7,8 @@ package foo;
// I'm leaving the incorrect results of FromJavaClassCompleters in the check
// file, so that we get notified when something changes there.
+// ^^^ It's not clear what those incorrect results were, but the fix for SI-7359
+// (backport of fix for SI-6548) has probably resolved some of these. OP, please revisit this comment.
class PackagePrivateJavaClass {
private int privateField = 0;
diff --git a/test/files/run/t7359.check b/test/files/run/t7359.check
new file mode 100644
index 0000000000..9766475a41
--- /dev/null
+++ b/test/files/run/t7359.check
@@ -0,0 +1 @@
+ok
diff --git a/test/files/run/t7359/Cyclic_1.java b/test/files/run/t7359/Cyclic_1.java
new file mode 100644
index 0000000000..42b46c1aed
--- /dev/null
+++ b/test/files/run/t7359/Cyclic_1.java
@@ -0,0 +1,3 @@
+abstract class Cyclic {
+ static interface Inner<T extends Inner> { }
+} \ No newline at end of file
diff --git a/test/files/run/t7359/Test_2.scala b/test/files/run/t7359/Test_2.scala
new file mode 100644
index 0000000000..bb6f4cb2d9
--- /dev/null
+++ b/test/files/run/t7359/Test_2.scala
@@ -0,0 +1,6 @@
+import scala.reflect.runtime.universe._
+
+object Test extends App {
+ typeOf[Cyclic].members
+ println("ok")
+} \ No newline at end of file