# Compiler can't figure out which version of exec()

**URL:** <https://community.gatling.io/t/compiler-cant-figure-out-which-version-of-exec/1564>\
**Category:** Gatling (Open-Source)\
**Created:** [October 18, 2014, 3:32pm UTC](https://community.gatling.io/t/compiler-cant-figure-out-which-version-of-exec/1564 "2014-10-18T15:32:50Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![jarrowwx](https://avatars.discourse-cdn.com/v4/letter/j/4af34b/32.png) [@jarrowwx](https://community.gatling.io/u/jarrowwx)\
**Post date:** [October 18, 2014, 3:32pm UTC](https://community.gatling.io/t/compiler-cant-figure-out-which-version-of-exec/1564/1 "2014-10-18T15:32:50Z")

</div>

Eclipse is giving me the following error:

`ambiguous reference to overloaded definition, both method exec in trait Execs of type (scenario: io.gatling.core.structure.ScenarioBuilder)io.gatling.core.structure.ChainBuilder and method exec in trait Execs of type (chains: Iterable[io.gatling.core.structure.ChainBuilder])io.gatling.core.structure.ChainBuilder match argument types (com.cigna.common.RestfulService)`

Here is part of the definition of RestfulService:

`  
object RestfulService {  
implicit def toRequest[T \<: StructureBuilder[T]]( x: RestfulService ) : T = x.apply  
}  
trait RestfulService {  
protected var formParams: Map[String,Any] = Map()  
protected def formParameter( key: String, value: Any ) = {  
formParams += ( key → value )  
this  
}  
protected var queryParams: Map[String,Any] = Map()  
protected def queryParameter( key: String, value: Any ) = {  
queryParams += ( key → value )  
this  
}  
protected var requestHeaders: Map[String,String] = Map()  
protected def header( key: String, value: String ) = {  
requestHeaders += ( key → value )  
this  
}  
def apply[T \<: StructureBuilder[T]] : T  
}

class RestfulGET(  
description: String,  
url: String  
) extends RestfulService {

def apply =  
http( description )  
.get( url )  
.header( HttpHeaderNames.Accept, HttpHeaderValues.ApplicationJson )  
.headers( requestHeaders )  
.queryParamMap( queryParams )

}  
`

The point is to be able to write code like this:

`  
val foo = exec( SomeService.get.withPreferences )

`

where that is a sub-class of RestfulService that adds the withPreferences convenience method which adds a particular query parameter.

But because I made the implicit apply method convert to a sub-type of StructureBuilder[T], both possible versions of exec() apply, so eclipse complains. Am I doing something wrong? Is there a way around this?

---

<div class="post-metadata">

**Author:** ![Excilys](https://avatars.discourse-cdn.com/v4/letter/e/8797f3/32.png) [@Excilys](https://community.gatling.io/u/Excilys)\
**Post date:** [October 18, 2014, 3:46pm UTC](https://community.gatling.io/t/compiler-cant-figure-out-which-version-of-exec/1564/2 "2014-10-18T15:46:52Z")

</div>

Why do you target StructureBuilder and not just ChainBuilder?  
exec(ScenarioBuilder) is mostly intended for people aiming to chain raw Recorder outputs (ie ScenarioBuilders) which is definitively not your case.

Then, I don’t get how exec(ScenarioBuilder) would match?!

---

<div class="post-metadata">

**Author:** ![jarrowwx](https://avatars.discourse-cdn.com/v4/letter/j/4af34b/32.png) [@jarrowwx](https://community.gatling.io/u/jarrowwx)\
**Post date:** [October 18, 2014, 11:53pm UTC](https://community.gatling.io/t/compiler-cant-figure-out-which-version-of-exec/1564/3 "2014-10-18T23:53:01Z")

</div>

I had been up until 2am working on it, so my head wasn’t quite where it needed to be.

It shouldn’t have been StructureBuilder, it was supposed to be AbstractHttpRequestBuilder. But that gives me the same error. But when I use ChainBuilder as the type, it doesn’t complain. Curious, but I won’t complain!

---

<div class="post-metadata">

**Author:** ![Excilys](https://avatars.discourse-cdn.com/v4/letter/e/8797f3/32.png) [@Excilys](https://community.gatling.io/u/Excilys)\
**Post date:** [October 20, 2014, 8:30am UTC](https://community.gatling.io/t/compiler-cant-figure-out-which-version-of-exec/1564/4 "2014-10-20T08:30:12Z")

</div>

I’d need your exact code to reproduce, but honestly, the error you pasted doesn’t make sense (I suspect you went with trials and errors and you got slightly different errors at some point):  
ambiguous reference to overloaded definition, both method  
exec(scenario: ScenarioBuilder)ChainBuilder and method  
exec(chains: Iterable[ChainBuilder])ChainBuilder  
match argument types (com.cigna.common.RestfulService)

It seems you ended up with RestfulService being BOTH a ScenarioBuilder AND an Iterable[ChainBuilder] ?! Looks wrong to me.
