From 10154cf27d4e8f9f9be5411fb6bfb9b8fbe62ebc Mon Sep 17 00:00:00 2001 From: Eugene Burmako Date: Fri, 7 Mar 2014 22:04:04 +0100 Subject: SI-8369 resetAttrs now correctly accounts for skolems MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit resetAttrs (née resetLocalAttrs) has been oblivious to existence of skolems. Not anymore, which prevents us from reverting to the untyper nightmare. --- src/compiler/scala/tools/nsc/ast/Trees.scala | 3 ++- test/files/pos/t8369a.check | 0 test/files/pos/t8369a.scala | 5 +++++ test/files/pos/t8369b.check | 0 test/files/pos/t8369b.scala | 18 ++++++++++++++++++ 5 files changed, 25 insertions(+), 1 deletion(-) create mode 100644 test/files/pos/t8369a.check create mode 100644 test/files/pos/t8369a.scala create mode 100644 test/files/pos/t8369b.check create mode 100644 test/files/pos/t8369b.scala diff --git a/src/compiler/scala/tools/nsc/ast/Trees.scala b/src/compiler/scala/tools/nsc/ast/Trees.scala index 9ca06427e8..3652f51153 100644 --- a/src/compiler/scala/tools/nsc/ast/Trees.scala +++ b/src/compiler/scala/tools/nsc/ast/Trees.scala @@ -240,6 +240,7 @@ trait Trees extends scala.reflect.internal.Trees { self: Global => registerLocal(sym.moduleClass) registerLocal(sym.companionClass) registerLocal(sym.companionModule) + registerLocal(sym.deSkolemize) sym match { case sym: TermSymbol => registerLocal(sym.referenced) case _ => ; @@ -309,7 +310,7 @@ trait Trees extends scala.reflect.internal.Trees { self: Global => // if we move these trees into lexical contexts different from their original locations. if (dupl.hasSymbol) { val sym = dupl.symbol - val vetoScope = !brutally && !(locals contains sym) + val vetoScope = !brutally && !(locals contains sym) && !(locals contains sym.deSkolemize) val vetoThis = dupl.isInstanceOf[This] && sym.isPackageClass if (!(vetoScope || vetoThis)) dupl.symbol = NoSymbol } diff --git a/test/files/pos/t8369a.check b/test/files/pos/t8369a.check new file mode 100644 index 0000000000..e69de29bb2 diff --git a/test/files/pos/t8369a.scala b/test/files/pos/t8369a.scala new file mode 100644 index 0000000000..0596fdaf74 --- /dev/null +++ b/test/files/pos/t8369a.scala @@ -0,0 +1,5 @@ +object Bug { + trait Sys[S] + def test[S <: Sys[S]] = read[S]() + def read[S <: Sys[S]](baz: Any = 0): Some[S] = ??? +} \ No newline at end of file diff --git a/test/files/pos/t8369b.check b/test/files/pos/t8369b.check new file mode 100644 index 0000000000..e69de29bb2 diff --git a/test/files/pos/t8369b.scala b/test/files/pos/t8369b.scala new file mode 100644 index 0000000000..8145911db1 --- /dev/null +++ b/test/files/pos/t8369b.scala @@ -0,0 +1,18 @@ +object Bug { + trait Sys[S] { + type Tx + } + + trait Baz[-Tx] + + trait Foo[S <: Sys[S]] { + def bar: Bar[S] = Bar.read[S]() + } + + object Bar { + object NoBaz extends Baz[Any] + + def read[S <: Sys[S]](baz: Baz[S#Tx] = NoBaz): Bar[S] = ??? + } + trait Bar[S <: Sys[S]] +} \ No newline at end of file -- cgit v1.2.3