summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/compiler/scala/tools/nsc/ast/TreeGen.scala6
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/RefChecks.scala2
-rw-r--r--test/files/run/t1537.check2
-rw-r--r--test/files/run/t1537.scala18
-rw-r--r--test/files/run/t3932.check6
-rw-r--r--test/files/run/t3932.scala35
6 files changed, 64 insertions, 5 deletions
diff --git a/src/compiler/scala/tools/nsc/ast/TreeGen.scala b/src/compiler/scala/tools/nsc/ast/TreeGen.scala
index 253d259af1..a47200a63d 100644
--- a/src/compiler/scala/tools/nsc/ast/TreeGen.scala
+++ b/src/compiler/scala/tools/nsc/ast/TreeGen.scala
@@ -293,10 +293,8 @@ abstract class TreeGen {
def mkCachedModuleAccessDef(accessor: Symbol, mvar: Symbol) =
DefDef(accessor, mkCached(mvar, newModule(accessor, mvar.tpe)))
- // def m: T = new tpe(...)
- // where (...) are eventual outer accessors
- def mkModuleAccessDef(accessor: Symbol, tpe: Type) =
- DefDef(accessor, newModule(accessor, tpe))
+ def mkModuleAccessDef(accessor: Symbol, msym: Symbol) =
+ DefDef(accessor, Select(This(msym.owner), msym))
def newModule(accessor: Symbol, tpe: Type) =
New(TypeTree(tpe),
diff --git a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
index fd8d8274d3..17048f691a 100644
--- a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala
@@ -965,7 +965,7 @@ abstract class RefChecks extends InfoTransform {
val ddef =
atPhase(phase.next) {
localTyper.typed {
- gen.mkModuleAccessDef(factory, sym.tpe)
+ gen.mkModuleAccessDef(factory, sym)
}
}
transformTrees(List(cdef, ddef))
diff --git a/test/files/run/t1537.check b/test/files/run/t1537.check
new file mode 100644
index 0000000000..0be5d980da
--- /dev/null
+++ b/test/files/run/t1537.check
@@ -0,0 +1,2 @@
+true
+true \ No newline at end of file
diff --git a/test/files/run/t1537.scala b/test/files/run/t1537.scala
new file mode 100644
index 0000000000..9776f4a279
--- /dev/null
+++ b/test/files/run/t1537.scala
@@ -0,0 +1,18 @@
+trait Syntax {
+ object Foo
+}
+
+trait Evaluation {
+ val syntax: Syntax
+
+ def equalInTrait = this.syntax.Foo == this.syntax.Foo
+}
+
+object Test extends Evaluation with Application {
+ object syntax extends Syntax
+
+ def equalInObject = this.syntax.Foo == this.syntax.Foo
+
+ println(equalInTrait)
+ println(equalInObject)
+}
diff --git a/test/files/run/t3932.check b/test/files/run/t3932.check
new file mode 100644
index 0000000000..5ec39bbdeb
--- /dev/null
+++ b/test/files/run/t3932.check
@@ -0,0 +1,6 @@
+true
+true
+true
+true
+true
+true
diff --git a/test/files/run/t3932.scala b/test/files/run/t3932.scala
new file mode 100644
index 0000000000..f577ef8315
--- /dev/null
+++ b/test/files/run/t3932.scala
@@ -0,0 +1,35 @@
+class Foo
+
+abstract class C {
+ val f: Foo
+ def g1 = (f == f)
+}
+object O1 extends C {
+ val f = new Foo()
+ def g2 = (f == f)
+}
+object O2 extends C {
+ object f extends Foo
+ def g2 = (f == f)
+}
+
+class O3 extends C {
+ object f extends Foo
+ def g2 = (f == f)
+}
+
+
+object Test {
+ def main(args: Array[String]): Unit = {
+ println(O1.g1)
+ println(O1.g2)
+
+ println(O2.g1)
+ println(O2.g2)
+
+ val o3 = new O3()
+ println(o3.g1)
+ println(o3.g2)
+
+ }
+}