diff options
author | Adriaan Moors <adriaan@lightbend.com> | 2016-07-14 16:52:20 -0700 |
---|---|---|
committer | Adriaan Moors <adriaan@lightbend.com> | 2016-08-29 09:52:04 +0200 |
commit | df3689139c4d4bcd2933364d13b8195c3433eb43 (patch) | |
tree | 0e8a6cbf6a870869a4ffac6e1a90be2cbf9f1320 /test/files/neg | |
parent | a3604707303e4b1f45b6afabccaf00510b281912 (diff) | |
download | scala-df3689139c4d4bcd2933364d13b8195c3433eb43.tar.gz scala-df3689139c4d4bcd2933364d13b8195c3433eb43.tar.bz2 scala-df3689139c4d4bcd2933364d13b8195c3433eb43.zip |
Fields phase expands lazy vals like modules
They remain ValDefs until then.
- remove lazy accessor logic
now that we have a single ValDef for lazy vals,
with the underlying machinery being hidden until the fields phase
leave a `@deprecated def lazyAccessor` for scala-refactoring
- don't skolemize in purely synthetic getters,
but *do* skolemize in lazy accessor during typers
Lazy accessors have arbitrary user code, so have to skolemize.
We exempt the purely synthetic accessors (`isSyntheticAccessor`)
for strict vals, and lazy accessors emitted by the fields phase
to avoid spurious type mismatches due to issues with existentials
(That bug is tracked as https://github.com/scala/scala-dev/issues/165)
When we're past typer, lazy accessors are synthetic,
but before they are user-defined to make this hack less hacky,
we could rework our flag usage to allow for
requiring both the ACCESSOR and the SYNTHETIC bits
to identify synthetic accessors and trigger the exemption.
see also https://github.com/scala/scala-dev/issues/165
ok 7 - pos/existentials-harmful.scala
ok 8 - pos/t2435.scala
ok 9 - pos/existentials.scala
previous attempt: skolemize type of val inside the private[this] val
because its type is only observed from inside the
accessor methods (inside the method scope its existentials are skolemized)
- bean accessors have regular method types, not nullary method types
- must re-infer type for param accessor
some weirdness with scoping of param accessor vals and defs?
- tailcalls detect lazy vals, which are defdefs after fields
- can inline constant lazy val from trait
- don't mix in fields etc for an overridden lazy val
- need try-lift in lazy vals: the assign is not seen in uncurry
because fields does the transform (see run/t2333.scala)
- ensure field members end up final in bytecode
- implicit class companion method: annot filter in completer
- update check: previous error message was tangled up with unrelated
field definitions (`var s` and `val s_scope`),
now it behaves consistently whether those are val/vars or defs
- analyzer plugin check update seems benign, but no way to know...
- error message gen: there is no underlying symbol for a deferred var
look for missing getter/setter instead
- avoid retypechecking valdefs while duplicating for specialize
see pos/spec-private
- Scaladoc uniformly looks to field/accessor symbol
- test updates to innerClassAttribute by Lukas
Diffstat (limited to 'test/files/neg')
-rw-r--r-- | test/files/neg/anytrait.check | 5 | ||||
-rw-r--r-- | test/files/neg/names-defaults-neg.check | 8 | ||||
-rw-r--r-- | test/files/neg/protected-constructors.check | 18 | ||||
-rw-r--r-- | test/files/neg/sabin2.check | 2 | ||||
-rw-r--r-- | test/files/neg/t1838.check | 6 | ||||
-rw-r--r-- | test/files/neg/t4158.check | 6 | ||||
-rw-r--r-- | test/files/neg/t6829.check | 12 | ||||
-rw-r--r-- | test/files/neg/t712.check | 3 | ||||
-rw-r--r-- | test/files/neg/t8217-local-alias-requires-rhs.check | 6 | ||||
-rw-r--r-- | test/files/neg/t963.check | 10 |
10 files changed, 39 insertions, 37 deletions
diff --git a/test/files/neg/anytrait.check b/test/files/neg/anytrait.check index fabe74d379..6d9d681d60 100644 --- a/test/files/neg/anytrait.check +++ b/test/files/neg/anytrait.check @@ -4,4 +4,7 @@ anytrait.scala:3: error: field definition is not allowed in universal trait exte anytrait.scala:5: error: this statement is not allowed in universal trait extending from class Any { x += 1 } ^ -two errors found +anytrait.scala:9: error: field definition is not allowed in universal trait extending from class Any + val y: T + ^ +three errors found diff --git a/test/files/neg/names-defaults-neg.check b/test/files/neg/names-defaults-neg.check index 0a7b1a7157..af164d90ea 100644 --- a/test/files/neg/names-defaults-neg.check +++ b/test/files/neg/names-defaults-neg.check @@ -1,7 +1,3 @@ -names-defaults-neg.scala:65: error: not enough arguments for method apply: (a: Int, b: String)(c: Int*)Fact in object Fact. -Unspecified value parameter b. - val fac = Fact(1)(2, 3) - ^ names-defaults-neg.scala:5: error: type mismatch; found : String("#") required: Int @@ -81,6 +77,10 @@ and method f in object t8 of type (a: Int, b: Object)String match argument types (a: Int,b: String) and expected result type Any println(t8.f(a = 0, b = "1")) // ambiguous reference ^ +names-defaults-neg.scala:65: error: not enough arguments for method apply: (a: Int, b: String)(c: Int*)Fact in object Fact. +Unspecified value parameter b. + val fac = Fact(1)(2, 3) + ^ names-defaults-neg.scala:69: error: wrong number of arguments for pattern A1(x: Int,y: String) A1() match { case A1(_) => () } ^ diff --git a/test/files/neg/protected-constructors.check b/test/files/neg/protected-constructors.check index 0279f5815d..4f076ec993 100644 --- a/test/files/neg/protected-constructors.check +++ b/test/files/neg/protected-constructors.check @@ -1,3 +1,12 @@ +protected-constructors.scala:15: error: class Foo3 in object Ding cannot be accessed in object dingus.Ding + Access to protected class Foo3 not permitted because + enclosing object P in package hungus is not a subclass of + object Ding in package dingus where target is defined + class Bar3 extends Ding.Foo3("abc") + ^ +protected-constructors.scala:15: error: no arguments allowed for nullary constructor Object: ()Object + class Bar3 extends Ding.Foo3("abc") + ^ protected-constructors.scala:17: error: no arguments allowed for nullary constructor Foo1: ()dingus.Foo1 val foo1 = new Foo1("abc") ^ @@ -13,13 +22,4 @@ protected-constructors.scala:19: error: class Foo3 in object Ding cannot be acce object Ding in package dingus where target is defined val foo3 = new Ding.Foo3("abc") ^ -protected-constructors.scala:15: error: class Foo3 in object Ding cannot be accessed in object dingus.Ding - Access to protected class Foo3 not permitted because - enclosing object P in package hungus is not a subclass of - object Ding in package dingus where target is defined - class Bar3 extends Ding.Foo3("abc") - ^ -protected-constructors.scala:15: error: no arguments allowed for nullary constructor Object: ()Object - class Bar3 extends Ding.Foo3("abc") - ^ 5 errors found diff --git a/test/files/neg/sabin2.check b/test/files/neg/sabin2.check index 8a09361069..aa0e8f734c 100644 --- a/test/files/neg/sabin2.check +++ b/test/files/neg/sabin2.check @@ -1,6 +1,6 @@ sabin2.scala:22: error: type mismatch; found : Test.Base#T - required: _7.T where val _7: Test.Base + required: _5.T where val _5: Test.Base a.set(b.get()) // Error ^ one error found diff --git a/test/files/neg/t1838.check b/test/files/neg/t1838.check index a476158c7b..af811a3810 100644 --- a/test/files/neg/t1838.check +++ b/test/files/neg/t1838.check @@ -1,7 +1,7 @@ -t1838.scala:6: error: `sealed' modifier can be used only for classes - sealed val v = 0 - ^ t1838.scala:5: error: `sealed' modifier can be used only for classes sealed def f = 0 ^ +t1838.scala:6: error: `sealed' modifier can be used only for classes + sealed val v = 0 + ^ two errors found diff --git a/test/files/neg/t4158.check b/test/files/neg/t4158.check index af281c52cd..7bac6558f7 100644 --- a/test/files/neg/t4158.check +++ b/test/files/neg/t4158.check @@ -1,7 +1,7 @@ -t4158.scala:3: error: an expression of type Null is ineligible for implicit conversion - var y = null: Int - ^ t4158.scala:2: error: an expression of type Null is ineligible for implicit conversion var x: Int = null ^ +t4158.scala:3: error: an expression of type Null is ineligible for implicit conversion + var y = null: Int + ^ two errors found diff --git a/test/files/neg/t6829.check b/test/files/neg/t6829.check index 914a1c9260..274094f791 100644 --- a/test/files/neg/t6829.check +++ b/test/files/neg/t6829.check @@ -17,32 +17,32 @@ t6829.scala:49: error: not found: value nextState ^ t6829.scala:50: error: type mismatch; found : s.type (with underlying type Any) - required: _53.State where val _53: G + required: _30.State where val _30: G val r = rewards(agent).r(s,a,s2) ^ t6829.scala:50: error: type mismatch; found : a.type (with underlying type Any) - required: _53.Action where val _53: G + required: _30.Action where val _30: G val r = rewards(agent).r(s,a,s2) ^ t6829.scala:50: error: type mismatch; found : s2.type (with underlying type Any) - required: _53.State where val _53: G + required: _30.State where val _30: G val r = rewards(agent).r(s,a,s2) ^ t6829.scala:51: error: type mismatch; found : s.type (with underlying type Any) - required: _50.State + required: _25.State agent.learn(s,a,s2,r): G#Agent ^ t6829.scala:51: error: type mismatch; found : a.type (with underlying type Any) - required: _50.Action + required: _25.Action agent.learn(s,a,s2,r): G#Agent ^ t6829.scala:51: error: type mismatch; found : s2.type (with underlying type Any) - required: _50.State + required: _25.State agent.learn(s,a,s2,r): G#Agent ^ t6829.scala:53: error: not found: value nextState diff --git a/test/files/neg/t712.check b/test/files/neg/t712.check index 831e943063..3f02b4b294 100644 --- a/test/files/neg/t712.check +++ b/test/files/neg/t712.check @@ -1,5 +1,4 @@ -t712.scala:10: error: value self is not a member of B.this.ParentImpl - Note: implicit method coerce is not applicable here because it comes after the application point and it lacks an explicit result type +t712.scala:10: error: overloaded method coerce needs result type implicit def coerce(p : ParentImpl) = p.self; ^ one error found diff --git a/test/files/neg/t8217-local-alias-requires-rhs.check b/test/files/neg/t8217-local-alias-requires-rhs.check index 0d4f0864ba..d970400ff6 100644 --- a/test/files/neg/t8217-local-alias-requires-rhs.check +++ b/test/files/neg/t8217-local-alias-requires-rhs.check @@ -1,9 +1,9 @@ -t8217-local-alias-requires-rhs.scala:6: error: only classes can have declared but undefined members - type B - ^ t8217-local-alias-requires-rhs.scala:3: error: only classes can have declared but undefined members type A ^ +t8217-local-alias-requires-rhs.scala:6: error: only classes can have declared but undefined members + type B + ^ t8217-local-alias-requires-rhs.scala:14: error: only classes can have declared but undefined members def this(a: Any) = { this(); type C } ^ diff --git a/test/files/neg/t963.check b/test/files/neg/t963.check index 483e53c77d..85b64b0bb5 100644 --- a/test/files/neg/t963.check +++ b/test/files/neg/t963.check @@ -1,12 +1,12 @@ +t963.scala:10: error: type mismatch; + found : AnyRef{def x: Integer} + required: AnyRef{val x: Integer} + val y2 : { val x : java.lang.Integer } = new { def x = new java.lang.Integer(r.nextInt) } + ^ t963.scala:14: error: stable identifier required, but y3.x.type found. val w3 : y3.x.type = y3.x ^ t963.scala:17: error: stable identifier required, but y4.x.type found. val w4 : y4.x.type = y4.x ^ -t963.scala:10: error: type mismatch; - found : AnyRef{def x: Integer} - required: AnyRef{val x: Integer} - val y2 : { val x : java.lang.Integer } = new { def x = new java.lang.Integer(r.nextInt) } - ^ three errors found |