Skip to content

Commit 8906fcf

Browse files
committed
Add tests
Add tests Add tests Add tests Update Desugar.scala Update InteractiveDriver.scala Update closureLeak.scala Update default-this.scala Update enum.scala Update leak-this-inner.scala Update leak-this.scala Update leak-warm.scala Update local-warm.scala updated test cases updated-default-this updated tests Add tests for cycle structure Add desugared version for enum.scala Update Desugar.scala Update InteractiveDriver.scala Update closureLeak.scala Update default-this.scala Update enum.scala Update leak-this-inner.scala Update leak-this.scala Update leak-warm.scala Update local-warm.scala Comment Typo Fix in Concat Correctly check experimental features - When inlining: emit "experimental" error only when the feature in question is actually annotated as experimental - Compiler-wide: treat non-bootstrapped compiler as experimental-friendly. The motivation is to compile the standard library with experimental features enabled at all times. This change isn't supposed to introduce any experimental features leaks into stable builds since we do not publish non-bootstrapped compiler. Fix #12128: Add test Don't force info to get signature in TreeChecker When we are reading a new definition from tasty and setting `info` of a symbol in `readNewDef`: sym.info = methodType(paramss, resType) The line above will reach `TreeChecker.transformSym`: assert(symd.signature == initial.signature At the time, the `symd` is not yet completed. Getting signature of the denotation will force the symbol and trigger completion of the info, which reaches the `PositionTree` in `readIndexedDef. Fix regression test for #12128 To properly reproduce #12128, the regression test has some atypical classpath requirements in addition to separate compilation. Snippet compiler PoC Reporter fix. Message levels Fix snippet wrapper. Integrate snippet checker with Wiki and Markdown renderers Further implementation of snippet compiler. Add package name and self type to pass context Add arguments to control snippet compiler. Start work on handling hide directives in code snippets Hide irrelevant code snippet fragments in scaladoc Apply review suggestions from PR #11822 Add returning real line of error in source file of snippet for snippet scaladoc compiler Add failing flag Add debug flag. Add addition operation for snippet compiler arg Refactor snippet compiler args Move snippet compiler logic to parsing phase. Refactor debug flag Display snippet compilation messages in scaladoc Apply review changes Run snippet compiler on static sites Further enhancements of snippet contexts Filter non-scala snippets. Report errors in parsing override flags Fix positions in static sites. Enchance snippet wrapping CRs Add and update tests for snippet compiler. Bugfixes found during testing Wrap compiler messages into Try block to avoid lazy exceptions Update branch Fix classpath problems. Add support for scala.js. Add bootclasspath to generateDocumentation task Temporarily turn off snippet checking for scala3 library Change requests from reviews Scala2Unpickler: Don't trust the owner field of tparams When a type parameter of a class external to the current pickle is referenced, Scala 2 will sometimes pickle it as if it was a type parameter of the current class. When we unpickle such a type parameter on our side, we enter it in the class, this leads the compiler to believe the class has more type parameters than it actually has. This doesn't happen in Scala 2 itself because it never enters unpickled type parameters in the class that owns them (it must be recreating them in some way, but I don't know how). It would be interesting to dig deeper to understand exactly how Scala 2 handles type parameter unpickling so we could emulate it given that this is not the first time we run into trouble here (cf #12120), but for now we fix the problem with the following heuristic: once we've loaded all the type parameters of a class (which we do eagerly via `ClassUnpickler#init()`), we simply stop from being entered any subsequent type parameter we see for this class. Time will tell if this is good enough. While I was touching that code, I also made ClassCompleter#completerTypeParams idempotent as one would expect it to be. Fixes #12641. Preserve hard unions in more situations There's multiple places where we take apart a union, apply some transformation to its parts, then either return the original union if nothing changed or recombine the transformed parts into a new union. The problem is that to check if nothing changed we use referential equality when `=:=` would be more correct, so we sometimes end up returning a union equivalent to the original one except the new one is a soft union. I've seen this lead to subtle type inference differences both when experimenting with changes to constraint solving and when trying to replace our Uniques hashmaps by weak hashmaps. We could fix this by replacing these `eq` calls by `=:=` but instead this commit takes the approach of preserving the softness of a union even when its components are modified, see the test case. Fix implicit ValueOf synthesis Foxes #12583 Fix hole in scan for outer references Type tests of singletons need to be considered as well. Fix typo in syntax.md The supertype symbol was ':>' and it was changed to '>:' . Always generate a partial function from a lambda `scalac` no longer complains, neither should `dotc`. I verified that the output of `i4241.scala` is the same for both `scalac` and `dotc`. Fixes #12661 drop unused code Fix test name Extract the function type and SAM in union type (#11760) Fixes #11694. forbid given patterns in val definitions. Suggest that they use an alias given instead. Fix #12544: Add test Add neg test Harden type comparer in presence of kind errors It should not crash when an override has the wrong kind. Fixes #12664 Fix #12546: Handle enum or object in provablyDisjoint A enum or object is provably disjoint with a class A if the module class does not derive from A. Better support type-heavy pattern matches Avoid type cast Fix unreachable code Fix CI Handle enums that have multiple parents Fix #12559: Try decomposable types in isSubspace Fix #12602: Only generate sum mirrors for sealed trait or sealed abstract class Fix #12681: Approximate `ThisType` in child instantiation Fix master: Remove test We will add the test again with a new PR fix #12634 - port sbt/zinc#979 Add sealedDescendants method to SymDenotation - recursive children of a symbol Add Matchable to the parents of Null in explicit nulls Add icons for all members. Add icons for search results. Re-enable the Scala.js test JSOptionalTest212FunParamInference. The issue #11694, which prevented this test from compiling, was fixed in #11760. Bump compiler version to the next one – 3.0.2-RC1 fix #12401: mangle ctor names in ExtractAPI Avoid assertion failure when forcing LazyRef while printing Fixes #12650 The fix that matters for #12650 is the one in Checking. The others generally increase robustness of printing diagnostics when triggering a LazyRef recursion. Drop flaky test Fixes #12693 Deskolemize PatternTypeConstrainer Before this commit, constrainSimplePatternType did a bunch of manipulations and then ran a subtype check. It wrapped one of the types in a SkolemType and replaces type arguments of the other one with wildcards. The point of those manipulations was to make TypeComparer take a specific path and compare appropriate subcomponents of constrainSimplePatternType's arguments. This turned out to be a problem overall. To improve the situation, we instead manually compare the appropriate subcomponents of constrainSimplePatternType - the changes can be seen as inlining pieces of code from TypeComparer. Also, this commit adds restoring the GADT constraint to TypeComparer - this turned out to be more important now that constrainSimplePatternType now does multiple isSubType checks. Fix failing test Add explanatory comments Adjust comments Insert conversions also on selections wrapped in type applications In i12708.scala, the problematic function was a selection `qual.m[tvs]` that was already applied to type variables. In that case we need to backtrack, forget the type variables and try to insert a conversion or extension method on `qual`. Fixes #12708 Fix tests Add 3.0.1-RC1 blog article Remove experimental macro feature mention Co-authored-by: Nicolas Stucki <[email protected]> macros.md: fix parentheses/braces in inlined Macros.assert() example The parantheses and braces where swapped. Also align the style with the follow up example to make it easier to spot the differences. Add regression test for #12723 Deleted unnecessary explanations As a result of replacing 'Dotty' with 'Scala 3' in the following commit, the explanation 'which is scheduled to become Scala 3' is no longer needed. ccb76da Improve display of references for ambiguous implicit errors If the first attempt yields equal strings, print the full path to the implicits instead. Fixes #12591 Reclassify test Add check file Improvements to search UX Pressing "S" while not focused on an input/textarea will now open the search. Pressing "F" while not focused on an input/textarea will focus the member filter input. Pressing Escape while focused on the search/filter will clear the input and close/unfocus it Search result links are now treated as block elements so you can click anywhere inside the rectangle rather than specifically on the result text. also allow '/' to trigger the search Add browsable versions extension for scaladoc Change local storage to session storage, fix bugs with undefined js variable Chagne try catching of undefined scalajs property to js.typeOf Add test for infix operator usage from Scala 2 libraries Fixes #7304 Preserve tvar instantiation in implicit error messages make default colors less harsh, add dark/light theme swapper make dottydoc anchors transparent instead of white when not hovered infer dark theme preference from user's system add some 'missing' semicolons to some JS set min-width on the theme switch so it doesn't get squished Make dark-mode footer actually dark. Improve contrast/accessibility. Used the "poor man's dark mode" approach to deal with the images in the footer in dark mode, i.e. invert and hue rotate (without the hue rotate, the red scala3doc logo becomes blue) Also fix an issue where if you click "back to top" and then refresh the page, the "container" element gains the "expand" class, which causes the main signature (i.e. `class List[A] ...`) to become 'inline' instead of a block, and it also triggers the 6.5em left-margin that's intended for method signatures when they get expanded. Also consolidated the `footer` styles, since they were spread all over. Check CLA for user who opened pull request, not workflow initiator Add regression test Closes #12754 Don't allow wildcard types in constraints Fixes #12677 Only drop wildcards for necesessary comparisons Wildcards in constraints essentially mean that the constrained variable is a sub/supertype of _every_ instance of the bound. For useNecesaryEither, this is wrong. Approximate the bound not to use wildcards instead. drop all kinds of WildcardType under useNecessaryEither better bounds for wildcards in resultTypeApprox Avoid wildcard types in constraints Ther semantics is fishy. Instead, use avoidance in necessarySubType and in TypeVarsMiss context mode, and use fresh type variables elsehwere. Cleanup addOneBound logic Verify that constraints do not contain wildcard types Cleanups Streamline approximateWildcards logic Test assertion Don't let wildcards enter constraints when adding type lambdas Fix typo Turn off "no wildcards in constraint" check Address review comments macros.md: Fix htmlized variant of first source code example Confusingly, the last part of the first source code example would appear as def showExpr(expr: Expr[Boolean])(using Quotes): Expr[String] = '{ " " } in the htmlized version of the markdown documentation source. Which reads as follows: def showExpr(expr: Expr[Boolean])(using Quotes): Expr[String] = '{ "<some source code>" } // Better implementation later in this document This seems to be cause by the usage of angle brackets. Also note that the code comment does not appear in the htmlized output. Fix typo in 3.0.1-RC1 release notes Fix #9588: Enable Scala.js test ObjectTest. The issue preventing that test from compiling in the past was fixed, although we don't know when or by what. Scala.js: Mangle test names when generating JUnit bootstrappers. This fixes the last remaining JUnit-related tests, which we therefore enable. Copy old site versions for Scala 3 instead of Dotty 0.X Support both 0.X and 3.X lines For extension label, avoid scala style Fix escaping illegal tokens in snippet renderer in scaladoc Use sbt makeScalaInstance Add definition Add doc for env Fix compilation Refactor trace Support Value.source for friendly error message Disallow non-hot arguments to non-constructors Handle access of parameters in constructors Handle exception No exceptions Fix Env.isHot Add missing checks for arguments Handle new expression with only cold args Fix soundness test Reorganize tests Add test Add test for secondary constructor Refactor promotion Add test More logging Fix bug with promotion of this The previous code does not work, because private fields are not included. Refactor code: introduce ArgInfo instead of Value.source Handle O.this outside of it's definition Fix owner of values with static flag With the flag <static>, the enclosing class will be skipped. See the documentation `SymDenotation.enclosingClass` Add documentation about caching Add test Add another neg test for promotion of ThisRef Handle outers of trait as the same in concrete semantics For traits, its outers will be proxy methods of the class that extends the trait. As the prefix is stable and is a valid value before any super constructor calls. Therefore, we may think the outers for traits are immediately set following the class parameters. Also, when trying promotion of warm values, we never try warm values whose fields are not fully filled -- which corresponds to promote ThisRef with non-initialized fields, and errors will be reported when the class is checked separately. Address review (thanks @michelou) Rename isFullyInitialized to isFullyFilled to avoid confusion Restrict function arguments to be hot This aligns with the design of restricting method arguments to be hot. We only allow non-hot to constructors. Add documentation Address review Simplify logic for checking local classes inside secondary constructors Address review: simplify logic Abstract parameters of non-local constructor parameters as cold This is a simple fix which should have no impact on expressiveness and usability, as local classes inside secondary constructors are extremely rare. Update docs Fix #11973: Add regression test community build: Update munit Add Libretto to community build. re-organize tests
1 parent 7b0bdf2 commit 8906fcf

18 files changed

+182
-1
lines changed

scaladoc-js/resources/scaladoc-searchbar.css

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,13 @@
9494

9595
.scaladoc-searchbar-result a {
9696
color: #1f2326;
97+
<<<<<<< HEAD
98+
=======
99+
<<<<<<< HEAD
100+
text-indent: -20px;
101+
padding-left: 20px;
102+
=======
103+
>>>>>>> Add tests
97104
/* for some reason, with display:block if there's a wrap between the
98105
* search result text and the location span, the dead space to the
99106
* left of the location span doesn't get treated as part of the block,
@@ -102,8 +109,12 @@
102109
*/
103110
display: inline-block;
104111
width: 100%;
112+
<<<<<<< HEAD
105113
text-indent: -20px;
106114
padding-left: 20px;
115+
=======
116+
>>>>>>> 89a6409cd0... Improvements to search UX
117+
>>>>>>> Add tests
107118
}
108119

109120
.scaladoc-searchbar-result .scaladoc-searchbar-location {
@@ -134,6 +145,24 @@
134145
background-repeat: no-repeat;
135146
border-radius: 12px;
136147
box-shadow: 0 0 2px black;
148+
<<<<<<< HEAD
149+
}
150+
151+
.snippet-comment-button:hover {
152+
background:
153+
linear-gradient(#444, #444),
154+
linear-gradient(#444, #444),
155+
#ddd;
156+
background-position: center;
157+
background-size: 50% 2px, 2px 50%;
158+
background-repeat: no-repeat;
159+
}
160+
161+
.hide-snippet-comments-button {
162+
-ms-transform: rotate(45deg);
163+
transform: rotate(45deg);
164+
=======
165+
>>>>>>> Add tests
137166
}
138167

139168
.snippet-comment-button:hover {
@@ -150,3 +179,4 @@
150179
-ms-transform: rotate(45deg);
151180
transform: rotate(45deg);
152181
}
182+

tests/init/neg/Desugar.check

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
-- Error: tests/init/neg/Desugar.scala:12:61 ---------------------------------------------------------------------------
2+
12 | val f: PartialFunction[A, Int] = {case C(_, rhs) => rhs.x} // error
3+
| ^
4+
| Calling the external method constructor $anon may cause initialization errors. Calling trace:
5+
| -> val f: PartialFunction[A, Int] = {case C(_, rhs) => rhs.x} // error [ Desugar.scala:12 ]
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
-- Error: tests/init/neg/InteractiveDriver.scala:22:71 -----------------------------------------------------------------
2+
22 | val l2: Seq[C[?]] = l.collect{ case x: InteractiveDriver[?] => h(x) } // error
3+
| ^
4+
|Calling the external method constructor $anon may cause initialization errors. Calling trace:
5+
| -> val l2: Seq[C[?]] = l.collect{ case x: InteractiveDriver[?] => h(x) } // error [ InteractiveDriver.scala:22 ]

tests/init/neg/InteractiveDriver.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,5 @@ object InteractiveDriver {
1919
case _ => new C[Int]
2020
}
2121
val l: Seq[Any] = Seq(1, 2, new C[Double], new D[Int])
22-
val l2: Seq[C[?]] = l.collect{ case x: InteractiveDriver[?] => h(x) }
22+
val l2: Seq[C[?]] = l.collect{ case x: InteractiveDriver[?] => h(x) } // error
2323
}

tests/init/neg/closureLeak.check

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
-- Error: tests/init/neg/closureLeak.scala:11:14 -----------------------------------------------------------------------
2+
11 | l.foreach(a => a.addX(this)) // error
3+
| ^^^^^^^^^^^^^^^^^
4+
| Promoting the value to fully-initialized is unsafe. May only use initialized value as arguments
5+
|
6+
| The unsafe promotion may cause the following problem(s):
7+
|
8+
| 1. Promote the value under initialization to fully-initialized. May only use initialized value as arguments.

tests/init/neg/closureLeak.scala

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,15 @@ class Outer {
99

1010
val l: List[A] = List(new A(5), new A(10))
1111
l.foreach(a => a.addX(this)) // error
12+
<<<<<<< HEAD
13+
=======
14+
<<<<<<< HEAD
15+
<<<<<<< HEAD
16+
val y = 10
17+
=======
18+
>>>>>>> a163464749... Update closureLeak.scala
19+
=======
20+
val p = 10
21+
>>>>>>> 5e4f243160... re-organize tests
22+
>>>>>>> Add tests
1223
}

tests/init/neg/cycle-structure.check

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
-- Error: tests/init/neg/cycle-structure.scala:3:14 --------------------------------------------------------------------
2+
3 | val x = B(this) // error
3+
| ^^^^
4+
| Promote the value under initialization to fully-initialized. May only use initialized value as arguments.
5+
-- Error: tests/init/neg/cycle-structure.scala:9:14 --------------------------------------------------------------------
6+
9 | val x = A(this) // error
7+
| ^^^^
8+
| Promote the value under initialization to fully-initialized. May only use initialized value as arguments.

tests/init/neg/cycle-structure.scala

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
case class A(b: B) {
2+
val x1 = b.x
3+
val x = B(this) // error
4+
val y = x.a
5+
}
6+
7+
case class B(a: A) {
8+
val x1 = a.x
9+
val x = A(this) // error
10+
val h = x.b
11+
}

tests/init/neg/default-this.check

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
-- Error: tests/init/neg/default-this.scala:9:8 ------------------------------------------------------------------------
2+
9 | compare() // error
3+
| ^^^^^^^
4+
|Promote the value under initialization to fully-initialized. May only use initialized value as arguments. Calling trace:
5+
| -> val result = updateThenCompare(5) [ default-this.scala:11 ]

tests/init/neg/enum-desugared.check

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
-- Error: tests/init/neg/enum-desugared.scala:17:15 --------------------------------------------------------------------
2+
17 | Array(this.LazyErrorId, this.NoExplanationID) // error // error
3+
| ^^^^^^^^^^^^^^^^
4+
| Promoting the value to fully-initialized is unsafe. May only use initialized value as method arguments
5+
|
6+
| The unsafe promotion may cause the following problem(s):
7+
|
8+
| 1. Calling the external method method name may cause initialization errors. Calling trace:
9+
| -> override def productPrefix: String = this.name() [ enum-desugared.scala:29 ]
10+
| -> Array(this.LazyErrorId, this.NoExplanationID) // error // error [ enum-desugared.scala:17 ]
11+
-- Error: tests/init/neg/enum-desugared.scala:17:33 --------------------------------------------------------------------
12+
17 | Array(this.LazyErrorId, this.NoExplanationID) // error // error
13+
| ^^^^^^^^^^^^^^^^^^^^
14+
| Promoting the value to fully-initialized is unsafe. May only use initialized value as method arguments
15+
|
16+
| The unsafe promotion may cause the following problem(s):
17+
|
18+
| 1. Calling the external method method ordinal may cause initialization errors. Calling trace:
19+
| -> def errorNumber: Int = this.ordinal() - 2 [ enum-desugared.scala:8 ]
20+
| -> Array(this.LazyErrorId, this.NoExplanationID) // error // error [ enum-desugared.scala:17 ]

tests/init/neg/enum-desugared.scala

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package example
2+
3+
import language.`3.0-migration`
4+
5+
sealed abstract class ErrorMessageID($name: String, _$ordinal: Int)
6+
extends java.lang.Enum[ErrorMessageID]($name, _$ordinal) with scala.reflect.Enum {
7+
8+
def errorNumber: Int = this.ordinal() - 2
9+
}
10+
11+
object ErrorMessageID {
12+
13+
final val LazyErrorId = $new(0, "LazyErrorId")
14+
final val NoExplanationID = $new(1, "NoExplanationID")
15+
16+
private[this] val $values: Array[ErrorMessageID] =
17+
Array(this.LazyErrorId, this.NoExplanationID) // error // error
18+
19+
def values: Array[ErrorMessageID] = $values.clone()
20+
21+
def valueOf($name: String): ErrorMessageID = $name match {
22+
case "LazyErrorId" => this.LazyErrorId
23+
case "NoExplanationID" => this.NoExplanationID
24+
case _ => throw new IllegalArgumentException("enum case not found: " + $name)
25+
}
26+
27+
private[this] def $new(_$ordinal: Int, $name: String): ErrorMessageID =
28+
new ErrorMessageID($name, _$ordinal) with scala.runtime.EnumValue {
29+
override def productPrefix: String = this.name()
30+
}
31+
32+
def fromOrdinal(ordinal: Int): ErrorMessageID =
33+
try ErrorMessageID.$values.apply(ordinal)
34+
catch { case _ => throw new NoSuchElementException(ordinal.toString()) }
35+
}

tests/init/neg/enum.check

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
-- Error: tests/init/neg/enum.scala:4:8 --------------------------------------------------------------------------------
2+
4 | NoExplanationID // error
3+
| ^
4+
| Promoting the value to fully-initialized is unsafe. May only use initialized value as method arguments
5+
|
6+
| The unsafe promotion may cause the following problem(s):
7+
|
8+
| 1. Calling the external method method name may cause initialization errors. Calling trace:
9+
| -> NoExplanationID // error [ enum.scala:4 ]

tests/init/neg/leak-warm.check

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
-- Error: tests/init/neg/leak-warm.scala:18:26 -------------------------------------------------------------------------
2+
18 | val l: List[A] = List(c, d) // error // error
3+
| ^
4+
|Promote the value under initialization to fully-initialized. May only use initialized value as method arguments.
5+
-- Error: tests/init/neg/leak-warm.scala:18:29 -------------------------------------------------------------------------
6+
18 | val l: List[A] = List(c, d) // error // error
7+
| ^
8+
|Promote the value under initialization to fully-initialized. May only use initialized value as method arguments.

tests/init/neg/leak-warm.scala

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,16 @@ object leakWarm {
1515
}
1616
val c = new C(1, 2)
1717
val d = new D(3, 4)
18+
<<<<<<< HEAD
1819
val l: List[A] = List(c, d) // error
20+
=======
21+
val l: List[A] = List(c, d) // error // error
22+
<<<<<<< HEAD
23+
=======
24+
val l: List[A] = List(c, d) // error
25+
>>>>>>> 93ec7cb48e... Update leak-warm.scala
26+
=======
27+
>>>>>>> 5e4f243160... re-organize tests
28+
>>>>>>> Add tests
1929
val l2 = l.map(_.m())
2030
}

tests/init/neg/local-warm.check

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
-- Error: tests/init/neg/local-warm.scala:12:12 ------------------------------------------------------------------------
2+
12 | val t = m1() // error
3+
| ^^^^^^^^^^^^
4+
|Promote the value under initialization to fully-initialized. Local definitions may only hold initialized values. Calling trace:
5+
| -> val x = g() [ local-warm.scala:15 ]
File renamed without changes.

tests/init/pos/methodAtLast.scala

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
class Foo(x: Int) {
2+
var y: Int = x
3+
case class Bar(z: Int) extends Foo(z)
4+
def updateY(n: Int): Unit = {
5+
if (y < 20) {
6+
val b = new Bar(x + n)
7+
y = b.z
8+
}
9+
}
10+
updateY(5)
11+
}

0 commit comments

Comments
 (0)