Muki-SkyWalker / specs

Automatically exported from code.google.com/p/specs
Other
0 stars 0 forks source link

Specs with a parameterized case class can be compiled without the parameter given #159

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. compile the attached Spec (I did it via sbt)

What is the expected output? What do you see instead?
I'd expect scalac to fail when trying to compile the spec. The case class used 
in the example seems to be instantiated, but it lacks the required parameter. I 
guess there is some implicit imported via org.specs._, which transforms this 
expression into something valid.
This arcane behaviour is not exhibited when using normal classes.

What version of the product are you using? On what operating system?
Fedora Linux 2.6.32.16-141.fc12.x86_64
Java 1.6.0_18, OpenJDK 64 Bit
Scala 2.8 final

Original issue reported on code.google.com by phdoerfler@gmail.com on 30 Aug 2010 at 1:36

Attachments:

GoogleCodeExporter commented 9 years ago
Forgot to mention: I'm using "org.scala-tools.testing" %% "specs" % 
"1.6.6-SNAPSHOT".

Original comment by phdoerfler@gmail.com on 30 Aug 2010 at 1:37

GoogleCodeExporter commented 9 years ago
I do have the explanation, and I have an idea on how to fix it

There is indeed an implicit conversion to be able to transform anything to a 
LazyParameter, something that's only evaluated on demand. This trick is helpful 
when you want to have repeated, by-name parameters.

Unfortunately I had the smart-bad idea to name the method used to retrieve the 
value "apply". So in your example, CaseClassWithOneParameter() is actually: 
lazyfy(CaseClassWithOneParameter).apply() 

where CaseClassWithOneParameter is the case object associated with the class!

The fix should be simple enough, just rename the "apply" method to "getValue" 
and this is what I'll do,... tomorrow because it's already late here!

Thanks for finding this, another reason to be cautious with implicits!

Original comment by etorrebo...@gmail.com on 30 Aug 2010 at 2:05

GoogleCodeExporter commented 9 years ago
Yay, what a gorgeous explanation! :)

Thanks for your fast response and happy fixing
~ Philipp

Original comment by phdoerfler@gmail.com on 30 Aug 2010 at 2:59

GoogleCodeExporter commented 9 years ago
That's fixed in the latest snapshot.

Original comment by etorrebo...@gmail.com on 30 Aug 2010 at 9:33

GoogleCodeExporter commented 9 years ago
The compile now fails like a charm ;)

Thanks again for fixing this.

Original comment by phdoerfler@gmail.com on 31 Aug 2010 at 12:47