diff options
author | Adriaan Moors <adriaan.moors@epfl.ch> | 2012-07-02 02:12:04 -0700 |
---|---|---|
committer | Adriaan Moors <adriaan.moors@epfl.ch> | 2012-07-02 02:12:04 -0700 |
commit | fd3118c3d2c99f24ae226d50b5487e235bdbd4d1 (patch) | |
tree | e750665a0bc6ee5117bdd2fba4e7a16f4bcdafc8 | |
parent | a82a6ab54ac2eb714ad99a9f411c326bbf2a22a7 (diff) | |
parent | 8f640e8a1d4a24f845005343a58e1297f51865fd (diff) | |
download | scala-fd3118c3d2c99f24ae226d50b5487e235bdbd4d1.tar.gz scala-fd3118c3d2c99f24ae226d50b5487e235bdbd4d1.tar.bz2 scala-fd3118c3d2c99f24ae226d50b5487e235bdbd4d1.zip |
Merge pull request #800 from retronym/ticket/5932
SI-5932 Tone down non-sensible == warning with refinements.
-rw-r--r-- | src/compiler/scala/tools/nsc/typechecker/RefChecks.scala | 2 | ||||
-rw-r--r-- | test/files/pos/t5932.flags | 1 | ||||
-rw-r--r-- | test/files/pos/t5932.scala | 15 |
3 files changed, 17 insertions, 1 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala index 119bb0852c..44fd4e9afd 100644 --- a/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala +++ b/src/compiler/scala/tools/nsc/typechecker/RefChecks.scala @@ -1150,7 +1150,7 @@ abstract class RefChecks extends InfoTransform with reflect.internal.transform.R nonSensiblyNew() else if (isNew(args.head) && (receiver.isEffectivelyFinal || isReferenceOp)) // object X ; X == new Y nonSensiblyNew() - else if (receiver.isEffectivelyFinal && !(receiver isSubClass actual)) { // object X, Y; X == Y + else if (receiver.isEffectivelyFinal && !(receiver isSubClass actual) && !actual.isRefinementClass) { // object X, Y; X == Y if (isEitherNullable) nonSensible("non-null ", false) else diff --git a/test/files/pos/t5932.flags b/test/files/pos/t5932.flags new file mode 100644 index 0000000000..e8fb65d50c --- /dev/null +++ b/test/files/pos/t5932.flags @@ -0,0 +1 @@ +-Xfatal-warnings
\ No newline at end of file diff --git a/test/files/pos/t5932.scala b/test/files/pos/t5932.scala new file mode 100644 index 0000000000..d824523d5b --- /dev/null +++ b/test/files/pos/t5932.scala @@ -0,0 +1,15 @@ +class A + +case object B extends A + +object Test { + val x1 = (B: A) + + println(x1 == B) // no warning + println(B == x1) // no warning + + val x2 = (B: A with Product) + + println(x2 == B) // no warning + println(B == x2) // spurious warning: "always returns false" +} |