diff options
Diffstat (limited to 'test/files')
43 files changed, 551 insertions, 190 deletions
diff --git a/test/files/jvm/innerClassAttribute/Test.scala b/test/files/jvm/innerClassAttribute/Test.scala index 5c666a615f..288c6ee30f 100644 --- a/test/files/jvm/innerClassAttribute/Test.scala +++ b/test/files/jvm/innerClassAttribute/Test.scala @@ -298,7 +298,7 @@ object Test extends BytecodeTest { assertEnclosingMethod ("SI_9105$B$5" , "SI_9105", "m$1", "()Ljava/lang/Object;") assertEnclosingMethod ("SI_9105$C$1" , "SI_9105", null , null) assertEnclosingMethod ("SI_9105$D$1" , "SI_9105", "met", "()Lscala/Function1;") - assertEnclosingMethod ("SI_9105$E$1" , "SI_9105", "m$3", "()Ljava/lang/Object;") + assertEnclosingMethod ("SI_9105$E$1" , "SI_9105", "m$2", "()Ljava/lang/Object;") assertEnclosingMethod ("SI_9105$F$1" , "SI_9105", "met", "()Lscala/Function1;") assertNoEnclosingMethod("SI_9105") @@ -311,7 +311,7 @@ object Test extends BytecodeTest { // by-name assertEnclosingMethod("SI_9105$G$1", "SI_9105", null , null) - assertEnclosingMethod("SI_9105$H$1", "SI_9105", "m$2", "()Ljava/lang/Object;") + assertEnclosingMethod("SI_9105$H$1", "SI_9105", "m$3", "()Ljava/lang/Object;") assertEnclosingMethod("SI_9105$I$1", "SI_9105", null , null) assertEnclosingMethod("SI_9105$J$1", "SI_9105", "bnM", "()I") assertEnclosingMethod("SI_9105$K$2", "SI_9105", "m$4", "()Ljava/lang/Object;") @@ -323,11 +323,11 @@ object Test extends BytecodeTest { def testSI_9124() { val classes: Map[String, String] = { List("SI_9124$$anon$10", - "SI_9124$$anon$11", "SI_9124$$anon$12", + "SI_9124$$anon$13", "SI_9124$$anon$8", "SI_9124$$anon$9", - "SI_9124$O$$anon$13").map({ name => + "SI_9124$O$$anon$11").map({ name => val node = loadClassNode(name) val fMethod = node.methods.asScala.find(_.name.startsWith("f")).get.name (fMethod, node.name) @@ -380,8 +380,8 @@ object Test extends BytecodeTest { val b3 = assertLocal(_ : InnerClassNode, "ImplClassesAreTopLevel$B3$1", "B3$1", flags = publicAbstractInterface) val b4 = assertLocal(_ : InnerClassNode, "ImplClassesAreTopLevel$B4$1", "B4$1", flags = publicAbstractInterface) - testInner("ImplClassesAreTopLevel$$anon$14", an14, b3) - testInner("ImplClassesAreTopLevel$$anon$15", an15, b2) + testInner("ImplClassesAreTopLevel$$anon$14", an14, b2) + testInner("ImplClassesAreTopLevel$$anon$15", an15, b3) testInner("ImplClassesAreTopLevel$$anon$16", an16, b4) testInner("ImplClassesAreTopLevel$B1", b1) diff --git a/test/files/jvm/javaReflection.check b/test/files/jvm/javaReflection.check index 9e9fe36d14..f3924940e9 100644 --- a/test/files/jvm/javaReflection.check +++ b/test/files/jvm/javaReflection.check @@ -2,13 +2,13 @@ A / A (canon) / A (simple) - declared cls: List(class A$B, interface A$C, class A$D$) - enclosing : null (declaring cls) / null (cls) / null (constr) / null (meth) - properties : false (local) / false (member) -A$$anon$1 / null (canon) / $anon$1 (simple) +A$$anon$2 / null (canon) / $anon$2 (simple) - declared cls: List() - enclosing : null (declaring cls) / class A (cls) / null (constr) / null (meth) - properties : true (local) / false (member) A$$anon$3 / null (canon) / $anon$3 (simple) - declared cls: List() -- enclosing : null (declaring cls) / class A (cls) / null (constr) / null (meth) +- enclosing : null (declaring cls) / class A (cls) / null (constr) / public java.lang.Object A.f() (meth) - properties : true (local) / false (member) A$$anon$4 / null (canon) / $anon$4 (simple) - declared cls: List() @@ -16,7 +16,7 @@ A$$anon$4 / null (canon) / $anon$4 (simple) - properties : true (local) / false (member) A$$anon$5 / null (canon) / $anon$5 (simple) - declared cls: List() -- enclosing : null (declaring cls) / class A (cls) / null (constr) / public java.lang.Object A.f() (meth) +- enclosing : null (declaring cls) / class A (cls) / null (constr) / null (meth) - properties : true (local) / false (member) A$$anon$6 / null (canon) / $anon$6 (simple) - declared cls: List() @@ -38,7 +38,7 @@ A$D$ / A.D$ (canon) / D$ (simple) - declared cls: List(class A$D$B, interface A$D$C, class A$D$D$) - enclosing : class A (declaring cls) / class A (cls) / null (constr) / null (meth) - properties : false (local) / true (member) -A$D$$anon$2 / null (canon) / anon$2 (simple) +A$D$$anon$1 / null (canon) / anon$1 (simple) - declared cls: List() - enclosing : null (declaring cls) / class A$D$ (cls) / null (constr) / null (meth) - properties : true (local) / false (member) 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/t6446-additional.check b/test/files/neg/t6446-additional.check index 45db63317c..23df978cd9 100644 --- a/test/files/neg/t6446-additional.check +++ b/test/files/neg/t6446-additional.check @@ -10,19 +10,18 @@ superaccessors 6 add super accessors in traits and nested classes pickler 8 serialize symbol tables refchecks 9 reference/override checking, translate nested objects uncurry 10 uncurry, translate function values to anonymous classes - fields 11 synthesize accessors and fields + fields 11 synthesize accessors and fields, including bitmaps for la... tailcalls 12 replace tail calls by jumps specialize 13 @specialized-driven class and method specialization explicitouter 14 this refs to outer pointers erasure 15 erase types, add interfaces for traits posterasure 16 clean up erased inline classes - lazyvals 17 allocate bitmaps, translate lazy vals into lazified defs - lambdalift 18 move nested functions to top level - constructors 19 move field definitions into constructors - flatten 20 eliminate inner classes - mixin 21 mixin composition - cleanup 22 platform-specific cleanups, generate reflective calls - delambdafy 23 remove lambdas - jvm 24 generate JVM bytecode - ploogin 25 A sample phase that does so many things it's kind of hard... - terminal 26 the last phase during a compilation run + lambdalift 17 move nested functions to top level + constructors 18 move field definitions into constructors + flatten 19 eliminate inner classes + mixin 20 mixin composition + cleanup 21 platform-specific cleanups, generate reflective calls + delambdafy 22 remove lambdas + jvm 23 generate JVM bytecode + ploogin 24 A sample phase that does so many things it's kind of hard... + terminal 25 the last phase during a compilation run diff --git a/test/files/neg/t6446-missing.check b/test/files/neg/t6446-missing.check index 04523d18e6..c0a8fea140 100644 --- a/test/files/neg/t6446-missing.check +++ b/test/files/neg/t6446-missing.check @@ -11,18 +11,17 @@ superaccessors 6 add super accessors in traits and nested classes pickler 8 serialize symbol tables refchecks 9 reference/override checking, translate nested objects uncurry 10 uncurry, translate function values to anonymous classes - fields 11 synthesize accessors and fields + fields 11 synthesize accessors and fields, including bitmaps for la... tailcalls 12 replace tail calls by jumps specialize 13 @specialized-driven class and method specialization explicitouter 14 this refs to outer pointers erasure 15 erase types, add interfaces for traits posterasure 16 clean up erased inline classes - lazyvals 17 allocate bitmaps, translate lazy vals into lazified defs - lambdalift 18 move nested functions to top level - constructors 19 move field definitions into constructors - flatten 20 eliminate inner classes - mixin 21 mixin composition - cleanup 22 platform-specific cleanups, generate reflective calls - delambdafy 23 remove lambdas - jvm 24 generate JVM bytecode - terminal 25 the last phase during a compilation run + lambdalift 17 move nested functions to top level + constructors 18 move field definitions into constructors + flatten 19 eliminate inner classes + mixin 20 mixin composition + cleanup 21 platform-specific cleanups, generate reflective calls + delambdafy 22 remove lambdas + jvm 23 generate JVM bytecode + terminal 24 the last phase during a compilation run diff --git a/test/files/neg/t6446-show-phases.check b/test/files/neg/t6446-show-phases.check index 03f8273c17..cf8595db5d 100644 --- a/test/files/neg/t6446-show-phases.check +++ b/test/files/neg/t6446-show-phases.check @@ -10,18 +10,17 @@ superaccessors 6 add super accessors in traits and nested classes pickler 8 serialize symbol tables refchecks 9 reference/override checking, translate nested objects uncurry 10 uncurry, translate function values to anonymous classes - fields 11 synthesize accessors and fields + fields 11 synthesize accessors and fields, including bitmaps for la... tailcalls 12 replace tail calls by jumps specialize 13 @specialized-driven class and method specialization explicitouter 14 this refs to outer pointers erasure 15 erase types, add interfaces for traits posterasure 16 clean up erased inline classes - lazyvals 17 allocate bitmaps, translate lazy vals into lazified defs - lambdalift 18 move nested functions to top level - constructors 19 move field definitions into constructors - flatten 20 eliminate inner classes - mixin 21 mixin composition - cleanup 22 platform-specific cleanups, generate reflective calls - delambdafy 23 remove lambdas - jvm 24 generate JVM bytecode - terminal 25 the last phase during a compilation run + lambdalift 17 move nested functions to top level + constructors 18 move field definitions into constructors + flatten 19 eliminate inner classes + mixin 20 mixin composition + cleanup 21 platform-specific cleanups, generate reflective calls + delambdafy 22 remove lambdas + jvm 23 generate JVM bytecode + terminal 24 the last phase during a compilation run diff --git a/test/files/neg/t6666.check b/test/files/neg/t6666.check index 090ef72770..bae948fe56 100644 --- a/test/files/neg/t6666.check +++ b/test/files/neg/t6666.check @@ -1,7 +1,7 @@ t6666.scala:23: error: Implementation restriction: access of method x$2 in object O1 from <$anon: Function0>, would require illegal premature access to object O1 F.byname(x) ^ -t6666.scala:30: error: Implementation restriction: access of method x$3 in object O2 from <$anon: Function0>, would require illegal premature access to object O2 +t6666.scala:30: error: Implementation restriction: access of lazy value x$3 in object O2 from <$anon: Function0>, would require illegal premature access to object O2 F.byname(x) ^ t6666.scala:37: error: Implementation restriction: access of method x$4 in object O3 from <$anon: Function0>, would require illegal premature access to object O3 @@ -10,7 +10,7 @@ t6666.scala:37: error: Implementation restriction: access of method x$4 in objec t6666.scala:50: error: Implementation restriction: access of method x$6 in class C1 from <$anon: Function0>, would require illegal premature access to the unconstructed `this` of class C1 F.byname(x) ^ -t6666.scala:54: error: Implementation restriction: access of method x$7 in class C2 from <$anon: Function0>, would require illegal premature access to the unconstructed `this` of class C2 +t6666.scala:54: error: Implementation restriction: access of lazy value x$7 in class C2 from <$anon: Function0>, would require illegal premature access to the unconstructed `this` of class C2 F.byname(x) ^ t6666.scala:58: error: Implementation restriction: access of method x$8 in class C3 from <$anon: Function0>, would require illegal premature access to the unconstructed `this` of class C3 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/t7494-no-options.check b/test/files/neg/t7494-no-options.check index bb143e8644..138d2fe9a3 100644 --- a/test/files/neg/t7494-no-options.check +++ b/test/files/neg/t7494-no-options.check @@ -11,19 +11,18 @@ superaccessors 6 add super accessors in traits and nested classes pickler 8 serialize symbol tables refchecks 9 reference/override checking, translate nested objects uncurry 10 uncurry, translate function values to anonymous classes - fields 11 synthesize accessors and fields + fields 11 synthesize accessors and fields, including bitmaps for la... tailcalls 12 replace tail calls by jumps specialize 13 @specialized-driven class and method specialization explicitouter 14 this refs to outer pointers erasure 15 erase types, add interfaces for traits posterasure 16 clean up erased inline classes - lazyvals 17 allocate bitmaps, translate lazy vals into lazified defs - lambdalift 18 move nested functions to top level - constructors 19 move field definitions into constructors - flatten 20 eliminate inner classes - mixin 21 mixin composition - cleanup 22 platform-specific cleanups, generate reflective calls - delambdafy 23 remove lambdas - jvm 24 generate JVM bytecode - ploogin 25 A sample phase that does so many things it's kind of hard... - terminal 26 the last phase during a compilation run + lambdalift 17 move nested functions to top level + constructors 18 move field definitions into constructors + flatten 19 eliminate inner classes + mixin 20 mixin composition + cleanup 21 platform-specific cleanups, generate reflective calls + delambdafy 22 remove lambdas + jvm 23 generate JVM bytecode + ploogin 24 A sample phase that does so many things it's kind of hard... + terminal 25 the last phase during a compilation run 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 diff --git a/test/files/pos/t5240.scala b/test/files/pos/t5240.scala index 065d175f2f..ae52c6d69a 100644 --- a/test/files/pos/t5240.scala +++ b/test/files/pos/t5240.scala @@ -1,11 +1,3 @@ - - - - - - package object foo { - var labels: Array[_ <: String] = null - } diff --git a/test/files/pos/t8873.scala b/test/files/pos/t8873.scala new file mode 100644 index 0000000000..e2f0a5fad2 --- /dev/null +++ b/test/files/pos/t8873.scala @@ -0,0 +1 @@ +case class X(@volatile var x:Int) diff --git a/test/files/pos/trait_lazy_accessboundary.scala b/test/files/pos/trait_lazy_accessboundary.scala new file mode 100644 index 0000000000..6529816ffb --- /dev/null +++ b/test/files/pos/trait_lazy_accessboundary.scala @@ -0,0 +1,2 @@ +package foo { trait HasLazy { private[foo] lazy val myLazy = "my lady" } } +package bar { class MixInSuperLazy extends foo.HasLazy } diff --git a/test/files/presentation/t5708.check b/test/files/presentation/t5708.check index 4b33893e98..0f24d9626b 100644 --- a/test/files/presentation/t5708.check +++ b/test/files/presentation/t5708.check @@ -35,7 +35,7 @@ final def wait(): Unit final def wait(x$1: Long): Unit final def wait(x$1: Long,x$2: Int): Unit final private[this] val CONST_STRING: String("constant") -lazy private[this] var foo: Int +lazy val foo: Int private[package test] def pkgPrivateM: String private[this] val pkgPrivateV: String ================================================================================ diff --git a/test/files/presentation/t8459.check b/test/files/presentation/t8459.check index 336c147141..4c105d2a00 100644 --- a/test/files/presentation/t8459.check +++ b/test/files/presentation/t8459.check @@ -9,6 +9,7 @@ scala.AnyRef { () }; private[this] val bar: F = new F(); + <stable> <accessor> def bar: F = Foo.this.bar; Foo.this.bar.<selectDynamic: error>("<error>") } ================================================================================ diff --git a/test/files/run/analyzerPlugins.check b/test/files/run/analyzerPlugins.check index ca0005ea4d..64b68db242 100644 --- a/test/files/run/analyzerPlugins.check +++ b/test/files/run/analyzerPlugins.check @@ -1,4 +1,5 @@ adaptBoundsToAnnots(List( <: Int), List(type T), List(Int @testAnn)) [2] +annotationsConform(Boolean @testAnn, Boolean @testAnn) [2] annotationsConform(Boolean @testAnn, Boolean) [1] annotationsConform(Boolean(false), Boolean @testAnn) [1] annotationsConform(Int @testAnn, ?A) [1] @@ -13,7 +14,7 @@ canAdaptAnnotations(Trees$Select, ?) [1] canAdaptAnnotations(Trees$Select, Boolean @testAnn) [1] canAdaptAnnotations(Trees$Select, Boolean) [1] canAdaptAnnotations(Trees$Select, String @testAnn) [1] -canAdaptAnnotations(Trees$TypeTree, ?) [10] +canAdaptAnnotations(Trees$TypeTree, ?) [8] canAdaptAnnotations(Trees$Typed, ?) [3] canAdaptAnnotations(Trees$Typed, Any) [1] canAdaptAnnotations(Trees$Typed, Int) [1] @@ -24,21 +25,21 @@ pluginsPt(?, Trees$ApplyImplicitView) [2] pluginsPt(?, Trees$Block) [4] pluginsPt(?, Trees$ClassDef) [2] pluginsPt(?, Trees$DefDef) [14] -pluginsPt(?, Trees$Ident) [50] +pluginsPt(?, Trees$Ident) [51] pluginsPt(?, Trees$If) [2] pluginsPt(?, Trees$Literal) [16] -pluginsPt(?, Trees$New) [5] +pluginsPt(?, Trees$New) [6] pluginsPt(?, Trees$PackageDef) [1] pluginsPt(?, Trees$Return) [1] -pluginsPt(?, Trees$Select) [43] +pluginsPt(?, Trees$Select) [45] pluginsPt(?, Trees$Super) [2] pluginsPt(?, Trees$This) [13] pluginsPt(?, Trees$TypeApply) [3] pluginsPt(?, Trees$TypeBoundsTree) [2] pluginsPt(?, Trees$TypeDef) [1] -pluginsPt(?, Trees$TypeTree) [38] +pluginsPt(?, Trees$TypeTree) [32] pluginsPt(?, Trees$Typed) [1] -pluginsPt(?, Trees$ValDef) [21] +pluginsPt(?, Trees$ValDef) [13] pluginsPt(Any, Trees$Literal) [2] pluginsPt(Any, Trees$Typed) [1] pluginsPt(Array[Any], Trees$ArrayValue) [1] @@ -60,7 +61,7 @@ pluginsPt(String, Trees$Ident) [3] pluginsPt(String, Trees$Literal) [1] pluginsPt(String, Trees$Select) [1] pluginsPt(Unit, Trees$Assign) [1] -pluginsPt(testAnn, Trees$Apply) [5] +pluginsPt(testAnn, Trees$Apply) [6] pluginsTypeSig(<none>, Trees$Template) [2] pluginsTypeSig(class A, Trees$ClassDef) [1] pluginsTypeSig(class testAnn, Trees$ClassDef) [1] @@ -70,16 +71,18 @@ pluginsTypeSig(method foo, Trees$DefDef) [1] pluginsTypeSig(method method, Trees$DefDef) [1] pluginsTypeSig(method nested, Trees$DefDef) [1] pluginsTypeSig(type T, Trees$TypeDef) [2] -pluginsTypeSig(value annotField, Trees$ValDef) [2] +pluginsTypeSig(value annotField, Trees$ValDef) [1] +pluginsTypeSig(value count_=, Trees$ValDef) [1] pluginsTypeSig(value f, Trees$ValDef) [1] -pluginsTypeSig(value inferField, Trees$ValDef) [2] -pluginsTypeSig(value lub1, Trees$ValDef) [2] -pluginsTypeSig(value lub2, Trees$ValDef) [2] +pluginsTypeSig(value inferField, Trees$ValDef) [1] +pluginsTypeSig(value lub1, Trees$ValDef) [1] +pluginsTypeSig(value lub2, Trees$ValDef) [1] pluginsTypeSig(value param, Trees$ValDef) [2] pluginsTypeSig(value str, Trees$ValDef) [1] -pluginsTypeSig(value x, Trees$ValDef) [4] -pluginsTypeSig(value y, Trees$ValDef) [4] -pluginsTypeSig(variable count, Trees$ValDef) [3] +pluginsTypeSig(value x, Trees$ValDef) [3] +pluginsTypeSig(value y, Trees$ValDef) [3] +pluginsTypeSig(variable count, Trees$DefDef) [1] +pluginsTypeSig(variable count, Trees$ValDef) [1] pluginsTypeSigAccessor(value annotField) [1] pluginsTypeSigAccessor(value inferField) [1] pluginsTypeSigAccessor(value lub1) [1] @@ -93,7 +96,7 @@ pluginsTyped(()Object, Trees$Select) [1] pluginsTyped(()String, Trees$Ident) [1] pluginsTyped(()String, Trees$TypeApply) [1] pluginsTyped(()scala.annotation.Annotation, Trees$Select) [1] -pluginsTyped(()testAnn, Trees$Select) [10] +pluginsTyped(()testAnn, Trees$Select) [12] pluginsTyped((str: String)A <and> (param: Double)A, Trees$Select) [1] pluginsTyped((x$1: Any)Boolean <and> (x: Double)Boolean <and> (x: Float)Boolean <and> (x: Long)Boolean <and> (x: Int)Boolean <and> (x: Char)Boolean <and> (x: Short)Boolean <and> (x: Byte)Boolean, Trees$Select) [1] pluginsTyped((x$1: Int)Unit, Trees$Select) [1] @@ -106,7 +109,7 @@ pluginsTyped(<notype>, Trees$ClassDef) [2] pluginsTyped(<notype>, Trees$DefDef) [14] pluginsTyped(<notype>, Trees$PackageDef) [1] pluginsTyped(<notype>, Trees$TypeDef) [1] -pluginsTyped(<notype>, Trees$ValDef) [21] +pluginsTyped(<notype>, Trees$ValDef) [13] pluginsTyped(=> Boolean @testAnn, Trees$Select) [1] pluginsTyped(=> Double, Trees$Select) [1] pluginsTyped(=> Int, Trees$Select) [5] @@ -122,7 +125,7 @@ pluginsTyped(Any, Trees$TypeTree) [1] pluginsTyped(AnyRef, Trees$Select) [4] pluginsTyped(Array[Any], Trees$ArrayValue) [1] pluginsTyped(Boolean @testAnn, Trees$Select) [1] -pluginsTyped(Boolean @testAnn, Trees$TypeTree) [4] +pluginsTyped(Boolean @testAnn, Trees$TypeTree) [3] pluginsTyped(Boolean(false), Trees$Literal) [1] pluginsTyped(Boolean, Trees$Apply) [1] pluginsTyped(Boolean, Trees$Select) [3] @@ -139,15 +142,15 @@ pluginsTyped(Int, Trees$Apply) [1] pluginsTyped(Int, Trees$Ident) [1] pluginsTyped(Int, Trees$If) [1] pluginsTyped(Int, Trees$Select) [12] -pluginsTyped(Int, Trees$TypeTree) [13] +pluginsTyped(Int, Trees$TypeTree) [10] pluginsTyped(List[Any], Trees$Apply) [1] pluginsTyped(List[Any], Trees$Select) [1] -pluginsTyped(List[Any], Trees$TypeTree) [3] +pluginsTyped(List[Any], Trees$TypeTree) [2] pluginsTyped(Nothing, Trees$Return) [1] pluginsTyped(Object, Trees$Apply) [1] pluginsTyped(String @testAnn, Trees$Ident) [1] pluginsTyped(String @testAnn, Trees$Select) [1] -pluginsTyped(String @testAnn, Trees$TypeTree) [4] +pluginsTyped(String @testAnn, Trees$TypeTree) [3] pluginsTyped(String(""), Trees$Literal) [2] pluginsTyped(String("huhu"), Trees$Literal) [1] pluginsTyped(String("str") @testAnn, Trees$Typed) [1] @@ -156,13 +159,13 @@ pluginsTyped(String("two"), Trees$Literal) [2] pluginsTyped(String, Trees$Apply) [2] pluginsTyped(String, Trees$Block) [2] pluginsTyped(String, Trees$Select) [7] -pluginsTyped(String, Trees$TypeTree) [7] +pluginsTyped(String, Trees$TypeTree) [6] pluginsTyped(Unit, Trees$Apply) [2] pluginsTyped(Unit, Trees$Assign) [1] pluginsTyped(Unit, Trees$Block) [4] pluginsTyped(Unit, Trees$If) [1] pluginsTyped(Unit, Trees$Literal) [5] -pluginsTyped(Unit, Trees$TypeTree) [1] +pluginsTyped(Unit, Trees$TypeTree) [2] pluginsTyped([A](xs: A*)List[A], Trees$Select) [1] pluginsTyped([T <: Int]=> Int, Trees$Select) [1] pluginsTyped([T0]()T0, Trees$Select) [1] @@ -176,9 +179,9 @@ pluginsTyped(scala.collection.immutable.List.type, Trees$Select) [2] pluginsTyped(scala.collection.immutable.StringOps, Trees$ApplyImplicitView) [2] pluginsTyped(scala.collection.mutable.WrappedArray[Any], Trees$Apply) [1] pluginsTyped(str.type, Trees$Ident) [3] -pluginsTyped(testAnn, Trees$Apply) [5] -pluginsTyped(testAnn, Trees$Ident) [5] -pluginsTyped(testAnn, Trees$New) [5] +pluginsTyped(testAnn, Trees$Apply) [6] +pluginsTyped(testAnn, Trees$Ident) [6] +pluginsTyped(testAnn, Trees$New) [6] pluginsTyped(testAnn, Trees$This) [1] pluginsTyped(testAnn, Trees$TypeTree) [2] pluginsTyped(testAnn.super.type, Trees$Super) [1] diff --git a/test/files/run/compiler-asSeenFrom.check b/test/files/run/compiler-asSeenFrom.check index 7305504115..46ea4d3685 100644 --- a/test/files/run/compiler-asSeenFrom.check +++ b/test/files/run/compiler-asSeenFrom.check @@ -332,11 +332,6 @@ value dZ { // after parser val cD: ll.C[List[T3]] } -value dZ { // after parser - private[this] val cD: ll.C[List[T3]] - val cD: ll.C[List[T3]] -} - value dZ { // after uncurry private[this] val cD: ll.C[List[T3]] val cD(): ll.C[List[T3]] @@ -347,11 +342,9 @@ value dZ { // after erasure val cD(): ll.C } -value jZ { // after parser - def thisI(): I.this.type - def thisC(): C.this.type - def t2(): T2 - def t1(): T1 +value dZ { // after parser + private[this] val cD: ll.C[List[T3]] + val cD: ll.C[List[T3]] } value jZ { // after parser @@ -393,6 +386,13 @@ value jZ { // after flatten def t1(): Object } +value jZ { // after parser + def thisI(): I.this.type + def thisC(): C.this.type + def t2(): T2 + def t1(): T1 +} + method kz { // after parser def thisI(): I.this.type def thisC(): C.this.type diff --git a/test/files/run/delambdafy_t6028.check b/test/files/run/delambdafy_t6028.check index 8b0ae7e9b9..eaba70ee1a 100644 --- a/test/files/run/delambdafy_t6028.check +++ b/test/files/run/delambdafy_t6028.check @@ -42,18 +42,12 @@ package <empty> { <synthetic> <stable> <artifact> def $outer(): T = MethodLocalObject$2.this.$outer; <synthetic> <stable> <artifact> def $outer(): T = MethodLocalObject$2.this.$outer }; - final <stable> private[this] def MethodLocalObject$lzycompute$1(barParam$1: String, MethodLocalObject$module$1: runtime.VolatileObjectRef): T#MethodLocalObject$2.type = { - T.this.synchronized({ - if (MethodLocalObject$module$1.elem.$asInstanceOf[T#MethodLocalObject$2.type]().eq(null)) - MethodLocalObject$module$1.elem = new T#MethodLocalObject$2.type(T.this, barParam$1); - scala.runtime.BoxedUnit.UNIT - }); + final <stable> private[this] def MethodLocalObject$1(barParam$1: String, MethodLocalObject$module$1: runtime.VolatileObjectRef): T#MethodLocalObject$2.type = { + if (MethodLocalObject$module$1.elem.$asInstanceOf[T#MethodLocalObject$2.type]().eq(null)) + T.this.synchronized[Unit](if (MethodLocalObject$module$1.elem.$asInstanceOf[T#MethodLocalObject$2.type]().eq(null)) + MethodLocalObject$module$1.elem = new T#MethodLocalObject$2.type(T.this, barParam$1)); MethodLocalObject$module$1.elem.$asInstanceOf[T#MethodLocalObject$2.type]() }; - final <stable> private[this] def MethodLocalObject$1(barParam$1: String, MethodLocalObject$module$1: runtime.VolatileObjectRef): T#MethodLocalObject$2.type = if (MethodLocalObject$module$1.elem.$asInstanceOf[T#MethodLocalObject$2.type]().eq(null)) - T.this.MethodLocalObject$lzycompute$1(barParam$1, MethodLocalObject$module$1) - else - MethodLocalObject$module$1.elem.$asInstanceOf[T#MethodLocalObject$2.type](); final <artifact> private[this] def $anonfun$tryy$1(tryyParam$1: String, tryyLocal$1: runtime.ObjectRef): Unit = try { tryyLocal$1.elem = tryyParam$1 } finally () diff --git a/test/files/run/existential-rangepos.check b/test/files/run/existential-rangepos.check index 1212b60bae..984baeaaf8 100644 --- a/test/files/run/existential-rangepos.check +++ b/test/files/run/existential-rangepos.check @@ -7,7 +7,7 @@ }; [24:51]private[this] val foo: [28]Set[_ <: T] = [47:51]null; [28]<stable> <accessor> def foo: [28]Set[_ <: T] = [28][28]A.this.foo; - [54:74]<stable> <accessor> def bar: [58]Set[_ <: T] + [54:74]<stable> <accessor> val bar: [58]Set[_ <: T] } } diff --git a/test/files/run/idempotency-lazy-vals.check b/test/files/run/idempotency-lazy-vals.check index 15afa5303c..3a6f1a7ef0 100644 --- a/test/files/run/idempotency-lazy-vals.check +++ b/test/files/run/idempotency-lazy-vals.check @@ -5,19 +5,11 @@ C.super.<init>(); () }; - lazy private[this] val x: Int = _; - <stable> <accessor> lazy def x: Int = { - C.this.x = 2; - C.this.x - }; - lazy private[this] val y: Int = _; - implicit <stable> <accessor> lazy def y: Int = { - C.this.y = 3; - C.this.y - } + <stable> <accessor> lazy val x: Int = 2; + implicit <stable> <accessor> lazy val y: Int = 3 }; val c: C = new C(); import c._; c.x.*(Predef.implicitly[Int](c.y)) } -error! +6 diff --git a/test/files/run/lazy-locals-2.scala b/test/files/run/lazy-locals-2.scala new file mode 100644 index 0000000000..d6c33cffcb --- /dev/null +++ b/test/files/run/lazy-locals-2.scala @@ -0,0 +1,322 @@ +object Logs { + val logBuf = new collection.mutable.StringBuilder() + def log(m: Any): Unit = { if (logBuf.nonEmpty) logBuf.append(":"); logBuf.append(m) } + def checkLog(expected: String): Unit = { + val res = logBuf.toString + assert(res == expected, s"expected:\n$expected\nfound:\n$res") + logBuf.clear() + } +} + +import Logs._ + +class C { + def getInt : Int = { log("getInt"); 1 } + def getString: String = { log("getString"); "s" } + def getUnit : Unit = { log("getUnit") } + + lazy val t1 = getInt + lazy val t2 = getString + lazy val t3 = getUnit + checkLog("") + + def m1 = { + lazy val t1 = getInt + t1 + t1 + } + def m2 = { + lazy val t1 = getString + t1 + t1 + } + def m3 = { + lazy val t1 = getUnit + log(t1); log(t1) + } + checkLog("") + + + val vl1 = { + lazy val t1 = getInt + t1 + t1 + } + val vl2 = { + lazy val t1 = getString + t1 + t1 + } + val vl3 = { + lazy val t1 = getUnit + log(t1); log(t1) + } + checkLog("getInt:getString:getUnit:():()") + + + var vr1 = { + lazy val t1 = getInt + t1 + t1 + } + var vr2 = { + lazy val t1 = getString + t1 + t1 + } + var vr3 = { + lazy val t1 = getUnit + log(t1); log(t1) + } + checkLog("getInt:getString:getUnit:():()") + + + lazy val lvl1 = { + lazy val t1 = getInt + t1 + t1 + } + lazy val lvl2 = { + lazy val t1 = getString + t1 + t1 + } + lazy val lvl3 = { + lazy val t1 = getUnit + log(t1); log(t1) + } + checkLog("") + + + { + lazy val t1 = getInt + lazy val t2 = getString + lazy val t3 = getUnit + + log(t1 + t1) + log(t2 + t2) + log(t3); log(t3) + } + checkLog("getInt:2:getString:ss:getUnit:():()") + + + def run(): Unit = { + log(t1); log(t1); + log(t2); log(t2); + log(t3); log(t3); + checkLog("getInt:1:1:getString:s:s:getUnit:():()") + + log(m1); log(m1) + log(m2); log(m2) + log(m3); log(m3) + checkLog("getInt:2:getInt:2:getString:ss:getString:ss:getUnit:():():():getUnit:():():()") + + log(vl1); log(vl1) + log(vl2); log(vl2) + log(vl3); log(vl3) + checkLog("2:2:ss:ss:():()") + + log(vr1); log(vr1); vr1 = 393; log(vr1) + log(vr2); log(vr2); vr2 = "h"; log(vr2) + log(vr3); log(vr3); vr3 = () ; log(vr3) + checkLog("2:2:393:ss:ss:h:():():()") + + log(lvl1); log(lvl1) + log(lvl2); log(lvl2) + log(lvl3); log(lvl3) + checkLog("getInt:2:2:getString:ss:ss:getUnit:():():():()") + } +} + +trait T { + def getInt : Int = { log("getInt"); 1 } + def getString: String = { log("getString"); "s" } + def getUnit : Unit = { log("getUnit") } + + lazy val t1 = getInt + lazy val t2 = getString + lazy val t3 = getUnit + checkLog("") + + def m1 = { + lazy val t1 = getInt + t1 + t1 + } + def m2 = { + lazy val t1 = getString + t1 + t1 + } + def m3 = { + lazy val t1 = getUnit + log(t1); log(t1) + } + checkLog("") + + + val vl1 = { + lazy val t1 = getInt + t1 + t1 + } + val vl2 = { + lazy val t1 = getString + t1 + t1 + } + val vl3 = { + lazy val t1 = getUnit + log(t1); log(t1) + } + checkLog("getInt:getString:getUnit:():()") + + + var vr1 = { + lazy val t1 = getInt + t1 + t1 + } + var vr2 = { + lazy val t1 = getString + t1 + t1 + } + var vr3 = { + lazy val t1 = getUnit + log(t1); log(t1) + } + checkLog("getInt:getString:getUnit:():()") + + + lazy val lvl1 = { + lazy val t1 = getInt + t1 + t1 + } + lazy val lvl2 = { + lazy val t1 = getString + t1 + t1 + } + lazy val lvl3 = { + lazy val t1 = getUnit + log(t1); log(t1) + } + checkLog("") + + + { + lazy val t1 = getInt + lazy val t2 = getString + lazy val t3 = getUnit + + log(t1 + t1) + log(t2 + t2) + log(t3); log(t3) + } + checkLog("getInt:2:getString:ss:getUnit:():()") + + + def run(): Unit = { + log(t1); log(t1); + log(t2); log(t2); + log(t3); log(t3); + checkLog("getInt:1:1:getString:s:s:getUnit:():()") + + log(m1); log(m1) + log(m2); log(m2) + log(m3); log(m3) + checkLog("getInt:2:getInt:2:getString:ss:getString:ss:getUnit:():():():getUnit:():():()") + + log(vl1); log(vl1) + log(vl2); log(vl2) + log(vl3); log(vl3) + checkLog("2:2:ss:ss:():()") + + log(vr1); log(vr1); vr1 = 393; log(vr1) + log(vr2); log(vr2); vr2 = "h"; log(vr2) + log(vr3); log(vr3); vr3 = () ; log(vr3) + checkLog("2:2:393:ss:ss:h:():():()") + + log(lvl1); log(lvl1) + log(lvl2); log(lvl2) + log(lvl3); log(lvl3) + checkLog("getInt:2:2:getString:ss:ss:getUnit:():():():()") + } +} + +class D extends T + +class D1 extends T { + override lazy val t1 = { log("o-t1"); -1 } + checkLog("") + + override def m1 = { log("o-m1"); -2 } + override val m2 = { log("o-m2"); "n" } + override lazy val m3 = { log("o-m3") } + checkLog("o-m2") + + override val vl1 = { log("o-vl1"); -3 } + checkLog("o-vl1") + + override lazy val lvl1 = { log("o-lvl1"); -4 } + checkLog("") + + override def run(): Unit = { + log(t1); log(t1) + checkLog("o-t1:-1:-1") + + log(m1); log(m1) + log(m2); log(m2) + log(m3); log(m3) + checkLog("o-m1:-2:o-m1:-2:n:n:o-m3:():()") + + log(vl1); log(vl1) + checkLog("-3:-3") + + log(lvl1); log(lvl1) + checkLog("o-lvl1:-4:-4") + } +} + +class E { + object T { log("init T"); override def toString = "T" } + def m = { object T { log("init T"); val x = 1 }; T.x } + checkLog("") +} + +object Test { + def main(args: Array[String]): Unit = { + val c = new C + c.run() + + val lzyComputeMethods = c.getClass.getDeclaredMethods.filter(_.getName contains "lzycompute").map(_.getName).toList.sorted + val expComputeMethods = List("lvl1$lzycompute", "lvl2$lzycompute", "lvl3$lzycompute", "t1$lzycompute", "t1$lzycompute$1", "t1$lzycompute$10", "t1$lzycompute$11", "t1$lzycompute$12", "t1$lzycompute$13", "t1$lzycompute$2", "t1$lzycompute$3", "t1$lzycompute$4", "t1$lzycompute$5", "t1$lzycompute$6", "t1$lzycompute$7", "t1$lzycompute$8", "t1$lzycompute$9", "t2$lzycompute", "t2$lzycompute$1", "t3$lzycompute", "t3$lzycompute$1") + assert( + lzyComputeMethods == expComputeMethods, + s"wrong lzycompute methods. expected:\n$expComputeMethods\nfound:\n$lzyComputeMethods") + + val fields = c.getClass.getDeclaredFields.toList.sortBy(_.getName).map(_.toString) + val expFields = List( + "private volatile byte C.bitmap$0", + "private int C.lvl1", + "private java.lang.String C.lvl2", + "private scala.runtime.BoxedUnit C.lvl3", + "private int C.t1", + "private java.lang.String C.t2", + "private scala.runtime.BoxedUnit C.t3", + "private final int C.vl1", + "private final java.lang.String C.vl2", + "private final scala.runtime.BoxedUnit C.vl3", + "private int C.vr1", + "private java.lang.String C.vr2", + "private scala.runtime.BoxedUnit C.vr3") + assert( + fields == expFields, + s"wrong fields. expected:\n$expFields\nfound:\n$fields") + + + val d = new D + d.run() + + val dFields = d.getClass.getDeclaredFields.toList.sortBy(_.getName).map(_.toString) + assert( + dFields == expFields.map(_.replaceAll(" C.", " D.")), + s"wrong fields. expected:\n$expFields\nfound:\n$fields") + + + val d1 = new D1 + d1.run() + + val e = new E + log(e.T); log(e.T) + checkLog("init T:T:T") + log(e.m); log(e.m) + checkLog("init T:1:init T:1") + } +} diff --git a/test/files/run/lazy-locals.check b/test/files/run/lazy-locals.check index 4565326bea..0a3a85ead6 100644 --- a/test/files/run/lazy-locals.check +++ b/test/files/run/lazy-locals.check @@ -1,9 +1,6 @@ lazy-locals.scala:153: warning: a pure expression does nothing in statement position; multiline expressions may require enclosing parentheses { ^ -lazy-locals.scala:159: warning: a pure expression does nothing in statement position; multiline expressions may require enclosing parentheses - { - ^ forced lazy val q q = 10 forced lazy val t diff --git a/test/files/run/lazy_local_labels.check b/test/files/run/lazy_local_labels.check new file mode 100644 index 0000000000..e42c8fb8ce --- /dev/null +++ b/test/files/run/lazy_local_labels.check @@ -0,0 +1,9 @@ +HI +HI +HI +HI +HI +HI +HI +HI +HI diff --git a/test/files/run/lazy_local_labels.scala b/test/files/run/lazy_local_labels.scala new file mode 100644 index 0000000000..f4a1cdf689 --- /dev/null +++ b/test/files/run/lazy_local_labels.scala @@ -0,0 +1,28 @@ +// should print HI nine times to indicate the lazy val has been re-initialized on every iteration +object Test extends App { + def fooDo: Unit = { + var i = 3 + do { + lazy val x = { println("HI"); 1 } + i -= x + } while(i > 0) + } + + def fooWhile: Unit = { + var i = 3 + while(i > 0) { + lazy val x = { println("HI"); 1 } + i -= x + } + } + + @annotation.tailrec def fooTail(i: Int): Unit = { + lazy val x = { println("HI"); 1 } + if (i > 0) fooTail(i - x) + } + + + fooWhile + fooDo + fooTail(3) +} diff --git a/test/files/run/programmatic-main.check b/test/files/run/programmatic-main.check index 03f8273c17..cf8595db5d 100644 --- a/test/files/run/programmatic-main.check +++ b/test/files/run/programmatic-main.check @@ -10,18 +10,17 @@ superaccessors 6 add super accessors in traits and nested classes pickler 8 serialize symbol tables refchecks 9 reference/override checking, translate nested objects uncurry 10 uncurry, translate function values to anonymous classes - fields 11 synthesize accessors and fields + fields 11 synthesize accessors and fields, including bitmaps for la... tailcalls 12 replace tail calls by jumps specialize 13 @specialized-driven class and method specialization explicitouter 14 this refs to outer pointers erasure 15 erase types, add interfaces for traits posterasure 16 clean up erased inline classes - lazyvals 17 allocate bitmaps, translate lazy vals into lazified defs - lambdalift 18 move nested functions to top level - constructors 19 move field definitions into constructors - flatten 20 eliminate inner classes - mixin 21 mixin composition - cleanup 22 platform-specific cleanups, generate reflective calls - delambdafy 23 remove lambdas - jvm 24 generate JVM bytecode - terminal 25 the last phase during a compilation run + lambdalift 17 move nested functions to top level + constructors 18 move field definitions into constructors + flatten 19 eliminate inner classes + mixin 20 mixin composition + cleanup 21 platform-specific cleanups, generate reflective calls + delambdafy 22 remove lambdas + jvm 23 generate JVM bytecode + terminal 24 the last phase during a compilation run diff --git a/test/files/run/showraw_mods.check b/test/files/run/showraw_mods.check index ff77d22adf..5afd7a438f 100644 --- a/test/files/run/showraw_mods.check +++ b/test/files/run/showraw_mods.check @@ -1 +1 @@ -Block(List(ClassDef(Modifiers(ABSTRACT | DEFAULTPARAM/TRAIT), TypeName("C"), List(), Template(List(Ident(TypeName("AnyRef"))), noSelfType, List(DefDef(Modifiers(), TermName("$init$"), List(), List(List()), TypeTree(), Block(List(), Literal(Constant(())))), DefDef(Modifiers(PRIVATE | METHOD | LOCAL | STABLE | ACCESSOR), TermName("x"), List(), List(), TypeTree(), Literal(Constant(2))), DefDef(Modifiers(METHOD | ACCESSOR), TermName("y"), List(), List(), TypeTree(), Select(This(TypeName("C")), TermName("x"))), DefDef(Modifiers(METHOD | ACCESSOR), TermName("y_$eq"), List(), List(List(ValDef(Modifiers(PARAM | SYNTHETIC), TermName("x$1"), TypeTree(), EmptyTree))), TypeTree(), EmptyTree), ValDef(Modifiers(LAZY), TermName("z"), TypeTree(), Select(This(TypeName("C")), TermName("y"))))))), Literal(Constant(()))) +Block(List(ClassDef(Modifiers(ABSTRACT | DEFAULTPARAM/TRAIT), TypeName("C"), List(), Template(List(Ident(TypeName("AnyRef"))), noSelfType, List(DefDef(Modifiers(), TermName("$init$"), List(), List(List()), TypeTree(), Block(List(), Literal(Constant(())))), ValDef(Modifiers(PRIVATE | LOCAL), TermName("x"), TypeTree(), Literal(Constant(2))), ValDef(Modifiers(MUTABLE), TermName("y"), TypeTree(), Select(This(TypeName("C")), TermName("x"))), DefDef(Modifiers(METHOD | ACCESSOR), TermName("y_$eq"), List(), List(List(ValDef(Modifiers(PARAM | SYNTHETIC), TermName("x$1"), TypeTree(), EmptyTree))), TypeTree(), EmptyTree), ValDef(Modifiers(LAZY), TermName("z"), TypeTree(), Select(This(TypeName("C")), TermName("y"))))))), Literal(Constant(()))) diff --git a/test/files/run/t3569.check b/test/files/run/t3569.check index a9fb5ff32e..e0e1d6c405 100644 --- a/test/files/run/t3569.check +++ b/test/files/run/t3569.check @@ -2,6 +2,8 @@ private final int Test$X.val1 private final int Test$X.val2 private final int Test$X.val3 +private int Test$X.const1 +private int Test$X.const2 private int Test$X.lval1 private int Test$X.lval2 private int Test$X.lval3 diff --git a/test/files/run/t3569.scala b/test/files/run/t3569.scala index eb3b424439..7da4de9e95 100644 --- a/test/files/run/t3569.scala +++ b/test/files/run/t3569.scala @@ -4,7 +4,13 @@ object Test { lazy val lv = scala.util.Random.nextInt() - class X(final var x: Int) { + trait T { final lazy val const1 = 1 } // no fields + + class X(final var x: Int) extends T { + // a lazy val does not receive a constant type, for backwards compat (e.g. for the repl) + // besides, since you explicitly wanted something lazy, we'll give you something lazy! (a field and a bitmap) + final lazy val const2 = 2 + final var var1: Int = 0 final private var var2: Int = 0 final private[this] var var3: Int = 0 diff --git a/test/files/run/t5552.check b/test/files/run/t5552.check index a19a60840e..73ad9cf824 100644 --- a/test/files/run/t5552.check +++ b/test/files/run/t5552.check @@ -1,2 +1,6 @@ +lazy: 3 (3,3) +(3,3) +lazy: 3.0 +(3.0,3.0) (3.0,3.0) diff --git a/test/files/run/t5552.scala b/test/files/run/t5552.scala index afb8a1f0be..5b717f9e13 100644 --- a/test/files/run/t5552.scala +++ b/test/files/run/t5552.scala @@ -1,10 +1,14 @@ class C[@specialized(Int) A](a:A) { - lazy val b = (a, a) + lazy val b = {println(s"lazy: $a"); (a, a)} // there should only be two instances of "lazy" in the output def c = b } object Test { def main(args:Array[String]) { - println(new C(3).c) - println(new C(3.0).c) + val cInt = new C(3) + println(cInt.c) + println(cInt.c) + val cFloat = new C(3.0) + println(cFloat.c) + println(cFloat.c) } } diff --git a/test/files/run/t6023.check b/test/files/run/t6023.check index ee93565234..dd6d8f1f1c 100644 --- a/test/files/run/t6023.check +++ b/test/files/run/t6023.check @@ -1,12 +1,12 @@ { abstract trait Foo extends AnyRef { - <stable> <accessor> def a: Int + val a: Int }; () } { abstract trait Foo extends AnyRef { - <stable> <accessor> def a: Int + <stable> <accessor> val a: Int }; () } diff --git a/test/files/run/t6028.check b/test/files/run/t6028.check index 532d177300..d6cc452bbf 100644 --- a/test/files/run/t6028.check +++ b/test/files/run/t6028.check @@ -54,18 +54,12 @@ package <empty> { <synthetic> <stable> <artifact> def $outer(): T = MethodLocalObject$2.this.$outer; <synthetic> <stable> <artifact> def $outer(): T = MethodLocalObject$2.this.$outer }; - final <stable> private[this] def MethodLocalObject$lzycompute$1(barParam$1: Int, MethodLocalObject$module$1: runtime.VolatileObjectRef): T#MethodLocalObject$2.type = { - T.this.synchronized({ - if (MethodLocalObject$module$1.elem.$asInstanceOf[T#MethodLocalObject$2.type]().eq(null)) - MethodLocalObject$module$1.elem = new T#MethodLocalObject$2.type(T.this, barParam$1); - scala.runtime.BoxedUnit.UNIT - }); + final <stable> private[this] def MethodLocalObject$1(barParam$1: Int, MethodLocalObject$module$1: runtime.VolatileObjectRef): T#MethodLocalObject$2.type = { + if (MethodLocalObject$module$1.elem.$asInstanceOf[T#MethodLocalObject$2.type]().eq(null)) + T.this.synchronized[Unit](if (MethodLocalObject$module$1.elem.$asInstanceOf[T#MethodLocalObject$2.type]().eq(null)) + MethodLocalObject$module$1.elem = new T#MethodLocalObject$2.type(T.this, barParam$1)); MethodLocalObject$module$1.elem.$asInstanceOf[T#MethodLocalObject$2.type]() }; - final <stable> private[this] def MethodLocalObject$1(barParam$1: Int, MethodLocalObject$module$1: runtime.VolatileObjectRef): T#MethodLocalObject$2.type = if (MethodLocalObject$module$1.elem.$asInstanceOf[T#MethodLocalObject$2.type]().eq(null)) - T.this.MethodLocalObject$lzycompute$1(barParam$1, MethodLocalObject$module$1) - else - MethodLocalObject$module$1.elem.$asInstanceOf[T#MethodLocalObject$2.type](); @SerialVersionUID(value = 0) final <synthetic> class $anonfun$tryy$1 extends scala.runtime.AbstractFunction0$mcV$sp with Serializable { def <init>($outer: T, tryyParam$1: Int, tryyLocal$1: runtime.IntRef): <$anon: Function0> = { $anonfun$tryy$1.super.<init>(); diff --git a/test/files/run/t6733.check b/test/files/run/t6733.check index 7062301c56..811a7d8f70 100644 --- a/test/files/run/t6733.check +++ b/test/files/run/t6733.check @@ -4,7 +4,6 @@ method pri2a: isPrivateThis = true, isProtectedThis = false variable pri3a: isPrivateThis = true, isProtectedThis = false variable pri3a: isPrivateThis = true, isProtectedThis = false lazy value pri4a: isPrivateThis = true, isProtectedThis = false -lazy value pri4a: isPrivateThis = true, isProtectedThis = false type Pri5a: isPrivateThis = true, isProtectedThis = false class Pri6: isPrivateThis = true, isProtectedThis = false trait Pri7: isPrivateThis = true, isProtectedThis = false @@ -18,7 +17,6 @@ variable pro3a: isPrivateThis = false, isProtectedThis = true variable pro3b: isPrivateThis = false, isProtectedThis = true variable pro3b: isPrivateThis = false, isProtectedThis = true lazy value pro4a: isPrivateThis = false, isProtectedThis = true -lazy value pro4a: isPrivateThis = true, isProtectedThis = false type Pro5a: isPrivateThis = false, isProtectedThis = true type Pro5b: isPrivateThis = false, isProtectedThis = true class Pro6: isPrivateThis = false, isProtectedThis = true diff --git a/test/files/run/trait-fields-override-lazy.check b/test/files/run/trait-fields-override-lazy.check new file mode 100644 index 0000000000..9e4a9fe6c2 --- /dev/null +++ b/test/files/run/trait-fields-override-lazy.check @@ -0,0 +1,2 @@ +warning: there was one feature warning; re-run with -feature for details +ok diff --git a/test/files/run/trait-fields-override-lazy.scala b/test/files/run/trait-fields-override-lazy.scala new file mode 100644 index 0000000000..2c1cf0e3b0 --- /dev/null +++ b/test/files/run/trait-fields-override-lazy.scala @@ -0,0 +1,13 @@ +trait T { + protected lazy val lv: Boolean = ??? +} + +object Test extends App { + val overrideLazy = new T { + override lazy val lv = true + def foo = lv + } + + assert(overrideLazy.foo) + println("ok") +} diff --git a/test/files/scalacheck/quasiquotes/TypecheckedProps.scala b/test/files/scalacheck/quasiquotes/TypecheckedProps.scala index fe07893a36..07bff40f13 100644 --- a/test/files/scalacheck/quasiquotes/TypecheckedProps.scala +++ b/test/files/scalacheck/quasiquotes/TypecheckedProps.scala @@ -103,7 +103,7 @@ object TypecheckedProps extends QuasiquoteProperties("typechecked") val lazyName = TermName("x") val lazyRhsVal = 42 val lazyRhs = Literal(Constant(lazyRhsVal)) - val q"{ $_ ; $mods val $pname: $_ = { $_ = $rhs ; $_ } }" = typecheck(q"{lazy val $lazyName = $lazyRhsVal}") + val q"{ $mods val $pname: $_ = $rhs }" = typecheck(q"{lazy val $lazyName = $lazyRhsVal}") assert(pname == lazyName) assert(rhs ≈ lazyRhs) |