From c130e19c1cb4f4a1126d543f29a6f0408f25763f Mon Sep 17 00:00:00 2001 From: Paul Phillips Date: Sun, 21 Oct 2012 07:30:38 -0700 Subject: Fix SI-6552, regression with self types. In 6eb55d4b7a we put in a remedy for an old issue SI-4560 which had accumulated a number of sketchy partial remedies which carried no tests to illustrate their necessity. Looks like at least one of those was doing something useful. Here's to reversion-reversion. This reverts commit c8bdf199, which itself reverted cb4fd6582. --- src/compiler/scala/tools/nsc/typechecker/Contexts.scala | 1 + src/reflect/scala/reflect/internal/Types.scala | 8 +++++--- test/files/pos/t6552.scala | 8 ++++++++ 3 files changed, 14 insertions(+), 3 deletions(-) create mode 100644 test/files/pos/t6552.scala diff --git a/src/compiler/scala/tools/nsc/typechecker/Contexts.scala b/src/compiler/scala/tools/nsc/typechecker/Contexts.scala index 211da044e6..b9b17c0277 100644 --- a/src/compiler/scala/tools/nsc/typechecker/Contexts.scala +++ b/src/compiler/scala/tools/nsc/typechecker/Contexts.scala @@ -558,6 +558,7 @@ trait Contexts { self: Analyzer => ( (ab.isTerm || ab == rootMirror.RootClass) || (accessWithin(ab) || accessWithinLinked(ab)) && ( !sym.hasLocalFlag + || sym.owner.isImplClass // allow private local accesses to impl classes || sym.isProtected && isSubThisType(pre, sym.owner) || pre =:= sym.owner.thisType ) diff --git a/src/reflect/scala/reflect/internal/Types.scala b/src/reflect/scala/reflect/internal/Types.scala index ab33c29153..403bf7d492 100644 --- a/src/reflect/scala/reflect/internal/Types.scala +++ b/src/reflect/scala/reflect/internal/Types.scala @@ -1409,9 +1409,11 @@ trait Types extends api.Types { self: SymbolTable => final class UniqueThisType(sym: Symbol) extends ThisType(sym) { } object ThisType extends ThisTypeExtractor { - def apply(sym: Symbol): Type = - if (phase.erasedTypes) sym.tpe - else unique(new UniqueThisType(sym)) + def apply(sym: Symbol): Type = ( + if (!phase.erasedTypes) unique(new UniqueThisType(sym)) + else if (sym.isImplClass) sym.typeOfThis + else sym.tpe + ) } /** A class for singleton types of the form `..type`. diff --git a/test/files/pos/t6552.scala b/test/files/pos/t6552.scala new file mode 100644 index 0000000000..98e686a1ae --- /dev/null +++ b/test/files/pos/t6552.scala @@ -0,0 +1,8 @@ +object Repros { + class Bar {} + class Baz(val myFoo: Foo) { } + trait Foo { + this: Bar => + val thing = new Baz(this) + } +} -- cgit v1.2.3