diff options
author | Paul Phillips <paulp@improving.org> | 2013-06-04 11:50:05 -0700 |
---|---|---|
committer | Paul Phillips <paulp@improving.org> | 2013-06-04 12:25:43 -0700 |
commit | 2f0e5ec1e96a6e4806841069736eda844d3a8dd6 (patch) | |
tree | 1a72792e2f08519f51e444e98eb19ffa2a855168 /test/files/neg/t6889.scala | |
parent | 803d451a28824af17f0cab446e4c76f51003fd01 (diff) | |
download | scala-2f0e5ec1e96a6e4806841069736eda844d3a8dd6.tar.gz scala-2f0e5ec1e96a6e4806841069736eda844d3a8dd6.tar.bz2 scala-2f0e5ec1e96a6e4806841069736eda844d3a8dd6.zip |
SI-6899, prohibit dangerous, useless implicit conversions.
Increase eligibility requirements for implicit conversions,
such that T => U is ineligible if
T <: Null <or> AnyRef <: U
This has the salutary effect of allowing us to ditch 16
ridiculous implicits from Predef, since they existed solely
to work around the absence of this restriction.
There was one tiny impact on actual source code (one line
in one file) shown here, necessitated because the literal null
is not eligible to be implicitly converted to A via <:<.
def f[A](implicit ev: Null <:< A): A = null // before
def f[A](implicit ev: Null <:< A): A = ev(null) // after
As impositions go it's on the tame side.
Diffstat (limited to 'test/files/neg/t6889.scala')
-rw-r--r-- | test/files/neg/t6889.scala | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/test/files/neg/t6889.scala b/test/files/neg/t6889.scala new file mode 100644 index 0000000000..ef1963669c --- /dev/null +++ b/test/files/neg/t6889.scala @@ -0,0 +1,18 @@ +package bippy { + trait Bippy[A] extends Any +} +package foo { + package object unrelated { + implicit def bippyDingo[A](x: bippy.Bippy[A]): AnyRef = Nil + } + package unrelated { + trait Unrelated + } +} + +object Test { + trait Dingo extends Any with bippy.Bippy[foo.unrelated.Unrelated] + + def f(x: Dingo): AnyRef = x // fail - no conversion to AnyRef + var x: Int = null // fail - no conversion from Null +} |