-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Backport "Consider static and non-static methods as non-double def" t…
- Loading branch information
Showing
6 changed files
with
61 additions
and
4 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package foo { | ||
|
||
import annotation.static | ||
|
||
class MirrorHelpers | ||
|
||
object MirrorHelpers: | ||
|
||
@static | ||
def throwStuff(i: Int): Any = throw new NoSuchElementException(String.valueOf(i)) | ||
|
||
} | ||
|
||
@main def Test = | ||
try | ||
foo.MirrorHelpers.throwStuff(23) | ||
??? // ko | ||
catch case ex: NoSuchElementException if ex.getMessage == "23" => () // ok |
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,20 @@ | ||
import scala.annotation.{ static, targetName } | ||
|
||
class Foo | ||
object Foo: | ||
@static def foo: String = "foo" | ||
@targetName("foo") def fooBincompat: String = foo | ||
|
||
class Bar | ||
object Bar: | ||
@static def bar: String = "bar" | ||
def bar: String = bar | ||
|
||
object Test: | ||
def main(args: Array[String]): Unit = | ||
assert(Foo.foo == "foo") | ||
assert(Bar.bar == "bar") | ||
|
||
import scala.reflect.Selectable.reflectiveSelectable | ||
assert(Foo.asInstanceOf[{ def foo: String }].foo == "foo") | ||
assert(Bar.asInstanceOf[{ def bar: String }].bar == "bar") |
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,16 @@ | ||
import scala.annotation.static | ||
|
||
class Foo | ||
|
||
object Foo { | ||
@static def foo = "foo" | ||
} | ||
|
||
class Bar { | ||
def bar = Foo.foo | ||
} | ||
|
||
object Test: | ||
def main(args: Array[String]): Unit = | ||
Foo.foo | ||
Bar().bar |
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 |
---|---|---|
@@ -1,5 +1,3 @@ | ||
// scalajs: --skip --pending | ||
|
||
import scala.annotation.static | ||
|
||
class Test | ||
|