Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #10635 from som-snytt/issue/7530-multiassign-warn
Nuance advice when var in multidef could be val
- Loading branch information
Showing
7 changed files
with
50 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
t7530.scala:4: warning: private var j in class C is never updated: consider refactoring vars to a separate definition | ||
private var (i, j) = init() | ||
^ | ||
t7530.scala:11: warning: private var j in class D is never updated: consider refactoring vars to a separate definition | ||
private var i, j = init() | ||
^ | ||
t7530.scala:19: warning: private var j in class E is never updated: consider refactoring vars to a separate definition | ||
private var K(i, j) = init() | ||
^ | ||
error: No warnings can be incurred under -Werror. | ||
3 warnings | ||
1 error |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
//> using options -Werror -Xlint | ||
|
||
class C { | ||
private var (i, j) = init() | ||
|
||
private def init() = (42, 27) | ||
def f(): Unit = println(i+j) | ||
def g(): Unit = i += 1 | ||
} | ||
class D { | ||
private var i, j = init() | ||
|
||
private def init() = 42 | ||
def f(): Unit = println(i+j) | ||
def g(): Unit = i += 1 | ||
} | ||
case class K(i: Int, j: Int) | ||
class E { | ||
private var K(i, j) = init() | ||
|
||
private def init() = K(42, 27) | ||
def f(): Unit = println(i+j) | ||
def g(): Unit = i += 1 | ||
} |