Home
Reading
Searching
Subscribe
Sponsors
Statistics
Posting
Contact
Spam
Lists
Links
About
Hosting
Filtering
Features Download
Marketing
Archives
FAQ
Blog
 
Gmane
From: Aleksandar Prokopec <aleksandar.prokopec-Re5JQEeQqe8AvxtiuMwx3w <at> public.gmane.org>
Subject: No feature warning for implicit objects which extend Function1
Newsgroups: gmane.comp.lang.scala.internals
Date: Wednesday 2nd May 2012 17:27:25 UTC (over 4 years ago)
While triaging some bugs today, I noticed:

object Test {
   class Foo
   class RichFoo

   implicit def enrich(foo: Foo) = new RichFoo

   def bar(rich: RichFoo) {}

   bar(new Foo)
}

With the "-feature" flag gives:

t5197.scala:10: warning: implicit conversion method enrich should be
enabled
by making the implicit value language.implicitConversions visible.
This can be achieved by adding the import clause 'import 
language.implicitConversions'
or by setting the compiler option -language:implicitConversions.
See the Scala docs for value scala.language.implicitConversions for a 
discussion
why the feature should be explicitly enabled.
   implicit def enrich(foo: Foo) = new RichFoo
                ^
one warning found

as expected. But:

object Test {
   class Foo
   class RichFoo

   implicit object enrich extends (Foo => RichFoo) {
     def apply(foo: Foo) = new RichFoo
   }

   def bar(rich: RichFoo) {}

   bar(new Foo)
}

yields no warning. Is this expected?


-- 
Aleksandar Prokopec,
Doctoral Assistant
LAMP, IC, EPFL
http://people.epfl.ch/aleksandar.prokopec
 
CD: 22ms