diff options
Diffstat (limited to 'test/files/pos')
-rw-r--r-- | test/files/pos/infer_override_def_args.flags | 1 | ||||
-rw-r--r-- | test/files/pos/infer_override_def_args.scala | 5 | ||||
-rw-r--r-- | test/files/pos/t7239.scala | 38 | ||||
-rw-r--r-- | test/files/pos/t9178.flags | 1 | ||||
-rw-r--r-- | test/files/pos/t9178.scala | 13 | ||||
-rw-r--r-- | test/files/pos/trait_fields_dependent_conflict.scala | 20 | ||||
-rw-r--r-- | test/files/pos/trait_fields_dependent_rebind.scala | 15 | ||||
-rw-r--r-- | test/files/pos/trait_fields_inherit_double_def.scala | 20 | ||||
-rw-r--r-- | test/files/pos/trait_fields_lambdalift.scala | 22 | ||||
-rw-r--r-- | test/files/pos/trait_fields_nested_private_object.scala | 8 | ||||
-rw-r--r-- | test/files/pos/trait_fields_nested_public_object.scala | 5 | ||||
-rw-r--r-- | test/files/pos/trait_fields_owners.scala | 19 | ||||
-rw-r--r-- | test/files/pos/trait_fields_private_this.scala | 5 | ||||
-rw-r--r-- | test/files/pos/trait_fields_static_fwd.scala | 10 | ||||
-rw-r--r-- | test/files/pos/trait_fields_var_override_deferred.scala | 2 | ||||
-rw-r--r-- | test/files/pos/trait_fields_volatile.scala | 13 | ||||
-rw-r--r-- | test/files/pos/val_infer.scala | 5 |
17 files changed, 150 insertions, 52 deletions
diff --git a/test/files/pos/infer_override_def_args.flags b/test/files/pos/infer_override_def_args.flags new file mode 100644 index 0000000000..d1a8244169 --- /dev/null +++ b/test/files/pos/infer_override_def_args.flags @@ -0,0 +1 @@ +-Yinfer-argument-types
\ No newline at end of file diff --git a/test/files/pos/infer_override_def_args.scala b/test/files/pos/infer_override_def_args.scala new file mode 100644 index 0000000000..ac10720c81 --- /dev/null +++ b/test/files/pos/infer_override_def_args.scala @@ -0,0 +1,5 @@ +abstract class A { def foo(a: Int): A } +class B extends A { + implicit def spackle(x: Int): A = new B + def foo(a) = a +}
\ No newline at end of file diff --git a/test/files/pos/t7239.scala b/test/files/pos/t7239.scala deleted file mode 100644 index 16e9d00f17..0000000000 --- a/test/files/pos/t7239.scala +++ /dev/null @@ -1,38 +0,0 @@ -object Test { - def BrokenMethod(): HasFilter[(Int, String)] = ??? - - trait HasFilter[B] { - def filter(p: B => Boolean) = ??? - } - - trait HasWithFilter { - def withFilter = ??? - } - - object addWithFilter { - trait NoImplicit - implicit def enrich(v: Any) - (implicit F0: NoImplicit): HasWithFilter = ??? - } - - BrokenMethod().withFilter(_ => true) // okay - BrokenMethod().filter(_ => true) // okay - - locally { - import addWithFilter._ - BrokenMethod().withFilter((_: (Int, String)) => true) // okay - } - - locally { - import addWithFilter._ - // adaptToMemberWithArgs sets the type of the tree `x` - // to ErrorType (while in silent mode, so the error is not - // reported. Later, when the fallback from `withFilter` - // to `filter` is attempted, the closure is taken to have - // have the type `<error> => Boolean`, which conforms to - // `(B => Boolean)`. Only later during pickling does the - // defensive check for erroneous types in the tree pick up - // the problem. - BrokenMethod().withFilter(x => true) // erroneous or inaccessible type. - } -} diff --git a/test/files/pos/t9178.flags b/test/files/pos/t9178.flags deleted file mode 100644 index 7de3c0f3ee..0000000000 --- a/test/files/pos/t9178.flags +++ /dev/null @@ -1 +0,0 @@ --Xfatal-warnings -deprecation diff --git a/test/files/pos/t9178.scala b/test/files/pos/t9178.scala deleted file mode 100644 index f2cf20a778..0000000000 --- a/test/files/pos/t9178.scala +++ /dev/null @@ -1,13 +0,0 @@ -// eta expansion to Function0 is problematic (as shown here). -// Perhaps we should we deprecate it? See discussion in the comments of -// on SI-9178. -// -// This test encodes the status quo: no deprecation. -object Test { - def foo(): () => String = () => "" - val f: () => Any = foo - - def main(args: Array[String]): Unit = { - println(f()) // <function0> - } -} diff --git a/test/files/pos/trait_fields_dependent_conflict.scala b/test/files/pos/trait_fields_dependent_conflict.scala new file mode 100644 index 0000000000..afb6f4b0c5 --- /dev/null +++ b/test/files/pos/trait_fields_dependent_conflict.scala @@ -0,0 +1,20 @@ +// derived from test/files/pos/S5.scala + +// compile with -uniqid to see a hint of the trouble +trait N { + // the symbol for self does not get rebound when synthesizing members in C + val self: N = ??? + val n: self.type = self +} + +abstract class M { + val self: N + val n: self.type +} + +abstract class MConflict extends N { + val self: N + val n: self.type +} + +class C extends M with N diff --git a/test/files/pos/trait_fields_dependent_rebind.scala b/test/files/pos/trait_fields_dependent_rebind.scala new file mode 100644 index 0000000000..e2cf4c43c3 --- /dev/null +++ b/test/files/pos/trait_fields_dependent_rebind.scala @@ -0,0 +1,15 @@ +// derived from test/files/pos/S5.scala + +// compile with -uniqid to see a hint of the trouble +trait N { + // the symbol for self does not get rebound when synthesizing members in C + val self: N = ??? + val n: self.type = self +} + +abstract class M { + val self: N + val n: self.type +} + +class C extends M with N diff --git a/test/files/pos/trait_fields_inherit_double_def.scala b/test/files/pos/trait_fields_inherit_double_def.scala new file mode 100644 index 0000000000..8703d6312c --- /dev/null +++ b/test/files/pos/trait_fields_inherit_double_def.scala @@ -0,0 +1,20 @@ +// done +// test/files/trait-defaults/fields.scala:24: error: double definition: +// def signalDelegate_=(x$1: Signalling): Unit at line 24 and +// def signalDelegate_=(x$1: Signalling): Unit at line 24 +// have same type +// class SUB extends IterableSplitter +// ^ +// one error found + +trait Signalling + +trait DelegatedSignalling extends Signalling { + var signalDelegate: Signalling +} + +trait IterableSplitter extends DelegatedSignalling { + var signalDelegate: Signalling = ??? +} + +class SUB extends IterableSplitter
\ No newline at end of file diff --git a/test/files/pos/trait_fields_lambdalift.scala b/test/files/pos/trait_fields_lambdalift.scala new file mode 100644 index 0000000000..62304a5268 --- /dev/null +++ b/test/files/pos/trait_fields_lambdalift.scala @@ -0,0 +1,22 @@ +class Lift { + def foo = { + // this will be captured by the MouseHandler trait, + // which gives rise to a new trait field during LambdaLift + var Clicked = "Clicked" + + def bar = Clicked + + trait MouseHandler { + def mouseClicked = Clicked + bar + } + + class CC extends MouseHandler + + // new C {} + (new CC).mouseClicked + } +} + +object O extends Lift with App { + println(foo) +} diff --git a/test/files/pos/trait_fields_nested_private_object.scala b/test/files/pos/trait_fields_nested_private_object.scala new file mode 100644 index 0000000000..8efc1cb3fa --- /dev/null +++ b/test/files/pos/trait_fields_nested_private_object.scala @@ -0,0 +1,8 @@ +trait NestedObj { + private object O { println("NO") } +} + + +class C extends NestedObj { + def O = ??? +}
\ No newline at end of file diff --git a/test/files/pos/trait_fields_nested_public_object.scala b/test/files/pos/trait_fields_nested_public_object.scala new file mode 100644 index 0000000000..016487fb8a --- /dev/null +++ b/test/files/pos/trait_fields_nested_public_object.scala @@ -0,0 +1,5 @@ +trait NestedObj { + object O { println("NO") } +} + +class C extends NestedObj
\ No newline at end of file diff --git a/test/files/pos/trait_fields_owners.scala b/test/files/pos/trait_fields_owners.scala new file mode 100644 index 0000000000..6aa5572171 --- /dev/null +++ b/test/files/pos/trait_fields_owners.scala @@ -0,0 +1,19 @@ +trait V { + // ok + // error: java.lang.IllegalArgumentException: Could not find proxy for val f: Function1 in List(value f, value v, trait V, package <empty>, package <root>) (currentOwner= value <local V$class> ) + val v = { val f = (x: Int) => x + 1; f(2) } + + // ok + // assertion failed: + // Trying to access the this of another class: tree.symbol = trait V, class symbol = object V$class compilation unit: fields.scala + val developmentVersion = + for { + v <- scalaPropOrNone("maven.version.number") + if v endsWith "-SNAPSHOT" + ov <- scalaPropOrNone("version.number") + } yield ov + + def scalaPropOrNone(name: String): Option[String] = ??? +} + +object O extends V
\ No newline at end of file diff --git a/test/files/pos/trait_fields_private_this.scala b/test/files/pos/trait_fields_private_this.scala new file mode 100644 index 0000000000..8065cc89e6 --- /dev/null +++ b/test/files/pos/trait_fields_private_this.scala @@ -0,0 +1,5 @@ +trait Chars { + private[this] val char2uescapeArray: String = ??? +} + +object Chars extends Chars
\ No newline at end of file diff --git a/test/files/pos/trait_fields_static_fwd.scala b/test/files/pos/trait_fields_static_fwd.scala new file mode 100644 index 0000000000..af2cdad9ff --- /dev/null +++ b/test/files/pos/trait_fields_static_fwd.scala @@ -0,0 +1,10 @@ +trait T { + // Need to mark the synthesized member in the object's module class as notPROTECTED, + // since the trait member will receive this flag later. + // If we don't add notPROTECTED to the synthesized one, the member will not be seen as overriding the trait member. + // Therefore, addForwarders's call to membersBasedOnFlags would see the deferred member in the trait, + // instead of the concrete (desired) one in the class, and thus not create the static forwarder. + protected val propFilename: String = "/" +} + +object P extends T diff --git a/test/files/pos/trait_fields_var_override_deferred.scala b/test/files/pos/trait_fields_var_override_deferred.scala new file mode 100644 index 0000000000..0205326506 --- /dev/null +++ b/test/files/pos/trait_fields_var_override_deferred.scala @@ -0,0 +1,2 @@ +trait SizeChangeEvent { protected var end: Int } +class BackedUpListIterator[E](override protected var end: Int) extends SizeChangeEvent diff --git a/test/files/pos/trait_fields_volatile.scala b/test/files/pos/trait_fields_volatile.scala new file mode 100644 index 0000000000..030b24f187 --- /dev/null +++ b/test/files/pos/trait_fields_volatile.scala @@ -0,0 +1,13 @@ +// This test illustrates the intent of what should work (but didn't for a while during the fields refactoring), +// but it does not actually defend against the regression seen in twitter-util's Scheduler, which I cannot reproduce +// outside the project. The whole project consistently fails to build before, and compiles after the commit +// that includes this test, but this single test file (as well as Scheduler.scala with external dependencies removed) +// compiles both before and after.... +// (https://github.com/twitter/util/blob/6398a56923/util-core/src/main/scala/com/twitter/concurrent/Scheduler.scala#L260-L265) +// There's also a run test that checks that the field in C is actually volatile. +trait Vola { + @volatile private[this] var _vola = "tile" + @volatile var vola = "tile" +} + +class C extends Vola diff --git a/test/files/pos/val_infer.scala b/test/files/pos/val_infer.scala new file mode 100644 index 0000000000..5f82da8393 --- /dev/null +++ b/test/files/pos/val_infer.scala @@ -0,0 +1,5 @@ +class Test { + implicit def s2i(s: String): Int = s.length + trait Base { def foo: Int } + trait Sub extends Base { val foo = "" } +} |