diff options
author | Paul Phillips <paulp@improving.org> | 2013-06-03 17:42:15 -0700 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2013-06-03 17:42:15 -0700 |
commit | 1472dadd03496aa89624c81ded01edeb71420cc3 (patch) | |
tree | 9d25317ecd880de24c8a4218c88320813e855132 /test | |
parent | f89f2d969fa0ed0a6bf036a1f6a9cad8267a7265 (diff) | |
parent | d2faeb9ae60389668f1b5f45eb91c73127401e40 (diff) | |
download | scala-1472dadd03496aa89624c81ded01edeb71420cc3.tar.gz scala-1472dadd03496aa89624c81ded01edeb71420cc3.tar.bz2 scala-1472dadd03496aa89624c81ded01edeb71420cc3.zip |
Merge pull request #2609 from retronym/ticket/7507
SI-7507 Fix lookup of private[this] member in presence of self type.
Diffstat (limited to 'test')
-rw-r--r-- | test/files/neg/t7507.check | 4 | ||||
-rw-r--r-- | test/files/neg/t7507.scala | 7 | ||||
-rw-r--r-- | test/files/run/t7507.scala | 31 |
3 files changed, 42 insertions, 0 deletions
diff --git a/test/files/neg/t7507.check b/test/files/neg/t7507.check new file mode 100644 index 0000000000..d402869fd4 --- /dev/null +++ b/test/files/neg/t7507.check @@ -0,0 +1,4 @@ +t7507.scala:6: error: value bippy in trait Cake cannot be accessed in Cake + locally(bippy) + ^ +one error found diff --git a/test/files/neg/t7507.scala b/test/files/neg/t7507.scala new file mode 100644 index 0000000000..1b4756d955 --- /dev/null +++ b/test/files/neg/t7507.scala @@ -0,0 +1,7 @@ +trait Cake extends Slice { + private[this] val bippy = () +} + +trait Slice { self: Cake => + locally(bippy) +} diff --git a/test/files/run/t7507.scala b/test/files/run/t7507.scala new file mode 100644 index 0000000000..6c1959ddac --- /dev/null +++ b/test/files/run/t7507.scala @@ -0,0 +1,31 @@ +trait Cake extends Slice + +// Minimization +trait Slice { self: Cake => // must have self type that extends `Slice` + private[this] val bippy = () // must be private[this] + locally(bippy) +} + +// Originally reported bug: +trait Cake1 extends Slice1 +trait Slice1 { self: Cake1 => + import java.lang.String // any import will do! + val Tuple2(x, y) = ((1, 2)) +} + + +// Nesting +trait Cake3 extends Outer.Slice3 + +// Minimization +object Outer { + private[this] val bippy = () + trait Slice3 { self: Cake3 => + locally(bippy) + } +} + +object Test extends App { + val s1 = new Cake1 {} + assert((s1.x, s1.y) == (1, 2), (s1.x, s1.y)) +} |